Skip to content

Commit fe34b4c

Browse files
bogdan-iancurazvancrainea
authored andcommitted
[tm] fix macros and indexing related to BRANCH_BITMASK
1 parent fb01782 commit fe34b4c

7 files changed

Lines changed: 33 additions & 32 deletions

File tree

modules/tm/t_cancel.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ extern int _tm_branch_index;
4848
*/
4949

5050

51-
void which_cancel( struct cell *t, branch_bm_t *cancel_bm )
51+
void which_cancel( struct cell *t, branch_bm_t cancel_bm )
5252
{
5353
int i;
5454

5555
for( i=t->first_branch ; i<t->nr_of_outgoings ; i++ ) {
5656
if (should_cancel_branch(t, i))
57-
BRANCH_BM_SET_IDX( *cancel_bm, i);
57+
BRANCH_BM_SET_IDX( cancel_bm, i);
5858
}
5959

6060
LM_DBG("branches to cancel ["BRANCH_BM_SPECS"], range %d:%d\n",
61-
BRANCH_BM_ARGS(*cancel_bm),t->first_branch,t->nr_of_outgoings-1);
61+
BRANCH_BM_ARGS(cancel_bm),t->first_branch,t->nr_of_outgoings-1);
6262

6363
}
6464

modules/tm/t_cancel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"Reason: SIP ;cause=200 ;text=\"Call completed elsewhere\"" CRLF
4343

4444

45-
void which_cancel( struct cell *t, branch_bm_t *cancel_bm );
45+
void which_cancel( struct cell *t, branch_bm_t cancel_bm );
4646
void cancel_uacs( struct cell *t, branch_bm_t cancel_bm );
4747
void cancel_branch( struct cell *t, int branch );
4848

modules/tm/t_fwd.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ void cancel_invite(struct sip_msg *cancel_msg,
694694
/* we need to check which branches should be canceled under lock to avoid
695695
* concurrency with replies that are coming in the same time */
696696
/* generate local cancels for all branches */
697-
which_cancel(t_invite, &cancel_bitmap );
697+
which_cancel(t_invite, cancel_bitmap );
698698
UNLOCK_REPLIES(t_invite);
699699

700700
set_cancel_extra_hdrs( reason.s, reason.len);
@@ -717,7 +717,7 @@ void cancel_invite(struct sip_msg *cancel_msg,
717717
if ( (t_invite->nr_of_outgoings-t_invite->first_branch)==1 &&
718718
(TM_BRANCH(t_invite,t_invite->first_branch).flags & T_UAC_IS_PHONY) ) {
719719
relay_reply( t_invite, FAKED_REPLY, t_invite->first_branch,
720-
487, &cancel_bitmap);
720+
487, cancel_bitmap);
721721
}
722722
#if 0
723723
/* internally cancel branches with no received reply */
@@ -1164,7 +1164,7 @@ int t_inject_branch( struct cell *t, struct sip_msg *msg, int flags)
11641164

11651165
/* do we have to cancel the existing branches before injecting new ones? */
11661166
if (flags&TM_INJECT_FLAG_CANCEL) {
1167-
which_cancel( t, &cancel_bm );
1167+
which_cancel( t, cancel_bm );
11681168
}
11691169

11701170
if (flags&TM_INJECT_FLAG_LAST)

modules/tm/t_reply.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
357357
/* determine if there are some branches to be canceled */
358358
if ( is_invite(trans) ) {
359359
if (lock) LOCK_REPLIES( trans );
360-
which_cancel(trans, &cancel_bitmap );
360+
which_cancel(trans, cancel_bitmap );
361361
if (lock) UNLOCK_REPLIES( trans );
362362
}
363363
/* and clean-up, including cancellations, if needed */
@@ -371,7 +371,7 @@ static int _reply_light( struct cell *trans, char* buf, unsigned int len,
371371
goto error2;
372372
}
373373
if ( is_invite(trans) && code>=200 )
374-
which_cancel(trans, &cancel_bitmap );
374+
which_cancel(trans, cancel_bitmap );
375375

376376

377377
rb = & trans->uas.response;
@@ -883,7 +883,7 @@ static inline int tran_is_completed( struct cell *t )
883883
*/
884884
static enum rps t_should_relay_response( struct cell *Trans , int new_code,
885885
int branch , int *should_store, int *should_relay,
886-
branch_bm_t *cancel_bitmap, struct sip_msg *reply )
886+
branch_bm_t cancel_bitmap, struct sip_msg *reply )
887887
{
888888
int branch_cnt;
889889
int picked_code;
@@ -998,7 +998,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
998998
}
999999
if (do_cancel) {
10001000
branch_bm_t cb = BRANCH_BM_ZERO;
1001-
which_cancel( Trans, &cb );
1001+
which_cancel( Trans, cb );
10021002
cleanup_uac_timers(Trans);
10031003
cancel_uacs( Trans, cb);
10041004
}
@@ -1242,7 +1242,7 @@ static int store_reply( struct cell *trans, int branch, struct sip_msg *rpl)
12421242
REPLY_LOCK and it returns unlocked!
12431243
*/
12441244
enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1245-
unsigned int msg_status, branch_bm_t *cancel_bitmap )
1245+
unsigned int msg_status, branch_bm_t cancel_bitmap )
12461246
{
12471247
int relay;
12481248
int save_clone;
@@ -1275,7 +1275,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
12751275
&save_clone, &relay, cancel_bitmap, p_msg );
12761276
LM_DBG("T_state=%d, branch=%d, save=%d, relay=%d, "
12771277
"cancel_BM="BRANCH_BM_SPECS"\n", reply_status, branch,
1278-
save_clone, relay, BRANCH_BM_ARGS(*cancel_bitmap));
1278+
save_clone, relay, BRANCH_BM_ARGS(cancel_bitmap));
12791279

