aboutsummaryrefslogtreecommitdiff
path: root/lib/multi.c
AgeCommit message (Collapse)Author
2011-12-07multi interface: fix block when CONNECT_ONLY option is usedGokhan Sengun
2011-12-02multi interface: only use non-NULL function pointer!Daniel Stenberg
If the socket callback function pointer hasn't been set, we must not attempt to use it. Commit adc88ca20 made it more likely to occur.
2011-12-02multi: handle timeouts on DNS servers by checking for new socketsJason Glasgow
If the first name server is not available, the multi interface does not invoke the socket_cb when the DNS request to the first name server timesout. Ensure that the list of sockets are always updated after calling Curl_resolver_is_resolved. This bug can be reproduced if Curl is complied with --enable_ares and your code uses the multi socket interfaces and the CURLMOPT_SOCKETFUNCTION option. To test try: iptables -I INPUT \ -s $(sed -n -e '/name/{s/.* //p;q}' /etc/resolv.conf)/32 \ -j REJECT and then run a program which uses the multi-interface.
2011-11-01multi.c: OOM handling fixYang Tse
2011-10-27multi.c: OOM handling fixYang Tse
Fix curl_multi_cleanup() segfault when using weird cleanup sequence.
2011-10-27multi: start ftp state machine when switching to DO_MOREDaniel Stenberg
This extends the fix from commit d7934b8bd491 When the multi state is changed within the multi_runsingle from DOING to DO_MORE, we didn't immediately start the FTP state machine again. That then left the FTP state in FTP_STOP. When curl_multi_fdset() was subsequently called, the ftp_domore_getsock() function would return the wrong fd info. Reported by: Gokhan Sengun
2011-10-21curl_multi_fdset: correct fdset with FTP PORT useDaniel Stenberg
After a PORT has been issued, and the multi handle would switch to the CURLM_STATE_DO_MORE state (which is unique for FTP), libcurl would return the wrong fdset to wait for when curl_multi_fdset() is called. The code would blindly assume that it was waiting for a connect of the second connection, while that isn't true immediately after the PORT command. Also, the function multi.c:domore_getsock() was highly FTP-centric and therefore ugly to keep in protocol-agnostic code. I solved this problem by introducing a new function pointer in the Curl_handler struct called domore_getsock() which is only called during the DOMORE state for protocols that set that pointer. The new ftp.c:ftp_domore_getsock() function now returns fdset info about the control connection's command/response handling while such a state is in use, and goes over to waiting for a writable second connection first once the commands are done. The original problem could be seen by running test 525 and checking the time stamps in the FTP server log. I can verify that this fix at least fixes this problem. Bug: http://curl.haxx.se/mail/lib-2011-10/0250.html Reported by: Gokhan Sengun
2011-10-21multi.c: fix segfaultYang Tse
2011-10-13multi.c: OOM handling fixesYang Tse
Prevent modification of easy handle being added with curl_multi_add_handle() unless this function actually suceeds. Run Curl_posttransfer() to allow restoring of SIGPIPE handler when Curl_connect() fails early in multi_runsingle().
2011-10-11OOM handling/cleanup slight adjustmentsYang Tse
2011-10-07libcurl: some OOM handling fixesYang Tse
2011-10-06multi.c: OOM handling fixes making torture tests 560 580 581 passYang Tse
2011-10-02multi: progress function abort must close connectionDaniel Stenberg
When the progress function returns to cancel the request, we must mark the connection to get closed and it must do to the DONE state. do_init() must be called as early as possible so that state variables for new connections are reset early. We could otherwise see that the old values were still there when a connection was to be disconnected very early and it would make it behave wrongly. Bug: http://curl.haxx.se/mail/lib-2011-10/0006.html Reported by: Vladimir Grishchenko
2011-09-30multi_runsingle: change state on callback abortDaniel Stenberg
Reported by: Marcin Adamski Bug: http://curl.haxx.se/mail/lib-2011-09/0329.html
2011-09-25Q&D fix header inclusion orderYang Tse
2011-09-25curl_multi_fdset: avoid FD_SET out of boundsDaniel Stenberg
If a socket is larger than FD_SETSIZE, avoid using FD_SET() on the platforms where this is possible. Bug: http://curl.haxx.se/bug/view.cgi?id=3413274 Reported by: Tim Starling
2011-09-05fix bool variables checking and assignmentYang Tse
2011-09-02MemoryTracking: fix logging of free() calls done where Curl_safefree is calledYang Tse
Just internal stuff... Curl_safefree is now a macro defined in memdebug.h instead of a function prototyped in url.h and implemented in url.c, so inclusion of url.h is no longer required in order to simply use Curl_safefree. Provide definition of macro WHILE_FALSE in setup_once.h in order to allow other macros such as DEBUGF and DEBUGASSERT, and code using it, to compile without 'conditional expression is constant' warnings. The WHILE_FALSE stuff fixes 150+ MSVC compiler warnings.
2011-04-28multi-socks: fix connect to proxyDaniel Stenberg
When connecting to a socks or similar proxy we do the proxy handshake at once when we know the TCP connect is completed and we only consider the "connection" complete after the proxy handshake. This fixes test 564 which is now no longer considered disabled. Reported by: Dmitri Shubin Bug: http://curl.haxx.se/mail/lib-2011-04/0127.html
2011-04-27whitespace cleanup: no space first in conditionalsDaniel Stenberg
"if(a)" is our style, not "if( a )"
2011-04-27source cleanup: unify look, style and indent levelsDaniel Stenberg
By the use of a the new lib/checksrc.pl script that checks that our basic source style rules are followed.
2011-04-25async resolvers: further cleanupsDaniel Stenberg
asyn-ares.c and asyn-thread.c are two separate backends that implement the same (internal) async resolver API for libcurl to use. Backend is specified at build time. The internal resolver API is defined in asyn.h for asynch resolvers.
2011-04-21Fix a couple of spelling errors in lib/Fabian Keil
Found with codespell.
2011-04-03multi: shorten linesDaniel Stenberg
We keep them less than 80 columns
2011-04-02multi: conn goes bad when data changeDaniel Stenberg
Within multi_socket when conn is used as a shorthand, data could be changed and multi_runsingle could modify the connectdata struct to deal with. This bug has not been included in a public release. Using 'conn' like that turned out to be ugly. This change is a partial revert of commit f1c6cd42f474df59. Reported by: Miroslav Spousta Bug: http://curl.haxx.se/bug/view.cgi?id=3265485
2011-03-14protocol handler: added flags fieldDaniel Stenberg
The protocol handler struct got a 'flags' field for special information and characteristics of the given protocol. This now enables us to move away central protocol information such as CLOSEACTION and DUALCHANNEL from single defines in a central place, out to each protocol's definition. It also made us stop abusing the protocol field for other info than the protocol, and we could start cleaning up other protocol-specific things by adding flags bits to set in the handler struct. The "protocol" field connectdata struct was removed as well and the code now refers directly to the conn->handler->protocol field instead. To make things work properly, the code now always store a conn->given pointer that points out the original handler struct so that the code can learn details from the original protocol even if conn->handler is modified along the way - for example when switching to go over a HTTP proxy.
2011-03-13SSH: add protocol lock directionDaniel Stenberg
Some protocols have to call the underlying functions without regard to what exact state the socket signals. For example even if the socket says "readable", the send function might need to be called while uploading, or vice versa. This is the case for libssh2 based protocols: SCP and SFTP and we now introduce a define to set those protocols and we make the multi interface code aware of this concept. This is another fix to make test 582 run properly.
2011-02-18multi: close connection on timeoutMike Crowe
After a request times out, the connection wasn't properly closed and prevented to get re-used, so subsequent transfers could still mistakenly get to use the previously aborted connection.
2011-02-18multi: better failed connect treatmentDaniel Stenberg
When failing to connect the protocol during the CURLM_STATE_PROTOCONNECT state, Curl_done() has to be called with the premature flag set TRUE as for the pingpong protocols this can be important. When Curl_done() is called with premature == TRUE, it needs to call Curl_disconnect() with its 'dead_connection' argument set to TRUE as well so that any protocol handler's disconnect function won't attempt to use the (control) connection for anything. This problem caused the pingpong protocols to fail to disconnect when STARTTLS failed. Reported by: Alona Rossen Bug: http://curl.haxx.se/mail/lib-2011-02/0195.html
2011-02-02multi: fix CURLM_STATE_TOOFAST for multi_socketNicholas Maniscalco
The code in the toofast state needs to first recalculate the values before it uses them again since it may have been a while since it last did it when it reaches this point.
2011-01-04Curl_timeleft: s/conn/data in first argumentDaniel Stenberg
As the function doesn't really use the connectdata struct but only the SessionHanadle struct I modified what argument it wants.
2010-12-22multi: inhibit some verbose outputsDaniel Stenberg
The info about pipe status and expire cleared are clearly debug-related and not anything mere mortals will or should care about so they are now ifdef'ed DEBUGBUILD
2010-12-13multi_runsingle: don't timeout completed handlesDaniel Stenberg
The generic timeout code must not check easy handles that are already completed. Going to completed (again) within there risked decreasing the number of alive handles again and thus it could go negative. This regression bug was added in 7.21.2 in commit ca10e28f06f1
2010-12-06url: provide dead_connection flag in Curl_handler::disconnectKamil Dudka
It helps to prevent a hangup with some FTP servers in case idle session timeout has exceeded. But it may be useful also for other protocols that send any quit message on disconnect. Currently used by FTP, POP3, IMAP and SMTP.
2010-11-28multi: fix compiler warning: conversion may lose significant bits follow-upYang Tse
2010-11-26multi: fix compiler warning: conversion may lose significant bitsYang Tse
2010-11-26multi: fix compiler warning: enumerated type mixed with another typeYang Tse
2010-11-25curl_multi_info_read: fix compiler warning: conversion may lose significant bitsYang Tse
2010-09-28multi: don't expire timeouts at disonnect or doneDaniel Stenberg
The functions Curl_disconnect() and Curl_done() are both used within the scope of a single request so they cannot be allowed to use Curl_expire(... 0) to kill all timeouts as there are some timeouts that are set before a request that are supposed to remain until the request is done. The timeouts are now instead cleared at curl_easy_cleanup() and when the multi state machine changes a handle to the complete state.
2010-09-27multi_runsingle: set timeout error messagesDirk Manske
With the latest changes to fix the timeout handling with multi interface we lost the timeout error messages. This patch brings them back.
2010-09-01multi: fixes for timing out handlesDaniel Stenberg
Add a timeout check for handles in the state machine so that they will timeout in all states disregarding what actions that may or may not happen. Fixed a bug in socket_action introduced recently when looping over timed out handles: it wouldn't assign the 'data' variable and thus it wouldn't properly take care of handles. In the update_timer function, the code now checks if the timeout has been removed and then it tells the application. Previously it would always let the remaining timeout(s) just linger to expire later on.
2010-08-31multi: make sure the next timeout is used when one expiresDaniel Stenberg
Each easy handle has a list of timeouts, so as soon as the main timeout for a handle expires, we must make sure to get the next entry from the list and re-add the handle to the splay tree. This was attempted previously but was done poorly in my commit 232ad6549a68450.
2010-08-24multi: Fix compile warning on 64-bit systemsBen Greear
2010-08-18Fixed a memory leak during OOM in the multi timeout codeDan Fandrich
2010-08-18multi: avoid sending multiple complete messagesDaniel Stenberg
I fell over this bug report that mentioned that libcurl could wrongly send more than one complete messages at the end of a transfer. Reading the code confirmed this, so I've added a new multi state to make it not happen. The mentioned bug report was made by Brad Jorsch but is (oddly enough) filed in Debian's bug tracker for the "wmweather+" tool. Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593390
2010-08-15multi: use timeouts properly for MAX_RECV/SEND_SPEEDDaniel Stenberg
When detecting that the send or recv speed, the multi interface changes state to TOOFAST and previously there was no timeout set that would force a recheck but it would rely on the application to somehow call libcurl anyway. This now sets a timeout for a suitable future time to check again if the average transfer speed is then below the threshold again.
2010-08-15multi: support timeoutsDaniel Stenberg
Curl_expire() is now expanded to hold a list of timeouts for each easy handle. Only the closest in time will be the one used as the primary timeout for the handle and will be used for the splay tree (which sorts and lists all handles within the multi handle). When the main timeout has triggered/expired, the next timeout in time that is kept in the list will be moved to the main timeout position and used as the key to splay with. This way, all timeouts that are set with Curl_expire() internally will end up as a proper timeout. Previously any Curl_expire() that set a _later_ timeout than what was already set was just silently ignored and thus missed. Setting Curl_expire() with timeout 0 (zero) will cancel all previously added timeouts. Corrects known bug #62.
2010-08-15multi: make curl_multi_info_read perform O(1)Daniel Stenberg
Instead of looping over all attached easy handles, this now keeps a list of messages in the multi handle. It allows curl_multi_info_read() to perform O(1) no matter how many easy handles that are handled. This is of importance since this function may be polled very frequently by apps using the multi interface.
2010-08-08typo: remove duplicate semicolonDaniel Stenberg
2010-08-08multi: avoid a malloc() when a transfer is completeDaniel Stenberg
The struct used for storing the message for a completed transfer is now no longer allocated separatly but is kept within the main struct kept for each easy handle so that we avoid one malloc (and the subsequent free).