← Back to team overview

apport-hackers team mailing list archive

[Merge] lp:~juliank/apport/lp1746874 into lp:apport

 

Julian Andres Klode has proposed merging lp:~juliank/apport/lp1746874 into lp:apport.

Requested reviews:
  Apport upstream developers (apport-hackers)

For more details, see:
https://code.launchpad.net/~juliank/apport/lp1746874/+merge/337558

Use a 30s time out on the lock to workaround the issue where two apps crash at the same (or very close) time like in bug 1746874
-- 
Your team Apport upstream developers is requested to review the proposed merge of lp:~juliank/apport/lp1746874 into lp:apport.
=== modified file 'NEWS'
--- NEWS	2018-02-02 01:22:59 +0000
+++ NEWS	2018-02-12 13:42:44 +0000
@@ -26,6 +26,7 @@
     case so check for both.
   * data/apport: add an exception handler in case either name space can not be
     found.
+  * data/apport: wait for lock, with 30s timeout (LP: #1746874)
 
 2.20.8 (2017-11-15)
 -------------------

=== modified file 'data/apport'
--- data/apport	2018-02-02 01:22:59 +0000
+++ data/apport	2018-02-12 13:42:44 +0000
@@ -40,12 +40,19 @@
         error_log('cannot create lock file (uid %i): %s' % (os.getuid(), str(e)))
         sys.exit(1)
 
-    try:
-        fcntl.lockf(fd, fcntl.LOCK_EX | fcntl.LOCK_NB)
-    except IOError:
+    def error_running(*args):
         error_log('another apport instance is already running, aborting')
         sys.exit(1)
 
+    original_handler = signal.signal(signal.SIGALRM, error_running)
+    signal.alarm(30) # Timeout after that many seconds
+    try:
+        fcntl.lockf(fd, fcntl.LOCK_EX)
+    except IOError:
+        error_running()
+    finally:
+        signal.alarm(0)
+        signal.signal(signal.SIGALRM, original_handler)
 
 (pidstat, real_uid, real_gid, cwd) = (None, None, None, None)
 


Follow ups