12801280
/* store the message if needed */
12811281
if (save_clone) /* save for later use, typically branch picking */
@@ -1442,7 +1442,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
14421442
text.len = sizeof("Reply processing error")-1;
14431443
t_reply_unsafe( t, t->uas.request, 500, &text );
14441444
UNLOCK_REPLIES(t);
1445-
if (is_invite(t)) cancel_uacs( t, *cancel_bitmap );
1445+
if (is_invite(t)) cancel_uacs( t, cancel_bitmap );
14461446
/* a serious error occurred -- attempt to send an error reply;
14471447
it will take care of clean-ups */
14481448

@@ -1455,7 +1455,7 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
14551455
it is entered locked with REPLY_LOCK and it returns unlocked!
14561456
*/
14571457
enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1458-
unsigned int msg_status, branch_bm_t *cancel_bitmap)
1458+
unsigned int msg_status, branch_bm_t cancel_bitmap)
14591459
{
14601460
/* how to deal with replies for local transaction */
14611461
int local_store, local_winner;
@@ -1523,7 +1523,7 @@ enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
15231523
UNLOCK_REPLIES(t);
15241524
cleanup_uac_timers(t);
15251525
if ( get_cseq(p_msg)->method_id==METHOD_INVITE )
1526-
cancel_uacs( t, *cancel_bitmap );
1526+
cancel_uacs( t, cancel_bitmap );
15271527
put_on_wait(t);
15281528
return RPS_ERROR;
15291529
}
@@ -1548,7 +1548,7 @@ void process_reply_and_timer(struct cell *t,int branch,int msg_status,
15481548
}
15491549

