GNOME Bugzilla – Bug 774485
curl: Sometimes upload hangs in case the connection was cut between the client and the HTTP server
Last modified: 2016-11-16 09:46:59 UTC
Created attachment 339955 [details] [review] PATCH: Time out in case transfer speed in bytes per second stay below CURLOPT_LOW_SPEED_LIMIT during CURLOPT_LOW_SPEED_TIME Image upload hangs in case the connection was cut between the client and the HTTP server. In function handle_transfer we are calling gst_poll_wait with 90 seconds time out and afterward curl_multi_perform to write the data into the socket send buffer. We have two cases: 1. Function gst_poll_wait which calls ppoll set POLLOUT in revents field, which means the socket is writable. Then curl_multi_perform fill the socket send buffer. During the upload we cut the connection between the client and the server. I mean we pull out the cable, physically terminate the connection between the client and the server. In case the socket send buffer level is above the low-water mark, then ppoll after 90 seconds throws a time out. Time out happens because the socket is not writable during 90 seconds. 2. Function gst_poll_wait, which calls ppoll set POLLOUT in revents field, which means the socket is writable. Afterward curl_multi_perform fill the socket send buffer. Let's say that curl_multi_perform sent all the data and now waiting for the transfer to finish. The kernel sending out the data from the socket send buffer. When the socket send buffer level goes below the low-water mark we cut the connection between the client and the server.I mean we pull out the cable, physically terminate the connection between the client and the server. In this case we stuck in the while loop, where we call gst_poll_wait and gst_multi_perform alternately. Function ppoll set only POLLOUT in revents field, because we can write more data to the socket send buffer. Then function curl_multi_perform is called, which has already copied all the data into the socket send buffer and waiting for the transfer to finish. During the upload in case we stop the Apache server, then ppoll set immediately POLLHUP in revents field. Despite of this fact if we cut the connection between the client and the server physically, POLLHUP is not set by ppoll. In the light of the above information, to fix this upload stuck issue, we set CURLOPT_LOW_SPEED_LIMIT and CURLOPT_LOW_SPEED_TIME. Please find the patch attached. We are using the below setup: client---switch---PC(NAT)---PROXY---HTTP server Connection is cut between the PC and the PROXY.
Comment on attachment 339955 [details] [review] PATCH: Time out in case transfer speed in bytes per second stay below CURLOPT_LOW_SPEED_LIMIT during CURLOPT_LOW_SPEED_TIME Thanks for the patch! Just some small niggles: >Subject: [PATCH] transfer hangs in case connection was cut between client and server Please prefix the summary line with 'curl: ' and add the bug url in the commit message body. >Change-Id: I3c21fa5fc349f6c3117b097edd662a9f1b888a39 This should not be in there. >diff --git a/gst-plugins-bad/ext/curl/gstcurlbasesink.c b/gst-plugins-bad/ext/curl/gstcurlbasesink.c >index 013839d..b3c7c2e 100644 >--- a/gst-plugins-bad/ext/curl/gstcurlbasesink.c >+++ b/gst-plugins-bad/ext/curl/gstcurlbasesink.c This patch does not apply with 'git am foo.patch'. Presumably because your git repo layout is different. Please fix up any patches you submit so we can apply them with 'git am'.
> >diff --git a/gst-plugins-bad/ext/curl/gstcurlbasesink.c b/gst-plugins-bad/ext/curl/gstcurlbasesink.c > >index 013839d..b3c7c2e 100644 > >--- a/gst-plugins-bad/ext/curl/gstcurlbasesink.c > >+++ b/gst-plugins-bad/ext/curl/gstcurlbasesink.c > > Please fix up any patches you submit so we can apply them with 'git am'. Just to be sure, it's probably enough to just edit the .patch file in an editor and remove the gst-plugins-bad/ from the paths.
Created attachment 339999 [details] [review] PATCH: curl: Time out in case transfer speed in bytes per second stay below CURLOPT_LOW_SPEED_LIMIT during CURLOPT_LOW_SPEED_TIME
Thanks Tim, please find attached the corrected patch.
Thanks! commit 2c3aa2f09cc8c02cc32af12d415181a0c42c9ef6 Author: Imre Eörs <imree@axis.com> Date: Tue Nov 15 16:20:10 2016 +0100 curl: transfer hangs in case connection was cut between client and server https://bugzilla.gnome.org/show_bug.cgi?id=774485
Comment on attachment 339999 [details] [review] PATCH: curl: Time out in case transfer speed in bytes per second stay below CURLOPT_LOW_SPEED_LIMIT during CURLOPT_LOW_SPEED_TIME Thanks for fixing it up. Please also mark old patches as 'obsolete' when attaching a new revision of a patch (there's a checkbox for that usually) :)