mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 485390 - utils.lockFile doesn't hold the file descriptor, which can cause parallel races in JarMaker, r=ted
This commit is contained in:
parent
f361caeff0
commit
5cb4a30638
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user