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.
This commit is contained in:
Sebastian Dröge 2016-07-11 19:57:18 +03:00
parent f02b05aa42
commit b1edc28695

View file

@ -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;
}