curl-library
curl_easy_perform hangs in poll() when other side closes connection
Date: Tue, 5 Aug 2014 13:48:16 +0200
Hello,
first of all, I am using libcurl version 7.32.0 on 64bit Ubuntu 12.04 LTS
(precise)
I have the problem that from time to time I cannot get out of
curl_easy_perform, when the server that I am sending data to closes the
connection. According to gdb curl_easy_perform is stuck in poll() while the
server is stuck in select().
Trace on client (curl):
#0 0x00007f6bb2bc8a43 in __GI___poll (fds=<optimized out>, nfds=<optimized
out>, timeout=<optimized out>)
at ../sysdeps/unix/sysv/linux/poll.c:87
87 in ../sysdeps/unix/sysv/linux/poll.c
(gdb) bt
#0 0x00007f6bb2bc8a43 in __GI___poll (fds=<optimized out>, nfds=<optimized
out>, timeout=<optimized out>)
at ../sysdeps/unix/sysv/linux/poll.c:87
#1 0x00007f6bb22786d4 in ?? () from
/usr/lib/x86_64-linux-gnu/libcurl-nss.so.4
#2 0x00007f6bb2271955 in curl_multi_wait () from
/usr/lib/x86_64-linux-gnu/libcurl-nss.so.4
#3 0x00007f6bb226adae in curl_easy_perform () from
/usr/lib/x86_64-linux-gnu/libcurl-nss.so.4
#4 0x00007f6bb4b95f65 in helper::client::HttpClient::doRequest
(this=0x7f6b9002b5e0, data=""> #5 0x00007f6bb4b95d4d in
helper::client::HttpClient::sendRequest (this=0x7f6b9002b5e0, fields=...,
dataFieldKey=...,
buffer=0x7f6b9c000b00)
Trace on server (libmicrohttpd):
#0 0x00007f6f19c7d763 in select () at ../sysdeps/unix/syscall-template.S:82
82 in ../sysdeps/unix/syscall-template.S
(gdb) bt
#0 0x00007f6f19c7d763 in select () at ../sysdeps/unix/syscall-template.S:82
#1 0x00007f6f19769bb3 in MHD_select (daemon=0x1564800, may_block=1) at
daemon.c:1469
#2 0x00007f6f19769d85 in MHD_select_thread (cls=0x1564800) at daemon.c:1729
#3 0x00007f6f1a6b7e9a in start_thread (arg=0x7f6f0f31e700) at
pthread_create.c:308
#4 0x00007f6f19c843fd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#5 0x0000000000000000 in ?? ()
netstat output for client:
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name Timer
tcp 0 224748 localhost:53500
localhost:http-alt CLOSE_WAIT - unkn-4 (1.52/0/0)
netstat output for server:
Proto Recv-Q Send-Q Local Address Foreign Address
State PID/Program name Timer
tcp 341202 0 localhost:http-alt
localhost:53500 FIN_WAIT2 - off (0.00/0/0)
As you can see, the server is in state FIN_WAIT2 while the client is in
CLOSE_WAIT.
As I understand it the client should send FIN to the server and then move
to LAST_ACK state and receive the last ACK from the server to successfully
close the connection.
But this never happens and cannot happen, as both - client and server -
seem to wait for input.
Please note that this does not always happen but it is easier to reproduce
on faster machines which makes me think that it could be a timing problem.
Has anybode else experienced this problem? Is it a fault on my side or
could it possibly be a libcurl bug?
I would be glad and thankful if you are able to help me!
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-08-05