From 2fc85d398057bb65421d39de588e72dd082f2c47 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 May 2013 10:50:42 +0200 Subject: [PATCH] rtsp: Cleanup the error path Make sure the watch is removed when we close the read socket because of an error. --- gst-libs/gst/rtsp/gstrtspconnection.c | 32 +++++++++++++++------------ 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/gst-libs/gst/rtsp/gstrtspconnection.c b/gst-libs/gst/rtsp/gstrtspconnection.c index 39c6c68950..473581df7c 100644 --- a/gst-libs/gst/rtsp/gstrtspconnection.c +++ b/gst-libs/gst/rtsp/gstrtspconnection.c @@ -2733,6 +2733,8 @@ struct _GstRTSPWatch GSource *readsrc; GSource *writesrc; + gboolean keep_running; + /* queued message for transmission */ guint id; GMutex mutex; @@ -2868,21 +2870,21 @@ eof: if (watch->funcs.closed) watch->funcs.closed (watch, watch->user_data); - /* always stop when the readfd returns EOF in non-tunneled mode */ + /* we closed the read connection, stop the watch now */ + watch->keep_running = FALSE; + + /* always stop when the input returns EOF in non-tunneled mode */ return FALSE; } read_error: { if (watch->funcs.error_full) - GST_RTSP_CHECK (watch->funcs.error_full (watch, res, &watch->message, - 0, watch->user_data), error); - } -error: - { - if (watch->funcs.error) + watch->funcs.error_full (watch, res, &watch->message, + 0, watch->user_data); + else if (watch->funcs.error) watch->funcs.error (watch, res, watch->user_data); - return FALSE; + goto eof; } } @@ -2949,15 +2951,16 @@ write_blocked: return TRUE; /* ERRORS */ +eof: + { + return FALSE; + } write_error: { if (watch->funcs.error_full) - GST_RTSP_CHECK (watch->funcs.error_full (watch, res, NULL, - watch->write_id, watch->user_data), error); - } -error: - { - if (watch->funcs.error) + watch->funcs.error_full (watch, res, NULL, + watch->write_id, watch->user_data); + else if (watch->funcs.error) watch->funcs.error (watch, res, watch->user_data); return FALSE; @@ -3041,6 +3044,7 @@ gst_rtsp_watch_new (GstRTSPConnection * conn, result->messages = g_queue_new (); gst_rtsp_watch_reset (result); + result->keep_running = TRUE; result->funcs = *funcs; result->user_data = user_data;