[asterisk-commits] tilghman: branch 1.4 r127068 - /branches/1.4/channels/chan_iax2.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Jul 1 13:52:54 CDT 2008
Author: tilghman
Date: Tue Jul 1 13:52:53 2008
New Revision: 127068
URL: http://svn.digium.com/view/asterisk?view=rev&rev=127068
Log:
Change around how we schedule pings and lagrqs, and fix a reason why the
jobs were not getting properly cancelled.
(closes issue #12903)
Reported by: stevedavies
Patches:
20080620__bug12903__2.diff.txt uploaded by Corydon76 (license 14)
Tested by: stevedavies
Modified:
branches/1.4/channels/chan_iax2.c
Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=127068&r1=127067&r2=127068
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Tue Jul 1 13:52:53 2008
@@ -997,12 +997,16 @@
ast_mutex_lock(&iaxsl[callno]);
- while (iaxs[callno] && iaxs[callno]->pingid != -1) {
+ if (iaxs[callno]) {
if (iaxs[callno]->peercallno) {
send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1);
- }
- iaxs[callno]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, data);
- break;
+ iaxs[callno]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, data);
+ } else {
+ /* I am the schedule, so I'm allowed to do this */
+ iaxs[callno]->pingid = -1;
+ }
+ } else if (option_debug > 0) {
+ ast_log(LOG_DEBUG, "I was supposed to send a PING with callno %d, but no such call exists (and I cannot remove pingid, either).\n", callno);
}
ast_mutex_unlock(&iaxsl[callno]);
@@ -1010,14 +1014,6 @@
static int send_ping(const void *data)
{
- int callno = (long) data;
-
- ast_mutex_lock(&iaxsl[callno]);
- if (iaxs[callno]) {
- iaxs[callno]->pingid = -1;
- }
- ast_mutex_unlock(&iaxsl[callno]);
-
#ifdef SCHED_MULTITHREADED
if (schedule_action(__send_ping, data))
#endif
@@ -1046,12 +1042,16 @@
ast_mutex_lock(&iaxsl[callno]);
- while (iaxs[callno] && iaxs[callno]->lagid > -1) {
+ if (iaxs[callno]) {
if (iaxs[callno]->peercallno) {
send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1);
- }
- iaxs[callno]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, data);
- break;
+ iaxs[callno]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, data);
+ } else {
+ /* I am the schedule, so I'm allowed to do this */
+ iaxs[callno]->lagid = -1;
+ }
+ } else if (option_debug > 0) {
+ ast_log(LOG_DEBUG, "I was supposed to send a LAGRQ with callno %d, but no such call exists (and I cannot remove lagid, either).\n", callno);
}
ast_mutex_unlock(&iaxsl[callno]);
@@ -1059,14 +1059,6 @@
static int send_lagrq(const void *data)
{
- int callno = (long) data;
-
- ast_mutex_lock(&iaxsl[callno]);
- if (iaxs[callno]) {
- iaxs[callno]->lagid = -1;
- }
- ast_mutex_unlock(&iaxsl[callno]);
-
#ifdef SCHED_MULTITHREADED
if (schedule_action(__send_lagrq, data))
#endif
@@ -1313,6 +1305,8 @@
}
}
if (!owner) {
+ AST_SCHED_DEL(sched, iaxs[callno]->lagid);
+ AST_SCHED_DEL(sched, iaxs[callno]->pingid);
iaxs[callno] = NULL;
}
@@ -1494,12 +1488,16 @@
for (x = TRUNK_CALL_START; x < ARRAY_LEN(iaxs) - 1; x++) {
ast_mutex_lock(&iaxsl[x]);
if (!iaxs[x] && ((now.tv_sec - lastused[x].tv_sec) > MIN_REUSE_TIME)) {
+ /* Update the two timers that should have been started */
+ /*!
+ * \note We delete these before switching the slot, because if
+ * they fire in the meantime, they will generate a warning.
+ */
+ AST_SCHED_DEL(sched, iaxs[x]->pingid);
+ AST_SCHED_DEL(sched, iaxs[x]->lagid);
iaxs[x] = iaxs[callno];
iaxs[x]->callno = x;
iaxs[callno] = NULL;
- /* Update the two timers that should have been started */
- AST_SCHED_DEL(sched, iaxs[x]->pingid);
- AST_SCHED_DEL(sched, iaxs[x]->lagid);
iaxs[x]->pingid = iax2_sched_add(sched, ping_time * 1000, send_ping, (void *)(long)x);
iaxs[x]->lagid = iax2_sched_add(sched, lagrq_time * 1000, send_lagrq, (void *)(long)x);
if (locked)
More information about the asterisk-commits
mailing list