[sr-dev] git:kamailio_3.0: modules_k/dialog: Prevent "unable to find dialog" WARN messages

Timo Reimann timo.reimann at 1und1.de
Tue Jul 27 15:44:57 CEST 2010


Module: sip-router
Branch: kamailio_3.0
Commit: 62e4b3d0e1aef798189b50cc869e540b9deff50b
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=62e4b3d0e1aef798189b50cc869e540b9deff50b

Author: Timo Reimann <timo.reimann at 1und1.de>
Committer: Timo Reimann <timo.reimann at 1und1.de>
Date:   Tue Jul 27 14:37:06 2010 +0200

modules_k/dialog: Prevent "unable to find dialog" WARN messages
caused by accessing a dialog in the "deleted" state (often happens
with simultaneous BYE requests when both UAs hang up at the same
time).

- Move POINTER_CLOSED_MARKER from dlg_cb.c into dlg_hash.h for
  common usage.
- in lookup_dlg() and internal_get_dlg(), return
  POINTER_CLOSED_MARKER when dialog is found but in the
  DLG_STATE_DELETED state.
- in dlg_onroute(), abort request processing if dialog is found to
  be in the "deleted" state.
(cherry picked from commit 9b7f25d7196e41cbcc77c1d6e316cb1a8664ed81)

---

 modules_k/dialog/dlg_cb.c       |    2 --
 modules_k/dialog/dlg_handlers.c |    6 +++++-
 modules_k/dialog/dlg_hash.c     |    7 ++++---
 modules_k/dialog/dlg_hash.h     |    2 ++
 4 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/modules_k/dialog/dlg_cb.c b/modules_k/dialog/dlg_cb.c
index 24b3b39..464083e 100644
--- a/modules_k/dialog/dlg_cb.c
+++ b/modules_k/dialog/dlg_cb.c
@@ -43,8 +43,6 @@ static struct dlg_head_cbl* load_cbs = 0;
 static struct dlg_cb_params params = {NULL, DLG_DIR_NONE, NULL, NULL};
 
 
-#define POINTER_CLOSED_MARKER  ((void *)(-1))
-
 
 static void run_load_callback(struct dlg_callback *cb);
 
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index 976ac0f..a3610cc 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -824,7 +824,11 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 				return;
 
 			dlg = lookup_dlg( h_entry, h_id);
-			if (dlg==0) {
+			if (dlg == POINTER_CLOSED_MARKER) {
+				LM_DBG("dialog marked for destruction, ignoring\n");
+				return;
+			}
+			else if (dlg==0) {
 				LM_WARN("unable to find dialog for %.*s "
 					"with route param '%.*s' [%u:%u]\n",
 					req->first_line.u.request.method.len,
diff --git a/modules_k/dialog/dlg_hash.c b/modules_k/dialog/dlg_hash.c
index 6df21e3..b3d626b 100644
--- a/modules_k/dialog/dlg_hash.c
+++ b/modules_k/dialog/dlg_hash.c
@@ -378,7 +378,8 @@ struct dlg_cell* lookup_dlg( unsigned int h_entry, unsigned int h_id)
 		if (dlg->h_id == h_id) {
 			if (dlg->state==DLG_STATE_DELETED) {
 				dlg_unlock( d_table, d_entry);
-				goto not_found;
+				LM_DBG("dialog id=%u on entry %u marked for deletion\n", h_id, h_entry);
+				return POINTER_CLOSED_MARKER;
 			}
 			dlg->ref++;
 			LM_DBG("ref dlg %p with 1 -> %d\n", dlg, dlg->ref);
@@ -418,8 +419,9 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
 		/* Check callid / fromtag / totag */
 		if (match_dialog( dlg, callid, ftag, ttag, dir)==1) {
 			if (dlg->state==DLG_STATE_DELETED) {
+				LM_DBG("dialog callid='%.*s' marked for deletion\n", callid->len, callid->s);
 				dlg_unlock( d_table, d_entry);
-				goto not_found;
+				return POINTER_CLOSED_MARKER;
 			}
 			dlg->ref++;
 			LM_DBG("ref dlg %p with 1 -> %d\n", dlg, dlg->ref);
@@ -432,7 +434,6 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
 
 	dlg_unlock( d_table, d_entry);
 
-not_found:
 	LM_DBG("no dialog callid='%.*s' found\n", callid->len, callid->s);
 	return 0;
 }
diff --git a/modules_k/dialog/dlg_hash.h b/modules_k/dialog/dlg_hash.h
index 889a318..6aa6db5 100644
--- a/modules_k/dialog/dlg_hash.h
+++ b/modules_k/dialog/dlg_hash.h
@@ -83,6 +83,8 @@
 #define DLG_DIR_DOWNSTREAM     1 /*!< dialog has downstream direction */
 #define DLG_DIR_UPSTREAM       2 /*!< dialog has upstream direction */
 
+#define POINTER_CLOSED_MARKER  ((void *)(-1))
+
 
 /*! entries in the dialog list */
 struct dlg_cell




More information about the sr-dev mailing list