The branch, eden has been updated
       via  074104ed5c01e3c382d534ce03225e98fc381db5 (commit)
      from  8c6ca78f7bdeb1b98de5be9cb0764ce0d1227c17 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=074104ed5c01e3c382d534ce03225e98fc381db5

commit 074104ed5c01e3c382d534ce03225e98fc381db5
Author: amet <[email protected]>
Date:   Sun May 13 00:07:19 2012 +0400

    [service.watchdog] -v0.6.0
    
    - fixed bug causing xbmc to hang on windows

diff --git a/service.watchdog/addon.xml b/service.watchdog/addon.xml
index 12485d2..be7b9d6 100644
--- a/service.watchdog/addon.xml
+++ b/service.watchdog/addon.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <addon id="service.watchdog"
        name="Library watchdog"
-       version="0.5"
+       version="0.6.0"
        provider-name="takoi">
   <requires>
     <import addon="xbmc.python" version="2.0"/>
diff --git a/service.watchdog/changelog.txt b/service.watchdog/changelog.txt
index e69de29..3b690cf 100644
--- a/service.watchdog/changelog.txt
+++ b/service.watchdog/changelog.txt
@@ -0,0 +1,3 @@
+[B]0.6.0[/B]
+- fixed bug causing xbmc to hang on windows
+
diff --git a/service.watchdog/watchdog/observers/__init__.py 
b/service.watchdog/watchdog/observers/__init__.py
index a511f23..16ddffb 100644
--- a/service.watchdog/watchdog/observers/__init__.py
+++ b/service.watchdog/watchdog/observers/__init__.py
@@ -55,4 +55,7 @@ except ImportError: # pragma: no cover
 
 
 Observer = _Observer
-
+"""
+Observer thread that schedules watching directories and dispatches
+calls to event handlers.
+"""
diff --git a/service.watchdog/watchdog/observers/api.py 
b/service.watchdog/watchdog/observers/api.py
index 023705c..1de80e2 100644
--- a/service.watchdog/watchdog/observers/api.py
+++ b/service.watchdog/watchdog/observers/api.py
@@ -279,10 +279,7 @@ class BaseObserver(EventDispatcher):
     return self._emitter_for_watch[watch]
 
   def _clear_emitters(self):
-    #print("WATCHDOG: BaseObserver._clear_emitters() ")
     for emitter in self._emitters:
-      #print("WATCHDOG: BaseObserver._clear_emitters() calling stop() on " + 
str(emitter))
-      #emitter.on_thread_exit()
       emitter.stop()
     self._emitters.clear()
     self._emitter_for_watch.clear()
@@ -409,9 +406,7 @@ class BaseObserver(EventDispatcher):
       self._watches.clear()
 
   def on_thread_exit(self):
-    print("WATCHDOG: BaseObserver.on_thread_exit()")
     self.unschedule_all()
-    
 
   def _dispatch_event(self, event, watch):
     with self._lock:
diff --git a/service.watchdog/watchdog/observers/fsevents.py 
b/service.watchdog/watchdog/observers/fsevents.py
index 0732871..7c55a6f 100644
--- a/service.watchdog/watchdog/observers/fsevents.py
+++ b/service.watchdog/watchdog/observers/fsevents.py
@@ -72,7 +72,7 @@ if platform.is_darwin():
       self._lock = threading.Lock()
       self.snapshot = DirectorySnapshot(watch.path, watch.is_recursive)
 
-    def on_thread_told_to_stop(self):
+    def on_thread_exit(self):
       _fsevents.remove_watch(self.watch)
       _fsevents.stop(self)
 
diff --git a/service.watchdog/watchdog/observers/inotify.py 
b/service.watchdog/watchdog/observers/inotify.py
index 31f5f42..e491a96 100644
--- a/service.watchdog/watchdog/observers/inotify.py
+++ b/service.watchdog/watchdog/observers/inotify.py
@@ -522,23 +522,16 @@ if platform.is_linux():
       """
       Closes the inotify instance and removes all associated watches.
       """
-      print("WATCHDOG: Inotify.close()")
       with self._lock:
-      #print("WATCHDOG: Inotify.close() middle 1")
         self._remove_all_watches()
-      #print("WATCHDOG: Inotify.close() middle 2")
         os.close(self._inotify_fd)
-      #print("WATCHDOG: Inotify.close() end")
 
     def read_events(self, event_buffer_size=DEFAULT_EVENT_BUFFER_SIZE):
       """
       Reads events from inotify and yields them.
       """
