Changeset 2122

Show
Ignore:
Timestamp:
04/16/12 06:33:31 (9 years ago)
Author:
jwoithe
Message:

ffado-mixer: use a unix domain socket as a lock to prevent multiple ffado-mixers being run simultaneously. This should address the majority of the issues raised in ticket #320.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/ffadowindow.py

    r2110 r2122  
    150150 
    151151 
     152def get_lock(process_name): 
     153    import socket 
     154    import sys 
     155 
     156    global lock_socket 
     157    lock_socket = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) 
     158    try: 
     159        lock_socket.bind('\0' + process_name) 
     160        # Lock acquired 
     161    except socket.error: 
     162        print 'ffado-mixer instance is already running' 
     163        sys.exit() 
     164 
     165 
    152166def ffadomain(args): 
    153167    #set up logging 
     
    159173    else: 
    160174        debug_level = logging.INFO 
     175 
     176    get_lock('ffado-mixer') 
    161177 
    162178    # main loggers: