bombshell-client gains a lock that prevents it from hanging if two parallel requests happen too fast

This commit is contained in:
Manuel Amador (Rudd-O) 2015-12-15 00:06:56 +00:00
parent 8e38ed73bb
commit eebd457b03

View File

@ -1,6 +1,7 @@
#!/usr/bin/python -u
import cPickle
import contextlib
import fcntl
import os
import pipes
@ -13,6 +14,18 @@ import sys
import threading
@contextlib.contextmanager
def mutexfile(filepath):
oldumask = os.umask(0077)
try:
f = file(filepath, "a")
finally:
os.umask(oldumask)
fcntl.lockf(f.fileno(), fcntl.LOCK_EX)
yield
f.close()
debug_lock = threading.Lock()
debug_enabled = False
class LoggingEmu():
@ -250,6 +263,7 @@ def main_master():
saved_stderr = os.fdopen(os.dup(sys.stderr.fileno()), "a")
with mutexfile(os.path.expanduser("~/.bombshell-lock")):
try:
p = subprocess.Popen(
["qrexec-client-vm", remote_vm, "qubes.VMShell"],