[asterisk-commits] file: branch 1.4 r51172 - /branches/1.4/channels/chan_iax2.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 16 17:46:30 MST 2007


Author: file
Date: Tue Jan 16 18:46:29 2007
New Revision: 51172

URL: http://svn.digium.com/view/asterisk?view=rev&rev=51172
Log:
Move rescheduling of lagrq/pings into the scheduler callback.

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=51172&r1=51171&r2=51172
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Tue Jan 16 18:46:29 2007
@@ -908,26 +908,25 @@
 #define schedule_action(func, data) __schedule_action(func, data, __PRETTY_FUNCTION__)
 #endif
 
+static int send_ping(void *data);
+
 static void __send_ping(void *data)
 {
 	int callno = (long)data;
 	ast_mutex_lock(&iaxsl[callno]);
-	if (iaxs[callno])
+	if (iaxs[callno] && iaxs[callno]->pingid != -1) {
 		send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_PING, 0, NULL, 0, -1);
+		iaxs[callno]->pingid = ast_sched_add(sched, ping_time * 1000, send_ping, data);
+	}
 	ast_mutex_unlock(&iaxsl[callno]);
 }
 
 static int send_ping(void *data)
 {
-	int callno = (long)data;
-	if (iaxs[callno]) {
 #ifdef SCHED_MULTITHREADED
-		if (schedule_action(__send_ping, data))
+	if (schedule_action(__send_ping, data))
 #endif		
-			__send_ping(data);
-		return 1;
-	} else
-		return 0;
+		__send_ping(data);
 	return 0;
 }
 
@@ -943,27 +942,26 @@
 	return e;
 }
 
+static int send_lagrq(void *data);
+
 static void __send_lagrq(void *data)
 {
 	int callno = (long)data;
 	/* Ping only if it's real not if it's bridged */
 	ast_mutex_lock(&iaxsl[callno]);
-	if (iaxs[callno])
+	if (iaxs[callno] && iaxs[callno]->lagid != -1) {
 		send_command(iaxs[callno], AST_FRAME_IAX, IAX_COMMAND_LAGRQ, 0, NULL, 0, -1);
+		iaxs[callno]->lagid = ast_sched_add(sched, lagrq_time * 1000, send_lagrq, data);
+	}
 	ast_mutex_unlock(&iaxsl[callno]);
 }
 
 static int send_lagrq(void *data)
 {
-	int callno = (long)data;
-	if (iaxs[callno]) {
 #ifdef SCHED_MULTITHREADED
-		if (schedule_action(__send_lagrq, data))
+	if (schedule_action(__send_lagrq, data))
 #endif		
-			__send_lagrq(data);
-		return 1;
-	} else
-		return 0;
+		__send_lagrq(data);
 	return 0;
 }
 



More information about the asterisk-commits mailing list