diff options
author | thegeorg <thegeorg@yandex-team.com> | 2024-07-30 09:57:24 +0300 |
---|---|---|
committer | thegeorg <thegeorg@yandex-team.com> | 2024-07-30 10:08:52 +0300 |
commit | 5b405616d0467647cb365e71237976a9f3810b42 (patch) | |
tree | c35e742877f95ba2b9357f178197c755f121cb1a /contrib/libs/c-ares/src/lib/ares_cancel.c | |
parent | 997c68115bc1c9dd2fce5a6a6f8eae92ad628df7 (diff) | |
download | ydb-5b405616d0467647cb365e71237976a9f3810b42.tar.gz |
Update contrib/libs/c-ares to 1.28.1
db71d0a3bd9ec3cf1e1ccb5a9cfac8abfd43fdb7
Diffstat (limited to 'contrib/libs/c-ares/src/lib/ares_cancel.c')
-rw-r--r-- | contrib/libs/c-ares/src/lib/ares_cancel.c | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/contrib/libs/c-ares/src/lib/ares_cancel.c b/contrib/libs/c-ares/src/lib/ares_cancel.c index 353624a111..5a9fb722cb 100644 --- a/contrib/libs/c-ares/src/lib/ares_cancel.c +++ b/contrib/libs/c-ares/src/lib/ares_cancel.c @@ -35,10 +35,15 @@ * on the given channel. It does NOT kill the channel, use ares_destroy() for * that. */ -void ares_cancel(ares_channel channel) +void ares_cancel(ares_channel_t *channel) { - if (ares__llist_len(channel->all_queries) > 0) - { + if (channel == NULL) { + return; + } + + ares__channel_lock(channel); + + if (ares__llist_len(channel->all_queries) > 0) { ares__llist_node_t *node = NULL; ares__llist_node_t *next = NULL; @@ -46,42 +51,43 @@ void ares_cancel(ares_channel channel) * into this function are cancelled. New queries added by callbacks of * queries being cancelled will not be cancelled themselves. */ - ares__llist_t *list_copy = channel->all_queries; - channel->all_queries = ares__llist_create(NULL); + ares__llist_t *list_copy = channel->all_queries; + channel->all_queries = ares__llist_create(NULL); /* Out of memory, this function doesn't return a result code though so we * can't report to caller */ if (channel->all_queries == NULL) { channel->all_queries = list_copy; - return; + goto done; } node = ares__llist_node_first(list_copy); while (node != NULL) { - struct query *query; - ares_socket_t fd = ARES_SOCKET_BAD; + struct query *query; + struct server_connection *conn; /* Cache next since this node is being deleted */ next = ares__llist_node_next(node); - query = ares__llist_node_claim(node); + query = ares__llist_node_claim(node); + conn = query->conn; query->node_all_queries = NULL; - /* Cache file descriptor for connection so we can clean it up possibly */ - if (query->conn) - fd = query->conn->fd; - /* NOTE: its possible this may enqueue new queries */ - query->callback(query->arg, ARES_ECANCELLED, 0, NULL, 0); + query->callback(query->arg, ARES_ECANCELLED, 0, NULL); ares__free_query(query); /* See if the connection should be cleaned up */ - if (fd != ARES_SOCKET_BAD) - ares__check_cleanup_conn(channel, fd); + ares__check_cleanup_conn(channel, conn); node = next; } ares__llist_destroy(list_copy); } + + ares_queue_notify_empty(channel); + +done: + ares__channel_unlock(channel); } |