diff --git a/modules/mid_registrar/save.c b/modules/mid_registrar/save.c index 1a6d5ded779..1726e33d43e 100644 --- a/modules/mid_registrar/save.c +++ b/modules/mid_registrar/save.c @@ -1861,6 +1861,28 @@ static int prepare_forward(struct sip_msg *msg, udomain_t *d, { struct mid_reg_info *mri; struct to_body *to, *from; + int rc; + + rc = tmb.t_newtran(msg); + switch (rc) { + case 1: + break; + + case E_SCRIPT: + LM_DBG("%.*s transaction already exists, continuing...\n", + msg->REQ_METHOD_S.len, msg->REQ_METHOD_S.s); + break; + + case 0: + LM_INFO("absorbing %.*s retransmission, use t_check_trans() " + "earlier\n", msg->REQ_METHOD_S.len, msg->REQ_METHOD_S.s); + return 0; + + default: + LM_ERR("internal error %d while creating %.*s transaction\n", + rc, msg->REQ_METHOD_S.len, msg->REQ_METHOD_S.s); + return -1; + } LM_DBG("from: '%.*s'\n", msg->from->body.len, msg->from->body.s); LM_DBG("Call-ID: '%.*s'\n", msg->callid->body.len, msg->callid->body.s); @@ -2471,11 +2493,6 @@ int mid_reg_save(struct sip_msg *msg, udomain_t *d, str *flags_str, return -1; } - if (((int (*)(struct sip_msg *))tmb.t_check_trans)(msg) == 0) { - LM_INFO("absorbing retransmission, use t_check_trans() earlier!\n"); - return 0; - } - rerrno = R_FINE; memset(&sctx, 0, sizeof sctx); diff --git a/modules/tm/t_hooks.h b/modules/tm/t_hooks.h index 3a458584652..5fbd98b39b1 100644 --- a/modules/tm/t_hooks.h +++ b/modules/tm/t_hooks.h @@ -153,6 +153,9 @@ struct cell; * to any other piece of code except the transaction cleanup routine. All * registered callbacks of this type will be invoked by the cleanup routine, * after which the transaction object will be freed. + * Note: if you schedule data for deletion using this callback, then you may + * have to ensure a transaction always exists beforehand, using + * tmb.t_newtran() * * TMCB_MSG_MATCHED_IN -- triggered whenever there is an * incoming SIP message matching the transaction. It may be diff --git a/modules/tm/tm_load.h b/modules/tm/tm_load.h index 0b0bc07088f..2c94332cdf7 100644 --- a/modules/tm/tm_load.h +++ b/modules/tm/tm_load.h @@ -54,7 +54,7 @@ struct tm_binds { * 1 (success) * 0 (retransmission) * < 0 (error) - * * E_SCRIPT (T already exists) + * * E_SCRIPT (the current transaction (@T) is already populated) * * (others) */ tnewtran_f t_newtran;