diff options
| author | thegeorg <[email protected]> | 2022-02-10 16:45:12 +0300 |
|---|---|---|
| committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:45:12 +0300 |
| commit | 49116032d905455a7b1c994e4a696afc885c1e71 (patch) | |
| tree | be835aa92c6248212e705f25388ebafcf84bc7a1 /contrib/libs/curl/lib/conncache.c | |
| parent | 4e839db24a3bbc9f1c610c43d6faaaa99824dcca (diff) | |
Restoring authorship annotation for <[email protected]>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/curl/lib/conncache.c')
| -rw-r--r-- | contrib/libs/curl/lib/conncache.c | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/contrib/libs/curl/lib/conncache.c b/contrib/libs/curl/lib/conncache.c index d74c2a6860d..cb3170c480f 100644 --- a/contrib/libs/curl/lib/conncache.c +++ b/contrib/libs/curl/lib/conncache.c @@ -6,11 +6,11 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <[email protected]> - * Copyright (C) 2012 - 2020, Daniel Stenberg, <[email protected]>, et al. + * Copyright (C) 2012 - 2020, Daniel Stenberg, <[email protected]>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms - * are also available at https://curl.se/docs/copyright.html. + * are also available at https://curl.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is @@ -49,57 +49,57 @@ static void conn_llist_dtor(void *user, void *element) conn->bundle = NULL; } -static CURLcode bundle_create(struct connectbundle **bundlep) +static CURLcode bundle_create(struct connectbundle **bundlep) { - DEBUGASSERT(*bundlep == NULL); - *bundlep = malloc(sizeof(struct connectbundle)); - if(!*bundlep) + DEBUGASSERT(*bundlep == NULL); + *bundlep = malloc(sizeof(struct connectbundle)); + if(!*bundlep) return CURLE_OUT_OF_MEMORY; - (*bundlep)->num_connections = 0; - (*bundlep)->multiuse = BUNDLE_UNKNOWN; + (*bundlep)->num_connections = 0; + (*bundlep)->multiuse = BUNDLE_UNKNOWN; - Curl_llist_init(&(*bundlep)->conn_list, (Curl_llist_dtor) conn_llist_dtor); + Curl_llist_init(&(*bundlep)->conn_list, (Curl_llist_dtor) conn_llist_dtor); return CURLE_OK; } -static void bundle_destroy(struct connectbundle *bundle) +static void bundle_destroy(struct connectbundle *bundle) { - if(!bundle) + if(!bundle) return; - Curl_llist_destroy(&bundle->conn_list, NULL); + Curl_llist_destroy(&bundle->conn_list, NULL); - free(bundle); + free(bundle); } /* Add a connection to a bundle */ -static void bundle_add_conn(struct connectbundle *bundle, +static void bundle_add_conn(struct connectbundle *bundle, struct connectdata *conn) { - Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn, + Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn, &conn->bundle_node); - conn->bundle = bundle; - bundle->num_connections++; + conn->bundle = bundle; + bundle->num_connections++; } /* Remove a connection from a bundle */ -static int bundle_remove_conn(struct connectbundle *bundle, +static int bundle_remove_conn(struct connectbundle *bundle, struct connectdata *conn) { - struct Curl_llist_element *curr; + struct Curl_llist_element *curr; - curr = bundle->conn_list.head; + curr = bundle->conn_list.head; while(curr) { if(curr->ptr == conn) { - Curl_llist_remove(&bundle->conn_list, curr, NULL); - bundle->num_connections--; + Curl_llist_remove(&bundle->conn_list, curr, NULL); + bundle->num_connections--; conn->bundle = NULL; return 1; /* we removed a handle */ } curr = curr->next; } - DEBUGASSERT(0); + DEBUGASSERT(0); return 0; } @@ -121,8 +121,8 @@ int Curl_conncache_init(struct conncache *connc, int size) rc = Curl_hash_init(&connc->hash, size, Curl_hash_str, Curl_str_key_compare, free_bundle_hash_entry); - if(rc) - Curl_close(&connc->closure_handle); + if(rc) + Curl_close(&connc->closure_handle); else connc->closure_handle->state.conn_cache = connc; @@ -143,16 +143,16 @@ static void hashkey(struct connectdata *conn, char *buf, const char *hostname; long port = conn->remote_port; -#ifndef CURL_DISABLE_PROXY +#ifndef CURL_DISABLE_PROXY if(conn->bits.httpproxy && !conn->bits.tunnel_proxy) { hostname = conn->http_proxy.host.name; port = conn->port; } else -#endif - if(conn->bits.conn_to_host) - hostname = conn->conn_to_host.name; - else +#endif + if(conn->bits.conn_to_host) + hostname = conn->conn_to_host.name; + else hostname = conn->host.name; if(hostp) @@ -169,9 +169,9 @@ static void hashkey(struct connectdata *conn, char *buf, size_t Curl_conncache_size(struct Curl_easy *data) { size_t num; - CONNCACHE_LOCK(data); + CONNCACHE_LOCK(data); num = data->state.conn_cache->num_conn; - CONNCACHE_UNLOCK(data); + CONNCACHE_UNLOCK(data); return num; } @@ -184,7 +184,7 @@ struct connectbundle *Curl_conncache_find_bundle(struct connectdata *conn, const char **hostp) { struct connectbundle *bundle = NULL; - CONNCACHE_LOCK(conn->data); + CONNCACHE_LOCK(conn->data); if(connc) { char key[HASHKEY_SIZE]; hashkey(conn, key, sizeof(key), hostp); @@ -206,8 +206,8 @@ static bool conncache_add_bundle(struct conncache *connc, static void conncache_remove_bundle(struct conncache *connc, struct connectbundle *bundle) { - struct Curl_hash_iterator iter; - struct Curl_hash_element *he; + struct Curl_hash_iterator iter; + struct Curl_hash_element *he; if(!connc) return; @@ -231,7 +231,7 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, struct connectdata *conn) { CURLcode result = CURLE_OK; - struct connectbundle *bundle = NULL; + struct connectbundle *bundle = NULL; struct Curl_easy *data = conn->data; /* *find_bundle() locks the connection cache */ @@ -240,16 +240,16 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, int rc; char key[HASHKEY_SIZE]; - result = bundle_create(&bundle); + result = bundle_create(&bundle); if(result) { goto unlock; } hashkey(conn, key, sizeof(key), NULL); - rc = conncache_add_bundle(data->state.conn_cache, key, bundle); + rc = conncache_add_bundle(data->state.conn_cache, key, bundle); if(!rc) { - bundle_destroy(bundle); + bundle_destroy(bundle); result = CURLE_OUT_OF_MEMORY; goto unlock; } @@ -264,17 +264,17 @@ CURLcode Curl_conncache_add_conn(struct conncache *connc, conn->connection_id, connc->num_conn)); unlock: - CONNCACHE_UNLOCK(data); + CONNCACHE_UNLOCK(data); return result; } /* - * Removes the connectdata object from the connection cache, but does *not* - * clear the conn->data association. The transfer still owns this connection. - * - * Pass TRUE/FALSE in the 'lock' argument depending on if the parent function - * already holds the lock or not. + * Removes the connectdata object from the connection cache, but does *not* + * clear the conn->data association. The transfer still owns this connection. + * + * Pass TRUE/FALSE in the 'lock' argument depending on if the parent function + * already holds the lock or not. */ void Curl_conncache_remove_conn(struct Curl_easy *data, struct connectdata *conn, bool lock) @@ -286,7 +286,7 @@ void Curl_conncache_remove_conn(struct Curl_easy *data, due to a failed connection attempt, before being added to a bundle */ if(bundle) { if(lock) { - CONNCACHE_LOCK(data); + CONNCACHE_LOCK(data); } bundle_remove_conn(bundle, conn); if(bundle->num_connections == 0) @@ -298,7 +298,7 @@ void Curl_conncache_remove_conn(struct Curl_easy *data, connc->num_conn)); } if(lock) { - CONNCACHE_UNLOCK(data); + CONNCACHE_UNLOCK(data); } } } @@ -320,14 +320,14 @@ bool Curl_conncache_foreach(struct Curl_easy *data, void *param, int (*func)(struct connectdata *conn, void *param)) { - struct Curl_hash_iterator iter; - struct Curl_llist_element *curr; - struct Curl_hash_element *he; + struct Curl_hash_iterator iter; + struct Curl_llist_element *curr; + struct Curl_hash_element *he; if(!connc) return FALSE; - CONNCACHE_LOCK(data); + CONNCACHE_LOCK(data); Curl_hash_start_iterate(&connc->hash, &iter); he = Curl_hash_next_element(&iter); @@ -345,12 +345,12 @@ bool Curl_conncache_foreach(struct Curl_easy *data, curr = curr->next; if(1 == func(conn, param)) { - CONNCACHE_UNLOCK(data); + CONNCACHE_UNLOCK(data); return TRUE; } } } - CONNCACHE_UNLOCK(data); + CONNCACHE_UNLOCK(data); return FALSE; } @@ -363,15 +363,15 @@ bool Curl_conncache_foreach(struct Curl_easy *data, static struct connectdata * conncache_find_first_connection(struct conncache *connc) { - struct Curl_hash_iterator iter; - struct Curl_hash_element *he; + struct Curl_hash_iterator iter; + struct Curl_hash_element *he; struct connectbundle *bundle; Curl_hash_start_iterate(&connc->hash, &iter); he = Curl_hash_next_element(&iter); while(he) { - struct Curl_llist_element *curr; + struct Curl_llist_element *curr; bundle = he->ptr; curr = bundle->conn_list.head; @@ -391,8 +391,8 @@ conncache_find_first_connection(struct conncache *connc) * * Return TRUE if stored, FALSE if closed. */ -bool Curl_conncache_return_conn(struct Curl_easy *data, - struct connectdata *conn) +bool Curl_conncache_return_conn(struct Curl_easy *data, + struct connectdata *conn) { /* data->multi->maxconnects can be negative, deal with it. */ size_t maxconnects = @@ -429,7 +429,7 @@ struct connectdata * Curl_conncache_extract_bundle(struct Curl_easy *data, struct connectbundle *bundle) { - struct Curl_llist_element *curr; + struct Curl_llist_element *curr; timediff_t highscore = -1; timediff_t score; struct curltime now; @@ -477,9 +477,9 @@ struct connectdata * Curl_conncache_extract_oldest(struct Curl_easy *data) { struct conncache *connc = data->state.conn_cache; - struct Curl_hash_iterator iter; - struct Curl_llist_element *curr; - struct Curl_hash_element *he; + struct Curl_hash_iterator iter; + struct Curl_llist_element *curr; + struct Curl_hash_element *he; timediff_t highscore =- 1; timediff_t score; struct curltime now; @@ -489,7 +489,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) now = Curl_now(); - CONNCACHE_LOCK(data); + CONNCACHE_LOCK(data); Curl_hash_start_iterate(&connc->hash, &iter); he = Curl_hash_next_element(&iter); @@ -502,8 +502,8 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) while(curr) { conn = curr->ptr; - if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close && - !conn->bits.connect_only) { + if(!CONN_INUSE(conn) && !conn->data && !conn->bits.close && + !conn->bits.connect_only) { /* Set higher score for the age passed since the connection was used */ score = Curl_timediff(now, conn->lastused); @@ -526,7 +526,7 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) connc->num_conn)); conn_candidate->data = data; /* associate! */ } - CONNCACHE_UNLOCK(data); + CONNCACHE_UNLOCK(data); return conn_candidate; } @@ -534,11 +534,11 @@ Curl_conncache_extract_oldest(struct Curl_easy *data) void Curl_conncache_close_all_connections(struct conncache *connc) { struct connectdata *conn; - char buffer[READBUFFER_MIN + 1]; - if(!connc->closure_handle) - return; - connc->closure_handle->state.buffer = buffer; - connc->closure_handle->set.buffer_size = READBUFFER_MIN; + char buffer[READBUFFER_MIN + 1]; + if(!connc->closure_handle) + return; + connc->closure_handle->state.buffer = buffer; + connc->closure_handle->set.buffer_size = READBUFFER_MIN; conn = conncache_find_first_connection(connc); while(conn) { @@ -548,21 +548,21 @@ void Curl_conncache_close_all_connections(struct conncache *connc) sigpipe_ignore(conn->data, &pipe_st); /* This will remove the connection from the cache */ connclose(conn, "kill all"); - Curl_conncache_remove_conn(conn->data, conn, TRUE); + Curl_conncache_remove_conn(conn->data, conn, TRUE); (void)Curl_disconnect(connc->closure_handle, conn, FALSE); sigpipe_restore(&pipe_st); conn = conncache_find_first_connection(connc); } - connc->closure_handle->state.buffer = NULL; + connc->closure_handle->state.buffer = NULL; if(connc->closure_handle) { SIGPIPE_VARIABLE(pipe_st); sigpipe_ignore(connc->closure_handle, &pipe_st); Curl_hostcache_clean(connc->closure_handle, connc->closure_handle->dns.hostcache); - Curl_close(&connc->closure_handle); + Curl_close(&connc->closure_handle); sigpipe_restore(&pipe_st); } } @@ -571,9 +571,9 @@ void Curl_conncache_close_all_connections(struct conncache *connc) /* Useful for debugging the connection cache */ void Curl_conncache_print(struct conncache *connc) { - struct Curl_hash_iterator iter; - struct Curl_llist_element *curr; - struct Curl_hash_element *he; + struct Curl_hash_iterator iter; + struct Curl_llist_element *curr; + struct Curl_hash_element *he; if(!connc) return; |
