curl-library
Re: curl_multi_socket_action, epoll and HTTP redirect
Date: Mon, 1 Apr 2013 22:26:34 +0200
On Mon, Apr 1, 2013 at 8:04 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> The problem isn't that socket() returns the same fd though, the problem is
> rather if libcurl doesn't properly handle this case - and I failed to repeat
> it...
Agree, but if socket() for some reason doesn't return the same file
descriptor number after the redirect than you'll never see the
problem. It would be interesting to see your output when running the
command below.
I added support for poll to the test program (attached), and when
using that instead of epoll it works as expected:
erik:~/source/curl-redirect % strace -esocket,connect ./curlepoll
http://127.0.0.1:41250
Using libcurl/7.30.0-DEV OpenSSL/1.0.1c zlib/1.2.7 libidn/1.25 librtmp/2.3
>>> timerCallback: timeout: 1 ms
>>> calling epoll_wait
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 4
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(41250),
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now
in progress)
>>> socketCallback: adding fd=4 action=1
>>> timerCallback: timeout: -1 ms
>>> calling epoll_wait
>>> calling epoll_wait
>>> calling epoll_wait
>>> calling epoll_wait
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1
ENOENT (No such file or directory)
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1
ENOENT (No such file or directory)
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(60946),
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now
in progress)
>>> calling epoll_wait
^C
erik:~/source/curl-redirect % strace -esocket,connect ./curlepoll
http://127.0.0.1:41250 1
Using libcurl/7.30.0-DEV OpenSSL/1.0.1c zlib/1.2.7 libidn/1.25 librtmp/2.3
>>> timerCallback: timeout: 1 ms
>>> calling poll
socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 4
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(41250),
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now
in progress)
>>> socketCallback: adding fd=4 action=1
>>> timerCallback: timeout: -1 ms
>>> calling poll
>>> calling poll
>>> calling poll
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1
ENOENT (No such file or directory)
socket(PF_FILE, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1
ENOENT (No such file or directory)
socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 4
connect(4, {sa_family=AF_INET, sin_port=htons(60946),
sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now
in progress)
>>> calling poll
>>> calling poll
Hello Port 60946!
>>> calling poll
>>> socketCallback: removing fd=4
>>> bye bye
// Erik
-- Erik Johansson Home Page: http://ejohansson.se/ PGP Key: http://ejohansson.se/erik.asc
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- text/x-csrc attachment: curlepoll.c