This is the mail archive of the pthreads-win32@sourceware.cygnus.com mailing list for the pthreads-win32 project. See the pthreads-win32 home page for more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

CancelableWait in misc.c should check for negative timeout



I think the function CancelableWait should check for timeout being
negative (when casted to an int, that is). This can happen if you call
pthread_cond_timedwait with an abstime that's already gone, because of
some rounding error or slightly incorrect handling of various
timestamp formats. It happens for instance in GLib's testgthread
program. If timeout is negative, it probably should be treated as
zero.

In CancelableWait, before calling WaitForMultipleObjects, insert:

  if (((int) timeout) < 0)
    timeout = 0;

Cheers,
--tml