[PATCH] grive: add timeout to curl_easy_perform()

442 views
Skip to first unread message

Martin Hundebøll

unread,
Dec 12, 2013, 7:00:51 AM12/12/13
to grive...@googlegroups.com, Martin Hundebøll
When experiencing a HTTP Error 500, grive failed to retry after 5
seconds, and instead ended up hanging in a call to curl_easy_perform().

This adds a timeout option to the curl handle. With this change, grive
haven't seen a single HTTP Error 500 after uploading more than 10 GB of
data.

Signed-off-by: Martin Hundebøll <mar...@hundeboll.net>
---
libgrive/src/http/CurlAgent.cc | 1 +
1 file changed, 1 insertion(+)

diff --git a/libgrive/src/http/CurlAgent.cc b/libgrive/src/http/CurlAgent.cc
index d725e86..33cd0a1 100644
--- a/libgrive/src/http/CurlAgent.cc
+++ b/libgrive/src/http/CurlAgent.cc
@@ -143,6 +143,7 @@ long CurlAgent::ExecCurl(
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &CurlAgent::Receive ) ;
::curl_easy_setopt(curl, CURLOPT_WRITEDATA, dest ) ;
+ ::curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 5000 );

SetHeader( hdr ) ;

--
1.8.5.1

Martin Hundebøll

unread,
Dec 12, 2013, 7:06:08 AM12/12/13
to grive...@googlegroups.com
Hi,

On 2013-12-12 13:00, Martin Hundebøll wrote:
> When experiencing a HTTP Error 500, grive failed to retry after 5
> seconds, and instead ended up hanging in a call to curl_easy_perform().
>
> This adds a timeout option to the curl handle. With this change, grive
> haven't seen a single HTTP Error 500 after uploading more than 10 GB of
> data.

Sorry for the noise... This patch does _not_ fix the issue :( Does
anyone have suggestions on how to recover from this error:

resquest failed due to temperory error: 500. retrying in 5 seconds

When attaching to the process with GDB, the backtrace reveals that grive
is stuck in curl_easy_perform():

#0 0x00007fb4d97309dd in poll () from /usr/lib/libc.so.6
#1 0x00007fb4daf1e5f9 in ?? () from /usr/lib/libcurl.so.4
#2 0x00007fb4daf194a0 in curl_multi_wait () from /usr/lib/libcurl.so.4
#3 0x00007fb4daf13c7f in curl_easy_perform () from /usr/lib/libcurl.so.4
#4 0x00000000004659c5 in gr::http::CurlAgent::ExecCurl(std::string
const&, gr::DataStream*, gr::http::Header const&) ()
#5 0x0000000000465f58 in gr::http::CurlAgent::Put(std::string const&,
gr::File*, gr::DataStream*, gr::http::Header const&) ()
#6 0x0000000000475aac in gr::AuthAgent::Put(std::string const&,
gr::File*, gr::DataStream*, gr::http::Header const&) ()
#7 0x0000000000457c58 in gr::v1::Resource::Upload(gr::http::Agent*,
std::string const&, bool) ()
#8 0x0000000000458329 in gr::v1::Resource::Create(gr::http::Agent*) ()
#9 0x00000000004589d8 in gr::v1::Resource::SyncSelf(gr::http::Agent*,
gr::Json const&) ()
#10 0x0000000000458ce7 in gr::v1::Resource::Sync(gr::http::Agent*,
gr::DateTime&, gr::Json const&) ()
#11 0x0000000000458e08 in gr::v1::Resource::Sync(gr::http::Agent*,
gr::DateTime&, gr::Json const&) ()
#12 0x0000000000458e08 in gr::v1::Resource::Sync(gr::http::Agent*,
gr::DateTime&, gr::Json const&) ()
#13 0x0000000000458e08 in gr::v1::Resource::Sync(gr::http::Agent*,
gr::DateTime&, gr::Json const&) ()
---Type <return> to continue, or q <return> to quit---
#14 0x000000000044dd58 in gr::v1::State::Sync(gr::http::Agent*, gr::Json
const&) ()
#15 0x00000000004602e0 in gr::v1::Drive::Update() ()
#16 0x000000000043e8be in Main(int, char**) ()
#17 0x000000000043c78b in main ()

Thanks,
Martin

> Signed-off-by: Martin Hundebøll <mar...@hundeboll.net>
> ---
> libgrive/src/http/CurlAgent.cc | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/libgrive/src/http/CurlAgent.cc b/libgrive/src/http/CurlAgent.cc
> index d725e86..33cd0a1 100644
> --- a/libgrive/src/http/CurlAgent.cc
> +++ b/libgrive/src/http/CurlAgent.cc
> @@ -143,6 +143,7 @@ long CurlAgent::ExecCurl(
> ::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
> ::curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &CurlAgent::Receive ) ;
> ::curl_easy_setopt(curl, CURLOPT_WRITEDATA, dest ) ;
> + ::curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 5000 );
>
> SetHeader( hdr ) ;
>
>


--
Kind Regards
Martin Hundebøll
Frederiks Allé 99, 1.th
8000 Aarhus C
Denmark

+45 61 65 54 61
mar...@hundeboll.net

signature.asc
Reply all
Reply to author
Forward
0 new messages