[vlc-devel] commit: RTP out: fix race condition in SDP generation from RTSP DESCRIBE ( Rémi Denis-Courmont )
git version control
git at videolan.org
Wed Feb 17 17:42:14 CET 2010
vlc/vlc-1.0 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Feb 17 18:42:08 2010 +0200| [34c0e337fd5ebf79d505ef94168092909fe7da3c] | committer: Rémi Denis-Courmont
RTP out: fix race condition in SDP generation from RTSP DESCRIBE
(cherry picked from commit b8ef158dad5705cd3aa74c5b703c8d6c2a128bc3)
Conflicts:
modules/stream_out/rtp.c
modules/stream_out/rtp.h
> http://git.videolan.org/gitweb.cgi/vlc/vlc-1.0.git/?a=commit;h=34c0e337fd5ebf79d505ef94168092909fe7da3c
---
modules/stream_out/rtp.c | 16 ++++++++++------
modules/stream_out/rtp.h | 2 +-
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index e37b083..e54bb6d 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -686,9 +686,9 @@ out:
* SDPGenerate
*****************************************************************************/
/*static*/
-char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
+char *SDPGenerate( sout_stream_t *p_stream, const char *rtsp_url )
{
- const sout_stream_sys_t *p_sys = p_stream->p_sys;
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
char *psz_sdp;
struct sockaddr_storage dst;
socklen_t dstlen;
@@ -710,11 +710,15 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
*/
int inclport;
+ vlc_mutex_lock( &p_sys->lock_es );
+ if( p_sys->i_es == 0 )
+ goto out; /* hmm... */
+
if( p_sys->psz_destination != NULL )
{
inclport = 1;
- /* Oh boy, this is really ugly! (+ race condition on lock_es) */
+ /* Oh boy, this is really ugly! */
dstlen = sizeof( dst );
if( p_sys->es[0]->listen_fd != NULL )
getsockname( p_sys->es[0]->listen_fd[0],
@@ -739,7 +743,7 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
psz_sdp = vlc_sdp_Start( VLC_OBJECT( p_stream ), SOUT_CFG_PREFIX,
NULL, 0, (struct sockaddr *)&dst, dstlen );
if( psz_sdp == NULL )
- return NULL;
+ goto out;
/* TODO: a=source-filter */
if( p_sys->rtcp_mux )
@@ -748,7 +752,6 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
if( rtsp_url != NULL )
sdp_AddAttribute ( &psz_sdp, "control", "%s", rtsp_url );
- /* FIXME: locking?! */
for( i = 0; i < p_sys->i_es; i++ )
{
sout_stream_id_t *id = p_sys->es[i];
@@ -812,7 +815,8 @@ char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url )
"SC:RTP%c", toupper( mime_major[0] ) );
}
}
-
+out:
+ vlc_mutex_unlock( &p_sys->lock_es );
return psz_sdp;
}
diff --git a/modules/stream_out/rtp.h b/modules/stream_out/rtp.h
index b3da884..6d2d5c0 100644
--- a/modules/stream_out/rtp.h
+++ b/modules/stream_out/rtp.h
@@ -34,7 +34,7 @@ rtsp_stream_id_t *RtspAddId( rtsp_stream_t *rtsp, sout_stream_id_t *sid,
unsigned loport, unsigned hiport );
void RtspDelId( rtsp_stream_t *rtsp, rtsp_stream_id_t * );
-char *SDPGenerate( const sout_stream_t *p_stream, const char *rtsp_url );
+char *SDPGenerate( sout_stream_t *p_stream, const char *rtsp_url );
int rtp_add_sink( sout_stream_id_t *id, int fd, bool rtcp_mux );
void rtp_del_sink( sout_stream_id_t *id, int fd );
More information about the vlc-devel
mailing list