rtsp-media: prepare continues after error
Submitted by David Svensson Fors
I've encountered the following problem with GstRTSPMedia:
gst_rtsp_media_prepare() got an error in wait_preroll() and jumped to preroll_failed(). The media status had been set to GST_RTSP_MEDIA_STATUS_ERROR. gst_rtsp_media_prepare() called gst_rtsp_media_unprepare() and started unpreparing.
At the same time, start_prepare() was running in another thread. It had been scheduled by default_prepare(), which had been called by gst_rtsp_media_prepare() before wait_preroll(). start_prepare() called start_preroll(), which continued to set the media pipeline to PLAYING, despite the error in the other thread.
When the pipeline tried to go to READY, a gstmultiudpsink called getsockopt on a socket that had already been closed (as a result of the unprepare in the other thread).
The following two excerpts of gdb backtraces show the problem (gst-rtsp-server 1.4.3):
#11 0x7787e894 in finish_unprepare (media=0x63973b60) at rtsp-media.c:2420 #12 0x7788309c in gst_rtsp_media_unprepare (media=0x63973b60) at rtsp-media.c:2529 #13 0x77883390 in gst_rtsp_media_prepare (media=0x63973b60, thread=0x5f1c8968) at rtsp-media.c:2391 #14 0x778959a0 in find_media (client=0xa7ac80, ctx=0x683febc8, path=0x61bc4e68 "/axis-media/media.amp", matched=0x0) at rtsp-client.c:625 #15 0x7789941c in handle_describe_request (ctx=0x683febc8, client=0xa7ac80) at rtsp-client.c:2076 #16 handle_request (request=<optimized out>, client=0xa7ac80) at rtsp-client.c:2412 #17 gst_rtsp_client_handle_message (client=0xa7ac80, message=<optimized out>) at rtsp-client.c:2978 #18 0x77d411e0 in gst_rtsp_source_dispatch_read (stream=<optimized out>, watch=0xaaad00) at gstrtspconnection.c:3279 ...
#1 0x004194c8 in getsockopt (sockfd=323, level=<optimized out>, optname=<optimized out>, optval=<optimized out>, optlen=0x5c2feb0c) at monolith/src/main.c:155 #2 0x7455afec in gst_multiudpsink_start (bsink=0x6cf2f7f0) at gstmultiudpsink.c:1365 #3 0x77838960 in gst_base_sink_change_state (element=0x6cf2f7f0, transition=GST_STATE_CHANGE_NULL_TO_READY) at gstbasesink.c:4901 #4 0x7778578c in gst_element_change_state (element=0x6cf2f7f0, transition=<optimized out>) at gstelement.c:2602 #5 0x77785bd8 in gst_element_set_state_func (element=0x6cf2f7f0, state=<optimized out>) at gstelement.c:2558 #6 0x77765d54 in gst_bin_element_set_state (next=GST_STATE_READY, current=<optimized out>, start_time=18446744073709551615, base_time=0, element=0x6cf2f7f0, bin=0x63957358) at gstbin.c:2328 #7 gst_bin_change_state_func (element=0x63957358, transition=GST_STATE_CHANGE_NULL_TO_READY) at gstbin.c:2665 #8 0x7778578c in gst_element_change_state (element=0x63957358, transition=<optimized out>) at gstelement.c:2602 #9 0x77785bd8 in gst_element_set_state_func (element=0x63957358, state=<optimized out>) at gstelement.c:2558 #10 0x7787e5fc in start_preroll (media=0x63973b60) at rtsp-media.c:2100 #11 0x7787f230 in start_prepare (media=0x63973b60) at rtsp-media.c:2179 #12 0x775ec0dc in g_main_dispatch (context=0x6a8c1e00) at gmain.c:3064