Browse code

dialog: lookup kemi engine for event route execution

Daniel-Constantin Mierla authored on 04/07/2017 09:11:41
Showing 2 changed files
... ...
@@ -1550,6 +1550,7 @@ void dlg_ontimeout(struct dlg_tl *tl)
1550 1550
 				if(dlg->toroute>0) {
1551 1551
 					run_top_route(main_rt.rlist[dlg->toroute], fmsg, 0);
1552 1552
 				} else {
1553
+					keng = sr_kemi_eng_get();
1553 1554
 					if(keng!=NULL) {
1554 1555
 						evname.s = "dialog:timeout";
1555 1556
 						evname.len = sizeof("dialog:timeout") - 1;
... ...
@@ -1703,22 +1704,28 @@ int dlg_run_event_route(dlg_cell_t *dlg, sip_msg_t *msg, int ostate, int nstate)
1703 1703
 	if(dlg_event_callback.s==NULL || dlg_event_callback.len<=0) {
1704 1704
 		if(nstate==DLG_STATE_CONFIRMED_NA) {
1705 1705
 			rt = dlg_event_rt[DLG_EVENTRT_START];
1706
+		} else if(nstate==DLG_STATE_DELETED) {
1707
+			if(ostate==DLG_STATE_CONFIRMED || ostate==DLG_STATE_CONFIRMED_NA) {
1708
+				rt = dlg_event_rt[DLG_EVENTRT_END];
1709
+			} else if(ostate==DLG_STATE_UNCONFIRMED || ostate==DLG_STATE_EARLY) {
1710
+				rt = dlg_event_rt[DLG_EVENTRT_FAILED];
1711
+			}
1712
+		}
1713
+		if(rt==-1 || event_rt.rlist[rt]==NULL)
1714
+			return 0;
1715
+	}  else {
1716
+		if(nstate==DLG_STATE_CONFIRMED_NA) {
1706 1717
 			evname.s = "dialog:start";
1707 1718
 			evname.len = sizeof("dialog:start") - 1;
1708 1719
 		} else if(nstate==DLG_STATE_DELETED) {
1709 1720
 			if(ostate==DLG_STATE_CONFIRMED || ostate==DLG_STATE_CONFIRMED_NA) {
1710
-				rt = dlg_event_rt[DLG_EVENTRT_END];
1711 1721
 				evname.s = "dialog:end";
1712 1722
 				evname.len = sizeof("dialog:end") - 1;
1713 1723
 			} else if(ostate==DLG_STATE_UNCONFIRMED || ostate==DLG_STATE_EARLY) {
1714 1724
 				evname.s = "dialog:failed";
1715 1725
 				evname.len = sizeof("dialog:failed") - 1;
1716
-				rt = dlg_event_rt[DLG_EVENTRT_FAILED];
1717 1726
 			}
1718 1727
 		}
1719
-		if(rt==-1 || event_rt.rlist[rt]==NULL)
1720
-			return 0;
1721
-	}  else {
1722 1728
 		keng = sr_kemi_eng_get();
1723 1729
 		if(keng==NULL) {
1724 1730
 			LM_DBG("event callback (%s) set, but no cfg engine\n",
... ...
@@ -594,8 +594,14 @@ int set_dlg_profile(struct sip_msg *msg, str *value, struct dlg_profile_table *p
594 594
 		linker->hash_linker.value.len = value->len;
595 595
 	}
596 596
 	sruid_next_safe(&_dlg_profile_sruid);
597
-	strcpy(linker->hash_linker.puid, _dlg_profile_sruid.uid.s);
598
-	linker->hash_linker.puid_len = _dlg_profile_sruid.uid.len;
597
+	if(_dlg_profile_sruid.uid.len<SRUID_SIZE) {
598
+		strcpy(linker->hash_linker.puid, _dlg_profile_sruid.uid.s);
599
+		linker->hash_linker.puid_len = _dlg_profile_sruid.uid.len;
600
+	} else {
601
+		LM_ERR("sruid size is too large\n");
602
+		shm_free(linker);
603
+		goto error;
604
+	}
599 605
 
600 606
 	if (dlg!=NULL) {
601 607
 		/* add linker directly to the dialog and profile */