ARES_CANCEL(3)
okay bestie, welcome to ARES_CANCEL(3) from the Library Functions Manual β the little page that literally says βcancel a resolveβ and honestly? iconic π«Ά
π NAME π
ares_cancel β cancel a resolve π
β¨ SYNOPSIS β¨
#include <ares.h>
void ares_cancel(ares_channel_t *channel)
πΈ DESCRIPTION πΈ
So ares_cancel(3) cancels all the lookups/requests made on the name service channel identified by channel. Not some. Not a few. All of them, bestie π
When it does that, it invokes the callbacks for each pending query on the channel and passes them a status of ARES_ECANCELLED. This is the whole point: those calls give the callbacks a chance to clean up any state that might have been stored in their arguments. Obsessed with a graceful exit π
One tiny but important vibe check: if one of those callback invocations adds a new request to the channel, that request will not be cancelled by the current invocation of ares_cancel(3). New request = new era, it survives this cancel β¨
π REENTRANCY π
A callback invoked by ares_cancel(3) may call c-ares functions on the same channel. Yes, fr fr β and hereβs why itβs not chaotic: the channel lock is recursive, and each query is unlinked from the libraryβs internal structures before its callback runs. So a reentrant call cannot encounter a query that is part-way through being torn down. No half-torn-down query jumpscare π
This includes starting new lookups, as described above, and reconfiguring the server list with ares_set_servers_csv(3) and related functions. Slay π
π AVAILABILITY π
The reentrancy guarantee described above applies as of c-ares version 1.35.0, and c-ares version 1.34.9 on the 1.34 branch. Cute, specific, documented π
π SEE ALSO π
π NOTES π
- This function was added in c-ares
1.2.0β - c-ares
1.6.0and earlier pass a status ofARES_ETIMEOUTinstead ofARES_ECANCELLED. Lowkey ancient lore, but important π§
xoxo, that was the ARES_CANCEL(3) page from the Library Functions Manual, dated 31 March 2004 β bye bestie, stay iconic ππ«Ά
π¦ where this page comes from
- alpine 3.22: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.23: c-ares-doc 1.34.9-r0 Β· MIT
- alpine 3.24: c-ares-doc 1.34.9-r0 Β· MIT
- arch rolling: c-ares 1.34.9-1 Β· MIT
- centos-stream 10: c-ares-devel 1.34.9-1.el10 Β· MIT
- nixos 26.05: c-ares 1.34.9
- π the page's license: MIT
- Copyright 1998 by the Massachusetts Institute of Technology
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms