Show More
@@ -330,27 +330,32 b' class lock(object):' | |||
|
330 | 330 | return None |
|
331 | 331 | raise |
|
332 | 332 | |
|
333 |
def _ |
|
|
333 | def _lockshouldbebroken(self, locker): | |
|
334 | 334 | if locker is None: |
|
335 |
return |
|
|
335 | return False | |
|
336 | 336 | try: |
|
337 | 337 | host, pid = locker.split(b":", 1) |
|
338 | 338 | except ValueError: |
|
339 |
return |
|
|
339 | return False | |
|
340 | 340 | if host != lock._host: |
|
341 |
return |
|
|
341 | return False | |
|
342 | 342 | try: |
|
343 | 343 | pid = int(pid) |
|
344 | 344 | except ValueError: |
|
345 |
return |
|
|
345 | return False | |
|
346 | 346 | if procutil.testpid(pid): |
|
347 | return False | |
|
348 | return True | |
|
349 | ||
|
350 | def _testlock(self, locker): | |
|
351 | if not self._lockshouldbebroken(locker): | |
|
347 | 352 | return locker |
|
353 | ||
|
348 | 354 | # if locker dead, break lock. must do this with another lock |
|
349 | 355 | # held, or can race and break valid lock. |
|
350 | 356 | try: |
|
351 |
|
|
|
357 | with lock(self.vfs, self.f + b'.break', timeout=0): | |
|
352 | 358 | self.vfs.unlink(self.f) |
|
353 | l.release() | |
|
354 | 359 | except error.LockError: |
|
355 | 360 | return locker |
|
356 | 361 |
General Comments 0
You need to be logged in to leave comments.
Login now