瀏覽代碼

modules/dialog_ng: set init ts for dialog_in

jaybeepee 10 年之前
父節點
當前提交
81feae1940
共有 3 個文件被更改,包括 7 次插入1 次删除
  1. 4 1
      modules/dialog_ng/dlg_handlers.c
  2. 2 0
      modules/dialog_ng/dlg_hash.c
  3. 1 0
      modules/dialog_ng/dlg_hash.h

+ 4 - 1
modules/dialog_ng/dlg_handlers.c

@@ -44,6 +44,7 @@ int spiral_detected = -1;
 extern struct rr_binds d_rrb; /*!< binding to record-routing module */
 extern struct tm_binds d_tmb;
 extern struct dialog_ng_counters_h dialog_ng_cnts_h;
+time_t act_time;
 
 extern pv_elem_t *ruri_param_model; /*!< pv-string to get r-uri */
 
@@ -1671,7 +1672,7 @@ int dlg_set_tm_callbacks(tm_cell_t *t, sip_msg_t *req, dlg_cell_t *dlg,
             goto error;
         }
         if (d_tmb.register_tmcb(req, t,
-                TMCB_RESPONSE_IN | TMCB_RESPONSE_READY | TMCB_RESPONSE_FWDED | TMCB_ON_FAILURE | TMCB_E2ECANCEL_IN | TMCB_REQUEST_OUT,
+                TMCB_DESTROY | TMCB_RESPONSE_IN | TMCB_RESPONSE_READY | TMCB_RESPONSE_FWDED | TMCB_ON_FAILURE | TMCB_E2ECANCEL_IN | TMCB_REQUEST_OUT,
                 dlg_onreply, (void*) iuid, dlg_iuid_sfree) < 0) {
             LM_ERR("failed to register TMCB\n");
             goto error;
@@ -1826,6 +1827,7 @@ void internal_print_all_dlg(struct dlg_cell *dlg) {
 
     LM_DBG("----------------------------");
     LM_DBG("Dialog h_entry:h_id = [%u : %u]\n", dlg->h_entry, dlg->h_id);
+	LM_DBG("Dialog age: %ld\n", act_time - dlg->init_ts);
     LM_DBG("Dialog call-id: %.*s\n", dlg->callid.len, dlg->callid.s);
     LM_DBG("Dialog state: %d\n", dlg->state);
     LM_DBG("Dialog ref counter: %d\n", dlg->ref);
@@ -1876,6 +1878,7 @@ void print_all_dlgs() {
     struct dlg_cell *dlg;
     unsigned int i;
 
+	act_time = time(0);
 
     LM_DBG("********************");
     LM_DBG("printing %i dialogs\n", d_table->size);

+ 2 - 0
modules/dialog_ng/dlg_hash.c

@@ -336,6 +336,7 @@ struct dlg_cell* build_new_dlg(str *callid, str *from_uri, str *from_tag, str *r
     }
 
     dlg->state = DLG_STATE_UNCONFIRMED;
+	dlg->init_ts = (unsigned int)time(NULL);
 
     dlg->h_entry = core_hash(callid, 0, d_table->size);
     LM_DBG("new dialog on hash %u\n", dlg->h_entry);
@@ -1240,6 +1241,7 @@ void next_state_dlg(struct dlg_cell *dlg, int event,
         case DLG_EVENT_REQBYE:
             switch (dlg->state) {
                 case DLG_STATE_CONFIRMED:
+				case DLG_STATE_CONFIRMED_NA:	/* we weight towards tearing the dialog down if we get a bye - perhaps bye can beat ack*/
                     dlg->dflags |= DLG_FLAG_HASBYE;
                     dlg->state = DLG_STATE_DELETED;
                     *unref = 1;

+ 1 - 0
modules/dialog_ng/dlg_hash.h

@@ -125,6 +125,7 @@ typedef struct dlg_cell {
     str caller_route_set; /*!< route set of caller*/
     struct socket_info * caller_bind_addr; /*! binded address of caller*/
     unsigned int state; /*!< dialog state */
+    unsigned int init_ts;/*!< init (creation) time (absolute UNIX ts)*/
     unsigned int start_ts; /*!< start time  (absolute UNIX ts)*/
     unsigned int lifetime; /*!< dialog lifetime */
     unsigned int toroute; /*!< index of route that is executed on timeout */