aboutsummaryrefslogtreecommitdiff
path: root/lib/multi.c
AgeCommit message (Collapse)Author
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).
2010-07-12multi: fix condition that remove timers before triggerConstantine Sapuntzakis
curl_multi perform has two phases: run through every easy handle calling multi_runsingle and remove expired timers (timer removal). If a small timer (e.g. 1-10ms) is set during multi_runsingle, then it's possible that the timer has passed by when the timer removal runs. The timer which was just added is then removed. This will potentially cause the timer list to be empty and cause the next call to curl_multi_timeout to return -1. Ideally, curl_multi_timeout should return 0 in this case. One way to fix this is to move the struct timeval now = Curl_tvnow(); to the top of curl_multi_perform. The change does that.
2010-07-01multi: CURLINFO_LASTSOCKET doesn't work after remove_handleDaniel Stenberg
When curl_multi_remove_handle() is called and an easy handle is returned to the connection cache held in the multi handle, then we cannot allow CURLINFO_LASTSOCKET to extract it since that will more or less encourage that the user uses the socket while it can get used by libcurl again. Without this fix, we'd get a segfault in Curl_getconnectinfo() trying to dereference the NULL pointer in 'data->state.connc'. Bug: http://curl.haxx.se/bug/view.cgi?id=3023840
2010-06-18multi: prevent NULL pointer dereferenceDaniel Stenberg
My additional call to Curl_pgrsUpdate() would sometimes get called even though there's no connection (left) so a NULL pointer would get passed, causing a segfault.
2010-06-17multi: unmark handle as used when no longer head of pipelineKrister Johansen
2010-06-17multi: call the progress function only once and allow abortDaniel Stenberg
1) no need to call the progress function twice when in the CURLM_STATE_TOOFAST state. 2) Make sure that the progress callback's return code is acknowledged when used
2010-06-17multi: call the progress callback in all statesDaniel Stenberg
As long as no error is reported, the progress function can get called. This may be a little TOO often so we should keep an eye on this and possibly make this conditional somehow.
2010-06-02lib: eliminate some dead codeKamil Dudka
2010-06-01multi_socket: handles timer inaccuracy better for timeoutsDaniel Stenberg
Igor Novoseltsev reported a problem with the multi socket API and using timeouts and timers. It boiled down to a problem with libcurl's use of GetTickCount() interally to figure out the current time, while Igor's own application code used another function call. It made his app call the socket API timeout function a bit _before_ libcurl would consider the timeout to trigger, and that could easily lead to timeouts or stalls in the app. It seems GetTickCount() in general often has no better resolution than 16ms and switching to the alternative function QueryPerformanceCounter has its share of problems: http://www.virtualdub.org/blog/pivot/entry.php?id=106 We address this problem by simply having libcurl treat timers that already has occured or will occur within 40ms subject for treatment. I'm confident that there are other implementations and operating systems with similarly in accurate timer functions so it makes sense to have applied generically and I don't believe we sacrifice much by adding a 40ms inaccuracy on these timeouts.
2010-05-16lib: Change some CRLF line endings to LFTor Arntsen
An update had added a couple of lines with DOS line endings, and some compilers will choke on that (e.g. the Tru64 compiler).
2010-05-12FTP: WILDCARDMATCH/CHUNKING/FNMATCH addedPavel Raiskup
2010-03-24remove the CVSish $Id$ linesDaniel Stenberg
2010-03-23delayed easy handle kill caused double Curl_close() callDaniel Stenberg
Hauke Duden provided an example program that made the multi interface crash. His example simply used the multi interface and did first one FTP transfer and after completion it used a second easy handle and did another FTP transfer on the same FTP server. This triggered a bug in the "delayed easy handle kill" system that curl uses: when an FTP connection is left alive it must keep an easy handle around internally - only for the purpose of having an easy handle when it later disconnects it. The code assumed that when the easy handle was removed and an internal reference was made, that version could be killed later on when a new easy handle came using the same connection. This was wrong as Hauke's example showed that the removed handle wasn't killed for real until later. This caused a double close attempt => segfault.
2010-03-15- Constantine Sapuntzakis brought a patch:Daniel Stenberg
The problem mentioned on Dec 10 2009 (http://curl.haxx.se/bug/view.cgi?id=2905220) was only partially fixed. Partially because an easy handle can be associated with many connections in the cache (e.g. if there is a redirect during the lifetime of the easy handle). The previous patch only cleaned up the first one. The new fix now removes the easy handle from all connections, not just the first one.
2010-02-04fix printf-style format stringsYang Tse
2010-02-02Fix compiler warnings: conversion from 'const int ' to 'unsigned char ', ↵Yang Tse
possible loss of data
2010-02-01We introduce a loop in lib/multi.c around all calls to multi_runsingle() andDaniel Stenberg
simply check for CURLM_CALL_MULTI_PERFORM internally. This has the added benefit that this goes in line with my long-term wishes to get rid of the CURLM_CALL_MULTI_PERFORM all together from the public API.
2010-01-28fix printf-style format stringsYang Tse
2010-01-11After the TCP connect is confirmed in CURLM_STATE_WAITCONNECT and it changesDaniel Stenberg
state, we return CURLM_CALL_MULTI_PERFORM unconditionally then so that we can act faster like in the case the protocol-specific connect doesn't block on anything and we can just persue on the next action immediately. It also then avoids a case where curl_multi_fdset() would return -1.
2010-01-09struct Curl_sh_entry's 'inuse' member was no longer used and is now removedDaniel Stenberg
2010-01-03- Julien Chaffraix eliminated a duplicated initialization in singlesocket().Kamil Dudka
2009-12-10- Constantine Sapuntzakis figured out a case which would lead to libcurlDaniel Stenberg
accessing alredy freed memory and thus crash when using HTTPS (with OpenSSL), multi interface and the CURLOPT_DEBUGFUNCTION and a certain order of cleaning things up. I fixed it. (http://curl.haxx.se/bug/view.cgi?id=2891591)
2009-11-18Make usage of calloc()'s arguments consistent with rest of code baseYang Tse
2009-08-24clarify the code by initing newurl to NULLDaniel Stenberg
2009-08-21- Andre Guibert de Bruet pointed out a missing return code check for aDaniel Stenberg
strdup() that could lead to segfault if it returned NULL. I extended his suggest patch to now have Curl_retry_request() return a regular return code and better check that.
2009-08-21- Lots of good work by Krister Johansen, mostly related to pipelining:Daniel Stenberg
Fix SIGSEGV on free'd easy_conn when pipe unexpectedly breaks Fix data corruption issue with re-connected transfers Fix use after free if we're completed but easy_conn not NULL
2009-08-03indentation fixes onlyDaniel Stenberg
2009-06-12fix compiler warningYang Tse
2009-06-10Adjusted to take in account that...Yang Tse
With the curl memory tracking feature decoupled from the debug build feature, CURLDEBUG and DEBUGBUILD preprocessor symbol definitions are used as follows: CURLDEBUG used for curl debug memory tracking specific code (--enable-curldebug) DEBUGBUILD used for debug enabled specific code (--enable-debug)
2009-05-11Internal cleanup: KEEP_WRITE and KEEP_READ are now called KEEP_SEND andDaniel Stenberg
KEEP_RECV to better match the general terminology: receive and send is what we do from the (remote) servers. We read and write from and to the local fs.
2009-05-08- Constantine Sapuntzakis fixed bug report #2784055Daniel Stenberg
(http://curl.haxx.se/bug/view.cgi?id=2784055) identifying a problem to connect to SOCKS proxies when using the multi interface. It turned out to almost not work at all previously. We need to wait for the TCP connect to be properly verified before doing the SOCKS magic. There's still a flaw in the FTP code for this.
2009-04-21libcurl's memory.h renamed to curl_memory.hYang Tse
2009-02-20- Linus Nielsen Feltzing reported and helped me repeat and fix a problem withDaniel Stenberg
FTP with the multi interface: when a transfer fails, like when aborted by a write callback, the control connection was wrongly closed and thus not re-used properly. This change is also an attempt to cleanup the code somewhat in this area, as now the FTP code attempts to keep (better) track on pending responses necessary to get read in ftp_done().
2009-02-02minor comment fixDaniel Stenberg
2009-01-10- Emil Romanus fixed:Daniel Stenberg
When using the multi interface over HTTP and the server returns a Location header, the running easy handle will get stuck in the CURLM_STATE_PERFORM state, leaving the external event loop stuck waiting for data from the ingoing socket (when using the curl_multi_socket_action stuff). While this bug was pretty hard to find, it seems to require only a one-line fix. The break statement on line 1374 in multi.c caused the function to skip the call to multistate(). How to reproduce this bug? Well, that's another question. evhiperfifo.c in the examples directory chokes on this bug only _sometimes_, probably depending on how fast the URLs are added. One way of testing the bug out is writing to hiper.fifo from more than one source at the same time.
2008-12-20- Igor Novoseltsev fixed a bad situation for the multi_socket() API when doingDaniel Stenberg
pipelining, as libcurl could then easily get confused and A) work on the handle that was not "first in queue" on a pipeline, or even B) tell the app to REMOVE a socket while it was in use by a second handle in a pipeline. Both errors caused hanging or stalling applications.
2008-12-19- curl_multi_timeout() could return a timeout value of 0 even though nothingDaniel Stenberg
was actually ready to get done, as the internal time resolution is higher than the returned millisecond timer. Therefore it could cause applications running on fast processors to do short bursts of busy-loops. curl_multi_timeout() will now only return 0 if the timeout is actually alreay triggered.
2008-12-19- Using the libssh2 0.19 function libssh2_session_block_directions(), libcurlDaniel Stenberg
now has an improved ability to do right when the multi interface (both "regular" and multi_socket) is used for SCP and SFTP transfers. This should result in (much) less busy-loop situations and thus less CPU usage with no speed loss.
2008-12-12- More work with Igor Novoseltsev to first fix the remaining stuff forDaniel Stenberg
removing easy handles from multi handles when the easy handle is/was within a HTTP pipeline. His bug report #2351653 (http://curl.haxx.se/bug/view.cgi?id=2351653) was also related and was eventually fixed by a patch by Igor himself.
2008-12-03- Igor Novoseltsev filed bug #2351645Daniel Stenberg
(http://curl.haxx.se/bug/view.cgi?id=2351645) that identified a problem with the multi interface that occured if you removed an easy handle while in progress and the handle was used in a HTTP pipeline.
2008-10-30Use our Curl_addrinfo definition even when an addrinfo struct is available.Yang Tse
Use a wrapper function to call system's getaddrinfo().
2008-10-25add missing header inclusionsYang Tse
2008-10-19attempt to fix or allow further detection of an elusive icc SIGSEGVYang Tse
2008-10-08- Igor filed bug #2111613 (http://curl.haxx.se/bug/view.cgi?id=2111613) thatDaniel Stenberg
eventually identified a flaw in how the multi_socket interface in some cases missed to call the timeout callback when easy interfaces are removed and added within the same millisecond.
2008-09-29- Bug #2107803 (http://curl.haxx.se/bug/view.cgi?id=2107803) "noDaniel Stenberg
CURLINFO_REDIRECT_URL in multi mode" also contained a patch that fixed the problem.
2008-09-13fix compiler warning: defined but not usedYang Tse
2008-09-13fix compiler warning: external declaration in primary source fileYang Tse