mirror of https://github.com/c-ares/c-ares.git
Implement ares_reinit() to reload system configuration into existing channel (#614)
This PR implements ares_reinit() to safely reload a channel's configuration even if there are existing queries. This function can be called when system configuration is detected to be changed, however since c-ares isn't thread aware, care must be taken to ensure no other c-ares calls are in progress at the time this function is called. Also, this function may update the open file descriptor list so care must also be taken to wake any event loops and reprocess the list of file descriptors. Fixes Bug #301 Fix By: Brad House (@bradh352)pull/617/head
parent
9a01e766ed
commit
0cc570eabe
12 changed files with 205 additions and 67 deletions
@ -1,23 +1,4 @@ |
||||
TODO |
||||
==== |
||||
|
||||
ares_reinit() |
||||
|
||||
- To allow an app to force a re-read of /etc/resolv.conf etc, pretty much |
||||
like the res_init() resolver function offers |
||||
|
||||
ares_gethostbyname |
||||
|
||||
- When built to support IPv6, it needs to also support PF_UNSPEC or similar, |
||||
so that an application can ask for any protocol and then c-ares would return |
||||
all known resolves and not just explicitly IPv4 _or_ IPv6 resolves. |
||||
|
||||
ares_process |
||||
|
||||
- Upon next ABI breakage ares_process() should be changed to return 'int' |
||||
and return ARES_ENOTINITIALIZED if ares_library_init() has not been called. |
||||
|
||||
ares_process_fd |
||||
|
||||
- Upon next ABI breakage ares_process_fd() should be changed to return |
||||
'int' and return ARES_ENOTINITIALIZED if library has not been initialized. |
||||
Please see https://github.com/c-ares/c-ares/issues |
||||
|
@ -0,0 +1,48 @@ |
||||
.\" |
||||
.\" SPDX-License-Identifier: MIT |
||||
.\" |
||||
.TH ARES_REINIT 3 "12 November 2023" |
||||
.SH NAME |
||||
ares_reinit \- ReInitialize a resolver channel from system configuration. |
||||
.SH SYNOPSIS |
||||
.nf |
||||
#include <ares.h> |
||||
|
||||
int ares_reinit(ares_channel_t *\fIchannel\fP) |
||||
.fi |
||||
.SH DESCRIPTION |
||||
The \fBares_reinit(3)\fP function re-reads the system configuration and safely |
||||
applies the configuration to the existing channel. System configuration will |
||||
never override user-provided settings such as provided via |
||||
\fBares_init_options(3)\fP or \fBares_set_servers(3)\fP. |
||||
|
||||
Any existing queries will be automatically requeued if the server they are |
||||
currently assigned to is removed from the system configuration. |
||||
|
||||
It is important to remember that c-ares is not currently thread-aware and this |
||||
function cannot be called while any other c-ares functions are being called. |
||||
This function may also cause additional file descriptors to be created if |
||||
server configuration has changed, so care needs to be taken to ensure any |
||||
event loop is updated with new file descriptors. |
||||
|
||||
.SH RETURN VALUES |
||||
\fIares_reinit(3)\fP can return any of the following values: |
||||
.TP 14 |
||||
.B ARES_SUCCESS |
||||
Initialization succeeded. |
||||
.TP 14 |
||||
.B ARES_EFILE |
||||
A configuration file could not be read. |
||||
.TP 14 |
||||
.B ARES_ENOMEM |
||||
The process's available memory was exhausted. |
||||
|
||||
.SH SEE ALSO |
||||
.BR ares_init (3), |
||||
.BR ares_init_options (3), |
||||
.BR ares_destroy (3), |
||||
.BR ares_dup (3), |
||||
.BR ares_library_init (3), |
||||
.BR ares_set_servers (3) |
||||
.SH AUTHOR |
||||
Copyright (C) 2023 The c-ares project and its members. |
Loading…
Reference in new issue