From 55337ecaa6dcc942686c070d002c615cb6191dff Mon Sep 17 00:00:00 2001 From: kpfleming Date: Fri, 27 Mar 2009 19:17:22 +0000 Subject: Merged revisions 184762 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ........ r184762 | kpfleming | 2009-03-27 14:10:32 -0500 (Fri, 27 Mar 2009) | 12 lines 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/branches/1.6.1@184765 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_iax2.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'channels') diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 5643952af..e4d495a38 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -175,7 +175,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 */ @@ -7550,8 +7550,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... */ @@ -10359,8 +10359,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(); @@ -10669,7 +10669,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); } @@ -10924,7 +10924,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); } @@ -12321,8 +12321,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); @@ -12463,9 +12463,8 @@ static int load_module(void) ast_manager_register( "IAXpeerlist", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_peer_list, "List IAX Peers" ); ast_manager_register( "IAXnetstats", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, manager_iax2_show_netstats, "Show IAX Netstats" ); - 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) { -- cgit v1.2.3