-      
-      #print("WATCHDOG: BEFORE OS READ")
       event_buffer = os.read(self._inotify_fd, event_buffer_size)
       with self._lock:
-        #print("WATCHDOG: AFTER OS READ")
         event_list = []
         for wd, mask, cookie, name in Inotify._parse_event_buffer(
           event_buffer):
@@ -651,23 +644,14 @@ if platform.is_linux():
                              mask)
       if wd == -1:
         Inotify._raise_error()
-      
-      #print("WATCHDOG: _add_watch: " + str(path))
-      #print("WATCHDOG: _add_watch: " + str(wd))
       self._wd_for_path[path] = wd
       self._path_for_wd[wd] = path
-      #print("WATCHDOG: _add_watch: " + str(self._wd_for_path[path]))
-      #print("WATCHDOG: _add_watch: " + str(self._path_for_wd[wd]))
       return wd
 
     def _remove_all_watches(self):
       """
       Removes all watches.
       """
-      #print("WATCHDOG: _remove_all_watches " + str(self._wd_for_path))
-      #print("WATCHDOG: _remove_all_watches " + 
str(self._wd_for_path.values()))
-      #print("WATCHDOG: _remove_all_watches " + str(self._path_for_wd))
-      
       for wd in self._wd_for_path.values():
         del self._path_for_wd[wd]
         if inotify_rm_watch(self._inotify_fd, wd) == -1:
@@ -757,8 +741,7 @@ if platform.is_linux():
       self._inotify = Inotify(watch.path, watch.is_recursive)
 
     def on_thread_exit(self):
-      print("WATCHDOG: InotifyEmitter.on_thread_exit() " + str(self))
-      ret = self._inotify.close()
+      self._inotify.close()
 
     def queue_events(self, timeout):
       with self._lock:
diff --git a/service.watchdog/watchdog/observers/winapi.py 
b/service.watchdog/watchdog/observers/winapi.py
index 7a9763b..2a3ab4e 100644
--- a/service.watchdog/watchdog/observers/winapi.py
+++ b/service.watchdog/watchdog/observers/winapi.py
@@ -154,6 +154,14 @@ if platform.is_windows():
     ctypes.wintypes.HANDLE, # hObject
     )
 
+  CancelIoEx = ctypes.windll.kernel32.CancelIoEx
+  CancelIoEx.restype = ctypes.wintypes.BOOL
+  CancelIoEx.errcheck = _errcheck_bool
+  CancelIoEx.argtypes = (
+    ctypes.wintypes.HANDLE, # hObject
+    ctypes.POINTER(OVERLAPPED) # lpOverlapped
+    )
+
   CreateEvent = ctypes.windll.kernel32.CreateEventW
   CreateEvent.restype = ctypes.wintypes.HANDLE
   CreateEvent.errcheck = _errcheck_handle
diff --git a/service.watchdog/watchdog/observers/winapi_common.py 
b/service.watchdog/watchdog/observers/winapi_common.py
index a83ee21..900fa59 100644
--- a/service.watchdog/watchdog/observers/winapi_common.py
+++ b/service.watchdog/watchdog/observers/winapi_common.py
@@ -45,7 +45,7 @@ if platform.is_windows():
     CreateFileW,\
     ReadDirectoryChangesW,\
     CreateIoCompletionPort,\
-    CloseHandle
+    CancelIoEx
   from watchdog.events import\
     DirDeletedEvent,\
     DirCreatedEvent,\
@@ -106,7 +106,7 @@ if platform.is_windows():
 
 
   def close_directory_handle(handle):
-    CloseHandle(handle)
+    CancelIoEx(handle, None) #force ReadDirectoryChangesW to return
 
 
   def read_directory_changes(handle, event_buffer, recursive):

-----------------------------------------------------------------------

Summary of changes:
 service.watchdog/addon.xml                         |    2 +-
 service.watchdog/changelog.txt                     |    3 +++
 service.watchdog/watchdog/observers/__init__.py    |    5 ++++-
 service.watchdog/watchdog/observers/api.py         |    5 -----
 service.watchdog/watchdog/observers/fsevents.py    |    2 +-
 service.watchdog/watchdog/observers/inotify.py     |   19 +------------------
 service.watchdog/watchdog/observers/winapi.py      |    8 ++++++++
 .../watchdog/observers/winapi_common.py            |    4 ++--
 8 files changed, 20 insertions(+), 28 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to