Commit b1edc286 authored by Sebastian Dröge's avatar Sebastian Dröge

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.
parent f02b05aa
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment