fix deadlock in fsnotifier

This commit is contained in:
Dmitry Jemerov
2009-02-02 17:30:08 +03:00
parent 7f2fe104a0
commit b26a25aa68
2 changed files with 10 additions and 11 deletions
Binary file not shown.
+10 -11
View 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);
}