Hi,
with respect to this thread on SR-Users
http://lists.sip-router.org/pipermail/sr-users/2011-March/067696.html
asking why set_dlg_profile() doesn't work in failure_route, I figured
out that the problem is related to dlg_manage() usage. Conceptually,
tracking dialogs on-demand via that function and using the dialog flag
should work equally well. However, the dialog creation process differs
regarding the parameters passed to dlg_new_dialog() (located in
dlg_handlers.c and called by both approaches) whose signature is
int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
When using dlg_manage(), a NULL pointer is passed instead of an existing
transaction cell. The pointer is subsequently passed to two tm module
callback registrations where one for the callback type TMCB_MAX is meant
as a "temporary workaround of missing dialog_ctx field" as noted by
Daniel in commit f6a66b42. However, that very registration call is bound
to a check that the transaction exists, i.e., parameter t is not NULL:
http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…
Consequently, no callback of type TMCB_MAX will be carried out for
dialogs generated from dlg_manage(). This poses to be a problem for a
bunch of dialog profiling-related exported functions as well as
is_known_dlg() since they rely on the get_current_dialog() function. For
non-REQUEST routes, that function accesses the current dialog by means
of iterating through all of the current transaction's callbacks looking
for one of type TMCB_MAX that was previously registered in
dlg_create_dialog(). However, as that registration never occurs in case
of dlg_manage()-based tracking for reasons lined out above, the set of
mentioned, exported functions cannot work. Refer to
http://git.sip-router.org/cgi-bin/gitweb.cgi?p=sip-router;a=blob;f=modules_…
to see how get_current_dialog() does it.
So how do we fix this?
My idea is to simply remove the not-NULL-check against the transaction t
prior to callback registration. If the transaction doesn't exists, the
tm module makes sure that it will be created lazily. This is how the
first callback registration for types TMCB_RESPONSE_READY and
TMCB_RESPONSE_FWDED in dlg_create_dialog() already works, apparently
with no issues. I also did a quick, simple test with the check left out
that proved to work fine.
As this looks like a fix to a work-around, however, I'd like to ask for
some feedback first.
Thanks and
cheers,
--Timo
Module: sip-router
Branch: kamailio_3.0
Commit: 76a81da0c28c1f1cdccb2fd3344bfb2cfddc8fbe
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=76a81da…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Mon Mar 7 09:57:33 2011 +0100
dialog(k): Register dlg_tmcb_dummy in dialog_new_dlg() even when
given transaction t is not available.
- Let tm's registration function deal with creating a transaction
lazily.
- Facilitates using dialogs (e.g., profiling) created on demand
with dlg_manage().
(cherry picked from commit 00d2d6b98739327a6eaaeeafa50023cf0c47b0f3)
---
modules_k/dialog/dlg_handlers.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index 5e5e3c5..9bedc60 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -629,12 +629,10 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
if (_dlg_ctx.to_bye!=0)
dlg->dflags |= DLG_FLAG_TOBYE;
- if (t) {
- if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
- dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
- LM_ERR("failed cache in T the shortcut to dlg\n");
- goto error;
- }
+ if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
+ dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
+ LM_ERR("failed cache in T the shortcut to dlg\n");
+ goto error;
}
#if 0
t->dialog_ctx = (void*) dlg;
Module: sip-router
Branch: sr_3.0
Commit: 00d56078199b4bc96d2f13fdfa19a2ddeb168669
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=00d5607…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Mon Mar 7 09:57:33 2011 +0100
dialog(k): Register dlg_tmcb_dummy in dialog_new_dlg() even when
given transaction t is not available.
- Let tm's registration function deal with creating a transaction
lazily.
- Facilitates using dialogs (e.g., profiling) created on demand
with dlg_manage().
(cherry picked from commit 00d2d6b98739327a6eaaeeafa50023cf0c47b0f3)
---
modules_k/dialog/dlg_handlers.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index 5e5e3c5..9bedc60 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -629,12 +629,10 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
if (_dlg_ctx.to_bye!=0)
dlg->dflags |= DLG_FLAG_TOBYE;
- if (t) {
- if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
- dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
- LM_ERR("failed cache in T the shortcut to dlg\n");
- goto error;
- }
+ if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
+ dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
+ LM_ERR("failed cache in T the shortcut to dlg\n");
+ goto error;
}
#if 0
t->dialog_ctx = (void*) dlg;
Module: sip-router
Branch: 3.1
Commit: cd88482b84f4411febdda5ad785f29876373ac34
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cd88482…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Mon Mar 7 09:57:33 2011 +0100
dialog(k): Register dlg_tmcb_dummy in dialog_new_dlg() even when
given transaction t is not available.
- Let tm's registration function deal with creating a transaction
lazily.
- Facilitates using dialogs (e.g., profiling) created on demand
with dlg_manage().
(cherry picked from commit 00d2d6b98739327a6eaaeeafa50023cf0c47b0f3)
---
modules_k/dialog/dlg_handlers.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index a118a91..193f16a 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -716,12 +716,10 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
if (_dlg_ctx.to_bye!=0)
dlg->dflags |= DLG_FLAG_TOBYE;
- if (t) {
- if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
- dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
- LM_ERR("failed cache in T the shortcut to dlg\n");
- goto error;
- }
+ if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
+ dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
+ LM_ERR("failed cache in T the shortcut to dlg\n");
+ goto error;
}
#if 0
t->dialog_ctx = (void*) dlg;
Module: sip-router
Branch: master
Commit: 00d2d6b98739327a6eaaeeafa50023cf0c47b0f3
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=00d2d6b…
Author: Timo Reimann <timo.reimann(a)1und1.de>
Committer: Timo Reimann <timo.reimann(a)1und1.de>
Date: Mon Mar 7 09:57:33 2011 +0100
dialog(k): Register dlg_tmcb_dummy in dialog_new_dlg() even when
given transaction t is not available.
- Let tm's registration function deal with creating a transaction
lazily.
- Facilitates using dialogs (e.g., profiling) created on demand
with dlg_manage().
---
modules_k/dialog/dlg_handlers.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/modules_k/dialog/dlg_handlers.c b/modules_k/dialog/dlg_handlers.c
index a118a91..193f16a 100644
--- a/modules_k/dialog/dlg_handlers.c
+++ b/modules_k/dialog/dlg_handlers.c
@@ -716,12 +716,10 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
if (_dlg_ctx.to_bye!=0)
dlg->dflags |= DLG_FLAG_TOBYE;
- if (t) {
- if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
- dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
- LM_ERR("failed cache in T the shortcut to dlg\n");
- goto error;
- }
+ if ( d_tmb.register_tmcb( msg, t, TMCB_MAX,
+ dlg_tmcb_dummy, (void*)dlg, 0)<0 ) {
+ LM_ERR("failed cache in T the shortcut to dlg\n");
+ goto error;
}
#if 0
t->dialog_ctx = (void*) dlg;