summaryrefslogtreecommitdiff
path: root/ext/soup
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2016-07-11 19:57:18 +0300
committerSebastian Dröge <sebastian@centricular.com>2016-07-11 19:59:22 +0300
commitb1edc28695daffb1f986c812098ce64bfeaa3e0c (patch)
tree8ef843a2aa96161737ca32cd2bb9750c673eb69c /ext/soup
parentf02b05aa42de99eddb02d83a3875198ec3ee4ed3 (diff)
souphttpsrc: Fix keep-alive handling
We have to get rid of the message on EOS when the complete stream is read to remember that we successfully finished handling this specific message. Otherwise we will cancel it later and close the connection instead of reusing it at a later time. It might also make sense to reuse connections if a non-200 response is received. As long as there was no connection error, the HTTP connection should be re-usable.
Diffstat (limited to 'ext/soup')
-rw-r--r--ext/soup/gstsouphttpsrc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ext/soup/gstsouphttpsrc.c b/ext/soup/gstsouphttpsrc.c
index cd6670439..4edc9263c 100644
--- a/ext/soup/gstsouphttpsrc.c
+++ b/ext/soup/gstsouphttpsrc.c
@@ -968,11 +968,16 @@ gst_soup_http_src_session_close (GstSoupHTTPSrc * src)
GST_DEBUG_OBJECT (src, "Closing session");
g_mutex_lock (&src->mutex);
+ if (src->msg) {
+ soup_session_cancel_message (src->session, src->msg, SOUP_STATUS_CANCELLED);
+ g_object_unref (src->msg);
+ src->msg = NULL;
+ }
+
if (src->session) {
- soup_session_abort (src->session); /* This unrefs the message. */
+ soup_session_abort (src->session);
g_object_unref (src->session);
src->session = NULL;
- src->msg = NULL;
}
g_mutex_unlock (&src->mutex);
}
@@ -1626,7 +1631,6 @@ gst_soup_http_src_read_buffer (GstSoupHTTPSrc * src, GstBuffer ** outbuf)
g_mutex_unlock (&src->mutex);
return GST_FLOW_FLUSHING;
}
- g_mutex_unlock (&src->mutex);
gst_buffer_unmap (*outbuf, &mapinfo);
if (read_bytes > 0) {
@@ -1645,10 +1649,14 @@ gst_soup_http_src_read_buffer (GstSoupHTTPSrc * src, GstBuffer ** outbuf)
/* Maybe the server disconnected, retry */
ret = GST_FLOW_CUSTOM_ERROR;
} else {
+ g_object_unref (src->msg);
+ src->msg = NULL;
ret = GST_FLOW_EOS;
src->have_body = TRUE;
}
}
+ g_mutex_unlock (&src->mutex);
+
return ret;
}