Browse Source

modules_k/dialog: Add DLGCB_CONFIRMED_NA callback and make
DLGCB_CONFIRM fit accordingly.

- Add DLGCB_CONFIRMED_NA callback which is triggered on reception
of a 200 OK message (setup-concluding ACK message still
pending).
- Execute DGLCB_CONFIRMED on reception of a setup-concluding ACK
message.
- Extend documentation and clarify that DLGCB_REQ_WITHIN does not
fire on DLGCB_CONFIRMED. (This is for consistency reasons as BYE
requests have their own callback (DLGCB_TERMINATED) as well.
Users who wish to track both setup-concluding ACK and other
sequential requests must register for both callbacks types now.)
- Closes Flyspray issue #143.

Timo Reimann 14 years ago
parent
commit
e1068cb0ab
3 changed files with 48 additions and 30 deletions
  1. 12 11
      modules_k/dialog/dlg_cb.h
  2. 26 17
      modules_k/dialog/dlg_handlers.c
  3. 10 2
      modules_k/dialog/doc/dialog_devel.xml

+ 12 - 11
modules_k/dialog/dlg_cb.h

@@ -64,17 +64,18 @@ typedef str* (*get_dlg_variable_f)( struct dlg_cell* dlg,
 #define DLGCB_LOADED          (1<<0)
 #define DLGCB_CREATED         (1<<1)
 #define DLGCB_FAILED          (1<<2)
-#define DLGCB_CONFIRMED       (1<<3)
-#define DLGCB_REQ_WITHIN      (1<<4)
-#define DLGCB_TERMINATED      (1<<5)
-#define DLGCB_EXPIRED         (1<<6)
-#define DLGCB_EARLY           (1<<7)
-#define DLGCB_RESPONSE_FWDED  (1<<8)
-#define DLGCB_RESPONSE_WITHIN (1<<9)
-#define DLGCB_MI_CONTEXT      (1<<10)
-#define DLGCB_RPC_CONTEXT     (1<<11)
-#define DLGCB_DESTROY         (1<<12)
-#define DLGCB_SPIRALED        (1<<13)
+#define DLGCB_CONFIRMED_NA    (1<<3)
+#define DLGCB_CONFIRMED       (1<<4)
+#define DLGCB_REQ_WITHIN      (1<<5)
+#define DLGCB_TERMINATED      (1<<6)
+#define DLGCB_EXPIRED         (1<<7)
+#define DLGCB_EARLY           (1<<8)
+#define DLGCB_RESPONSE_FWDED  (1<<9)
+#define DLGCB_RESPONSE_WITHIN (1<<10)
+#define DLGCB_MI_CONTEXT      (1<<11)
+#define DLGCB_RPC_CONTEXT     (1<<12)
+#define DLGCB_DESTROY         (1<<13)
+#define DLGCB_SPIRALED        (1<<14)
 #define DLGCB_TERMINATED_CONFIRMED (1<<14)
 
 struct dlg_callback {

+ 26 - 17
modules_k/dialog/dlg_handlers.c

@@ -398,7 +398,7 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
 
 	if (new_state==DLG_STATE_CONFIRMED_NA &&
 	old_state!=DLG_STATE_CONFIRMED_NA && old_state!=DLG_STATE_CONFIRMED ) {
-		LM_DBG("dialog %p confirmed\n",dlg);
+		LM_DBG("dialog %p confirmed (ACK pending)\n",dlg);
 
 		 if (rpl != FAKED_REPLY) {
 			/* get to tag*/
@@ -445,8 +445,8 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
 			ref_dlg(dlg,1);
 		}
 
-		/* dialog confirmed */
-		run_dlg_callbacks( DLGCB_CONFIRMED, dlg, req, rpl, DLG_DIR_UPSTREAM, 0);
+		/* dialog confirmed (ACK pending) */
+		run_dlg_callbacks( DLGCB_CONFIRMED_NA, dlg, req, rpl, DLG_DIR_UPSTREAM, 0);
 
 		if (old_state==DLG_STATE_EARLY)
 			if_update_stat(dlg_enable_stats, early_dlgs, -1);
@@ -1168,7 +1168,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 
 	if ( (event==DLG_EVENT_REQ || event==DLG_EVENT_REQACK)
 	&& new_state==DLG_STATE_CONFIRMED) {
-		LM_DBG("sequential request successfully processed\n");
+
 		timeout = get_dlg_timeout(req);
 		if (timeout!=default_timeout) {
 			dlg->lifetime = timeout;
@@ -1184,20 +1184,29 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param)
 				update_dialog_dbinfo(dlg);
 		}
 
-		/* within dialog request */
-		run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, NULL, dir, 0);
-
-		if ( (event!=DLG_EVENT_REQACK) &&
-		(dlg->cbs.types)&DLGCB_RESPONSE_WITHIN ) {
-			/* ref the dialog as registered into the transaction callback.
-			 * unref will be done when the callback will be destroyed */
-			ref_dlg( dlg , 1);
-			/* register callback for the replies of this request */
-			if ( d_tmb.register_tmcb( req, 0, TMCB_RESPONSE_FWDED,
-			(dir==DLG_DIR_UPSTREAM)?dlg_seq_down_onreply:dlg_seq_up_onreply,
-			(void*)dlg, unreference_dialog)<0 ) {
-				LM_ERR("failed to register TMCB (2)\n");
+		if (old_state==DLG_STATE_CONFIRMED_NA) {
+			LM_DBG("confirming ACK successfully processed\n");
+
+			/* confirming ACK request */
+			run_dlg_callbacks( DLGCB_CONFIRMED, dlg, req, NULL, dir, 0);
+		} else {
+			LM_DBG("sequential request successfully processed\n");
+
+			/* within dialog request */
+			run_dlg_callbacks( DLGCB_REQ_WITHIN, dlg, req, NULL, dir, 0);
+
+			if ( (event!=DLG_EVENT_REQACK) &&
+					(dlg->cbs.types)&DLGCB_RESPONSE_WITHIN ) {
+				/* ref the dialog as registered into the transaction callback.
+				 * unref will be done when the callback will be destroyed */
+				ref_dlg( dlg , 1);
+				/* register callback for the replies of this request */
+				if ( d_tmb.register_tmcb( req, 0, TMCB_RESPONSE_FWDED,
+							(dir==DLG_DIR_UPSTREAM)?dlg_seq_down_onreply:dlg_seq_up_onreply,
+							(void*)dlg, unreference_dialog)<0 ) {
+					LM_ERR("failed to register TMCB (2)\n");
 					unref_dlg( dlg , 1);
+				}
 			}
 		}
 	}

+ 10 - 2
modules_k/dialog/doc/dialog_devel.xml

@@ -51,14 +51,22 @@
 				</para>
 			</listitem>
 			<listitem>
-				<para><emphasis>DLGCB_CONFIRMED</emphasis> - called when the 
+				<para><emphasis>DLGCB_CONFIRMED_NA</emphasis> - called when the
+				dialog is confirmed (2xx replied) but the setup-concluding ACK
+				message from the caller is yet pending - it's a per dialog type.
+				</para>
+			</listitem>
+			<listitem>
+				<para><emphasis>DLGCB_CONFIRMED</emphasis> - called when the
 				dialog is confirmed (2xx replied) and the setup-concluding ACK
 				message from the caller has been seen - it's a per dialog type.
 				</para>
 			</listitem>
 			<listitem>
 				<para><emphasis>DLGCB_REQ_WITHIN</emphasis> - called when the 
-				dialog matches a sequential request - it's a per dialog type.
+				dialog matches a sequential request (excluding setup-concluding
+				ACK messages which are handled in DLGCB_CONFIRMED) - it's a per
+				dialog type.
 				</para>
 			</listitem>
 			<listitem>