Code

utils channel: Normalize time before passing it to phtread_cond_timedwait.
authorSebastian Harl <sh@tokkee.org>
Mon, 21 Oct 2013 06:59:03 +0000 (08:59 +0200)
committerSebastian Harl <sh@tokkee.org>
Mon, 21 Oct 2013 06:59:03 +0000 (08:59 +0200)
src/utils/channel.c

index af41b477b4748252763123b8a0303aa5edc06676..8e55ae564872f1052494f78ddd62658b40d48394 100644 (file)
@@ -210,6 +210,11 @@ sdb_channel_select(sdb_channel_t *chan, int *wantread, void *read_data,
                        abstime.tv_sec += timeout->tv_sec;
                        abstime.tv_nsec += timeout->tv_nsec;
 
+                       if (abstime.tv_nsec > 1000000000) {
+                               abstime.tv_nsec -= 1000000000;
+                               abstime.tv_sec += 1;
+                       }
+
                        status = pthread_cond_timedwait(&chan->cond, &chan->lock,
                                        &abstime);
                }