modules_k/dialog: Fix timer reset and improve timeout value logging
authorTimo Reimann <timo.reimann@1und1.de>
Thu, 24 Jun 2010 16:39:49 +0000 (18:39 +0200)
committerTimo Reimann <timo.reimann@1und1.de>
Thu, 24 Jun 2010 16:47:03 +0000 (18:47 +0200)
- Fix a bug that caused dialog timeout values to be refreshed only
  when a custom timeout was provided by the user via AVP.
- Do not log failure to get timeout from AVP when in fact no AVP
  was used.
- Add missing newline character.

modules_k/dialog/dlg_handlers.c

index 3b671ab..5fd3d31 100644 (file)
@@ -469,11 +469,13 @@ inline static int get_dlg_timeout(struct sip_msg *req)
 {
        pv_value_t pv_val;
 
-       if( timeout_avp && pv_get_spec_value( req, timeout_avp, &pv_val)==0
-       && pv_val.flags&PV_VAL_INT && pv_val.ri>0 ) {
-               return pv_val.ri;
+       if( timeout_avp ) {
+               if ( pv_get_spec_value( req, timeout_avp, &pv_val)==0 &&
+                               pv_val.flags&PV_VAL_INT && pv_val.ri>0 ) {
+                       return pv_val.ri;
+               }
+               LM_DBG("invalid AVP value, using default timeout\n");
        }
-       LM_DBG("invalid AVP value, use default timeout");
        return default_timeout;
 }
 
@@ -923,11 +925,11 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
        && new_state==DLG_STATE_CONFIRMED) {
                LM_DBG("sequential request successfully processed\n");
                timeout = get_dlg_timeout(req);
-               /* update timer during sequential request? */
                if (timeout!=default_timeout) {
                        dlg->lifetime = timeout;
-                       if (update_dlg_timer( &dlg->tl, dlg->lifetime )==-1)
-                               LM_ERR("failed to update dialog lifetime\n");
+               }
+               if (update_dlg_timer( &dlg->tl, dlg->lifetime )==-1) {
+                       LM_ERR("failed to update dialog lifetime\n");
                }
                if (update_cseqs(dlg, req, dir)!=0) {
                        LM_ERR("cseqs update failed\n");