diff options
author | Daniel Stenberg <daniel@haxx.se> | 2022-01-19 13:57:30 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-01-20 09:07:30 +0100 |
commit | e74a6b7b72233662d47fad8d43c7157e665a1f1e (patch) | |
tree | fe83e750db596e03a1bda709bb2f41c5309cafa3 | |
parent | cdb495f743d9154294686b4faf7075ff6b4f1b5a (diff) | |
download | curl-e74a6b7b72233662d47fad8d43c7157e665a1f1e.tar.gz |
url: make Curl_disconnect return void
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
-rw-r--r-- | lib/conncache.c | 6 | ||||
-rw-r--r-- | lib/multi.c | 8 | ||||
-rw-r--r-- | lib/url.c | 15 | ||||
-rw-r--r-- | lib/url.h | 6 |
4 files changed, 14 insertions, 21 deletions
diff --git a/lib/conncache.c b/lib/conncache.c index fec1937f0..493758dc5 100644 --- a/lib/conncache.c +++ b/lib/conncache.c @@ -6,7 +6,7 @@ * \___|\___/|_| \_\_____| * * Copyright (C) 2012 - 2016, Linus Nielsen Feltzing, <linus@haxx.se> - * Copyright (C) 2012 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 2012 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -410,7 +410,7 @@ bool Curl_conncache_return_conn(struct Curl_easy *data, conn_candidate = Curl_conncache_extract_oldest(data); if(conn_candidate) { /* the winner gets the honour of being disconnected */ - (void)Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE); + Curl_disconnect(data, conn_candidate, /* dead_connection */ FALSE); } } @@ -547,7 +547,7 @@ void Curl_conncache_close_all_connections(struct conncache *connc) /* This will remove the connection from the cache */ connclose(conn, "kill all"); Curl_conncache_remove_conn(connc->closure_handle, conn, TRUE); - (void)Curl_disconnect(connc->closure_handle, conn, FALSE); + Curl_disconnect(connc->closure_handle, conn, FALSE); sigpipe_restore(&pipe_st); conn = conncache_find_first_connection(connc); diff --git a/lib/multi.c b/lib/multi.c index c2a8a6b09..66e269cb9 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -687,16 +687,10 @@ static CURLcode multi_done(struct Curl_easy *data, #endif ) || conn->bits.close || (premature && !(conn->handler->flags & PROTOPT_STREAM))) { - CURLcode res2; connclose(conn, "disconnecting"); Curl_conncache_remove_conn(data, conn, FALSE); CONNCACHE_UNLOCK(data); - res2 = Curl_disconnect(data, conn, premature); - - /* If we had an error already, make sure we return that one. But - if we got a new error, return that. */ - if(!result && res2) - result = res2; + Curl_disconnect(data, conn, premature); } else { char buffer[256]; @@ -830,8 +830,8 @@ static void conn_free(struct connectdata *conn) * */ -CURLcode Curl_disconnect(struct Curl_easy *data, - struct connectdata *conn, bool dead_connection) +void Curl_disconnect(struct Curl_easy *data, + struct connectdata *conn, bool dead_connection) { /* there must be a connection to close */ DEBUGASSERT(conn); @@ -851,7 +851,7 @@ CURLcode Curl_disconnect(struct Curl_easy *data, */ if(CONN_INUSE(conn) && !dead_connection) { DEBUGF(infof(data, "Curl_disconnect when inuse: %zu", CONN_INUSE(conn))); - return CURLE_OK; + return; } if(conn->dns_entry) { @@ -883,7 +883,6 @@ CURLcode Curl_disconnect(struct Curl_easy *data, Curl_detach_connnection(data); conn_free(conn); - return CURLE_OK; } /* @@ -1105,7 +1104,7 @@ static void prune_dead_connections(struct Curl_easy *data) Curl_conncache_remove_conn(data, prune.extracted, TRUE); /* disconnect it */ - (void)Curl_disconnect(data, prune.extracted, TRUE); + Curl_disconnect(data, prune.extracted, TRUE); } CONNCACHE_LOCK(data); data->state.conn_cache->last_cleanup = now; @@ -1209,7 +1208,7 @@ ConnectionExists(struct Curl_easy *data, if(extract_if_dead(check, data)) { /* disconnect it */ - (void)Curl_disconnect(data, check, TRUE); + Curl_disconnect(data, check, TRUE); continue; } @@ -3963,7 +3962,7 @@ static CURLcode create_conn(struct Curl_easy *data, CONNCACHE_UNLOCK(data); if(conn_candidate) - (void)Curl_disconnect(data, conn_candidate, FALSE); + Curl_disconnect(data, conn_candidate, FALSE); else { infof(data, "No more connections allowed to host %s: %zu", bundlehost, max_host_connections); @@ -3983,7 +3982,7 @@ static CURLcode create_conn(struct Curl_easy *data, /* The cache is full. Let's see if we can kill a connection. */ conn_candidate = Curl_conncache_extract_oldest(data); if(conn_candidate) - (void)Curl_disconnect(data, conn_candidate, FALSE); + Curl_disconnect(data, conn_candidate, FALSE); else { infof(data, "No connections available in cache"); connections_available = FALSE; @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -35,8 +35,8 @@ void Curl_freeset(struct Curl_easy *data); CURLcode Curl_uc_to_curlcode(CURLUcode uc); CURLcode Curl_close(struct Curl_easy **datap); /* opposite of curl_open() */ CURLcode Curl_connect(struct Curl_easy *, bool *async, bool *protocol_connect); -CURLcode Curl_disconnect(struct Curl_easy *data, - struct connectdata *, bool dead_connection); +void Curl_disconnect(struct Curl_easy *data, + struct connectdata *, bool dead_connection); CURLcode Curl_setup_conn(struct Curl_easy *data, bool *protocol_done); void Curl_free_request_state(struct Curl_easy *data); |