* CancelableWait in misc.c should check for negative timeout
@ 1999-03-25 14:28 Tor Lillqvist
[not found] ` < 199903252227.AAA25040@m3.pp.htv.fi >
0 siblings, 1 reply; 3+ messages in thread
From: Tor Lillqvist @ 1999-03-25 14:28 UTC (permalink / raw)
To: pthreads-win32
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: CancelableWait in misc.c should check for negative timeout
[not found] ` < 199903252227.AAA25040@m3.pp.htv.fi >
@ 1999-03-25 14:43 ` Tor Lillqvist
1999-03-25 17:45 ` Ross Johnson
0 siblings, 1 reply; 3+ messages in thread
From: Tor Lillqvist @ 1999-03-25 14:43 UTC (permalink / raw)
To: pthreads-win32
Tor Lillqvist writes:
> if (((int) timeout) < 0)
> timeout = 0;
Actually, as INFINITE is 0xFFFFFFFF, i.e. -1, this code snippet
shouldn't be in CancelableWait, but in pthreadCancelableTimedWait.
--tml
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: CancelableWait in misc.c should check for negative timeout
1999-03-25 14:43 ` Tor Lillqvist
@ 1999-03-25 17:45 ` Ross Johnson
0 siblings, 0 replies; 3+ messages in thread
From: Ross Johnson @ 1999-03-25 17:45 UTC (permalink / raw)
To: Tor Lillqvist; +Cc: pthreads-win32
Hi Tor,
On Thu, 25 Mar 1999, Tor Lillqvist wrote:
> Tor Lillqvist writes:
> > if (((int) timeout) < 0)
> > timeout = 0;
>
> Actually, as INFINITE is 0xFFFFFFFF, i.e. -1, this code snippet
> shouldn't be in CancelableWait, but in pthreadCancelableTimedWait.
>
I'm thinking that the check should go in _pthread_sem_timedwait
which does the conversion from an abstime value to milliseconds.
pthreadCancelableTimedWait is called by _pthread_sem_timedwait which
is called by pthread_cond_timedwait.
The reason is: I think that the millisecond timeout argument for
pthreadCancelableTimedWait should behave the same as for
WaitForMultipleObjects.
Ross
+----------------------+---+
| Ross Johnson | | E-Mail: rpj@ise.canberra.edu.au
| Info Sciences and Eng|___|
| University of Canberra | FAX: +61 6 2015227
| PO Box 1 |
| Belconnen ACT 2616 | WWW: http://willow.canberra.edu.au/~rpj/
| AUSTRALIA |
+--------------------------+
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1999-03-25 17:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-25 14:28 CancelableWait in misc.c should check for negative timeout Tor Lillqvist
[not found] ` < 199903252227.AAA25040@m3.pp.htv.fi >
1999-03-25 14:43 ` Tor Lillqvist
1999-03-25 17:45 ` Ross Johnson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).