fix deadlock in fsnotifier
authorDmitry Jemerov <yole@intellij.com>
Mon, 2 Feb 2009 14:30:08 +0000 (17:30 +0300)
committerDmitry Jemerov <yole@intellij.com>
Mon, 2 Feb 2009 14:30:08 +0000 (17:30 +0300)
bin/fsnotifier.exe
tools/fileWatcher3/fileWatcher3.cpp

index 4d86ec022c40185ede2d025aba04f2c588d754bd..2a9d49c184530ee6452e069bd1d2ab63d67831a9 100644 (file)
Binary files a/bin/fsnotifier.exe and b/bin/fsnotifier.exe differ
index c3a5d7fb277574ade52cf32b5139a6ed4d9ecb86..556148f141a6fc46bf981b75d8c4f453338b5e00 100644 (file)
@@ -266,7 +266,9 @@ void StopRoot(WatchRootInfo *info)
 
 void UpdateRoots()
 {
-       bool haveUsedRoots = false;
+       bool haveUnwatchableRoots = false;
+       char infoBuffer [256];
+       strcpy_s(infoBuffer, "UNWATCHEABLE\n");
        for(int i=0; i<ROOT_COUNT; i++)
        {
                if (watchRootInfos [i].bInitialized && (!watchRootInfos [i].bUsed || watchRootInfos [i].bFailed))
@@ -276,18 +278,13 @@ void UpdateRoots()
                }
                if (watchRootInfos [i].bUsed)
                {
-                       if (!haveUsedRoots)
-                       {
-                               haveUsedRoots = true;
-                               EnterCriticalSection(&csOutput);
-                               puts("UNWATCHEABLE");
-                       }
-
                        char rootPath[8];
                        sprintf_s(rootPath, 8, "%c:\\", watchRootInfos [i].driveLetter);
                        if (!IsWatchable(rootPath))
                        {
-                               puts(rootPath);
+                               haveUnwatchableRoots = true;
+                               strcat_s(infoBuffer, rootPath);
+                               strcat_s(infoBuffer, "\n");
                                continue;
                        }
                        if (!watchRootInfos [i].bInitialized)
@@ -297,9 +294,11 @@ void UpdateRoots()
                        PrintMountPoints(rootPath);
                }
        }
-       if (haveUsedRoots)
+       if (haveUnwatchableRoots)
        {
-               puts("#");
+               strcat_s(infoBuffer, "#");
+               EnterCriticalSection(&csOutput);
+               puts(infoBuffer);
                fflush(stdout);
                LeaveCriticalSection(&csOutput);
        }