ARES\_DESTROY(3) Library Functions Manual ARES\_DESTROY(3)

# [NAME](#NAME)

ares\_destroy - Destroy a resolver channel

# [SYNOPSIS](#SYNOPSIS)

```
#include <ares.h>
void ares_destroy(ares_channel_t *channel)
```

# [DESCRIPTION](#DESCRIPTION)

The [**ares\_destroy(3)**](/man/os/c-ares/ares_destroy.3) function destroys the name service channel identified by *channel*, freeing all memory and closing all sockets used by the channel.

[**ares\_destroy(3)**](/man/os/c-ares/ares_destroy.3) invokes the callbacks for each pending query on the channel, passing a status of *ARES\_EDESTRUCTION*. These calls give the callbacks a chance to clean up any state which might have been stored in their arguments. A callback must not add new requests to a channel being destroyed. Such a request is refused: the request is not started, and its callback is invoked with a status of *ARES\_EDESTRUCTION* so that any state attached to its argument can be released. A request made from within that notification is refused without a further notification, so that a callback which responds to failure by retrying cannot recurse without bound; its argument is not handed back. This applies as of c-ares version 1.35.0, and c-ares version 1.34.9 on the 1.34 branch.

There is no ability to make this function thread-safe. No additional calls using this channel may be made once this function is called.

# [SEE ALSO](#SEE_ALSO)

[**ares\_init**(3)](/man/os/c-ares/ares_init.3), [**ares\_cancel**(3)](/man/os/c-ares/ares_cancel.3), [**ares\_threadsafety**(3)](/man/os/c-ares/ares_threadsafety.3)

7 December 2004

---

Document: ares_destroy(3) from c-ares 1.34.9-r0 (Chainguard OS)
Source: https://github.com/c-ares/c-ares
