[webkit-changes] [WebKit/WebKit] 1c10ca: [webkitcorepy] Fix race condition in FileLock

Jonathan Bedard noreply at github.com
Mon May 22 07:40:15 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 1c10cac855587753cfb42e0e7f3b62e2480eb62e
      https://github.com/WebKit/WebKit/commit/1c10cac855587753cfb42e0e7f3b62e2480eb62e
  Author: Jonathan Bedard <jbedard at apple.com>
  Date:   2023-05-22 (Mon, 22 May 2023)

  Changed paths:
    M Tools/Scripts/libraries/webkitcorepy/setup.py
    M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py
    M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/file_lock.py
    M Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/file_lock_unittest.py

  Log Message:
  -----------
  [webkitcorepy] Fix race condition in FileLock
https://bugs.webkit.org/show_bug.cgi?id=256931
rdar://109487762

Reviewed by Alexey Proskuryakov.

* Tools/Scripts/libraries/webkitcorepy/setup.py: Bump version.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/__init__.py: Ditto.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/file_lock.py:
(FileLock.is_process_running): Check if a specific PID is running.
(FileLock.acquire): Create and acquire lock in a single operation on Unix systems.
Save the current PID to the file, which allows future processes to ignore this lock
if the PID saved in it is dead. For systems which support it, use O_EXLOCK and interrupts
instead of a spinlock. Raise exceptions when we fail to acquire the lock.
(FileLock.release): Delete the lockfile before releasing it on Unix systems. Systems using
O_EXLOCK simply need to close their file handle.
(FileLock.__exit__): Don't raise a 2nd exception if __enter__ has raised one.
* Tools/Scripts/libraries/webkitcorepy/webkitcorepy/tests/file_lock_unittest.py:
(action):
(FileLockTestCase.test_locked):
(FileLockTestCase.test_locked_timeout):
(FileLockTestCase.test_double):
(FileLockTestCase.test_race):

Canonical link: https://commits.webkit.org/264321@main




More information about the webkit-changes mailing list