<div dir="ltr">Hi Lucian,<div><br></div><div><div>I made a few changes like you and I think it's working. Loads dialogs and generate cdr. It needs more testing. The function  cdr_on_load it's copy and paste to avoid touching those params in on_create. A lot of improve is needed. </div><div><br></div><div><div>diff --git a/modules/dialog/dialog.c b/modules/dialog/<b>dialog.c</b></div><div>index ceaf08a..59210e8 100644</div><div>--- a/modules/dialog/dialog.c</div><div>+++ b/modules/dialog/dialog.c</div><div>@@ -692,7 +692,7 @@ static int mod_init(void)</div><div>                        LM_ERR("failed to initialize the DB support\n");</div><div>                        return -1;</div><div>                }</div><div>-               run_load_callbacks();</div><div>+               //run_load_callbacks();</div><div>        }</div><div> </div><div>        destroy_dlg_callbacks( DLGCB_LOADED );</div></div></div><div><br></div><div>########</div><div><br></div><div><div>diff --git a/modules/dialog/dlg_db_handler.c b/modules/dialog/<b>dlg_db_handler.c</b></div><div>index e27f8b2..22d0f04 100644</div><div>--- a/modules/dialog/dlg_db_handler.c</div><div>+++ b/modules/dialog/dlg_db_handler.c</div><div>@@ -173,6 +173,7 @@ int init_dlg_db(const str *db_url, int dlg_hash_size , int db_update_period, int</div><div>                        LM_ERR("unable to load the dialog data\n");</div><div>                        return -1;</div><div>                }</div><div>+               run_load_callbacks();</div><div>        }</div><div>        dialog_dbf.close(dialog_db_handle);</div><div>        dialog_db_handle = 0;</div></div><div><br></div><div><br></div><div>########</div><div><br></div><div><div><div>diff --git a/modules/acc/acc_cdr.c b/modules/acc/<b>acc_cdr.c</b></div><div>index 73bdd45..81ad640 100644</div><div>--- a/modules/acc/acc_cdr.c</div><div>+++ b/modules/acc/acc_cdr.c</div><div>@@ -733,11 +733,79 @@ static void cdr_on_destroy( struct dlg_cell* dialog,</div><div>     LM_DBG("dialog '%p' destroyed!\n", dialog);</div><div> }</div><div> </div><div>+/* callback for loading a dialog from db. */</div><div>+static void cdr_on_load( struct dlg_cell* dialog,</div><div>+                           int type,</div><div>+                           struct dlg_cb_params* params)</div><div>+{</div><div>+</div><div>+    LM_ERR("ON LOAD\n");</div><div>+    if( !dialog)</div><div>+    {</div><div>+        LM_ERR( "invalid dialog\n!");</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    if( cdr_enable == 0)</div><div>+    {</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    if( dlgb.register_dlgcb( dialog, DLGCB_CONFIRMED, cdr_on_start, 0, 0) != 0)</div><div>+    {</div><div>+        LM_ERR("can't register create dialog CONFIRM callback\n");</div><div>+       return;</div><div>+    }</div><div>+</div><div>+    if(_acc_cdr_on_failed==1) {</div><div>+           if( dlgb.register_dlgcb( dialog, DLGCB_FAILED, cdr_on_failed, 0, 0) != 0)</div><div>+           {</div><div>+                   LM_ERR("can't register create dialog FAILED callback\n");</div><div>+                   return;</div><div>+           }</div><div>+    }</div><div>+</div><div>+    if( dlgb.register_dlgcb( dialog, DLGCB_TERMINATED, cdr_on_end, 0, 0) != 0)</div><div>+    {</div><div>+        LM_ERR("can't register create dialog TERMINATED callback\n");</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    if( dlgb.register_dlgcb( dialog, DLGCB_TERMINATED_CONFIRMED, cdr_on_end_confirmed, 0, 0) != 0)</div><div>+    {</div><div>+        LM_ERR("can't register create dialog TERMINATED CONFIRMED callback\n");</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    if( dlgb.register_dlgcb( dialog, DLGCB_EXPIRED, cdr_on_expired, 0, 0) != 0)</div><div>+    {</div><div>+        LM_ERR("can't register create dialog EXPIRED callback\n");</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    if( dlgb.register_dlgcb( dialog, DLGCB_DESTROY, cdr_on_destroy, 0, 0) != 0)</div><div>+    {</div><div>+        LM_ERR("can't register create dialog DESTROY callback\n");</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    LM_DBG("dialog '%p' created!", dialog);</div><div>+</div><div>+    if( set_start_time( dialog) != 0)</div><div>+    {</div><div>+        LM_ERR( "failed to set start time");</div><div>+        return;</div><div>+    }</div><div>+}</div><div>+</div><div>+</div><div> /* callback for the creation of a dialog. */</div><div> static void cdr_on_create( struct dlg_cell* dialog,</div><div>                            int type,</div><div>                            struct dlg_cb_params* params)</div><div> {</div><div>+</div><div>+    LM_ERR("ON CREATE\n");</div><div>     if( !dialog || !params || !params->req)</div><div>     {</div><div>         LM_ERR( "invalid values\n!");</div><div>@@ -852,13 +920,19 @@ int init_cdr_generation( void)</div><div>         LM_ERR("can't load dialog API\n");</div><div>         return -1;</div><div>     }</div><div>-</div><div>-    if( dlgb.register_dlgcb( 0, DLGCB_CREATED, cdr_on_create, 0, 0) != 0)</div><div>+    //Loaded from db</div><div>+    if( dlgb.register_dlgcb( 0, DLGCB_LOADED, cdr_on_load, 0, 0) != 0)</div><div>     {</div><div>         LM_ERR("can't register create callback\n");</div><div>         return -1;</div><div>     }</div><div> </div><div>+    if( dlgb.register_dlgcb( 0, DLGCB_CREATED, cdr_on_create, 0, 0) != 0)</div><div>+    {</div><div>+       LM_ERR("can't register create callback\n");</div><div>+       return -1;</div><div>+    }</div><div>+</div><div>     return 0;</div><div> }</div><div> </div></div><div><br></div><div><br></div><div>    if( cdr_enable == 0)</div><div>    {   </div><div>        return;</div><div>    }</div><div><br></div><div>    if( dlgb.register_dlgcb( dialog, DLGCB_CONFIRMED, cdr_on_start, 0, 0) != 0)</div><div>    {   </div><div>        LM_ERR("can't register create dialog CONFIRM callback\n");</div><div>        return;</div><div>    }</div></div><div><br></div><div><br></div><div><br></div><div>Diego.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-03-20 10:06 GMT-03:00 Kordován Szabolcs <span dir="ltr"><<a href="mailto:koszab@gmail.com" target="_blank">koszab@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi All,<div><br></div><div>I have tired your patch but it dosen't work. No any changes. :(</div><div><br></div><div>Regards,</div><div>Szabolcs</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2017-03-16 15:36 GMT+01:00 Lucian Balaceanu <span dir="ltr"><<a href="mailto:lucian.balaceanu@1and1.ro" target="_blank">lucian.balaceanu@1and1.ro</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hello all,<br>
    <br>
    Just created the pull request:
    <a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-freetext" href="https://github.com/kamailio/kamailio/pull/1036" target="_blank">https://github.com/kamailio/ka<wbr>mailio/pull/1036</a> in relation to this
    problem with the sketch of a solution.<br>
    <br>
    Any input is appreciated,<br>
    Lucian<div><div class="m_-5312088303227092265h5"><br>
    <br>
    <div class="m_-5312088303227092265m_-4207112656109430867moz-cite-prefix">On 15.03.2017 15:17, Daniel-Constantin
      Mierla wrote:<br>
    </div>
    <blockquote type="cite">
      
      <p>Hello,</p>
      <p>ok, good to know is someone tackling it.</p>
      <p>Thanks,<br>
        Daniel<br>
      </p>
      <br>
      <div class="m_-5312088303227092265m_-4207112656109430867moz-cite-prefix">On 15/03/2017 12:14, Pawel Kuzak
        wrote:<br>
      </div>
      <blockquote type="cite">
        <p>Hello,</p>
        <p>This indeed is a bug we've also spotted. It is not only
          present in 5.0. It seems the <i>run_create_callbacks()</i>
          function which triggers the <i>DLGCB_CREATED</i> callbacks to
          be executed is not called for dialogs created from database.
          We are already working on a fix and are currently testing it.
          We will try push it upstream as soon as possible. We will
          answer on this thread when a fix is upstream.</p>
        <p>Regards,<br>
          Paul<br>
        </p>
        <br>
        <div class="m_-5312088303227092265m_-4207112656109430867moz-cite-prefix">Am 14.03.2017 um 22:00 schrieb
          Kordován Szabolcs:<br>
        </div>
        <blockquote type="cite">
          <div dir="ltr">Hello Daniel,
            <div><br>
            </div>
            <div>Sorry for my reply, I didn't receive your mail.</div>
            <div>So, only the active calls are affected. The new call,
              from invite to bye-ok, is recorded into table acc and
              acc_cdrs.</div>
            <div><br>
            </div>
            <div>Regards,</div>
            <div>Szabolcs</div>
          </div>
          <div class="gmail_extra"><br>
            <div class="gmail_quote">2017-03-14 11:13 GMT+01:00 Kordován
              Szabolcs <span dir="ltr"><<a href="mailto:koszab@gmail.com" target="_blank">koszab@gmail.com</a>></span>:<br>
              <blockquote class="gmail_quote">
                <div dir="ltr">Hi,
                  <div><br>
                  </div>
                  <div>I use acc module for create cdr into db and also
                    make acc log into db.</div>
                  <div>After restart Kamailio cdr won't be created but
                    acc log will be inserted into db. In the syslog also
                    I see just the acc log. The dialog will be remove
                    from db.</div>
                  <div><br>
                  </div>
                  <div>I have read many threads. I know that it should
                    work.</div>
                  <div><br>
                  </div>
                  <div>Thanks for help!</div>
                  <div>Regards,</div>
                  <div>Szabolcs</div>
                  <div><br>
                  </div>
                  <div>From my configs:</div>
                  <div><br>
                  </div>
                  <div>
                    <div>#!define FLT_ACC 1</div>
                    <div>#!define FLT_ACCMISSED 2</div>
                    <div>#!define FLT_ACCFAILED 3</div>
                    <div><br>
                    </div>
                    <div>modparam("acc", "db_url", DBURL)</div>
                    <div>modparam("acc", "db_flag", FLT_ACC)</div>
                    <div>modparam("acc", "db_missed_flag",
                      FLT_ACCMISSED)</div>
                    <div>modparam("acc", "db_extra",
                      "src_user=$fU;src_domain=$fd;d<wbr>st_ouser=$tU;dst_user=$rU;dst_<wbr>domain=$rd;src_ip=$si")</div>
                    <div><br>
                    </div>
                    <div>modparam("acc", "log_level", 3)</div>
                    <div>modparam("acc", "log_flag", FLT_ACC)</div>
                    <div>modparam("acc", "log_missed_flag",
                      FLT_ACCMISSED)</div>
                    <div><br>
                    </div>
                    <div>modparam("acc", "report_ack", 1)</div>
                    <div>modparam("acc", "report_cancels", 1)</div>
                    <div>modparam("acc", "early_media", 1)</div>
                    <div><br>
                    </div>
                    <div>modparam("acc", "failed_transaction_flag",
                      FLT_ACCFAILED)</div>
                    <div><br>
                    </div>
                    <div>modparam("acc", "acc_prepare_always", 1)</div>
                    <div>modparam("acc", "time_mode", 1)</div>
                    <div>modparam("acc", "time_attr", "seconds")</div>
                    <div>modparam("acc", "time_exten", "microsecs")</div>
                    <div>modparam("acc", "reason_from_hf", 1)</div>
                    <div><br>
                    </div>
                    <div>modparam("acc", "cdr_enable", 1)</div>
                    <div>modparam("acc", "cdr_expired_dlg_enable", 1)</div>
                    <div>modparam("acc", "cdr_start_on_confirmed", 1)</div>
                    <div>modparam("acc", "cdrs_table", "acc_cdrs")</div>
                    <div>modparam("acc", "cdr_on_failed", 1) </div>
                    <div>modparam("acc", "cdr_extra",
                      "callid=$ci;src_user=$dlg_var(<wbr>fU);src_domain=$dlg_var(fd);ds<wbr>t_ouser=$dlg_var(tU);dst_user=<wbr>$dlg_var(rU);dst_domain=$dlg_v<wbr>ar(rd);src_ip=$dlg_var(si);pee<wbr>r_in=$dlg_var(peerin);peer_out<wbr>=$dlg_var(peerout)")</div>
                    <div><br>
                    </div>
                  </div>
                  <div>
                    <div>request_route {</div>
                    <div><------></div>
                    <div><------>$var(loose) = loose_route();</div>
                    <div><------>$var(check_trans) =
                      t_check_trans();</div>
                    <div><------>sip_trace();<br>
                    </div>
                    <div><------>setflag(FLT_SIPTRACE);</div>
                    <div><------>dlg_manage();</div>
                    <div><br>
                    </div>
                    <div><------># handle retransmissions</div>
                    <div><------>if(t_precheck_trans()) {</div>
                    <div><------>    xlogl("LOG_LOCAL0",
                      "L_ALERT", "================== kamaty $rm route
                      $ci ==== $rm ==== precheck_trans exit\n");</div>
                    <div><------>    exit;</div>
                    <div><------>}</div>
                    <div><br>
                    </div>
                    <div><------>if(is_method("OPTIONS"<wbr>)) {.</div>
                    <div><------>    # send reply for each options
                      request.</div>
                    <div><------>    sl_send_reply("200", "ok");.</div>
                    <div><------>    exit();.</div>
                    <div><------>}</div>
                    <div>
                      <div><------># CANCEL processing<br>
                      </div>
                      <div><------>if (is_method("CANCEL")) {</div>
                      <div><------><------>if
                        (t_check_trans()) {</div>
                      <div><------><------>    route(RELAY);</div>
                      <div><------><------>}</div>
                      <div><------><------>exit;</div>
                      <div><------>}</div>
                      <div><------>if ( is_method("ACK") ) {</div>
                      <div><------><------>if (
                        $var(check_trans) ) {</div>
                      <div><------><------>    route(RELAY);</div>
                      <div><------><------>}</div>
                      <div><------><------>exit;</div>
                      <div><------>}</div>
                      <div><------>if (is_method("BYE")) {</div>
                      <div><------>    if ($var(loose)) {</div>
                      <div><------><------>setflag(FLT_AC<wbr>C);

                        # do accounting ...</div>
                      <div><------><------>setflag(FLT_AC<wbr>CFAILED);

                        # ... even if the transaction fails</div>
                      <div><------><------>setflag(FLT_AC<wbr>CMISSED);</div>
                      <div><------><------>route(RELAY);</div>
                      <div><------>    <-->exit;</div>
                      <div><------>    }</div>
                      <div><------>    exit;</div>
                      <div><------>}</div>
                      <div>etc.</div>
                      <div><br>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
            </div>
            <br>
          </div>
          <br>
          <fieldset class="m_-5312088303227092265m_-4207112656109430867mimeAttachmentHeader"></fieldset>
          <br>
          <pre>______________________________<wbr>_________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cg<wbr>i-bin/mailman/listinfo/sr-user<wbr>s</a>
</pre>
        </blockquote>
        <br>
        <fieldset class="m_-5312088303227092265m_-4207112656109430867mimeAttachmentHeader"></fieldset>
        <br>
        <pre>______________________________<wbr>_________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cg<wbr>i-bin/mailman/listinfo/sr-user<wbr>s</a>
</pre>
      </blockquote>
      <br>
      <pre class="m_-5312088303227092265m_-4207112656109430867moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="http://www.twitter.com/miconda" target="_blank">www.twitter.com/miconda</a> -- <a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda" target="_blank">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - Mar 6-8 (Europe) and Mar 20-22 (USA) - <a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="http://www.asipto.com" target="_blank">www.asipto.com</a>
Kamailio World Conference - May 8-10, 2017 - <a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="http://www.kamailioworld.com" target="_blank">www.kamailioworld.com</a></pre>
      <br>
      <fieldset class="m_-5312088303227092265m_-4207112656109430867mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a class="m_-5312088303227092265m_-4207112656109430867moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cg<wbr>i-bin/mailman/listinfo/sr-user<wbr>s</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/cg<wbr>i-bin/mailman/listinfo/sr-user<wbr>s</a><br>
<br></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" rel="noreferrer" target="_blank">http://lists.sip-router.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a><br>
<br></blockquote></div><br></div>