After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 774485 - curl: Sometimes upload hangs in case the connection was cut between the client and the HTTP server
curl: Sometimes upload hangs in case the connection was cut between the clien...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other other
: Normal normal
: 1.11.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-11-15 17:58 UTC by Imre.Eors
Modified: 2016-11-16 09:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
PATCH: Time out in case transfer speed in bytes per second stay below CURLOPT_LOW_SPEED_LIMIT during CURLOPT_LOW_SPEED_TIME (1.44 KB, patch)
2016-11-15 17:58 UTC, Imre.Eors
needs-work 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 (1.36 KB, patch)
2016-11-16 09:05 UTC, Imre.Eors
committed Details | Review

Description Imre.Eors 2016-11-15 17:58:32 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 1 Tim-Philipp Müller 2016-11-16 00:12:18 UTC
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'.
Comment 2 Tim-Philipp Müller 2016-11-16 00:22:23 UTC
> >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.
Comment 3 Imre.Eors 2016-11-16 09:05:44 UTC
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
Comment 4 Imre.Eors 2016-11-16 09:36:40 UTC
Thanks Tim, please find attached the corrected patch.
Comment 5 Tim-Philipp Müller 2016-11-16 09:45:32 UTC
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 6 Tim-Philipp Müller 2016-11-16 09:46:21 UTC
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) :)