[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

ossy at webkit.org ossy at webkit.org
Wed Dec 22 15:28:49 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 8956c9ca81ddb1c776fd537d67a03ac839566ffb
Author: ossy at webkit.org <ossy at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 4 16:08:10 2010 +0000

    [NRWT] Clear invalid http locks on Windows platform as well
    https://bugs.webkit.org/show_bug.cgi?id=48515
    
    Patch by Gabor Rapcsanyi <rgabor at inf.u-szeged.hu> on 2010-11-04
    Reviewed by Eric Seidel.
    
    * Scripts/webkitpy/common/system/executive.py:
    * Scripts/webkitpy/common/system/executive_unittest.py:
    * Scripts/webkitpy/layout_tests/port/http_lock.py:
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@71338 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 1f1cb5c..45db252 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,14 @@
+2010-11-04  Gabor Rapcsanyi  <rgabor at inf.u-szeged.hu>
+
+        Reviewed by Eric Seidel.
+
+        [NRWT] Clear invalid http locks on Windows platform as well
+        https://bugs.webkit.org/show_bug.cgi?id=48515
+
+        * Scripts/webkitpy/common/system/executive.py:
+        * Scripts/webkitpy/common/system/executive_unittest.py:
+        * Scripts/webkitpy/layout_tests/port/http_lock.py:
+
 2010-11-02  Adam Roben  <aroben at apple.com>
 
         Reduce our dependence on coreutils when running Python tests
diff --git a/WebKitTools/Scripts/webkitpy/common/system/executive.py b/WebKitTools/Scripts/webkitpy/common/system/executive.py
index 216cf58..7321ce9 100644
--- a/WebKitTools/Scripts/webkitpy/common/system/executive.py
+++ b/WebKitTools/Scripts/webkitpy/common/system/executive.py
@@ -33,6 +33,7 @@ try:
 except ImportError:
     multiprocessing = None
 
+import ctypes
 import errno
 import logging
 import os
@@ -205,6 +206,55 @@ class Executive(object):
                     return
                 raise
 
+    def _win32_check_running_pid(self):
+
+        class PROCESSENTRY32(ctypes.Structure):
+            _fields_ = [("dwSize", ctypes.c_ulong),
+                        ("cntUsage", ctypes.c_ulong),
+                        ("th32ProcessID", ctypes.c_ulong),
+                        ("th32DefaultHeapID", ctypes.c_ulong),
+                        ("th32ModuleID", ctypes.c_ulong),
+                        ("cntThreads", ctypes.c_ulong),
+                        ("th32ParentProcessID", ctypes.c_ulong),
+                        ("pcPriClassBase", ctypes.c_ulong),
+                        ("dwFlags", ctypes.c_ulong),
+                        ("szExeFile", ctypes.c_char * 260)]
+
+        CreateToolhelp32Snapshot = ctypes.windll.kernel32.CreateToolhelp32Snapshot
+        Process32First = ctypes.windll.kernel32.Process32First
+        Process32Next = ctypes.windll.kernel32.Process32Next
+        CloseHandle = ctypes.windll.kernel32.CloseHandle
+        TH32CS_SNAPPROCESS = 0x00000002  # win32 magic number
+        hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
+        pe32 = PROCESSENTRY32()
+        pe32.dwSize = ctypes.sizeof(PROCESSENTRY32)
+        result = False
+        if not Process32First(hProcessSnap, ctypes.byref(pe32)):
+            _log.debug("Failed getting first process.")
+            CloseHandle(hProcessSnap)
+            return result
+        while True:
+            if pe32.th32ProcessID == pid:
+                result = True
+                break
+            if not Process32Next(hProcessSnap, ctypes.byref(pe32)):
+                break
+        CloseHandle(hProcessSnap)
+        return result
+
+    def check_running_pid(self, pid):
+        """Return True if pid is alive, otherwise return False."""
+        if sys.platform in ('darwin', 'linux2', 'cygwin'):
+            try:
+                os.kill(pid, 0)
+                return True
+            except OSError:
+                return False
+        elif sys.platform == 'win32':
+            return self._win32_check_running_pid()
+
+        assert(False)
+
     def _windows_image_name(self, process_name):
         name, extension = os.path.splitext(process_name)
         if not extension:
diff --git a/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py b/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
index 6106be8..af2b45e 100644
--- a/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/common/system/executive_unittest.py
@@ -27,6 +27,7 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
+import os
 import signal
 import subprocess
 import sys
@@ -121,3 +122,9 @@ class ExecutiveTest(unittest.TestCase):
         self.assertEqual(process.wait(), expected_exit_code)
         # Killing again should fail silently.
         executive.kill_all("yes")
+
+    def test_check_running_pid(self):
+        executive = Executive()
+        self.assertTrue(executive.check_running_pid(os.getpid()))
+        # Maximum pid number on Linux is 32768 by default
+        self.assertFalse(executive.check_running_pid(100000))
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/http_lock.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_lock.py
index b2615a3..08dca1f 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/port/http_lock.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_lock.py
@@ -29,11 +29,17 @@
 http and websocket tests in a same time."""
 
 import glob
+import logging
 import os
 import sys
 import tempfile
 import time
 
+from webkitpy.common.system.executive import Executive
+
+
+_log = logging.getLogger("webkitpy.layout_tests.port.http_lock")
+
 
 class HttpLock(object):
 
@@ -46,10 +52,12 @@ class HttpLock(object):
                                                    self._lock_file_prefix)
         self._guard_lock_file = os.path.join(self._lock_path, guard_lock)
         self._process_lock_file_name = ""
+        self._executive = Executive()
 
     def cleanup_http_lock(self):
         """Delete the lock file if exists."""
         if os.path.exists(self._process_lock_file_name):
+            _log.debug("Removing lock file: %s" % self._process_lock_file_name)
             os.unlink(self._process_lock_file_name)
 
     def _extract_lock_number(self, lock_file_name):
@@ -70,17 +78,6 @@ class HttpLock(object):
             return 0
         return self._extract_lock_number(lock_list[-1]) + 1
 
-    def _check_pid(self, current_pid):
-        """Return True if pid is alive, otherwise return False.
-        FIXME: os.kill() doesn't work on Windows for checking if
-        a pid is alive, so always return True"""
-        if sys.platform in ('darwin', 'linux2'):
-            try:
-                os.kill(current_pid, 0)
-            except OSError:
-                return False
-        return True
-
     def _curent_lock_pid(self):
         """Return with the current lock pid. If the lock is not valid
         it deletes the lock file."""
@@ -91,7 +88,8 @@ class HttpLock(object):
             current_lock_file = open(lock_list[0], 'r')
             current_pid = current_lock_file.readline()
             current_lock_file.close()
-            if not (current_pid and self._check_pid(int(current_pid))):
+            if not (current_pid and self._executive.check_running_pid(int(current_pid))):
+                _log.debug("Removing stuck lock file: %s" % lock_list[0])
                 os.unlink(lock_list[0])
                 return
         except IOError, OSError:
@@ -108,6 +106,7 @@ class HttpLock(object):
                 self._process_lock_file_name = (self._lock_file_path_prefix +
                                                 str(self._next_lock_number()))
                 lock_file = open(self._process_lock_file_name, 'w')
+                _log.debug("Creating lock file: %s" % self._process_lock_file_name)
                 lock_file.write(str(os.getpid()))
                 lock_file.close()
                 os.close(sequential_guard_lock)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list