Skip to content

Commit 6a84f2c

Browse files
twpedersenalfred2g
andauthored
Posix: fix event_wait_timed() (#346)
event_wait_timed() was ignoring a timeout of 1000 ms. Presumably this is because pthread_cond_timedwait() only considers tv_nsec less than one second. Convert the timeout in miliseconds to second and nanosecond components to fix this. Co-authored-by: alfred gedeon <28123637+alfred2g@users.noreply.github.com>
1 parent bad8f01 commit 6a84f2c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

portable/ThirdParty/GCC/Posix/utils/wait_for_event.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ bool event_wait_timed( struct event * ev,
7676
int ret = 0;
7777

7878
clock_gettime( CLOCK_REALTIME, &ts );
79-
//ts.tv_sec += ms;
80-
ts.tv_nsec += (ms * 1000000);
79+
ts.tv_sec += ms / 1000;
80+
ts.tv_nsec += ((ms % 1000) * 1000000);
8181
pthread_mutex_lock( &ev->mutex );
8282

8383
while( (ev->event_triggered == false) && (ret == 0) )

0 commit comments

Comments
 (0)