[vlc-commits] VoD: fix deadlock between RTSP and VLM

Pierre Ynard git at videolan.org
Sun Jan 15 00:38:44 CET 2012


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Jan 15 00:27:52 2012 +0100| [7ac6ae55e2496c7178ce0b15a3c16a2db464a38c] | committer: Pierre Ynard

VoD: fix deadlock between RTSP and VLM

The deadlock would occur when the VLM would stop an instance and detach
its RTP output, at the same time as an RTSP client would issue a VoD
command to the VLM.

Unfortunately this introduces a race condition where wrong RTP-Info can
be returned.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7ac6ae55e2496c7178ce0b15a3c16a2db464a38c
---

 modules/stream_out/rtsp.c |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/modules/stream_out/rtsp.c b/modules/stream_out/rtsp.c
index c71139f..2f9569a 100644
--- a/modules/stream_out/rtsp.c
+++ b/modules/stream_out/rtsp.c
@@ -1052,16 +1052,17 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                     info[infolen - 2] = '\0'; /* remove trailing ", " */
                     httpd_MsgAdd( answer, "RTP-Info", "%s", info );
                 }
+            }
+            vlc_mutex_unlock( &rtsp->lock );
+
+            if (ses != NULL)
+            {
                 if (vod)
                 {
                     vod_play(rtsp->vod_media, psz_session, &start, end);
                     npt = start;
                 }
-            }
-            vlc_mutex_unlock( &rtsp->lock );
 
-            if (ses != NULL)
-            {
                 double f_npt = (double) npt / CLOCK_FREQ;
                 httpd_MsgAdd( answer, "Range", "npt=%f-", f_npt );
             }
@@ -1089,15 +1090,7 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
             ses = RtspClientGet( rtsp, psz_session );
             if (ses != NULL)
             {
-                if (id == NULL)
-                {
-                    assert(vod);
-                    int64_t npt;
-                    vod_pause(rtsp->vod_media, psz_session, &npt);
-                    double f_npt = (double) npt / CLOCK_FREQ;
-                    httpd_MsgAdd( answer, "Range", "npt=%f-", f_npt );
-                }
-                else /* "Mute" the selected track */
+                if (id != NULL) /* "Mute" the selected track */
                 {
                     bool found = false;
                     for (int i = 0; i < ses->trackc; i++)
@@ -1123,6 +1116,15 @@ static int RtspHandler( rtsp_stream_t *rtsp, rtsp_stream_id_t *id,
                 RtspClientAlive(ses);
             }
             vlc_mutex_unlock( &rtsp->lock );
+
+            if (ses != NULL && id == NULL)
+            {
+                assert(vod);
+                int64_t npt = 0;
+                vod_pause(rtsp->vod_media, psz_session, &npt);
+                double f_npt = (double) npt / CLOCK_FREQ;
+                httpd_MsgAdd( answer, "Range", "npt=%f-", f_npt );
+            }
             break;
         }
 



More information about the vlc-commits mailing list