From 83ed2586841bb912ad1d6ba6cdf0da10b6c43f18 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 5 Mar 2010 18:23:18 +0100 Subject: [PATCH] media: limit the time to wait to something huge Avoid waiting forever but limit the timeout to 20 seconds. --- gst/rtsp-server/rtsp-media.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c index a2fe5d3f5d..116e806b83 100644 --- a/gst/rtsp-server/rtsp-media.c +++ b/gst/rtsp-server/rtsp-media.c @@ -1115,12 +1115,18 @@ static GstRTSPMediaStatus gst_rtsp_media_get_status (GstRTSPMedia *media) { GstRTSPMediaStatus result; + GTimeVal timeout; g_mutex_lock (media->lock); + g_get_current_time (&timeout); + g_time_val_add (&timeout, 20 * G_USEC_PER_SEC); /* while we are preparing, wait */ while (media->status == GST_RTSP_MEDIA_STATUS_PREPARING) { GST_DEBUG ("waiting for status change"); - g_cond_wait (media->cond, media->lock); + if (!g_cond_timed_wait (media->cond, media->lock, &timeout)) { + GST_DEBUG ("timeout, assuming error status"); + media->status = GST_RTSP_MEDIA_STATUS_ERROR; + } } /* could be success or error */ result = media->status;