Maarten Lankhorst : winmm: Fix fd leak on restarting timer.

Alexandre Julliard julliard at winehq.org
Mon Aug 16 12:24:56 CDT 2010


Module: wine
Branch: master
Commit: 6910b0f1439b15d73783bcd276512a517fe8fd83
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=6910b0f1439b15d73783bcd276512a517fe8fd83

Author: Maarten Lankhorst <m.b.lankhorst at gmail.com>
Date:   Tue Aug 10 16:04:24 2010 +0200

winmm: Fix fd leak on restarting timer.

---

 dlls/winmm/time.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/winmm/time.c b/dlls/winmm/time.c
index e692fb6..e055f6b 100644
--- a/dlls/winmm/time.c
+++ b/dlls/winmm/time.c
@@ -243,16 +243,19 @@ static DWORD CALLBACK TIME_MMSysTimeThread(LPVOID arg)
 static void TIME_MMTimeStart(void)
 {
     TIME_TimeToDie = 0;
-    if (!TIME_hMMTimer) {
-        HMODULE mod;
-        if (pipe(TIME_fdWake) < 0)
-        {
+
+    if (TIME_fdWake[0] < 0) {
+        if (pipe(TIME_fdWake) < 0) {
             TIME_fdWake[0] = TIME_fdWake[1] = -1;
             ERR("Cannot create pipe: %s\n", strerror(errno));
         } else {
             fcntl(TIME_fdWake[0], F_SETFL, O_NONBLOCK);
             fcntl(TIME_fdWake[1], F_SETFL, O_NONBLOCK);
         }
+    }
+
+    if (!TIME_hMMTimer) {
+        HMODULE mod;
         GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCWSTR)TIME_MMSysTimeThread, &mod);
         TIME_hMMTimer = CreateThread(NULL, 0, TIME_MMSysTimeThread, mod, 0, NULL);
         SetThreadPriority(TIME_hMMTimer, THREAD_PRIORITY_TIME_CRITICAL);




More information about the wine-cvs mailing list