15501550
if (is_local(t)) {
1551-
reply_status = local_reply(t,p_msg, branch,msg_status,&cancel_bitmap);
1551+
reply_status = local_reply(t,p_msg, branch,msg_status, cancel_bitmap);
15521552
if (reply_status == RPS_COMPLETED) {
15531553
cleanup_uac_timers(t);
15541554
if (is_invite(t)) cancel_uacs(t, cancel_bitmap);
@@ -1557,7 +1557,7 @@ void process_reply_and_timer(struct cell *t,int branch,int msg_status,
15571557
put_on_wait(t);
15581558
}
15591559
} else {
1560-
reply_status = relay_reply(t,p_msg,branch,msg_status,&cancel_bitmap);
1560+
reply_status = relay_reply(t,p_msg,branch,msg_status, cancel_bitmap);
15611561
/* clean-up the transaction when transaction completed */
15621562
if (reply_status == RPS_COMPLETED) {
15631563
/* no more UAC FR/RETR (if I received a 2xx, there may

modules/tm/t_reply.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,19 @@ int unmatched_totag(struct cell *t, struct sip_msg *ack);
6666

6767
/* branch bitmap type */
6868
typedef uint32_t branch_bm_t[TM_BRANCH_MAX_FACTOR];
69+
#define FLGS_PER_UINT32 (8*sizeof(uint32_t))
6970
#define BRANCH_BM_ZERO {0}
7071
#define BRANCH_BM_ALL {~0}
7172
#define BRANCH_BM_SET_IDX( _bm, _idx) \
72-
(_bm[(_idx)/sizeof(uint32_t)] |= (1 << ((_idx)%sizeof(uint32_t))))
73+
((_bm)[(_idx)/FLGS_PER_UINT32] |= (1 << ((_idx)%FLGS_PER_UINT32)))
7374
#define BRANCH_BM_RST_IDX( _bm, _idx) \
74-
(_bm[(_idx)/sizeof(uint32_t)] &= ~(1 << ((_idx)%sizeof(uint32_t))))
75+
((_bm)[(_idx)/FLGS_PER_UINT32] &= ~(1 << ((_idx)%FLGS_PER_UINT32)))
7576
#define BRANCH_BM_TST_IDX( _bm, _idx) \
76-
(_bm[(_idx)/sizeof(uint32_t)] & (1 << ((_idx)%sizeof(uint32_t))))
77+
((_bm)[(_idx)/FLGS_PER_UINT32] & (1 << ((_idx)%FLGS_PER_UINT32)))
7778
#define BRANCH_BM_SET_ALL( _bm ) \
78-
memset( &(_bm), 0xFF, sizeof(branch_bm_t))
79+
memset( (_bm), 0xFF, sizeof(branch_bm_t))
7980
#define BRANCH_BM_RST_ALL( _bm ) \
80-
memset( &(_bm), 0x00, sizeof(branch_bm_t))
81+
memset( (_bm), 0x00, sizeof(branch_bm_t))
8182
/* the below are a bit hackish, as rely on the default value of 8 for
8283
* TM_BRANCH_MAX_FACTOR */
8384
#define BRANCH_BM_NONE_SET( _bm) \
@@ -140,10 +141,10 @@ int t_reply_unsafe( struct cell *t, struct sip_msg * , unsigned int , str * );
140141

141142

142143
enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
143-
unsigned int msg_status, branch_bm_t *cancel_bitmap );
144+
unsigned int msg_status, branch_bm_t cancel_bitmap );
144145

145146
enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
146-
unsigned int msg_status, branch_bm_t *cancel_bitmap );
147+
unsigned int msg_status, branch_bm_t cancel_bitmap );
147148

148149
void set_final_timer( /* struct s_table *h_table,*/ struct cell *t );
149150

modules/tm/timer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ static void fake_reply(struct cell *t, int branch, int code )
254254
_tm_branch_index = branch;
255255
if ( is_local(t) ) {
256256
reply_status=local_reply( t, FAKED_REPLY, branch,
257-
code, &cancel_bitmap );
257+
code, cancel_bitmap );
258258
if (reply_status==RPS_COMPLETED) {
259259
put_on_wait(t);
260260
}
261261
} else {
262262
reply_status=relay_reply( t, FAKED_REPLY, branch, code,
263-
&cancel_bitmap );
263+
cancel_bitmap );
264264
}
265265
_tm_branch_index = 0;
266266
/* again, a final negative reply on a branch will never lead to a

modules/tm/tm.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ static int t_cancel_trans(struct cell *t, str *extra_hdrs)
14481448
}
14491449

14501450
LOCK_REPLIES(t);
1451-
which_cancel( t, &cancel_bitmap );
1451+
which_cancel( t, cancel_bitmap );
14521452
UNLOCK_REPLIES(t);
14531453

14541454
/* send cancels out */
@@ -1481,10 +1481,10 @@ static int w_t_cancel_branch(struct sip_msg *msg, void *sflags)
14811481
/* lock and get the branches to cancel */
14821482
if (!onreply_avp_mode) {
14831483
LOCK_REPLIES(t);
1484-
which_cancel( t, &cancel_bitmap );
1484+
which_cancel( t, cancel_bitmap );
14851485
UNLOCK_REPLIES(t);
14861486
} else {
1487-
which_cancel( t, &cancel_bitmap );
1487+
which_cancel( t, cancel_bitmap );
14881488
}
14891489
if (msg->first_line.u.reply.statuscode>=200)
14901490
/* do not cancel the current branch as we got
@@ -1494,10 +1494,10 @@ static int w_t_cancel_branch(struct sip_msg *msg, void *sflags)
14941494
/* lock and get the branches to cancel */
14951495
if (!onreply_avp_mode) {
14961496
LOCK_REPLIES(t);
1497-
which_cancel( t, &cancel_bitmap );
1497+
which_cancel( t, cancel_bitmap );
14981498
UNLOCK_REPLIES(t);
14991499
} else {
1500-
which_cancel( t, &cancel_bitmap );
1500+
which_cancel( t, cancel_bitmap );
15011501
}
15021502
/* ignore current branch */
15031503
BRANCH_BM_RST_IDX( cancel_bitmap, _tm_branch_index);

0 commit comments

Comments
 (0)