diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-27 19:10:32 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-27 19:10:32 +0000 |
commit | 4a40e0ec6f423de8e8cd744bd5e5c1592f88d2bc (patch) | |
tree | ce5d46d0d87fc7ee22af3c25180e9916951b3cfc /channels/chan_iax2.c | |
parent | 34087ec576d4a7446ecd9fd0ed97430b57c4004b (diff) |
Improve timing interface to remember which provider provided a timer
The ability to load/unload timing interfaces is nice, but it means that when a timer is allocated, it may come from provider A, but later provider B becomes the 'preferred' provider. If this happens, all timer API calls on the timer that was provided by provider A will actually be handed to provider B, which will say WTF and return an error.
This patch changes the timer API to include a pointer to the provider of the timer handle so that future operations on the timer will be forwarded to the proper provider.
(closes issue #14697)
Reported by: moy
Review: http://reviewboard.digium.com/r/211/
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@184762 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_iax2.c')
-rw-r--r-- | channels/chan_iax2.c | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 3d88ecb48..aa7d24e42 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -257,7 +257,7 @@ static int max_reg_expire; static int srvlookup = 0; -static int timingfd = -1; /* Timing file descriptor */ +static struct ast_timer *timer; /* Timer for trunking */ static struct ast_netsock_list *netsock; static struct ast_netsock_list *outsock; /*!< used if sourceaddress specified and bindaddr == INADDR_ANY */ @@ -7717,8 +7717,8 @@ static int timing_read(int *id, int fd, short events, void *cbdata) if (iaxtrunkdebug) ast_verbose("Beginning trunk processing. Trunk queue ceiling is %d bytes per host\n", trunkmaxsize); - if (timingfd > -1) { - ast_timer_ack(timingfd, 1); + if (timer) { + ast_timer_ack(timer, 1); } /* For each peer that supports trunking... */ @@ -10500,8 +10500,8 @@ static void *network_thread(void *ignore) int res, count, wakeup; struct iax_frame *f; - if (timingfd > -1) - ast_io_add(io, timingfd, timing_read, AST_IO_IN | AST_IO_PRI, NULL); + if (timer) + ast_io_add(io, ast_timer_fd(timer), timing_read, AST_IO_IN | AST_IO_PRI, NULL); for(;;) { pthread_testcancel(); @@ -10809,7 +10809,7 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st ast_string_field_set(peer, dbsecret, v->value); } else if (!strcasecmp(v->name, "trunk")) { ast_set2_flag(peer, ast_true(v->value), IAX_TRUNK); - if (ast_test_flag(peer, IAX_TRUNK) && (timingfd < 0)) { + if (ast_test_flag(peer, IAX_TRUNK) && !timer) { ast_log(LOG_WARNING, "Unable to support trunking on peer '%s' without a timing interface\n", peer->name); ast_clear_flag(peer, IAX_TRUNK); } @@ -11076,7 +11076,7 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, st ast_parse_allow_disallow(&user->prefs, &user->capability,v->value, 0); } else if (!strcasecmp(v->name, "trunk")) { ast_set2_flag(user, ast_true(v->value), IAX_TRUNK); - if (ast_test_flag(user, IAX_TRUNK) && (timingfd < 0)) { + if (ast_test_flag(user, IAX_TRUNK) && !timer) { ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without a timing interface\n", user->name); ast_clear_flag(user, IAX_TRUNK); } @@ -12486,8 +12486,8 @@ static int __unload_module(void) ao2_ref(users, -1); ao2_ref(iax_peercallno_pvts, -1); ao2_ref(iax_transfercallno_pvts, -1); - if (timingfd > -1) { - ast_timer_close(timingfd); + if (timer) { + ast_timer_close(timer); } con = ast_context_find(regcontext); @@ -12627,9 +12627,8 @@ static int load_module(void) ast_manager_register( "IAXnetstats", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_netstats, "Show IAX Netstats" ); ast_manager_register( "IAXregistry", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_registry, "Show IAX registrations"); - timingfd = ast_timer_open(); - if (timingfd > -1) { - ast_timer_set_rate(timingfd, trunkfreq); + if ((timer = ast_timer_open())) { + ast_timer_set_rate(timer, trunkfreq); } if (set_config(config, 0) == -1) { |