[sr-dev] git:5.0:6be63b8e: acc: Fix for no cdr after Kamailio 5.0 restart

Lucian Balaceanu lucian.balaceanu at 1and1.ro
Tue Apr 4 13:29:00 CEST 2017


Module: kamailio
Branch: 5.0
Commit: 6be63b8e0141bb1fbb3c1ff3ba5001d6353c65b3
URL: https://github.com/kamailio/kamailio/commit/6be63b8e0141bb1fbb3c1ff3ba5001d6353c65b3

Author: Lucian Balaceanu <lucian.balaceanu at 1and1.ro>
Committer: Lucian Balaceanu <lucian.balaceanu at 1and1.ro>
Date: 2017-04-04T14:26:55+03:00

acc: Fix for no cdr after Kamailio 5.0 restart

- created cdr_on_load() to be called on DLGCB_LOAD

(cherry picked from commit b70382583ea2c7962f7268db3e672236fb35e521)

---

Modified: src/modules/acc/acc_cdr.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6be63b8e0141bb1fbb3c1ff3ba5001d6353c65b3.diff
Patch: https://github.com/kamailio/kamailio/commit/6be63b8e0141bb1fbb3c1ff3ba5001d6353c65b3.patch

---

diff --git a/src/modules/acc/acc_cdr.c b/src/modules/acc/acc_cdr.c
index f9b25eb..4ffab23 100644
--- a/src/modules/acc/acc_cdr.c
+++ b/src/modules/acc/acc_cdr.c
@@ -588,7 +588,7 @@ static void cdr_on_start( struct dlg_cell* dialog,
                           int type,
                           struct dlg_cb_params* params)
 {
-    if( !dialog || !params)
+    if( !dialog )
     {
         LM_ERR("invalid values\n!");
         return;
@@ -663,7 +663,7 @@ static void cdr_on_end( struct dlg_cell* dialog,
                         int type,
                         struct dlg_cb_params* params)
 {
-    if( !dialog || !params)
+    if( !dialog )
     {
         LM_ERR("invalid values\n!");
         return;
@@ -724,7 +724,7 @@ static void cdr_on_destroy( struct dlg_cell* dialog,
                             int type,
                             struct dlg_cb_params* params)
 {
-    if( !dialog || !params)
+    if( !dialog )
     {
         LM_ERR("invalid values\n!");
         return;
@@ -738,7 +738,7 @@ static void cdr_on_create( struct dlg_cell* dialog,
                            int type,
                            struct dlg_cb_params* params)
 {
-    if( !dialog || !params || !params->req)
+    if( !dialog )
     {
         LM_ERR( "invalid values\n!");
         return;
@@ -795,6 +795,65 @@ static void cdr_on_create( struct dlg_cell* dialog,
         return;
     }
 }
+
+/* callback for loading a dialog frm database */
+static void cdr_on_load( struct dlg_cell* dialog,
+                           int type,
+                           struct dlg_cb_params* params)
+{
+    if( !dialog )
+    {
+        LM_ERR( "invalid values\n!");
+        return;
+    }
+
+    if( cdr_enable == 0)
+    {
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_CONFIRMED, cdr_on_start, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog CONFIRM callback\n");
+        return;
+    }
+
+	if(_acc_cdr_on_failed==1) {
+		if( dlgb.register_dlgcb( dialog, DLGCB_FAILED, cdr_on_failed, 0, 0) != 0)
+		{
+			LM_ERR("can't register create dialog FAILED callback\n");
+			return;
+		}
+	}
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_TERMINATED, cdr_on_end, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog TERMINATED callback\n");
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_TERMINATED_CONFIRMED, cdr_on_end_confirmed, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog TERMINATED CONFIRMED callback\n");
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_EXPIRED, cdr_on_expired, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog EXPIRED callback\n");
+        return;
+    }
+
+    if( dlgb.register_dlgcb( dialog, DLGCB_DESTROY, cdr_on_destroy, 0, 0) != 0)
+    {
+        LM_ERR("can't register create dialog DESTROY callback\n");
+        return;
+    }
+
+    LM_DBG("dialog '%p' loaded!", dialog);
+
+}
+
 /* convert the extra-data string into a list and store it */
 int set_cdr_extra( char* cdr_extra_value)
 {
@@ -859,6 +918,12 @@ int init_cdr_generation( void)
         return -1;
     }
 
+	if( dlgb.register_dlgcb( 0, DLGCB_LOADED, cdr_on_load, 0, 0) != 0)
+	{
+		LM_ERR("can't register create callback\n");
+		return -1;
+	}
+
     return 0;
 }
 




More information about the sr-dev mailing list