diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-04-27 21:18:02 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-04-27 21:18:02 +0000 |
commit | a795f8eae3aabb3a99af818ec011c330f621d4a5 (patch) | |
tree | c91bf9fcb157dbdfa94c95d0767b014bec7f69ed /channels/chan_mgcp.c | |
parent | 5897660860459018e08d2b3416a6087147515996 (diff) |
Improve responsiveness of MGCP during a reload (bug #1488)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@2785 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_mgcp.c')
-rwxr-xr-x | channels/chan_mgcp.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/channels/chan_mgcp.c b/channels/chan_mgcp.c index 25ae705f5..9bb773528 100755 --- a/channels/chan_mgcp.c +++ b/channels/chan_mgcp.c @@ -44,6 +44,9 @@ -- enhance retransmit mechanism (RTO calc. etc.) -- embedded command support */ +/* FS: Changes + * -- fixed reload_config() / do_monitor to stay responsive during reloads + */ #include <stdio.h> #include <pthread.h> @@ -3116,6 +3119,8 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore) return 1; } +static int *mgcpsock_read_id = NULL; + static void *do_monitor(void *data) { int res; @@ -3126,7 +3131,7 @@ static void *do_monitor(void *data) /* Add an I/O event to our UDP socket */ if (mgcpsock > -1) - ast_io_add(io, mgcpsock, mgcpsock_read, AST_IO_IN, NULL); + mgcpsock_read_id = ast_io_add(io, mgcpsock, mgcpsock_read, AST_IO_IN, NULL); /* This thread monitors all the frame relay interfaces which are not yet in use (and thus do not have a separate thread) indefinitely */ @@ -3865,22 +3870,28 @@ static int reload_config(void) cat = ast_category_browse(cfg, NULL); while(cat) { if (strcasecmp(cat, "general")) { - ast_mutex_lock(&gatelock); + ast_mutex_lock(&gatelock); g = build_gateway(cat, ast_variable_browse(cfg, cat)); if (g) { if (option_verbose > 2) { ast_verbose(VERBOSE_PREFIX_3 "Added gateway '%s'\n", g->name); - } - g->next = gateways; - gateways = g; + } + g->next = gateways; + gateways = g; + } + ast_mutex_unlock(&gatelock); + + /* FS: process queue and IO */ + if (monitor_thread == pthread_self()) { + if (sched) ast_sched_runq(sched); + if (io) ast_io_wait(io, 10); } - ast_mutex_unlock(&gatelock); } cat = ast_category_browse(cfg, cat); } - /* SC: prune deleted entries etc. */ - prune_gateways(); + /* SC: prune deleted entries etc. */ + prune_gateways(); if (ntohl(bindaddr.sin_addr.s_addr)) { memcpy(&__ourip, &bindaddr.sin_addr, sizeof(__ourip)); @@ -3899,6 +3910,10 @@ static int reload_config(void) ast_mutex_lock(&netlock); if (mgcpsock > -1) close(mgcpsock); + + if (mgcpsock_read_id != NULL) + mgcpsock_read_id = ast_io_remove(io, mgcpsock_read_id); + mgcpsock = socket(AF_INET, SOCK_DGRAM, 0); if (mgcpsock < 0) { ast_log(LOG_WARNING, "Unable to create MGCP socket: %s\n", strerror(errno)); |