From 1f995361dde3d5703257be255f0be19b745e4b1b Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 7 Aug 2009 21:01:01 +0200 Subject: [PATCH] Switch to pthread_cond_timedwait in streammsg queue. --- src/stream.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/stream.c b/src/stream.c index 7f819403ee..66c6286b8e 100644 --- a/src/stream.c +++ b/src/stream.c @@ -101,8 +101,12 @@ StreamMsg *StreamMsgGetFromQueue(StreamMsgQueue *q) { mutex_lock(&q->mutex_q); if (q->len == 0) { - /* if we have no stream msgs in queue, wait... */ - pthread_cond_wait(&q->cond_q, &q->mutex_q); + struct timespec cond_time; + cond_time.tv_sec = time(NULL) + 5; + cond_time.tv_nsec = 0; + + /* if we have no stream msgs in queue, wait... for 5 seconds */ + pthread_cond_timedwait(&q->cond_q, &q->mutex_q, &cond_time); } if (q->len > 0) { StreamMsg *s = StreamMsgDequeue(q);