mirror of
https://github.com/curl/curl.git
synced 2025-04-12 16:20:35 +08:00
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
This commit is contained in:
parent
cdb495f743
commit
e74a6b7b72
@ -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);
|
||||
|
@ -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];
|
||||
|
15
lib/url.c
15
lib/url.c
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user