mirror of
https://github.com/curl/curl.git
synced 2026-08-26 12:23:34 +03:00
dnscache: own source file, improvements
- Rename `Curl_resolv_unlink()` to `Curl_dns_entry_unlink()`. - Change `Curl_dnscache_get()` to return CURLcode result. Returns now `CURLE_COULDNT_RESOLVE_HOST` for "negative" cache entries. - Add `Curl_dnscache_add_negative()` to put a "negative" entry into the cache. Closes #20864
This commit is contained in:
parent
b0f6e9a3d7
commit
96d5b5c688
35 changed files with 1648 additions and 1413 deletions
37
lib/multi.c
37
lib/multi.c
|
|
@ -633,8 +633,8 @@ static void multi_done_locked(struct connectdata *conn,
|
|||
data->state.done = TRUE; /* called now! */
|
||||
data->state.recent_conn_id = conn->connection_id;
|
||||
|
||||
Curl_resolv_unlink(data, &data->state.dns[0]); /* done with this */
|
||||
Curl_resolv_unlink(data, &data->state.dns[1]);
|
||||
Curl_dns_entry_unlink(data, &data->state.dns[0]); /* done with this */
|
||||
Curl_dns_entry_unlink(data, &data->state.dns[1]);
|
||||
Curl_dnscache_prune(data);
|
||||
|
||||
if(multi_conn_should_close(conn, data, (bool)mdctx->premature)) {
|
||||
|
|
@ -2295,12 +2295,13 @@ static CURLMcode state_resolving(struct Curl_multi *multi,
|
|||
CURLcode *resultp)
|
||||
{
|
||||
struct Curl_dns_entry *dns = NULL;
|
||||
CURLcode result;
|
||||
CURLMcode mresult = CURLM_OK;
|
||||
CURLcode result;
|
||||
|
||||
result = Curl_resolv_check(data, &dns);
|
||||
CURL_TRC_DNS(data, "Curl_resolv_check() -> %d, %s",
|
||||
result = Curl_resolv_take_result(data, &dns);
|
||||
CURL_TRC_DNS(data, "Curl_resolv_take_result() -> %d, %s",
|
||||
result, dns ? "found" : "missing");
|
||||
|
||||
/* Update sockets here, because the socket(s) may have been closed and the
|
||||
application thus needs to be told, even if it is likely that the same
|
||||
socket(s) will again be used further down. If the name has not yet been
|
||||
|
|
@ -2314,23 +2315,21 @@ static CURLMcode state_resolving(struct Curl_multi *multi,
|
|||
bool connected;
|
||||
/* Perform the next step in the connection phase, and then move on to the
|
||||
WAITCONNECT state */
|
||||
result = Curl_once_resolved(data, dns, &connected);
|
||||
|
||||
if(result)
|
||||
/* if Curl_once_resolved() returns failure, the connection struct is
|
||||
already freed and gone */
|
||||
data->conn = NULL; /* no more connection */
|
||||
else {
|
||||
/* call again please so that we get the next socket setup */
|
||||
mresult = CURLM_CALL_MULTI_PERFORM;
|
||||
if(connected)
|
||||
multistate(data, MSTATE_PROTOCONNECT);
|
||||
else {
|
||||
multistate(data, MSTATE_CONNECTING);
|
||||
}
|
||||
result = Curl_setup_conn(data, dns, &connected);
|
||||
if(result) {
|
||||
/* setup failed, terminate connection */
|
||||
struct connectdata *conn = data->conn;
|
||||
Curl_detach_connection(data);
|
||||
Curl_conn_terminate(data, conn, TRUE);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* call again please so that we get the next socket setup */
|
||||
mresult = CURLM_CALL_MULTI_PERFORM;
|
||||
multistate(data, connected ? MSTATE_PROTOCONNECT : MSTATE_CONNECTING);
|
||||
}
|
||||
|
||||
out:
|
||||
if(result)
|
||||
/* failure detected */
|
||||
*stream_errorp = TRUE;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue