summaryrefslogtreecommitdiff
path: root/lib/conncache.c
Commit message (Collapse)AuthorAgeFilesLines
* lib: skip Curl_llist_destroy callsDaniel Stenberg2023-03-151-13/+1
| | | | | | | | 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
* copyright: update all copyright lines and remove year rangesDaniel Stenberg2023-01-031-2/+2
| | | | | | | | | | | | - 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
* ws: initial websockets supportDaniel Stenberg2022-09-091-1/+1
| | | | Closes #8995
* 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
* conncache: remove name arg from Curl_conncache_find_bundleDaniel Stenberg2022-04-251-14/+6
| | | | | | | | To simplify, and also since the returned name is not the full actual name used for the check. The port number and zone id is also involved, so just showing the name is misleading. Closes #8750
* conncache: include the zone id in the "bundle" hashkeyDaniel Stenberg2022-04-251-2/+6
| | | | | | | | | Make connections to two separate IPv6 zone ids create separate connections. Reported-by: Harry Sintonen Bug: https://curl.se/docs/CVE-2022-27775.html Closes #8747
* connecache: remove duplicate connc->closure_handle checkDaniel Stenberg2022-04-061-9/+6
| | | | | | | The superfluous extra check could cause analyzer false positives and doesn't serve any purpose. Closes #8676
* conncache: make conncache_add_bundle return the pointerDaniel Stenberg2022-01-301-9/+5
| | | | | | | Simplifies the logic a little and avoids a ternary operator. Ref: #8346 Closes #8349
* url: make Curl_disconnect return voidDaniel Stenberg2022-01-201-3/+3
| | | | | | | | 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
* hash: lazy-alloc the table in Curl_hash_add()bagder/hash-lazyallocDaniel Stenberg2021-12-101-9/+4
| | | | | | This makes Curl_hash_init() infallible which saves error paths. Closes #8132
* infof: remove newline from format strings, always append itDaniel Stenberg2021-07-071-5/+5
| | | | | | | | | | | | | | | | - the data needs to be "line-based" anyway since it's also passed to the debug callback/application - it makes infof() work like failf() and consistency is good - there's an assert that triggers on newlines in the format string - Also removes a few instances of "..." - Removes the code that would append "..." to the end of the data *iff* it was truncated in infof() Closes #7357
* conncache: lowercase the hash key for better matchDaniel Stenberg2021-06-011-0/+2
| | | | | | | | | | As host names are case insensitive, the use of case sensitive hashing caused unnecesary cache misses and therefore lost performance. This lowercases the hash key. Reported-by: Harry Sintonen Fixes #7159 Closes #7161
* lib: remove 'conn->data' completelyDaniel Stenberg2021-02-161-2/+0
| | | | | | | | The Curl_easy pointer struct entry in connectdata is now gone. Just before commit 215db086e0 landed on January 8, 2021 there were 919 references to conn->data. Closes #6608
* lib: more conn->data cleanupsDaniel Stenberg2021-01-191-17/+19
| | | | Closes #6479
* lib: pass in 'struct Curl_easy *' to most functionsDaniel Stenberg2021-01-171-3/+4
| | | | | | | | | | | | | | | | | | | | | ... in most cases instead of 'struct connectdata *' but in some cases in addition to. - We mostly operate on transfers and not connections. - We need the transfer handle to log, store data and more. Everything in libcurl is driven by a transfer (the CURL * in the public API). - This work clarifies and separates the transfers from the connections better. - We should avoid "conn->data". Since individual connections can be used by many transfers when multiplexing, making sure that conn->data points to the current and correct transfer at all times is difficult and has been notoriously error-prone over the years. The goal is to ultimately remove the conn->data pointer for this reason. Closes #6425
* curl.se: new homeDaniel Stenberg2020-11-041-1/+1
| | | | Closes #6172
* hash: make it 'struct Curl_hash'Daniel Stenberg2020-09-021-10/+10
| | | | | | As internal global names should use captical C. Closes #5906
* llist: make it "struct Curl_llist"Daniel Stenberg2020-09-021-7/+7
| | | | | | As internal global names should use captical C. Closes #5906
* conncache: download buffer needs +1 size for trailing zeroDaniel Stenberg2020-05-311-1/+1
| | | | | Follow-up to c4e6968127e Detected by OSS-Fuzz: https://oss-fuzz.com/testcase-detail/5727799779524608
* build: disable more code/data when built without proxy supportDaniel Stenberg2020-05-301-2/+5
| | | | | | Added build to travis to verify Closes #5466
* url: alloc the download buffer at transfer startDaniel Stenberg2020-05-301-0/+6
| | | | | | | | | | | ... and free it as soon as the transfer is done. It removes the extra alloc when a new size is set with setopt() and reduces memory for unused easy handles. In addition: the closure_handle now doesn't use an allocated buffer at all but the smallest supported size as a stack based one. Closes #5472
* conncache: various concept cleanupsDaniel Stenberg2020-04-301-47/+40
| | | | | | | | | | | | | | | | More connection cache accesses are protected by locks. CONNCACHE_* is a beter prefix for the connection cache lock macros. Curl_attach_connnection: now called as soon as there's a connection struct available and before the connection is added to the connection cache. Curl_disconnect: now assumes that the connection is already removed from the connection cache. Ref: #4915 Closes #5009
* conncache: removed unused Curl_conncache_bundle_size()Daniel Stenberg2020-01-241-13/+1
|
* conncache: CONNECT_ONLY connections assumed always in-useDaniel Stenberg2019-12-111-1/+2
| | | | | | | | | | | | | | | This makes them never to be considered "the oldest" to be discarded when reaching the connection cache limit. The reasoning here is that CONNECT_ONLY is primarily used in combination with using the connection's socket post connect and since that is used outside of curl's knowledge we must assume that it is in use until explicitly closed. Reported-by: Pavel Pavlov Reported-by: Pavel Löbl Fixes #4426 Fixes #4369 Closes #4696
* conncache: fix multi-thread use of shared connection cacheDaniel Stenberg2019-12-091-26/+4
| | | | | | | | | It could accidentally let the connection get used by more than one thread, leading to double-free and more. Reported-by: Christopher Reid Fixes #4544 Closes #4557
* url: make Curl_close() NULLify the pointer tooDaniel Stenberg2019-10-301-5/+3
| | | | | | | This is the common pattern used in the code and by a unified approach we avoid mistakes. Closes #4534
* conncache: Remove the DEBUGASSERT on length checkSteve Holme2019-05-291-4/+4
| | | | | | We trust the calling code as this is an internal function. Closes #3962
* url: default conn->port to the same as conn->remote_portDaniel Stenberg2019-05-281-2/+5
| | | | | | | | | | | | | | ... so that it has a sensible value when ConnectionExists() is called which needs it set to differentiate host "bundles" correctly on port number! Also, make conncache:hashkey() use correct port for bundles that are proxy vs host connections. Probably a regression from 7.62.0 Reported-by: Tom van der Woerdt Fixes #3956 Closes #3957
* conncache: make "bundles" per host name when doing proxy tunnelsDaniel Stenberg2019-05-281-8/+12
| | | | | | | | | Only HTTP proxy use where multiple host names can be used over the same connection should use the proxy host name for bundles. Reported-by: Tom van der Woerdt Fixes #3951 Closes #3955
* CURLOPT_MAXAGE_CONN: set the maximum allowed age for conn reuseDaniel Stenberg2019-04-211-2/+3
| | | | | | | | | ... and disconnect too old ones instead of trying to reuse. Default max age is set to 118 seconds. Ref: #3722 Closes #3782
* conncache: use conn->data to know if a transfer owns itDaniel Stenberg2019-03-171-2/+3
| | | | | | | | | | | | | - make sure an already "owned" connection isn't returned unless multiplexed. - clear ->data when returning the connection to the cache again Regression since 7.62.0 (probably in commit 1b76c38904f0) Bug: https://curl.haxx.se/mail/lib-2019-03/0064.html Closes #3686
* cleanup: make local functions staticDaniel Stenberg2019-02-101-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | urlapi: turn three local-only functions into statics conncache: make conncache_find_first_connection static multi: make detach_connnection static connect: make getaddressinfo static curl_ntlm_core: make hmac_md5 static http2: make two functions static http: make http_setup_conn static connect: make tcpnodelay static tests: make UNITTEST a thing to mark functions with, so they can be static for normal builds and non-static for unit test builds ... and mark Curl_shuffle_addr accordingly. url: make up_free static setopt: make vsetopt static curl_endian: make write32_le static rtsp: make rtsp_connisdead static warnless: remove unused functions memdebug: remove one unused function, made another static
* urldata: rename easy_conn to just connDaniel Stenberg2019-01-111-3/+1
| | | | | | | | | | | | | | | We use "conn" everywhere to be a pointer to the connection. Introduces two functions that "attaches" and "detaches" the connection to and from the transfer. Going forward, we should favour using "data->conn" (since a transfer always only has a single connection or none at all) to "conn->data" (since a connection can have none, one or many transfers associated with it and updating conn->data to be correct is error prone and a frequent reason for internal issues). Closes #3442
* conncache_unlock: avoid indirection by changing input argument typeDaniel Stenberg2018-12-221-2/+2
|
* disconnect: separate connections and easy handles betterDaniel Stenberg2018-12-221-2/+8
| | | | | | | | | | | | Do not assume/store assocation between a given easy handle and the connection if it can be avoided. Long-term, the 'conn->data' pointer should probably be removed as it is a little too error-prone. Still used very widely though. Reported-by: masbug on github Fixes #3391 Closes #3400
* snprintf: renamed and we now only use msnprintf()Daniel Stenberg2018-11-231-1/+1
| | | | | | | | | | | The function does not return the same value as snprintf() normally does, so readers may be mislead into thinking the code works differently than it actually does. A different function name makes this easier to detect. Reported-by: Tomas Hoger Assisted-by: Daniel Gustafsson Fixes #3296 Closes #3297
* vtls: set conn->data when closing TLSDaniel Stenberg2018-07-221-1/+0
| | | | | | | | | Follow-up to 1b76c38904f0. The VTLS backends that close down the TLS layer for a connection still needs a Curl_easy handle for the session_id cache etc. Fixes #2764 Closes #2771
* conn: remove the boolean 'inuse' fieldDaniel Stenberg2018-07-111-18/+12
| | | | ... as the usage needs to be counted.
* url: check Curl_conncache_add_conn return codeDaniel Stenberg2018-06-251-11/+4
| | | | | | | ... it was previously unchecked in two places and thus errors could remain undetected and cause trouble. Closes #2681
* url: fix dangling conn->data pointerDaniel Stenberg2018-06-211-1/+2
| | | | | | | | | | | By masking sure to use the *current* easy handle with extracted connections from the cache, and make sure to NULLify the ->data pointer when the connection is put into the cache to make this mistake easier to detect in the future. Reported-by: Will Dietz Fixes #2669 Closes #2672
* strictness: correct {infof, failf} format specifiersRikard Falkeborn2018-05-311-11/+8
| | | | Closes #2623
* conncache: fix a return code [regression]Daniel Stenberg2017-12-121-1/+1
| | | | | This broke in 07cb27c98e. Make sure to return 'result' properly. Pointed out by scan-build!
* conncache: fix several lock issuesDaniel Stenberg2017-12-051-33/+189
| | | | | | | | | If the lock is released before the dealings with the bundle is over, it may have changed by another thread in the mean time. Fixes #2132 Fixes #2151 Closes #2139
* share: add support for sharing the connection cacheDaniel Stenberg2017-11-091-8/+133
|
* llist: no longer uses mallocDaniel Stenberg2017-04-221-5/+3
| | | | | | | | | | | | The 'list element' struct now has to be within the data that is being added to the list. Removes 16.6% (tiny) mallocs from a simple HTTP transfer. (96 => 80) Also removed return codes since the llist functions can't fail now. Test 1300 updated accordingly. Closes #1435
* llist: replace Curl_llist_alloc with Curl_llist_initDaniel Stenberg2017-04-041-14/+8
| | | | | | | | No longer allocate the curl_llist head struct for lists separately. Removes 17 (15%) tiny allocations in a normal "curl localhost" invoke. closes #1381
* conncache: make hashkey avoid mallocDaniel Stenberg2017-03-291-18/+15
| | | | | | ... to make it much faster. Idea developed with primepie on IRC. Closes #1365
* string formatting: fix 4 printf-style format stringsMichael Kaufmann2017-02-191-1/+1
|
* proxy: Support HTTPS proxy and SOCKS+HTTP(s)Alex Rousskov2016-11-241-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * HTTPS proxies: An HTTPS proxy receives all transactions over an SSL/TLS connection. Once a secure connection with the proxy is established, the user agent uses the proxy as usual, including sending CONNECT requests to instruct the proxy to establish a [usually secure] TCP tunnel with an origin server. HTTPS proxies protect nearly all aspects of user-proxy communications as opposed to HTTP proxies that receive all requests (including CONNECT requests) in vulnerable clear text. With HTTPS proxies, it is possible to have two concurrent _nested_ SSL/TLS sessions: the "outer" one between the user agent and the proxy and the "inner" one between the user agent and the origin server (through the proxy). This change adds supports for such nested sessions as well. A secure connection with a proxy requires its own set of the usual SSL options (their actual descriptions differ and need polishing, see TODO): --proxy-cacert FILE CA certificate to verify peer against --proxy-capath DIR CA directory to verify peer against --proxy-cert CERT[:PASSWD] Client certificate file and password --proxy-cert-type TYPE Certificate file type (DER/PEM/ENG) --proxy-ciphers LIST SSL ciphers to use --proxy-crlfile FILE Get a CRL list in PEM format from the file --proxy-insecure Allow connections to proxies with bad certs --proxy-key KEY Private key file name --proxy-key-type TYPE Private key file type (DER/PEM/ENG) --proxy-pass PASS Pass phrase for the private key --proxy-ssl-allow-beast Allow security flaw to improve interop --proxy-sslv2 Use SSLv2 --proxy-sslv3 Use SSLv3 --proxy-tlsv1 Use TLSv1 --proxy-tlsuser USER TLS username --proxy-tlspassword STRING TLS password --proxy-tlsauthtype STRING TLS authentication type (default SRP) All --proxy-foo options are independent from their --foo counterparts, except --proxy-crlfile which defaults to --crlfile and --proxy-capath which defaults to --capath. Curl now also supports %{proxy_ssl_verify_result} --write-out variable, similar to the existing %{ssl_verify_result} variable. Supported backends: OpenSSL, GnuTLS, and NSS. * A SOCKS proxy + HTTP/HTTPS proxy combination: If both --socks* and --proxy options are given, Curl first connects to the SOCKS proxy and then connects (through SOCKS) to the HTTP or HTTPS proxy. TODO: Update documentation for the new APIs and --proxy-* options. Look for "Added in 7.XXX" marks.
* strcasecompare: all case insensitive string compares ignore locale nowDaniel Stenberg2016-10-311-1/+0
| | | | | We had some confusions on when each function was used. We should not act differently on different locales anyway.