Background DNS update manager. More...
#include "asterisk.h"#include "asterisk/_private.h"#include <regex.h>#include <signal.h>#include "asterisk/dnsmgr.h"#include "asterisk/linkedlists.h"#include "asterisk/utils.h"#include "asterisk/config.h"#include "asterisk/sched.h"#include "asterisk/cli.h"#include "asterisk/manager.h"#include "asterisk/acl.h"
Go to the source code of this file.
Data Structures | |
| struct | ast_dnsmgr_entry |
| struct | entry_list |
| struct | refresh_info |
Defines | |
| #define | REFRESH_DEFAULT 300 |
Functions | |
| int | ast_dnsmgr_changed (struct ast_dnsmgr_entry *entry) |
| Check is see if a dnsmgr entry has changed. | |
| struct ast_dnsmgr_entry * | ast_dnsmgr_get (const char *name, struct ast_sockaddr *result, const char *service) |
| Allocate a new DNS manager entry. | |
| struct ast_dnsmgr_entry * | ast_dnsmgr_get_family (const char *name, struct ast_sockaddr *result, const char *service, unsigned int family) |
| Allocate a new DNS manager entry. | |
| int | ast_dnsmgr_lookup (const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service) |
| Allocate and initialize a DNS manager entry. | |
| int | ast_dnsmgr_lookup_cb (const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data) |
| Allocate and initialize a DNS manager entry, with update callback. | |
| int | ast_dnsmgr_refresh (struct ast_dnsmgr_entry *entry) |
| Force a refresh of a dnsmgr entry. | |
| void | ast_dnsmgr_release (struct ast_dnsmgr_entry *entry) |
| Free a DNS manager entry. | |
| int | dnsmgr_init (void) |
| static int | dnsmgr_refresh (struct ast_dnsmgr_entry *entry, int verbose) |
| int | dnsmgr_reload (void) |
| static void | dnsmgr_shutdown (void) |
| void | dnsmgr_start_refresh (void) |
| static void * | do_refresh (void *data) |
| static int | do_reload (int loading) |
| static char * | handle_cli_refresh (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_cli_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_cli_status (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | internal_dnsmgr_lookup (const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service, dns_update_func func, void *data) |
| static int | refresh_list (const void *data) |
Variables | |
| static struct ast_cli_entry | cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh") |
| static struct ast_cli_entry | cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Reloads the DNS manager configuration") |
| static struct ast_cli_entry | cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status") |
| static int | enabled |
| static struct entry_list | entry_list |
| static struct refresh_info | master_refresh_info |
| static int | refresh_interval |
| static ast_mutex_t | refresh_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } |
| static int | refresh_sched = -1 |
| static pthread_t | refresh_thread = AST_PTHREADT_NULL |
| static struct ast_sched_context * | sched |
Background DNS update manager.
Definition in file dnsmgr.c.
| #define REFRESH_DEFAULT 300 |
Definition at line 79 of file dnsmgr.c.
Referenced by do_reload().
| int ast_dnsmgr_changed | ( | struct ast_dnsmgr_entry * | entry | ) |
Check is see if a dnsmgr entry has changed.
| non-zero | if the dnsmgr entry has changed since the last call to this function |
| zero | if the dnsmgr entry has not changed since the last call to this function |
Definition at line 237 of file dnsmgr.c.
References ast_mutex_lock, ast_mutex_unlock, ast_dnsmgr_entry::changed, and ast_dnsmgr_entry::lock.
Referenced by iax2_do_register().
{
int changed;
ast_mutex_lock(&entry->lock);
changed = entry->changed;
entry->changed = 0;
ast_mutex_unlock(&entry->lock);
return changed;
}
| struct ast_dnsmgr_entry* ast_dnsmgr_get | ( | const char * | name, |
| struct ast_sockaddr * | result, | ||
| const char * | service | ||
| ) | [read] |
Allocate a new DNS manager entry.
| name | the hostname |
| result | where the DNS manager should store the IP address as it refreshes it. |
| service |
This function allocates a new DNS manager entry object, and fills it with the provided hostname and IP address. This function does not force an initial lookup of the IP address. So, generally, this should be used when the initial address is already known.
Definition at line 121 of file dnsmgr.c.
References ast_dnsmgr_get_family().
{
return ast_dnsmgr_get_family(name, result, service, 0);
}
| struct ast_dnsmgr_entry* ast_dnsmgr_get_family | ( | const char * | name, |
| struct ast_sockaddr * | result, | ||
| const char * | service, | ||
| unsigned int | family | ||
| ) | [read] |
Allocate a new DNS manager entry.
| name | the hostname |
| result | where the DNS manager should store the IP address as it refreshes it. |
| service | |
| family | Address family to filter DNS addresses. |
This function allocates a new DNS manager entry object, and fills it with the provided hostname and IP address. This function does not force an initial lookup of the IP address. So, generally, this should be used when the initial address is already known.
Definition at line 96 of file dnsmgr.c.
References ast_calloc, ast_mutex_init, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_dnsmgr_entry::family, ast_dnsmgr_entry::lock, ast_dnsmgr_entry::result, and ast_dnsmgr_entry::service.
Referenced by ast_dnsmgr_get(), and internal_dnsmgr_lookup().
{
struct ast_dnsmgr_entry *entry;
int total_size = sizeof(*entry) + strlen(name) + (service ? strlen(service) + 1 : 0);
if (!result || ast_strlen_zero(name) || !(entry = ast_calloc(1, total_size))) {
return NULL;
}
entry->result = result;
ast_mutex_init(&entry->lock);
strcpy(entry->name, name);
if (service) {
entry->service = ((char *) entry) + sizeof(*entry) + strlen(name);
strcpy(entry->service, service);
}
entry->family = family;
AST_RWLIST_WRLOCK(&entry_list);
AST_RWLIST_INSERT_HEAD(&entry_list, entry, list);
AST_RWLIST_UNLOCK(&entry_list);
return entry;
}
| int ast_dnsmgr_lookup | ( | const char * | name, |
| struct ast_sockaddr * | result, | ||
| struct ast_dnsmgr_entry ** | dnsmgr, | ||
| const char * | service | ||
| ) |
Allocate and initialize a DNS manager entry.
| name | the hostname |
| result | where to store the IP address as the DNS manager refreshes it. The address family is used as an input parameter to filter the returned addresses. If it is 0, both IPv4 and IPv6 addresses can be returned. |
| dnsmgr | Where to store the allocate DNS manager entry |
| service |
| 0 | success |
| non-zero | failure |
Definition at line 181 of file dnsmgr.c.
References internal_dnsmgr_lookup().
Referenced by build_peer(), and iax2_append_register().
{
return internal_dnsmgr_lookup(name, result, dnsmgr, service, NULL, NULL);
}
| int ast_dnsmgr_lookup_cb | ( | const char * | name, |
| struct ast_sockaddr * | result, | ||
| struct ast_dnsmgr_entry ** | dnsmgr, | ||
| const char * | service, | ||
| dns_update_func | func, | ||
| void * | data | ||
| ) |
Allocate and initialize a DNS manager entry, with update callback.
| name | the hostname |
| result | The addr which is intended to be updated in the update callback when DNS manager calls it on refresh. The address family is used as an input parameter to filter the returned addresses. If it is 0, both IPv4 and IPv6 addresses can be returned. |
| dnsmgr | Where to store the allocate DNS manager entry |
| service | |
| func | The update callback function The update callback will be called when DNS manager detects that an IP address has been changed. Instead of updating the addr itself, DNS manager will call this callback function with the old and new addresses. It is the responsibility of the callback to perform any updates |
| data | A pointer to data that will be passed through to the callback function |
| 0 | success |
| non-zero | failure |
Definition at line 186 of file dnsmgr.c.
References internal_dnsmgr_lookup().
Referenced by __sip_subscribe_mwi_do(), build_peer(), and transmit_register().
{
return internal_dnsmgr_lookup(name, result, dnsmgr, service, func, data);
}
| int ast_dnsmgr_refresh | ( | struct ast_dnsmgr_entry * | entry | ) |
Force a refresh of a dnsmgr entry.
| non-zero | if the result is different than the previous result |
| zero | if the result is the same as the previous result |
Definition at line 229 of file dnsmgr.c.
References dnsmgr_refresh().
Referenced by build_peer(), iax2_do_register(), and sip_reg_timeout().
{
return dnsmgr_refresh(entry, 0);
}
| void ast_dnsmgr_release | ( | struct ast_dnsmgr_entry * | entry | ) |
Free a DNS manager entry.
| entry | the DNS manager entry to free |
Definition at line 126 of file dnsmgr.c.
References ast_debug, ast_free, ast_mutex_destroy, AST_RWLIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_dnsmgr_entry::lock.
Referenced by cleanup_all_regs(), delete_users(), match_and_cleanup_peer_sched(), peer_destructor(), and unload_module().
{
if (!entry) {
return;
}
AST_RWLIST_WRLOCK(&entry_list);
AST_RWLIST_REMOVE(&entry_list, entry, list);
AST_RWLIST_UNLOCK(&entry_list);
ast_debug(6, "removing dns manager for '%s'\n", entry->name);
ast_mutex_destroy(&entry->lock);
ast_free(entry);
}
| int dnsmgr_init | ( | void | ) |
Provided by dnsmgr.c
Definition at line 420 of file dnsmgr.c.
References ast_cli_register(), ast_log(), ast_register_atexit(), ast_sched_context_create(), cli_refresh, cli_reload, cli_status, dnsmgr_shutdown(), do_reload(), and LOG_ERROR.
Referenced by main().
{
if (!(sched = ast_sched_context_create())) {
ast_log(LOG_ERROR, "Unable to create schedule context.\n");
return -1;
}
ast_cli_register(&cli_reload);
ast_cli_register(&cli_status);
ast_cli_register(&cli_refresh);
ast_register_atexit(dnsmgr_shutdown);
return do_reload(1);
}
| static int dnsmgr_refresh | ( | struct ast_dnsmgr_entry * | entry, |
| int | verbose | ||
| ) | [static] |
Definition at line 194 of file dnsmgr.c.
References ast_debug, ast_get_ip_or_srv(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_sockaddr_cmp(), ast_sockaddr_copy(), ast_sockaddr_port, ast_sockaddr_set_port, ast_sockaddr_stringify(), ast_dnsmgr_entry::changed, ast_dnsmgr_entry::data, ast_dnsmgr_entry::family, ast_sockaddr::len, ast_dnsmgr_entry::lock, LOG_NOTICE, ast_dnsmgr_entry::result, ast_dnsmgr_entry::service, ast_sockaddr::ss, and ast_dnsmgr_entry::update_func.
Referenced by ast_dnsmgr_refresh(), and refresh_list().
{
struct ast_sockaddr tmp = { .len = 0, };
int changed = 0;
ast_mutex_lock(&entry->lock);
ast_debug(6, "refreshing '%s'\n", entry->name);
tmp.ss.ss_family = entry->family;
if (!ast_get_ip_or_srv(&tmp, entry->name, entry->service)) {
if (!ast_sockaddr_port(&tmp)) {
ast_sockaddr_set_port(&tmp, ast_sockaddr_port(entry->result));
}
if (ast_sockaddr_cmp(&tmp, entry->result)) {
const char *old_addr = ast_strdupa(ast_sockaddr_stringify(entry->result));
const char *new_addr = ast_strdupa(ast_sockaddr_stringify(&tmp));
if (entry->update_func) {
entry->update_func(entry->result, &tmp, entry->data);
} else {
ast_log(LOG_NOTICE, "dnssrv: host '%s' changed from %s to %s\n",
entry->name, old_addr, new_addr);
ast_sockaddr_copy(entry->result, &tmp);
changed = entry->changed = 1;
}
}
}
ast_mutex_unlock(&entry->lock);
return changed;
}
| int dnsmgr_reload | ( | void | ) |
Provided by dnsmgr.c
Definition at line 435 of file dnsmgr.c.
References do_reload().
{
return do_reload(0);
}
| static void dnsmgr_shutdown | ( | void | ) | [static] |
Definition at line 400 of file dnsmgr.c.
References ast_cli_unregister(), ast_mutex_lock, ast_mutex_unlock, AST_PTHREADT_NULL, ast_sched_context_destroy(), cli_refresh, cli_reload, and cli_status.
Referenced by dnsmgr_init().
{
ast_cli_unregister(&cli_reload);
ast_cli_unregister(&cli_status);
ast_cli_unregister(&cli_refresh);
/* Destroy refresh thread. */
ast_mutex_lock(&refresh_lock);
if (refresh_thread != AST_PTHREADT_NULL) {
/* wake up the thread so it will exit */
pthread_cancel(refresh_thread);
pthread_kill(refresh_thread, SIGURG);
pthread_join(refresh_thread, NULL);
refresh_thread = AST_PTHREADT_NULL;
}
ast_mutex_unlock(&refresh_lock);
ast_sched_context_destroy(sched);
}
| void dnsmgr_start_refresh | ( | void | ) |
Provided by dnsmgr.c
Definition at line 292 of file dnsmgr.c.
References ast_sched_add_variable(), AST_SCHED_DEL, master_refresh_info, and refresh_list().
Referenced by main().
{
if (refresh_sched > -1) {
AST_SCHED_DEL(sched, refresh_sched);
refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1);
}
}
| static void* do_refresh | ( | void * | data | ) | [static] |
Definition at line 251 of file dnsmgr.c.
References ast_sched_runq(), and ast_sched_wait().
Referenced by do_reload().
{
for (;;) {
pthread_testcancel();
usleep((ast_sched_wait(sched)*1000));
pthread_testcancel();
ast_sched_runq(sched);
}
return NULL;
}
| static int do_reload | ( | int | loading | ) | [static] |
Definition at line 440 of file dnsmgr.c.
References ast_config_destroy(), ast_config_load2(), ast_log(), ast_mutex_lock, ast_mutex_unlock, ast_pthread_create_background, AST_PTHREADT_NULL, ast_sched_add_variable(), AST_SCHED_DEL, ast_true(), ast_variable_browse(), config, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEMISSING, CONFIG_STATUS_FILEUNCHANGED, do_refresh(), enabled, EVENT_FLAG_SYSTEM, LOG_ERROR, LOG_NOTICE, LOG_WARNING, manager_event, master_refresh_info, ast_variable::name, ast_variable::next, REFRESH_DEFAULT, refresh_interval, refresh_list(), and ast_variable::value.
Referenced by dnsmgr_init(), dnsmgr_reload(), and handle_cli_reload().
{
struct ast_config *config;
struct ast_variable *v;
struct ast_flags config_flags = { loading ? 0 : CONFIG_FLAG_FILEUNCHANGED };
int interval;
int was_enabled;
if ((config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) {
return 0;
}
/* ensure that no refresh cycles run while the reload is in progress */
ast_mutex_lock(&refresh_lock);
/* reset defaults in preparation for reading config file */
refresh_interval = REFRESH_DEFAULT;
was_enabled = enabled;
enabled = 0;
if (config == CONFIG_STATUS_FILEMISSING || config == CONFIG_STATUS_FILEINVALID) {
ast_mutex_unlock(&refresh_lock);
return 0;
}
AST_SCHED_DEL(sched, refresh_sched);
for (v = ast_variable_browse(config, "general"); v; v = v->next) {
if (!strcasecmp(v->name, "enable")) {
enabled = ast_true(v->value);
} else if (!strcasecmp(v->name, "refreshinterval")) {
if (sscanf(v->value, "%30d", &interval) < 1) {
ast_log(LOG_WARNING, "Unable to convert '%s' to a numeric value.\n", v->value);
} else if (interval < 0) {
ast_log(LOG_WARNING, "Invalid refresh interval '%d' specified, using default\n", interval);
} else {
refresh_interval = interval;
}
}
}
ast_config_destroy(config);
if (enabled && refresh_interval) {
ast_log(LOG_NOTICE, "Managed DNS entries will be refreshed every %d seconds.\n", refresh_interval);
}
/* if this reload enabled the manager, create the background thread
if it does not exist */
if (enabled) {
if (!was_enabled && (refresh_thread == AST_PTHREADT_NULL)) {
if (ast_pthread_create_background(&refresh_thread, NULL, do_refresh, NULL) < 0) {
ast_log(LOG_ERROR, "Unable to start refresh thread.\n");
}
}
/* make a background refresh happen right away */
refresh_sched = ast_sched_add_variable(sched, 100, refresh_list, &master_refresh_info, 1);
/* if this reload disabled the manager and there is a background thread, kill it */
} else if (!enabled && was_enabled && (refresh_thread != AST_PTHREADT_NULL)) {
/* wake up the thread so it will exit */
pthread_cancel(refresh_thread);
pthread_kill(refresh_thread, SIGURG);
pthread_join(refresh_thread, NULL);
refresh_thread = AST_PTHREADT_NULL;
}
ast_mutex_unlock(&refresh_lock);
manager_event(EVENT_FLAG_SYSTEM, "Reload", "Module: DNSmgr\r\nStatus: %s\r/nMessage: DNSmgr reload Requested\r\n", enabled ? "Enabled" : "Disabled");
return 0;
}
| static char* handle_cli_refresh | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 322 of file dnsmgr.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, enabled, refresh_info::entries, entry_list, ast_cli_args::fd, refresh_info::filter, refresh_list(), refresh_info::regex_present, and ast_cli_entry::usage.
{
struct refresh_info info = {
.entries = &entry_list,
.verbose = 1,
};
switch (cmd) {
case CLI_INIT:
e->command = "dnsmgr refresh";
e->usage =
"Usage: dnsmgr refresh [pattern]\n"
" Peforms an immediate refresh of the managed DNS entries.\n"
" Optional regular expression pattern is used to filter the entries to refresh.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (!enabled) {
ast_cli(a->fd, "DNS Manager is disabled.\n");
return 0;
}
if (a->argc > 3) {
return CLI_SHOWUSAGE;
}
if (a->argc == 3) {
if (regcomp(&info.filter, a->argv[2], REG_EXTENDED | REG_NOSUB)) {
return CLI_SHOWUSAGE;
} else {
info.regex_present = 1;
}
}
refresh_list(&info);
if (info.regex_present) {
regfree(&info.filter);
}
return CLI_SUCCESS;
}
| static char* handle_cli_reload | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 302 of file dnsmgr.c.
References ast_cli_args::argc, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, do_reload(), and ast_cli_entry::usage.
{
switch (cmd) {
case CLI_INIT:
e->command = "dnsmgr reload";
e->usage =
"Usage: dnsmgr reload\n"
" Reloads the DNS manager configuration.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc > 2) {
return CLI_SHOWUSAGE;
}
do_reload(0);
return CLI_SUCCESS;
}
| static char* handle_cli_status | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 366 of file dnsmgr.c.
References ast_cli_args::argc, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, enabled, ast_cli_args::fd, refresh_interval, and ast_cli_entry::usage.
{
int count = 0;
struct ast_dnsmgr_entry *entry;
switch (cmd) {
case CLI_INIT:
e->command = "dnsmgr status";
e->usage =
"Usage: dnsmgr status\n"
" Displays the DNS manager status.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc > 2) {
return CLI_SHOWUSAGE;
}
ast_cli(a->fd, "DNS Manager: %s\n", enabled ? "enabled" : "disabled");
ast_cli(a->fd, "Refresh Interval: %d seconds\n", refresh_interval);
AST_RWLIST_RDLOCK(&entry_list);
AST_RWLIST_TRAVERSE(&entry_list, entry, list)
count++;
AST_RWLIST_UNLOCK(&entry_list);
ast_cli(a->fd, "Number of entries: %d\n", count);
return CLI_SUCCESS;
}
| static int internal_dnsmgr_lookup | ( | const char * | name, |
| struct ast_sockaddr * | result, | ||
| struct ast_dnsmgr_entry ** | dnsmgr, | ||
| const char * | service, | ||
| dns_update_func | func, | ||
| void * | data | ||
| ) | [static] |
Definition at line 141 of file dnsmgr.c.
References ast_debug, ast_dnsmgr_get_family(), ast_get_ip_or_srv(), ast_sockaddr_parse(), ast_strlen_zero(), ast_dnsmgr_entry::data, enabled, ast_dnsmgr_entry::family, PARSE_PORT_FORBID, and ast_sockaddr::ss.
Referenced by ast_dnsmgr_lookup(), and ast_dnsmgr_lookup_cb().
{
unsigned int family;
if (ast_strlen_zero(name) || !result || !dnsmgr) {
return -1;
}
if (*dnsmgr && !strcasecmp((*dnsmgr)->name, name)) {
return 0;
}
/* Lookup address family filter. */
family = result->ss.ss_family;
/*
* If it's actually an IP address and not a name, there's no
* need for a managed lookup.
*/
if (ast_sockaddr_parse(result, name, PARSE_PORT_FORBID)) {
return 0;
}
ast_debug(6, "doing dnsmgr_lookup for '%s'\n", name);
/* do a lookup now but add a manager so it will automagically get updated in the background */
ast_get_ip_or_srv(result, name, service);
/* if dnsmgr is not enable don't bother adding an entry */
if (!enabled) {
return 0;
}
ast_debug(6, "adding dns manager for '%s'\n", name);
*dnsmgr = ast_dnsmgr_get_family(name, result, service, family);
(*dnsmgr)->update_func = func;
(*dnsmgr)->data = data;
return !*dnsmgr;
}
| static int refresh_list | ( | const void * | data | ) | [static] |
Definition at line 262 of file dnsmgr.c.
References ast_debug, ast_log(), ast_mutex_trylock, ast_mutex_unlock, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, dnsmgr_refresh(), refresh_info::entries, refresh_info::filter, LOG_WARNING, refresh_interval, refresh_info::regex_present, and refresh_info::verbose.
Referenced by dnsmgr_start_refresh(), do_reload(), and handle_cli_refresh().
{
struct refresh_info *info = (struct refresh_info *)data;
struct ast_dnsmgr_entry *entry;
/* if a refresh or reload is already in progress, exit now */
if (ast_mutex_trylock(&refresh_lock)) {
if (info->verbose) {
ast_log(LOG_WARNING, "DNS Manager refresh already in progress.\n");
}
return -1;
}
ast_debug(6, "Refreshing DNS lookups.\n");
AST_RWLIST_RDLOCK(info->entries);
AST_RWLIST_TRAVERSE(info->entries, entry, list) {
if (info->regex_present && regexec(&info->filter, entry->name, 0, NULL, 0)) {
continue;
}
dnsmgr_refresh(entry, info->verbose);
}
AST_RWLIST_UNLOCK(info->entries);
ast_mutex_unlock(&refresh_lock);
/* automatically reschedule based on the interval */
return refresh_interval * 1000;
}
struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh") [static] |
Definition at line 397 of file dnsmgr.c.
Referenced by dnsmgr_init(), and dnsmgr_shutdown().
struct ast_cli_entry cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Reloads the DNS manager configuration") [static] |
Definition at line 396 of file dnsmgr.c.
Referenced by dnsmgr_init(), and dnsmgr_shutdown().
struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status") [static] |
Definition at line 398 of file dnsmgr.c.
Referenced by dnsmgr_init(), and dnsmgr_shutdown().
struct entry_list entry_list [static] |
Referenced by handle_cli_refresh().
struct refresh_info master_refresh_info [static] |
{
.entries = &entry_list,
.verbose = 0,
}
Definition at line 91 of file dnsmgr.c.
Referenced by dnsmgr_start_refresh(), and do_reload().
int refresh_interval [static] |
Definition at line 82 of file dnsmgr.c.
Referenced by do_reload(), handle_cli_status(), and refresh_list().
ast_mutex_t refresh_lock = { PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP , NULL, 1 } [static] |
int refresh_sched = -1 [static] |
pthread_t refresh_thread = AST_PTHREADT_NULL [static] |
struct ast_sched_context* sched [static] |