ext/soup/gstsouphttpsrc.*: Fix seeking race condition in #540300

Original commit message from CVS:
* ext/soup/gstsouphttpsrc.c:
* ext/soup/gstsouphttpsrc.h:
Fix seeking race condition in #540300
Patch By: Wouter Cloetens  <wouter at mind be>
This commit is contained in:
Wouter Cloetens 2008-08-02 21:39:01 +00:00 committed by Jan Schmidt
parent d0bb024e11
commit 4223e83f3c
3 changed files with 25 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2008-08-02 Jan Schmidt <jan.schmidt@sun.com>
* ext/soup/gstsouphttpsrc.c:
* ext/soup/gstsouphttpsrc.h:
Fix seeking race condition in #540300
Patch By: Wouter Cloetens <wouter at mind be>
2008-08-02 Sebastian Dröge <sebastian.droege@collabora.co.uk> 2008-08-02 Sebastian Dröge <sebastian.droege@collabora.co.uk>
* gst/matroska/matroska-demux.c: (gst_matroskademux_do_index_seek), * gst/matroska/matroska-demux.c: (gst_matroskademux_do_index_seek),

View file

@ -495,8 +495,10 @@ gst_soup_http_src_unicodify (const gchar * str)
static void static void
gst_soup_http_src_cancel_message (GstSoupHTTPSrc * src) gst_soup_http_src_cancel_message (GstSoupHTTPSrc * src)
{ {
if (src->msg != NULL) if (src->msg != NULL) {
src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED;
soup_session_cancel_message (src->session, src->msg, SOUP_STATUS_CANCELLED); soup_session_cancel_message (src->session, src->msg, SOUP_STATUS_CANCELLED);
}
src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE; src->session_io_status = GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE;
src->msg = NULL; src->msg = NULL;
} }
@ -695,19 +697,21 @@ gst_soup_http_src_finished_cb (SoupMessage * msg, GstSoupHTTPSrc * src)
} }
GST_DEBUG_OBJECT (src, "finished"); GST_DEBUG_OBJECT (src, "finished");
src->ret = GST_FLOW_UNEXPECTED; src->ret = GST_FLOW_UNEXPECTED;
if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING && if (src->session_io_status == GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED) {
src->read_position > 0) { /* gst_soup_http_src_cancel_message() triggered this; probably a seek
* that occurred in the QUEUEING state; i.e. before the connection setup
* was complete. Do nothing */
} else if (src->session_io_status ==
GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING && src->read_position > 0) {
/* The server disconnected while streaming. Reconnect and seeking to the /* The server disconnected while streaming. Reconnect and seeking to the
* last location. */ * last location. */
src->retry = TRUE; src->retry = TRUE;
src->ret = GST_FLOW_CUSTOM_ERROR; src->ret = GST_FLOW_CUSTOM_ERROR;
} else if (G_UNLIKELY (src->session_io_status != } else if (G_UNLIKELY (src->session_io_status !=
GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) { GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING)) {
if (msg->status_code != SOUP_STATUS_CANCELLED) { GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND,
GST_ELEMENT_ERROR (src, RESOURCE, NOT_FOUND, ("%s", msg->reason_phrase),
("%s", msg->reason_phrase), ("libsoup status code %d", msg->status_code));
("libsoup status code %d", msg->status_code));
}
} }
if (src->loop) if (src->loop)
g_main_loop_quit (src->loop); g_main_loop_quit (src->loop);
@ -850,6 +854,8 @@ gst_soup_http_src_response_cb (SoupSession * session, SoupMessage * msg,
src->retry = TRUE; src->retry = TRUE;
} else } else
gst_soup_http_src_parse_status (msg, src); gst_soup_http_src_parse_status (msg, src);
/* The session's SoupMessage object expires after this callback returns. */
src->msg = NULL;
g_main_loop_quit (src->loop); g_main_loop_quit (src->loop);
} }
@ -993,6 +999,9 @@ gst_soup_http_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING: case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING:
gst_soup_http_src_session_unpause_message (src); gst_soup_http_src_session_unpause_message (src);
break; break;
case GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED:
/* Impossible. */
break;
} }
if (src->ret == GST_FLOW_CUSTOM_ERROR) if (src->ret == GST_FLOW_CUSTOM_ERROR)

View file

@ -42,6 +42,7 @@ typedef enum {
GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE, GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_IDLE,
GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED, GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_QUEUED,
GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING, GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_RUNNING,
GST_SOUP_HTTP_SRC_SESSION_IO_STATUS_CANCELLED,
} GstSoupHTTPSrcSessionIOStatus; } GstSoupHTTPSrcSessionIOStatus;
struct _GstSoupHTTPSrc { struct _GstSoupHTTPSrc {