summaryrefslogtreecommitdiff
path: root/lib/multi.c
Commit message (Collapse)AuthorAgeFilesLines
* checksrc: find bad indentation in conditions without open braceDaniel Stenberg2023-04-281-1/+1
| | | | | | | | | | | If the previous line starts with if/while/for AND ends with a closed parenthesis and there's an equal number of open and closed parentheses on that line, verify that this line is indented $indent more steps, if not a cpp line. Also adjust the fall-out from this fix. Closes #11054
* multi: add multi-ignore logic to multi_socket_actionDaniel Stenberg2023-04-281-5/+16
| | | | | | | | | | | | The multi-ignore logic that was previously applied to curl_multi_perform() (#10750) is here applied to the loop within curl_multi_socket_action() to make it use the same optimization: most handles have the same signal-ignore option state so this drastically reduces the number of ignore/unignore calls per libcurl function invoke. Follow-up to bc90308328afb8 Closes #11045
* urldata: shrink *select_bits int => unsigned charDaniel Stenberg2023-04-261-1/+1
| | | | | | | | | | - dselect_bits - cselect_bits ... are using less than 8 bits. Changed types and moved them towards the end of the structs to fit better. Closes #11025
* multi: free up more data earleier in DONEDaniel Stenberg2023-04-151-8/+9
| | | | | | | | | Before checking for more users of the connection and possibly bailing out. Fixes #10971 Reported-by: Paweł Wegner Closes #10972
* multi: remove a few superfluous assignsDaniel Stenberg2023-04-111-6/+2
| | | | | | | PVS found these "The 'rc' variable was assigned the same value." cases. Ref: #10929 Closes #10932
* multi: remove PENDING + MSGSENT handles from the main linked listDaniel Stenberg2023-03-261-30/+59
| | | | | | | | | | | | | | | | | | | | | | As they are not driving transfers or any socket activity, the main loop does not need to iterate over these handles. A performance improvement. They are instead only held in their own separate lists. 'data->multi' is kept a pointer to the multi handle as long as the easy handle is actually part of it even when the handle is moved to the pending/msgsent lists. It needs to know which multi handle it belongs to, if for example curl_easy_cleanup() is called before the handle is removed from the multi handle. Alll 'data->multi' pointers of handles still part of the multi handle gets cleared by curl_multi_cleanup() which "orphans" all previously attached easy handles. This is take 2. The first version was reverted for the 8.0.1 release. Assisted-by: Stefan Eissing Closes #10801
* multi: add handle asserts in DEBUG buildsStefan Eissing2023-03-221-0/+9
| | | | | | | | | For GOOD_EASY_HANDLE and GOOD_MULTI_HANDLE checks - allow NULL pointers to "just" return an error as before - fail hard on nun-NULL pointers that no longer show the MAGICs Closes #10812
* Revert "multi: remove PENDING + MSGSENT handles from the main linked list"Daniel Stenberg2023-03-201-43/+30
| | | | | | | | | This reverts commit f6d6f3ce01e377932f1ce7c24ee34d45a36950b8. The commits caused issues in the 8.0.0 release. Needs a retake. Reported-by: Kamil Dudka Closes #10795
* multi: remove PENDING + MSGSENT handles from the main linked listDaniel Stenberg2023-03-151-30/+43
| | | | | | | | | | | As they are not driving transfers or any socket activity, the main loop does not need to iterate over these handles. A performance improvement. They are instead only held in their own separate lists. Assisted-by: Stefan Eissing Ref: #10743 Closes #10762
* multi: turn link/unlinking easy handles into dedicated functionsDaniel Stenberg2023-03-151-24/+38
|
* lib: skip Curl_llist_destroy callsDaniel Stenberg2023-03-151-10/+0
| | | | | | | | Linked lists themselves do not carry any allocations, so for the lists that do not have have a set destructor we can just skip the Curl_llist_destroy() call and save CPU time. Closes #10764
* multi: make multi_perform ignore/unignore signals less oftenDaniel Stenberg2023-03-131-8/+15
| | | | | | | | For improved performance Reported-by: Jerome St-Louis Ref: #10743 Closes #10750
* url: remove dummy protocol handlerDaniel Stenberg2023-03-101-1/+1
| | | | | | Just two added checks were needed saves a whole handler struct. Closes #10727
* ftp: allocate the wildcard struct on demandDaniel Stenberg2023-03-031-3/+3
| | | | | | | | | | The feature is rarely used so this frees up data for the vast majority of easy handles that don't use it. Rename "protdata" to "ftpwc" since it is always an FTP wildcard struct pointer. Made the state struct field an unsigned char to save space. Closes #10639
* multi: stop sending empty HTTP/3 UDP datagrams on WindowsJay Satiro2023-02-131-2/+18
| | | | | | | | | | | | | | | - Limit the 0-sized send procedure that is used to reset a SOCKET's FD_WRITE to TCP sockets only. Prior to this change the reset was used on UDP sockets as well, but unlike TCP sockets a 0-sized send actually sends out a datagram. Assisted-by: Marc Hörsken Ref: https://github.com/curl/curl/pull/9203 Fixes https://github.com/curl/curl/issues/9086 Closes https://github.com/curl/curl/pull/10430
* curl: output warning at --verbose output for debug-enabled versionDaniel Stenberg2023-01-121-0/+9
| | | | | | | | | + a libcurl warning in the debug output Assisted-by: Jay Satiro Ref: https://curl.se/mail/lib-2023-01/0039.html Closes #10278
* copyright: update all copyright lines and remove year rangesDaniel Stenberg2023-01-031-1/+1
| | | | | | | | | | | | - they are mostly pointless in all major jurisdictions - many big corporations and projects already don't use them - saves us from pointless churn - git keeps history for us - the year range is kept in COPYING checksrc is updated to allow non-year using copyright statements Closes #10205
* lib: connect/h2/h3 refactorStefan Eissing2022-12-301-10/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactoring of connection setup and happy eyeballing. Move nghttp2. ngtcp2, quiche and msh3 into connection filters. - eyeballing cfilter that uses sub-filters for performing parallel connects - socket cfilter for all transport types, including QUIC - QUIC implementations in cfilter, can now participate in eyeballing - connection setup is more dynamic in order to adapt to what filter did really connect. Relevant to see if a SSL filter needs to be added or if SSL has already been provided - HTTP/3 test cases similar to HTTP/2 - multiuse of parallel transfers for HTTP/3, tested for ngtcp2 and quiche - Fix for data attach/detach in VTLS filters that could lead to crashes during parallel transfers. - Eliminating setup() methods in cfilters, no longer needed. - Improving Curl_conn_is_alive() to replace Curl_connalive() and integrated ssl alive checks into cfilter. - Adding CF_CNTRL_CONN_INFO_UPDATE to tell filters to update connection into and persist it at the easy handle. - Several more cfilter related cleanups and moves: - stream_weigth and dependency info is now wrapped in struct Curl_data_priority - Curl_data_priority members depend is available in HTTP2|HTTP3 - Curl_data_priority members depend on NGHTTP2 support - handling init/reset/cleanup of priority part of url.c - data->state.priority same struct, but shallow copy for compares only - PROTOPT_STREAM has been removed - Curl_conn_is_mulitplex() now available to check on capability - Adding query method to connection filters. - ngtcp2+quiche: implementing query for max concurrent transfers. - Adding is_alive and keep_alive cfilter methods. Adding DATA_SETUP event. - setting keepalive timestamp on connect - DATA_SETUP is called after the connection has been completely setup (but may not connected yet) to allow filters to initialize data members they use. - there is no socket to be had with msh3, it is unclear how select shall work - manual test via "curl --http3 https://curl.se" fail with "empty reply from server". - Various socket/conn related cleanups: - Curl_socket is now Curl_socket_open and in cf-socket.c - Curl_closesocket is now Curl_socket_close and in cf-socket.c - Curl_ssl_use has been replaced with Cur_conn_is_ssl - Curl_conn_tcp_accepted_set has been split into Curl_conn_tcp_listen_set and Curl_conn_tcp_accepted_set with a clearer purpose Closes #10141
* multihandle: turn bool struct fields into bitsDaniel Stenberg2022-12-301-1/+1
| | | | Closes #10179
* lib: rewind BEFORE request instead of AFTER previousDaniel Stenberg2022-11-251-2/+91
| | | | | | | | | | | | This makes a big difference for cases when the rewind is not actually necessary to perofm (for example HTTP response code 301 converts to GET) and therefore the rewind can be avoided. In particular for situations when that rewind fails, for example when reading from a pipe or similar. Reported-by: Ali Utku Selen Fixes #9735 Closes #9958
* vtls: localization of state data in filtersStefan Eissing2022-11-221-6/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - almost all backend calls pass the Curl_cfilter intance instead of connectdata+sockindex - ssl_connect_data is remove from struct connectdata and made internal to vtls - ssl_connect_data is allocated in the added filter, kept at cf->ctx - added function to let a ssl filter access its ssl_primary_config and ssl_config_data this selects the propert subfields in conn and data, for filters added as plain or proxy - adjusted all backends to use the changed api - adjusted all backends to access config data via the exposed functions, no longer using conn or data directly cfilter renames for clear purpose: - methods `Curl_conn_*(data, conn, sockindex)` work on the complete filter chain at `sockindex` and connection `conn`. - methods `Curl_cf_*(cf, ...)` work on a specific Curl_cfilter instance. - methods `Curl_conn_cf()` work on/with filter instances at a connection. - rebased and resolved some naming conflicts - hostname validation (und session lookup) on SECONDARY use the same name as on FIRST (again). new debug macros and removing connectdata from function signatures where not needed. adapting schannel for new Curl_read_plain paramter. Closes #9919
* lib: connection filters (cfilter) addition to curl:Stefan Eissing2022-11-111-113/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | - general construct/destroy in connectdata - default implementations of callback functions - connect: cfilters for connect and accept - socks: cfilter for socks proxying - http_proxy: cfilter for http proxy tunneling - vtls: cfilters for primary and proxy ssl - change in general handling of data/conn - Curl_cfilter_setup() sets up filter chain based on data settings, if none are installed by the protocol handler setup - Curl_cfilter_connect() boot straps filters into `connected` status, used by handlers and multi to reach further stages - Curl_cfilter_is_connected() to check if a conn is connected, e.g. all filters have done their work - Curl_cfilter_get_select_socks() gets the sockets and READ/WRITE indicators for multi select to work - Curl_cfilter_data_pending() asks filters if the have incoming data pending for recv - Curl_cfilter_recv()/Curl_cfilter_send are the general callbacks installed in conn->recv/conn->send for io handling - Curl_cfilter_attach_data()/Curl_cfilter_detach_data() inform filters and addition/removal of a `data` from their connection - adding vtl functions to prevent use of Curl_ssl globals directly in other parts of the code. Reviewed-by: Daniel Stenberg Closes #9855
* openssl: reduce CA certificate bundle reparsing by cachingMichael Drake2022-11-081-0/+5
| | | | Closes #9620
* multi: remove duplicate include of connect.hDaniel Stenberg2022-10-241-1/+0
| | | | | | Reported-by: Martin Strunz Fixes #9794 Closes #9795
* hostip: lazily wait to figure out if IPv6 works until neededDaniel Stenberg2022-09-221-1/+0
| | | | | | | | The check may take many milliseconds, so now it is performed once the value is first needed. Also, this change makes sure that the value is not used if the resolve is set to be IPv4-only. Closes #9553
* ws: initial websockets supportDaniel Stenberg2022-09-091-2/+2
| | | | Closes #8995
* misc: spelling fixesViktor Szakats2022-08-311-1/+1
| | | | | | | | | Found using codespell 2.2.1. Also delete the redundant protocol designator from an archive.org URL. Reviewed-by: Daniel Stenberg Closes #9403
* multi: use larger dns hash table for multi interfaceDaniel Stenberg2022-08-291-3/+9
| | | | | | | | | | | | Have curl_multi_init() use a much larger DNS hash table than used for the easy interface to scale and perform better when used with _many_ host names. curl_share_init() sets an in-between size. Inspired-by: Ivan Tsybulin See #9340 Closes #9376
* multi_wait: fix and improve Curl_poll error handling on WindowsMarc Hoersken2022-08-261-5/+6
| | | | | | | | | | | | | | First check for errors and return CURLM_UNRECOVERABLE_POLL before moving forward and waiting on socket readiness events. Reviewed-by: Jay Satiro Reviewed-by: Marcel Raad Reported-by: Daniel Stenberg Ref: #9361 Follow up to #8961 Closes #9372
* multi_wait: fix skipping to populate revents for extra_fdsMarc Hoersken2022-08-251-3/+6
| | | | | | | | | | | On Windows revents was not populated for extra_fds if multi_wait had to wait due to the Curl_poll pre-check not signalling any readiness. This commit fixes that. Reviewed-by: Marcel Raad Reviewed-by: Jay Satiro Closes #9361
* multi: use a pipe instead of a socketpair on apple platformsrcombs2022-08-251-7/+23
| | | | | | | | | | Sockets may be shut down by the kernel when the app is moved to the background, but pipes are not. Removed from KNOWN_BUGS Fixes #6132 Closes #9368
* multi: have curl_multi_remove_handle close CONNECT_ONLY transferDaniel Stenberg2022-08-231-0/+18
| | | | | | | | | | | | Ẃhen it has been used in the multi interface, it is otherwise left in the connection cache, can't be reused and nothing will close them since the easy handle loses the association with the multi handle and thus the connection cache - until the multi handle is closed or it gets pruned because the cache is full. Reported-by: Dominik Thalhammer Fixes #9335 Closes #9342
* multi: fix the return code from Curl_pgrsDone()Daniel Stenberg2022-07-231-1/+1
| | | | | | | It does not return a CURLcode. Detected by the icc compiler warning "enumerated type mixed with another type" Closes #9179
* copyright: make repository REUSE compliantmax.mehl2022-06-131-0/+2
| | | | | | | | | | | Add licensing and copyright information for all files in this repository. This either happens in the file itself as a comment header or in the file `.reuse/dep5`. This commit also adds a Github workflow to check pull requests and adapts copyright.pl to the changes. Closes #8869
* select: return error from "lethal" poll/select errorsDaniel Stenberg2022-06-081-0/+2
| | | | | | | | | Adds two new error codes: CURLE_UNRECOVERABLE_POLL and CURLM_UNRECOVERABLE_POLL one each for the easy and the multi interfaces. Reported-by: Harry Sintonen Fixes #8921 Closes #8961
* conn: fix typo 'connnection' -> 'connection' in two function namesAdam Rosenfield2022-04-271-9/+9
| | | | Closes #8759
* lib: remove exclamation marksDaniel Stenberg2022-04-161-2/+2
| | | | | | ... from infof() and failf() calls. Make them less attention seeking. Closes #8713
* header api: add curl_easy_header and curl_easy_nextheaderDaniel Stenberg2022-03-221-1/+0
| | | | | | Add test 1940 to 1946 to verify. Closes #8593
* multi: allow user callbacks to call curl_multi_assignJay Satiro2022-02-211-3/+0
| | | | | | | | | | | | | | | | | | | Several years ago a change was made to block user callbacks from calling back into the API when not supported (recursive calls). One of the calls blocked was curl_multi_assign. Recently the blocking was extended to the multi interface API, however curl_multi_assign may need to be called from within those user callbacks (eg CURLMOPT_SOCKETFUNCTION). I can't think of any callback where it would be unsafe to call curl_multi_assign so I removed the restriction entirely. Reported-by: Michael Wallner Ref: https://github.com/curl/curl/commit/b46cfbc Ref: https://github.com/curl/curl/commit/340bb19 Fixes https://github.com/curl/curl/issues/8480 Closes https://github.com/curl/curl/pull/8483
* multi: grammar fix in commentSebastian Sterk2022-02-011-2/+2
| | | | | | | After 'must', the verb is used without 'to'. Correct: "must" or "have to" Closes #8368
* multi: remember connection_id before returning connection to poolluminixinc on github2022-01-311-2/+3
| | | | | | | | | Fix a bug that does not require a new CVE as discussed on hackerone.com. Previously `connection_id` was accessed after returning connection to the shared pool. Bug: https://hackerone.com/reports/1463013 Closes #8355
* url: make Curl_disconnect return voidDaniel Stenberg2022-01-201-7/+1
| | | | | | | | 1. The function would only ever return CURLE_OK anyway 2. Only one caller actually used the return code 3. Most callers did (void)Curl_disconnect() Closes #8303
* multi: set in_callback for multi interface callbacksDaniel Stenberg2022-01-171-2/+17
| | | | | | | | | | This makes most libcurl functions return error if called from within a callback using the same multi handle. For example timer or socket callbacks calling curl_multi_socket_action. Reported-by: updatede on github Fixes #8282 Closes #8286
* hash: lazy-alloc the table in Curl_hash_add()bagder/hash-lazyallocDaniel Stenberg2021-12-101-12/+7
| | | | | | This makes Curl_hash_init() infallible which saves error paths. Closes #8132
* multi: cleanup the socket hash when destroying itbagder/sockhash-destroyDaniel Stenberg2021-12-101-6/+27
| | | | | | | | | Since each socket hash entry may themselves have a hash table in them, the destroying of the socket hash needs to make sure all the subhashes are also correctly destroyed to avoid leaking memory. Fixes #8129 Closes #8131
* multi: handle errors returned from socket/timer callbacksDaniel Stenberg2021-12-061-54/+119
| | | | | | | | | | | | The callbacks were partially documented to support this. Now the behavior is documented and returning error from either of these callbacks will effectively kill all currently ongoing transfers. Added test 530 to verify Reported-by: Marcelo Juchem Fixes #8083 Closes #8089
* multi: shut down CONNECT in Curl_detach_connnectionDaniel Stenberg2021-11-111-0/+1
| | | | | | | | | | ... to prevent a lingering pointer that would lead to a double-free. Added test 1939 to verify. Reported-by: Stephen M. Coakley Fixes #7982 Closes #7986
* lib: fixing comment spelling typos in lib filesEddie Lumpkin2021-10-221-1/+1
| | | | | Closes #7894 Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
* CURLOPT_PREREQFUNCTION: add new callbackMax Dymond2021-09-271-0/+22
| | | | | | | | | | | | | | Triggered before a request is made but after a connection is set up Changes: - callback: Update docs and callback for pre-request callback - Add documentation for CURLOPT_PREREQDATA and CURLOPT_PREREQFUNCTION, - Add redirect test and callback failure test - Note that the function may be called multiple times on a redirection - Disable new 2086 test due to Windows weirdness Closes #7477
* cleanup: constify unmodified static structsRikard Falkeborn2021-09-231-1/+1
| | | | | | | Constify a number of static structs that are never modified. Make them const to show this. Closes #7759