[sr-dev] git:master: async: safety check for next action in async_sleep()

Daniel-Constantin Mierla miconda at gmail.com
Sun Jun 26 11:52:40 CEST 2011


Module: sip-router
Branch: master
Commit: b427618d03f5753eb56ac84e3ed4262119a0d5d4
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=b427618d03f5753eb56ac84e3ed4262119a0d5d4

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Sun Jun 26 11:32:12 2011 +0200

async: safety check for next action in async_sleep()

---

 modules/async/async_mod.c   |   15 ++++++++++-----
 modules/async/async_sleep.c |    4 ++--
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/modules/async/async_mod.c b/modules/async/async_mod.c
index fc974e2..38374ce 100644
--- a/modules/async/async_mod.c
+++ b/modules/async/async_mod.c
@@ -132,20 +132,25 @@ static void mod_destroy(void)
 static int w_async_sleep(struct sip_msg* msg, char* sec, char* str2)
 {
 	int s;
-	async_param_t *ai;
+	async_param_t *ap;
 	
 	if(msg==NULL)
 		return -1;
 
-	ai = (async_param_t*)sec;
-	if(fixup_get_ivalue(msg, ai->pinterval, &s)!=0)
+	ap = (async_param_t*)sec;
+	if(fixup_get_ivalue(msg, ap->pinterval, &s)!=0)
 	{
 		LM_ERR("no async sleep time value\n");
 		return -1;
 	}
-	if(ai->type==0)
+	if(ap->type==0)
 	{
-		if(async_sleep(msg, s, ai->u.paction)<0)
+		if(ap->u.paction==NULL || ap->u.paction->next!=NULL)
+		{
+			LM_ERR("cannot be executed as last action in a route block\n");
+			return -1;
+		}
+		if(async_sleep(msg, s, ap->u.paction->next)<0)
 			return -1;
 		/* force exit in config */
 		return 0;
diff --git a/modules/async/async_sleep.c b/modules/async/async_sleep.c
index eec5eb9..16d67b9 100644
--- a/modules/async/async_sleep.c
+++ b/modules/async/async_sleep.c
@@ -181,7 +181,7 @@ void async_timer_exec(unsigned int ticks, void *param)
 
 		if(ai==NULL)
 			break;
-		if(ai->act!=NULL && ai->act->next!=NULL)
-			tmb.t_continue(ai->tindex, ai->tlabel, ai->act->next);
+		if(ai->act!=NULL)
+			tmb.t_continue(ai->tindex, ai->tlabel, ai->act);
 	}
 }




More information about the sr-dev mailing list