summaryrefslogtreecommitdiff
path: root/lib/multi.c
Commit message (Collapse)AuthorAgeFilesLines
* hostip: remove 'stale' argument from Curl_fetch_addr protoDaniel Stenberg2015-01-071-5/+2
| | | | | Also, remove the log output of the resolved name is NOT in the cache in the spirit of only telling when something is actually happening.
* multi.c: Fixed compilation warningSteve Holme2014-12-051-5/+5
| | | | multi.c:2695: warning: declaration of `exp' shadows a global declaration
* multi.c: Fixed compilation warnings when no verbose string supportSteve Holme2014-11-231-4/+8
| | | | | warning: variable 'connection_id' set but not used warning: unused parameter 'lineno'
* multi: inform about closed sockets before they are closedJon Spencer2014-11-191-1/+1
| | | | | | | | | When the connection code decides to close a socket it informs the multi system via the Curl_multi_closed function. The multi system may, in turn, invoke the CURLMOPT_SOCKETFUNCTION function with CURL_POLL_REMOVE. This happens after the socket has already been closed. Reorder the code so that CURL_POLL_REMOVE is called before the socket is closed.
* debug: added new connection cache output, plus fixupsCarlo Wood2014-11-181-2/+2
| | | | | | | | | | | | | Debug output 'typo' fix. Don't print an extra "0x" in * Pipe broke: handle 0x0x2546d88, url = / Add debug output. Print the number of connections in the connection cache when adding one, and not only when one is removed. Fix typos in comments.
* multi: move the ending condition into the loop as wellDaniel Stenberg2014-11-181-12/+13
| | | | | ... as it was before I changed the loop in commit e04ccbd50. It caused test 2030 and 2032 to fail.
* multi: Prefer we don't use CURLE_OK and NULL in comparisonsSteve Holme2014-11-181-5/+6
|
* multi_runsingle: use 'result' for local CURLcode storageDaniel Stenberg2014-11-181-79/+79
| | | | | ... and assign data->result only at the end. Makes the code more compact (easier to read) and more similar to other code.
* multi_runsingle: rename result to rcDaniel Stenberg2014-11-181-29/+29
| | | | save 'result' for CURLcode types
* multi: make multi_runsingle loop internallyDaniel Stenberg2014-11-181-13/+6
| | | | simplifies the use of this function at little cost.
* multi: when leaving for timeout, close accordinglyCarlo Wood2014-11-181-10/+13
| | | | Fixes the problem when a transfer in a pipeline times out.
* multi: removed Curl_multi_set_easy_connectionDaniel Stenberg2014-11-101-6/+0
| | | | | | It isn't used anywhere! Reported-by: Carlo Wood
* code cleanup: we prefer 'CURLcode result'Daniel Stenberg2014-10-241-12/+12
| | | | | | | | | | | | | | ... for the local variable name in functions holding the return code. Using the same name universally makes code easier to read and follow. Also, unify code for checking for CURLcode errors with: if(result) or if(!result) instead of if(result == CURLE_OK), if(CURLE_OK == result) or if(result != CURLE_OK)
* multi_runsingle: fix possible memory leakDaniel Stenberg2014-10-071-0/+1
| | | | | Coverity CID 1202837. 'newurl' can in fact be allocated even when Curl_retry_request() returns failure so free it if need be.
* curl_multi_remove_handle: remove dead codeDaniel Stenberg2014-10-031-97/+92
| | | | | | Coverify CID 1157776. Removed a superfluous if() that always evaluated true (and an else clause that never ran), and then re-indented the function accordingly.
* multi_runsingle: fix memory leakDaniel Stenberg2014-10-021-0/+2
| | | | | Coverity CID 1202837. There's a potential risk that 'newurl' gets overwritten when it was already pointing to allocated memory.
* multi.c: Avoid invalid memory read after free() from commit 3c8c873252Steve Holme2014-09-071-2/+8
| | | | | | As the current element in the list is free()d by Curl_llist_remove(), when the associated connection is pending, reworked the loop to avoid accessing the next element through e->next afterward.
* multi.c: Fixed compilation warning from commit 3c8c873252Steve Holme2014-09-071-1/+1
| | | | | warning: implicit conversion from enumeration type 'CURLMcode' to different enumeration type 'CURLcode'
* curl_multi_cleanup: remove superfluous NULL assignsDaniel Stenberg2014-09-021-11/+0
| | | | | | | ... as the struct is free()d in the end anyway. It was first pointed out to me that one of the ->msglist assignments were supposed to have been ->pending but was a copy and paste mistake when I realized none of the clearing of pointers had to be there.
* multi: convert CURLM_STATE_CONNECT_PEND handling to a listDaniel Stenberg2014-09-021-6/+21
| | | | | | | | | | | | | | ... instead of scanning through all handles, stash only the actual handles that are in that state in the new ->pending list and scan that list only. It should be mostly empty or very short. And only used for pipelining. This avoids a rather hefty slow-down especially notable if you add many handles to the same multi handle. Regression introduced in commit 0f147887 (version 7.30.0). Bug: http://curl.haxx.se/mail/lib-2014-07/0206.html Reported-by: David Meyer
* low-speed-limit: avoid timeout floodDaniel Stenberg2014-08-311-3/+43
| | | | | | | | | | | | | | | | | | | | Introducing Curl_expire_latest(). To be used when we the code flow only wants to get called at a later time that is "no later than X" so that something can be checked (and another timeout be added). The low-speed logic for example could easily be made to set very many expire timeouts if it would be called faster or sooner than what it had set its own timer and this goes for a few other timers too that aren't explictiy checked for timer expiration in the code. If there's no condition the code that says if(time-passed >= TIME), then Curl_expire_latest() is preferred to Curl_expire(). If there exists such a condition, it is on the other hand important that Curl_expire() is used and not the other. Bug: http://curl.haxx.se/mail/lib-2014-06/0235.html Reported-by: Florian Weimer
* resolve: cache lookup for async resolversMichael Wallner2014-08-311-1/+25
| | | | | | | | | | While waiting for a host resolve, check if the host cache may have gotten the name already (by someone else), for when the same name is resolved by several simultanoues requests. The resolver thread occasionally gets stuck in getaddrinfo() when the DNS or anything else is crappy or slow, so when a host is found in the DNS cache, leave the thread alone and let itself cleanup the mess.
* CONNECT: Revert Curl_proxyCONNECT back to 7.29.0 designDaniel Stenberg2014-07-221-6/+10
| | | | | | | | | | | | | | This reverts commit cb3e6dfa3511 and instead fixes the problem differently. The reverted commit addressed a test failure in test 1021 by simplifying and generalizing the code flow in a way that damaged the performance. Now we modify the flow so that Curl_proxyCONNECT() again does as much as possible in one go, yet still do test 1021 with and without valgrind. It failed due to mistakes in the multi state machine. Bug: http://curl.haxx.se/bug/view.cgi?id=1397 Reported-by: Paul Saab
* progress callback: skip last callback update on errorsRay Satiro2014-07-021-1/+1
| | | | | | | | | | | | When an error has been detected, skip the final forced call to the progress callback by making sure to pass the current return code variable in the Curl_done() call in the CURLM_STATE_DONE state. This avoids the "extra" callback that could occur even if you returned error from the progress callback. Bug: http://curl.haxx.se/mail/lib-2014-06/0062.html Reported by: Jonathan Cardoso Machado
* bits.close: introduce connection close trackingDaniel Stenberg2014-05-221-5/+5
| | | | | | | Make all code use connclose() and connkeep() when changing the "close state" for a connection. These two macros take a string argument with an explanation, and debug builds of curl will include that in the debug output. Helps tracking connection re-use/close issues.
* timers: fix timer regression involving redirects / reconnectsDaniel Stenberg2014-05-151-1/+2
| | | | | | | | | | | | | | | | | | | | In commit 0b3750b5c23c25f (released in 7.36.0) we fixed a timeout issue but instead broke the timings. To fix this, I introduce a new timestamp to use for the timeouts and restored the previous timestamp and timestamp position so that the old timer functionality is restored. In addition to that, that change also broke connection timeouts for when more than one connect was used (as it would then count the total time from the first connect and not for the most recent one). Now Curl_timeleft() has been modified so that it checks against different start times depending on which timeout it checks. Test 1303 is updated accordingly. Bug: http://curl.haxx.se/mail/lib-2014-05/0147.html Reported-by: Ryan Braud
* curl_multi_cleanup: ignore SIGPIPE betterJeff King2014-05-051-0/+3
| | | | | | | When looping and closing each individual connection left open, the SIGPIPE ignoring was not done and could thus lead to death by signal 13. Bug: http://thread.gmane.org/gmane.comp.version-control.git/238242
* INFILESIZE: fields in UserDefined must not be changed run-timeDaniel Stenberg2014-04-261-0/+2
| | | | | | set.infilesize in this case was modified in several places, which could lead to repeated requests using the same handle to get unintendent/wrong consequences based on what the previous request did!
* multi.c: fix possible invalid memory access in case nfds overflowsMarc Hoersken2014-04-191-1/+1
| | | | | | ufds might not be allocated in case nfds overflows to zero while extra_nfds is still non-zero. udfs is then accessed within the extra_nfds-based for loop.
* multi_runsingle: move timestamp into INITDaniel Stenberg2014-03-031-1/+1
| | | | | | | | | | Setting the TIMER_STARTSINGLE timestamp first in CONNECT has the drawback that for actions that go back to the CONNECT state, the time stamp is reset and for the multi_socket API there's no corresponding Curl_expire() then so the timeout logic gets wrong! Reported-by: Brad Spencer Bug: http://curl.haxx.se/mail/lib-2014-02/0036.html
* multi: ignore sigpipe internallyDaniel Stenberg2014-02-171-0/+11
| | | | | When the multi API is used we must also ignore SIGPIPE signals when caused by things we do, like they can easily be generated by OpenSSL.
* ConnectionDone: default maxconnects to 4 x number of easy handlesShao Shuchao2014-02-171-0/+3
| | | | ... as documented!
* ftp: fixed a memory leak on wildcard error pathDan Fandrich2014-01-301-1/+3
|
* multi: Fixed a memory leak on OOM conditionDan Fandrich2014-01-241-0/+1
|
* error message: Sensible message on timeout when transfer size unknownColin Hogben2014-01-131-5/+13
| | | | | | | A transfer timeout could result in an error message such as "Operation timed out after 3000 milliseconds with 19 bytes of -1 received". This patch removes the non-sensical "of -1" when the size of the transfer is unknown, mirroring the logic in lib/transfer.c
* multi: remove MULTI_TIMEOUT_INACCURACYDaniel Stenberg2014-01-121-24/+2
| | | | | | | | | | | | With the recently added timeout "reminder" functionality, there's no reason left for us to execute timeout code before the time is ripe. Simplifies the handling too. This will make the *TIMEOUT and *CONNECTTIMEOUT options more accurate again, which probably is most important when the *_MS versions are used. In multi_socket, make sure to update 'now' after having handled activity on a socket.
* multi_socket: remind app if timeout didn't runDaniel Stenberg2014-01-101-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BACKGROUND: We have learned that on some systems timeout timers are inaccurate and might occasionally fire off too early. To make the multi_socket API work with this, we made libcurl execute timeout actions a bit early too if they are within our MULTI_TIMEOUT_INACCURACY. (added in commit 2c72732ebf, present since 7.21.0) Switching everything to the multi API made this inaccuracy problem slightly more notable as now everyone can be affected. Recently (commit 21091549c02) we tweaked that inaccuracy value to make timeouts more accurate and made it platform specific. We also figured out that we have code at places that check for fixed timeout values so they MUST NOT run too early as then they will not trigger at all (see commit be28223f35 and a691e044705) - so there are definitately problems with running timeouts before they're supposed to run. (We've handled that so far by adding the inaccuracy margin to those specific timeouts.) The libcurl multi_socket API tells the application with a callback that a timeout expires in N milliseconds (and it explicitly will not tell it again for the same timeout), and the application is then supposed to call libcurl when that timeout expires. When libcurl subsequently gets called with curl_multi_socket_action(...CURL_SOCKET_TIMEOUT...), it knows that the application thinks the timeout expired - and alas, if it is within the inaccuracy level libcurl will run code handling that handle. If the application says CURL_SOCKET_TIMEOUT to libcurl and _isn't_ within the inaccuracy level, libcurl will not consider the timeout expired and it will not tell the application again since the timeout value is still the same. NOW: This change introduces a modified behavior here. If the application says CURL_SOCKET_TIMEOUT and libcurl finds no timeout code to run, it will inform the application about the timeout value - *again* even if it is the same timeout that it already told about before (although libcurl will of course tell it the updated time so that it'll still get the correct remaining time). This way, we will not risk that the application believes it has done its job and libcurl thinks the time hasn't come yet to run any code and both just sit waiting. This also allows us to decrease the MULTI_TIMEOUT_INACCURACY margin, but that will be handled in a separate commit. A repeated timeout update to the application risk that the timeout will then fire again immediately and we have what basically is a busy-loop until the time is fine even for libcurl. If that becomes a problem, we need to address it.
* multi.c: fix possible dereference of null pointerMarc Hoersken2014-01-051-4/+6
|
* progresscallback: make CURLE_ABORTED_BY_CALLBACK get returned betterDaniel Stenberg2014-01-031-2/+10
| | | | | | | | | | When the progress callback returned 1 at a very early state, the code would not make CURLE_ABORTED_BY_CALLBACK get returned but the process would still be interrupted. In the HTTP case, this would then cause a CURLE_GOT_NOTHING to erroneously get returned instead. Reported-by: Petr Novak Bug: http://curl.haxx.se/bug/view.cgi?id=1318
* mprintf: Replaced internal usage of FORMAT_OFF_T and FORMAT_OFF_TUSteve Holme2013-12-311-1/+2
| | | | | | | | | Following commit 0aafd77fa4c6f2, replaced the internal usage of FORMAT_OFF_T and FORMAT_OFF_TU with the external versions that we expect API programmers to use. This negates the need for separate definitions which were subtly different under different platforms/compilers.
* FILE: don't wait due to CURLOPT_MAX_RECV_SPEED_LARGEDaniel Stenberg2013-12-221-1/+8
| | | | | | | | | | | | | | | | | | The FILE:// code doesn't support this option - and it doesn't make sense to support it as long as it works as it does since then it'd only block even longer. But: setting CURLOPT_MAX_RECV_SPEED_LARGE would make the transfer first get done and then libcurl would wait until the average speed would get low enough. This happened because the transfer happens completely in the DO state for FILE:// but then it would still unconditionally continue in to the PERFORM state where the speed check is made. Starting now, the code will skip from DO_DONE to DONE immediately if no socket is set to be recv()ed or send()ed to. Bug: http://curl.haxx.se/bug/view.cgi?id=1312 Reported-by: Mohammad AlSaleh
* multi.c: Fixed compilation warningSteve Holme2013-12-011-3/+3
| | | | warning: declaration of 'pipe' shadows a global declaration
* multi.c: Fixed compilation error introduced in commit a900d45489fc14Steve Holme2013-11-271-1/+1
| | | | | Systems that define SIGPIPE_VARIABLE as a noop would not compile as restore_pipe was defined afterwards.
* curl_multi_cleanup: ignore SIGPIPEJeff King2013-11-271-0/+9
| | | | | | | | | This is an extension to the fix in 7d80ed64e43515. We may call Curl_disconnect() while cleaning up the multi handle, which could lead to openssl sending packets, which could get a SIGPIPE. Signed-off-by: Jeff King <peff@peff.net>
* multi: Small code tidy up to avoid hard returnSteve Holme2013-11-121-1/+1
|
* multi: Set read socket when returning READSOCK(0)Björn Stenberg2013-11-111-1/+3
| | | | | | | This patch fixes and issue introduced in commit 7d7df831981fee, if the tunnel state was TUNNEL_CONNECT, waitconnect_getsock() would return a bitmask indicating a readable socket but never stored the socket in the return array.
* connect: Add connection delay to Happy Eyeballs.Björn Stenberg2013-11-041-0/+1
| | | | | | | | | | | | This patch adds a 200ms delay between the first and second address family socket connection attempts. It also iterates over IP addresses in the order returned by the system, meaning most dual-stack systems will try IPv6 first. Additionally, it refactors the connect code, removing most code that handled synchronous connects. Since all sockets are now non-blocking, the logic can be made simpler.
* curl_multi_wait: accept 0 from multi_timeout() as valid timeoutDaniel Stenberg2013-10-301-2/+2
| | | | | | | The code rejected 0 as a valid timeout while in fact the function could indeed legitimately return that and it should be respected. Reported-by: Bjorn Stenberg
* Add "Happy Eyeballs" for IPv4/IPv6.Björn Stenberg2013-10-271-2/+11
| | | | | | | | | This patch invokes two socket connect()s nearly simultaneously, and the socket that is first connected "wins" and is subsequently used for the connection. The other is terminated. There is a very slight IPv4 preference, in that if both sockets connect simultaneously IPv4 is checked first and thus will win.
* curl_multi_remove_handle: allow multiple removesDaniel Stenberg2013-08-291-0/+4
| | | | | When removing an already removed handle, avoid that to ruin the internals and just return OK instead.