curl-library
Unable to handle timeouts properly
Date: Tue, 23 Mar 2010 13:08:57 +0100 (CET)
Hi,
I'm scratching my head on how CURLOPT_TIMEOUT_MS and actually work.
I'm currently sending regularly status updates to the Twitter service, using the liboauth library. Everything goes fine except that very occasionally, the process seems to keep waiting for incoming data. An strace command shows the following :
strace -p 17067
Process 17067 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 0
poll([{fd=11, events=POLLIN|POLLPRI}], 1, 0) = 0
poll([{fd=11, events=POLLIN|POLLPRI}], 1, 1000) = 0
.
.
.
.
.
However, the POST request is done as follow :
#define OAUTH_POST_TIMEOUT 20000
char *oauth_curl_post (const char *u, const char *p) {
CURL *curl;
CURLcode res;
struct MemoryStruct chunk;
chunk.data=NULL;
chunk.size = 0;
curl = curl_easy_init();
if(!curl) return NULL;
curl_easy_setopt(curl, CURLOPT_URL, u);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, p);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
curl_easy_setopt(curl, CURLOPT_USERAGENT, OAUTH_USER_AGENT);
curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, OAUTH_POST_TIMEOUT);
res = curl_easy_perform(curl);
if (res) {
return NULL;
}
curl_easy_cleanup(curl);
return (chunk.data);
}
So I assume the timeout is properly set (I didn't set connection timeout though).
The socket seems connected :
ll /proc/17067/fd
total 0
lrwx------ 1 XXXXXXXX XXXXXXXX 64 2010-03-23 10:43 11 -> socket:[266941449]
lsof -c my_process
my_process 17067 XXXXXXXX 11u IPv4 266941449 TCP YYYYYY.ZZZZZZZZZ.WWW:37108->168.143.162.52:www (ESTABLISHED)
What is unclear to me is that the timeout is never triggered and the waiting goes forever...
Any ideas ?
Config:
Ubuntu 8.04 LTS
Kernel 2.6.25
curl 7.18.0 (x86_64-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1
Thanks !
RC
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-23