ARES_REINIT(3)

πŸ“¦
version 1.34.9 Β· 2 versions
  • 1.34.9 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.27.0 Β· ubuntu noble
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ARES_REINIT(3) πŸ’–

ok so bestie, we're deep in the Library Functions Manual section today and this one is a certified glow-up function. it's called ares_reinit and it's literally here to give your resolver channel a little refresh from the system config. no biggie. πŸ¦‹


✨ NAME ✨

ares_reinit β€” reinitialize a resolver channel from system configuration. that's it, that's the vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <ares.h>

int ares_reinit(ares_channel_t *channel)

πŸ‘‘ DESCRIPTION πŸ‘‘

ok so the way that ares_reinit(3) works is: it re-reads the system configuration and then safely applies that config to the channel you already have. no destroying, no rebuilding from scratch, just a lil makeover on the existing one. ✨

and here's the part that matters, lowkey the most important thing: system configuration will never override user-provided settings. like, if you set stuff yourself via ares_init_options(3) or ares_set_servers(3), that's yours, bestie, and the system config is not about to come in and touch it. boundaries. 🫢

Any existing queries will be automatically requeued if the server they are currently assigned to is removed from the system configuration. so like, no queries get ghosted, they just get reassigned to a new server. iconic behaviour honestly. πŸ”₯

Also heads up: this function may cause additional file descriptors to be created, and existing ones to be destroyed if server configuration has changed. so yeah, fds are moving around. keep up. πŸ’€

0d safety, will spawn a background thread to read the configuration and apply it. 🧚
It is crucial that developers use the ARES_OPT_SOCK_STATE_CB or ARES_OPT_EVENT_THREAD so that notifications of changes are alerted. If using ares_getsock(3) or ares_fds(3), no notification is possible which could cause a stall. 🚨

like genuinely, do not skip that part. if you're on ares_getsock(3) or ares_fds(3) and you're expecting a notification, it is not coming, and you will stall. not cute. 😭


⭐ RETURN VALUES ⭐

ares_reinit(3) can return any of the following values, and every one of them is here so nobody gets surprised:

  • ARES_SUCCESS β€” Initialization succeeded. slay, you're done. πŸŽ€
  • ARES_EFILE β€” A configuration file could not be read. oop, the file said no. πŸ™ˆ
  • ARES_ENOMEM β€” The process's available memory was exhausted. out of memory, out of vibes. πŸ’€

🌈 AVAILABILITY 🌈

This function was first introduced in c-ares version 1.22.0. so if you're on anything older, bestie, it's simply not there. ✨


πŸ’œ SEE ALSO πŸ’œ

go read those too, iykyk. πŸ“š


and that's the whole page, bestie! πŸ¦‹ this one dropped on 12 November 2023 and lives in the Library Functions Manual (c-ares, obviously, the version that brought us 1.22.0). go forth and reinit responsibly. mwah. πŸ’–πŸŽ€βœ¨