Skip to content

Commit

Permalink
tm: new parameter reply_relay_mode
Browse files Browse the repository at this point in the history
- control the behaviour introduced by 18410da
- if set to 0, the behaviour is like before the commit referenced above,
tm is attemptime to send suspended 200ok after another final response
that was forwarded while 200ok was suspended
- default is 1 (behave as the patch changed the forwarding policy, not
to overwrite the response buffer)

(cherry picked from commit 90dfc42)
  • Loading branch information
miconda committed Feb 9, 2021
1 parent 31f8466 commit be90816
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/modules/tm/t_reply.c
Expand Up @@ -109,6 +109,10 @@ extern int tm_remap_503_500;
/* send path and flags in 3xx class reply */
int tm_rich_redirect = 0;

/* control if reply should be relayed
* when transaction reply status is RPS_PUSHED_AFTER_COMPLETION */
extern int tm_reply_relay_mode;

/* how to deal with winning branch reply selection in failure_route
* can be overwritten per transaction with t_drop_replies(...)
* Values:
Expand Down Expand Up @@ -2044,7 +2048,8 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
goto error02;
}

if (reply_status != RPS_PUSHED_AFTER_COMPLETION) {
if (tm_reply_relay_mode == 0
|| reply_status != RPS_PUSHED_AFTER_COMPLETION) {
/* attempt to copy the message to UAS's shmem:
* - copy to-tag for ACK matching as well
* - allocate little a bit more for provisional as
Expand Down Expand Up @@ -2104,7 +2109,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
}
if (likely(uas_rb->dst.send_sock)) {
if (onsend_route_enabled(SIP_REPLY) && p_msg
&& (p_msg != FAKED_REPLY) && (reply_status != RPS_PUSHED_AFTER_COMPLETION)) {
&& (p_msg != FAKED_REPLY)
&& (tm_reply_relay_mode == 0
|| reply_status != RPS_PUSHED_AFTER_COMPLETION)) {
if (run_onsend(p_msg, &uas_rb->dst, buf, res_len)==0){
su2ip_addr(&ip, &(uas_rb->dst.to));
LM_ERR("reply to %s:%d(%d) dropped"
Expand All @@ -2120,7 +2127,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
if (SEND_PR_BUFFER( uas_rb, buf, res_len ) >= 0){
LM_DBG("reply buffer sent out\n");
if (unlikely(!totag_retr
&& has_tran_tmcbs(t, TMCB_RESPONSE_OUT) && (reply_status != RPS_PUSHED_AFTER_COMPLETION))){
&& has_tran_tmcbs(t, TMCB_RESPONSE_OUT)
&& (tm_reply_relay_mode == 0
|| reply_status != RPS_PUSHED_AFTER_COMPLETION))){
LOCK_REPLIES( t );
if(relayed_code==uas_rb->rbtype) {
run_trans_callbacks_with_buf( TMCB_RESPONSE_OUT, uas_rb,
Expand All @@ -2132,7 +2141,9 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
}
UNLOCK_REPLIES( t );
}
if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT) && (reply_status != RPS_PUSHED_AFTER_COMPLETION))){
if (unlikely(has_tran_tmcbs(t, TMCB_RESPONSE_SENT)
&& (tm_reply_relay_mode == 0
|| reply_status != RPS_PUSHED_AFTER_COMPLETION))){
INIT_TMCB_ONSEND_PARAMS(onsend_params, t->uas.request,
relayed_msg, uas_rb, &uas_rb->dst, buf,
res_len,
Expand Down
5 changes: 5 additions & 0 deletions src/modules/tm/tm.c
Expand Up @@ -222,6 +222,10 @@ str on_sl_reply_name = {NULL, 0};
int tm_remap_503_500 = 1;
str _tm_event_callback_lres_sent = {NULL, 0};

/* control if reply should be relayed
* when transaction reply status is RPS_PUSHED_AFTER_COMPLETION */
int tm_reply_relay_mode = 1;

unsigned long tm_exec_time_check = 0; /* microseconds */
int tm_exec_time_check_param = 5000; /* milliseconds */

Expand Down Expand Up @@ -480,6 +484,7 @@ static param_export_t params[]={
{"rich_redirect" , PARAM_INT, &tm_rich_redirect },
{"event_callback_lres_sent", PARAM_STR, &_tm_event_callback_lres_sent },
{"exec_time_check" , PARAM_INT, &tm_exec_time_check_param },
{"reply_relay_mode", PARAM_INT, &tm_reply_relay_mode },
{0,0,0}
};

Expand Down

0 comments on commit be90816

Please sign in to comment.