зеркало из https://github.com/mozilla/gecko-dev.git
Bug 485390 - utils.lockFile doesn't hold the file descriptor, which can cause parallel races in JarMaker, r=ted
This commit is contained in:
Родитель
4f47062f0c
Коммит
c1cdb183bb
|
@ -50,9 +50,11 @@ class LockFile(object):
|
|||
This object should not be used directly, but only through
|
||||
the lockFile method below.
|
||||
'''
|
||||
def __init__(self, lockfile):
|
||||
def __init__(self, lockfile, fd):
|
||||
self.lockfile = lockfile
|
||||
self.fd = fd
|
||||
def __del__(self):
|
||||
os.close(self.fd)
|
||||
os.remove(self.lockfile)
|
||||
|
||||
|
||||
|
@ -100,10 +102,8 @@ def lockFile(lockfile, max_wait = 600):
|
|||
# if we get here. we have the lockfile. Convert the os.open file
|
||||
# descriptor into a Python file object and record our PID in it
|
||||
|
||||
f = os.fdopen(fd, "w")
|
||||
f.write("%d\n" % os.getpid())
|
||||
f.close()
|
||||
return LockFile(lockfile)
|
||||
os.write(fd, "%d\n" % os.getpid())
|
||||
return LockFile(lockfile, fd)
|
||||
|
||||
class pushback_iter(object):
|
||||
'''Utility iterator that can deal with pushed back elements.
|
||||
|
|
Загрузка…
Ссылка в новой задаче