Skip to content

Commit f73abff

Browse files
committed
Do not inherit nothing (from prev branches) in failure route.
Reset all per-branch values before entering failure route - provide a fresh start for creating the new branches.
1 parent 0390ec9 commit f73abff

File tree

4 files changed

+23
-19
lines changed

4 files changed

+23
-19
lines changed

modules/tm/async.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ int t_resume_async(int fd, void *param)
104104
if (!fake_req( &faked_req /* the fake msg to be built*/,
105105
t->uas.request, /* the template msg saved in transaction */
106106
&t->uas, /*the UAS side of the transaction*/
107-
&uac, /* the fake UAC */
108-
1 /* copy dst_uri too */)
107+
&uac /* the fake UAC */)
109108
) {
110109
LM_ERR("fake_req failed\n");
111110
return 0;

modules/tm/t_fwd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1013,7 +1013,7 @@ int t_inject_branch( struct cell *t, struct sip_msg *msg, int flags)
10131013
return -2;
10141014
}
10151015

1016-
if (!fake_req( &faked_req, t->uas.request, &t->uas, NULL, 0)) {
1016+
if (!fake_req( &faked_req, t->uas.request, &t->uas, NULL)) {
10171017
LM_ERR("fake_req failed\n");
10181018
return -1;
10191019
}

modules/tm/t_msgbuilder.h

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static inline int fix_fake_req_headers(struct sip_msg *req)
190190

191191

192192
static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
193-
struct ua_server *uas, struct ua_client *uac, int inherit_br_data)
193+
struct ua_server *uas, struct ua_client *uac)
194194
{
195195
/* on_negative_reply faked msg now copied from shmem msg (as opposed
196196
* to zero-ing) -- more "read-only" actions (exec in particular) will
@@ -208,8 +208,11 @@ static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
208208

209209
faked_req->msg_flags |= FL_TM_FAKE_REQ;
210210

211-
/* new_uri can change -- make a private copy */
212211
if (uac) {
212+
213+
/* duplicate some values into private mem
214+
* so that they can be visible and changed at script level */
215+
/* RURI / new URI */
213216
faked_req->new_uri.s=pkg_malloc( uac->uri.len+1 );
214217
if (!faked_req->new_uri.s) {
215218
LM_ERR("no uri/pkg mem\n");
@@ -218,13 +221,6 @@ static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
218221
faked_req->new_uri.len = uac->uri.len;
219222
memcpy( faked_req->new_uri.s, uac->uri.s, uac->uri.len);
220223
faked_req->new_uri.s[faked_req->new_uri.len]=0;
221-
} else {
222-
faked_req->new_uri.s = NULL;
223-
faked_req->new_uri.len = 0;
224-
}
225-
faked_req->parsed_uri_ok = 0;
226-
227-
if (inherit_br_data) {
228224

229225
/* duplicate the dst_uri and path_vec into private mem
230226
* so that they can be visible and changed at script level */
@@ -245,6 +241,11 @@ static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
245241
memcpy(faked_req->path_vec.s, uac->path_vec.s, uac->path_vec.len);
246242
}
247243

244+
/* set the branch flags from the elected branch */
245+
setb0flags( faked_req, uac->br_flags);
246+
/* Q and force_send_socket values were already copied
247+
* as part of the sip_msg struct */
248+
248249
/* duplicate advertised address and port from UAC into
249250
* private mem so that they can be changed at script level */
250251
if (uac->adv_address.s) {
@@ -272,16 +273,23 @@ static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
272273
faked_req->set_global_port.len = 0;
273274
}
274275

275-
/* Q value was already copied as part of the sip_msg struct */
276276
} else {
277277

278+
/* reset new URI value */
279+
faked_req->new_uri.s = NULL;
280+
faked_req->new_uri.len = 0;
281+
278282
/* reset DST URI, PATH vector and Q value */
279283
faked_req->dst_uri.s = NULL;
280284
faked_req->dst_uri.len = 0;
281285
faked_req->path_vec.s = NULL;
282286
faked_req->path_vec.len = 0;
283287
faked_req->ruri_q = Q_UNSPECIFIED;
284288

289+
/* reset force_send_socket and the per-branch flags */
290+
faked_req->force_send_socket = NULL;
291+
setb0flags( faked_req, 0);
292+
285293
/* duplicate advertised address and port from SIP MSG into
286294
* private mem so that they can be changed at script level */
287295
if (shm_msg->set_global_address.s) {
@@ -318,11 +326,8 @@ static inline int fake_req(struct sip_msg *faked_req, struct sip_msg *shm_msg,
318326
goto out4;
319327
}
320328

321-
/* set as flags the global flags and the branch flags from the
322-
* elected branch */
329+
/* set as flags the global flags */
323330
faked_req->flags = uas->request->flags;
324-
if (uac)
325-
setb0flags( faked_req, uac->br_flags);
326331

327332
return 1;
328333
out4:

modules/tm/t_reply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ static inline int run_failure_handlers(struct cell *t)
581581
return 1;
582582
}
583583

584-
if (!fake_req(&faked_req, shmem_msg, &t->uas, uac, 0/*no dst_uri*/)) {
584+
if (!fake_req(&faked_req, shmem_msg, &t->uas, NULL)) {
585585
LM_ERR("fake_req failed\n");
586586
return 0;
587587
}
@@ -693,7 +693,7 @@ static inline int do_dns_failover(struct cell *t)
693693
}
694694
shmem_msg = t->uas.request;
695695

696-
if (!fake_req(&faked_req, shmem_msg, &t->uas, uac, 1/*with dst_uri*/)) {
696+
if (!fake_req(&faked_req, shmem_msg, &t->uas, uac)) {
697697
LM_ERR("fake_req failed\n");
698698
return -1;
699699
}

0 commit comments

Comments
 (0)