Maxime Larocque [Tue, 7 Aug 2012 21:24:13 +0000 (23:24 +0200)]
Curl_socket_check: fix return code for timeout
We found a problem with ftp transfer using libcurl (7.23 and 7.25)
inside an application which is receiving unix signals (SIGUSR1,
SIGUSR2...) almost continuously. (Linux 2.4, PowerPC, HAVE_POLL_FINE
defined).
Curl_socket_check() uses poll() to wait for the socket, and retries it
when a signal is received (EINTR). However, if a signal is received and
it also happens that the timeout has been reached, Curl_socket_check()
returns -1 instead of 0 (indicating an error instead of a timeout).
In our case, the result is an aborted connection even before the ftp
banner is received from the server, and a return value of
CURLE_OUT_OF_MEMORY from curl_easy_perform() (Curl_pp_multi_statemach(),
in pingpong.c, actually returns OOM if Curl_socket_check() fails :-)
Funny to debug on a system on which OOM is a possible cause).
Daniel Stenberg [Tue, 7 Aug 2012 13:01:54 +0000 (15:01 +0200)]
WSAPoll: disabled on all windows builds
Due to WSAPoll bugs, libcurl does not work as intended. When the cURL
library is used to setup a connection to an incorrect port, normally the
result is CURLE_COULDNT_CONNECT, /* 7 */, but due to the bug in WSAPoll,
the result now is CURLE_OPERATION_TIMEDOUT, /* 28 - the timeout time was
reached */.
On August 1, Jan Koen Annot opened a case for this to Microsoft Premier
Online (https://premier.microsoft.com/). The support engineer handling
the case wrote that the case description is quite clear. He will try to
reproduce the issue and then proceed with troubleshooting it.
Reported by: Jan Koen Annot
Bug: http://curl.haxx.se/mail/lib-2012-07/0310.html
Daniel Stenberg [Tue, 7 Aug 2012 12:55:19 +0000 (14:55 +0200)]
retry request: only access the HTTP data if in fact HTTP
When figuring out if the data stream needs to be rewound when the
request is to be resent, we must not access the HTTP struct unless the
protocol used is indeed HTTP...
Joe Mason [Thu, 2 Aug 2012 21:22:46 +0000 (17:22 -0400)]
Add a polling loop in main to read from more than one socket at once. Add the O_NONBLOCK and
SO_KEEPALIVE flag to all sockets. Note that several loops which used to continue on a return value
of 0 (theoretical since 0 would never be returned without O_NONBLOCK) now break on 0 so that they
won't continue reading until after poll is called again.
Joe Mason [Thu, 2 Aug 2012 21:11:05 +0000 (17:11 -0400)]
Change return values of get_request, accept_connection and service_connection to add a return code
for non-blocking sockets: now -1 means error or connection finished, 1 means data was read, and 0
means there is no data available now so need to wait for poll (new return value)
Joe Mason [Wed, 1 Aug 2012 21:09:38 +0000 (17:09 -0400)]
Hoist the loop out of get_request, and make sure that it can be reentered when a request is
half-finished.
Note the the req struct used to be re-initialized AFTER reading pipeline data, so now that we
initialize it from the caller we must be careful not to overwrite the pipeline data.
Also we now need to handle the case where the buffer is already full when get_request is called -
previously this never happened as it was always called with an empty buffer and looped until done.
Now get_request is called in a loop, so the next step is to run the loop on a socket only when poll
signals it is readable.
Joe Mason [Wed, 1 Aug 2012 17:30:46 +0000 (13:30 -0400)]
Move blocks of code from the sws main loop into their own functions for easier refactoring later.
The next step will be to call the correct function after a poll, rather than looping unconditionally
Steve Holme [Sat, 28 Jul 2012 10:46:50 +0000 (11:46 +0100)]
TODO: Updated after 7.27.0 release
Removed APOP and SASL authentication from the POP3 section and metalink
support from the client section as these features were implemented in
this release.
Moved adding gssapi to SASL into it's own section rather than repeat it
for each protocol.
This needs another look from the configure experts. I tested that
it works so far with MinGW64 cross-compiler; libcurl builds and
links fine, but curl not yet ...
Nick Zitzmann [Tue, 17 Jul 2012 02:20:57 +0000 (20:20 -0600)]
darwinssl: fixed freeze involving the multi interface
Previously the curl_multi interface would freeze if darwinssl was
enabled and at least one of the handles tried to connect to a Web site
using HTTPS. Removed the "wouldblock" state darwinssl was using because
I figured out a solution for our "would block but in which direction?"
dilemma.
Replaced the Windows real path from mount hack with a more
reliable and simpler hack: the MSYS shell has a builtin pwd
which understands a -W option which does convertion to Windows
paths. Tested and confirmed that this works on all MSYS versions
I have back to a 3 year old one.
Daniel Stenberg [Sun, 15 Jul 2012 18:31:37 +0000 (20:31 +0200)]
multi_runsingle: added precaution against easy_conn NULL pointer
In many states the easy_conn pointer is referenced and just assumed to
be working. This is an added extra check since analyzing indicates
there's a risk we can end up in these states with a NULL pointer there.
Daniel Stenberg [Wed, 11 Jul 2012 22:07:16 +0000 (00:07 +0200)]
SWS: use of uninitialized memory fix
I made "connmon" not get initialized properly before use, and I use the
big hammer and make sure we always clear the entire struct to avoid any
problem like this in the future.
Daniel Stenberg [Wed, 11 Jul 2012 21:50:19 +0000 (23:50 +0200)]
test48: verify that HEAD doesn't close extra
Two commits ago, we fixed a bug where the connction would be closed
prematurely after a HEAD. Now I added connection-monitor to test 48 and
added a second HEAD and make sure that both are sent over the same
connection.
This triggered a failure before the bug fix and now works. Will help us
avoid a future regression of this kind.
Daniel Stenberg [Wed, 11 Jul 2012 21:49:01 +0000 (23:49 +0200)]
connection-monitor: always log disconnect when enabled
This makes verifying easier and makes us more sure curl closes the
connection only at the correct point in time. Adjusted test 206 and 1008
accordingly and updated the docs for it.
Daniel Stenberg [Wed, 11 Jul 2012 21:13:52 +0000 (23:13 +0200)]
HEAD: don't force-close after response-headers
A HEAD response has no body length and gets the headers like the
corresponding GET would so it should not get closed after the response
based on the same rules. This mistake caused connections that did HEAD
to get closed too often without a valid reason.
Daniel Stenberg [Tue, 10 Jul 2012 21:11:30 +0000 (23:11 +0200)]
cmdline: parse numerical options stricter
1 - str2offset() no longer accepts negative numbers since offsets are by
nature positive.
2 - introduced str2unum() for the command line parser that accepts
numericals which are not supposed to be negative, so that it will
properly complain on apparent bad uses and mistakes.
Daniel Stenberg [Mon, 9 Jul 2012 13:25:54 +0000 (15:25 +0200)]
test 46: use different path lengths to get reliable sort order
Since the order of the cookies is sorted by the length of the paths,
having them on the same path length will make the test depend on what
order the qsort() implementation will put them. As seen in the
windows/msys output posted by Guenter in this posting:
http://curl.haxx.se/mail/lib-2012-07/0105.html