Ignore:
Timestamp:
Aug 5, 2011, 2:08:17 PM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

OS/2: Fixed native QFileSystemWatcher failure die to bad timings.

It was possible that under the certain CPU load the client (Qt) would
not get its instance of the notification pipe in time and simply fail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/corelib/io/qfilesystemwatcher_os2.cpp

    r806 r942  
    9797    : notifyPipe(NULLHANDLE), eventSem(NULLHANDLE), isRunning(false)
    9898{
    99     ULONG dummy;
    100     APIRET arc = DosOpen(PIPE_CHANGENOTIFY, &notifyPipe, &dummy, 0, FILE_OPEN,
    101                          OPEN_ACTION_OPEN_IF_EXISTS,
    102                          OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY, NULL);
     99    ULONG dummy, retries = 3;
     100    APIRET arc;
     101
     102    // Try to grab a free pipe instance. Retries are necessary because
     103    // DosWaitNPipe() is not "atomic" (even if it returns NO_ERROR, our next
     104    // DosOpen() can still fail due to some client being faster). Note that we
     105    // wait for max 1000ms on each try because the XWP pipe server may perform
     106    // a 1000ms delay between client connections under some circumstances.
     107    forever {
     108        arc = DosOpen(PIPE_CHANGENOTIFY, &notifyPipe, &dummy, 0, FILE_OPEN,
     109                      OPEN_ACTION_OPEN_IF_EXISTS,
     110                      OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY |
     111                      OPEN_FLAGS_NOINHERIT, NULL);
     112        if (arc == ERROR_PIPE_BUSY && --retries) {
     113            arc = DosWaitNPipe(PIPE_CHANGENOTIFY, 1000);
     114            if (arc == NO_ERROR)
     115                continue;
     116        }
     117        break;
     118    }
     119
    103120    if (arc == NO_ERROR) {
    104121        // make sure the pipe is non-blocking so that we can get ERROR_NO_DATA
Note: See TracChangeset for help on using the changeset viewer.