Module: sip-router Branch: master Commit: a85e18b152f841e35d790f74164ce7d8deb22a57 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a85e18b1...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Fri Oct 17 11:06:41 2014 +0200
tm: transaction uses number of branches specified by max_branches global parameter
- the number of UACs per transaction is based on max_branches global parameter
---
modules/tm/h_table.c | 18 +++++++++++++----- modules/tm/h_table.h | 4 ++-- modules/tm/t_fwd.c | 8 ++++---- modules/tm/t_lookup.c | 2 +- modules/tm/timer.c | 2 +- modules/tm/tm.c | 4 ++-- 6 files changed, 23 insertions(+), 15 deletions(-)
diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c index 051c326..d0d2d5b 100644 --- a/modules/tm/h_table.c +++ b/modules/tm/h_table.c @@ -290,7 +290,7 @@ static void inline init_branches(struct cell *t) unsigned int i; struct ua_client *uac;
- for(i=0;i<MAX_BRANCHES;i++) + for(i=0;i<sr_dst_max_branches;i++) { uac=&t->uac[i]; uac->request.my_T = t; @@ -313,21 +313,29 @@ struct cell* build_cell( struct sip_msg* p_msg ) #ifdef WITH_XAVP sr_xavp_t** xold; #endif + unsigned int cell_size;
- /* allocs a new cell, add space for md5 (MD5_LEN - sizeof(struct cell.md5)) */ - new_cell = (struct cell*)shm_malloc( sizeof( struct cell )+ - MD5_LEN-sizeof(((struct cell*)0)->md5) ); + /* allocs a new cell, add space for: + * md5 (MD5_LEN - sizeof(struct cell.md5)) + * uac (sr_dst_max_banches * sizeof(struct ua_client) ) */ + cell_size = sizeof( struct cell ) + MD5_LEN - sizeof(((struct cell*)0)->md5) + + (sr_dst_max_branches * sizeof(struct ua_client)); + + new_cell = (struct cell*)shm_malloc( cell_size ); if ( !new_cell ) { ser_error=E_OUT_OF_MEM; return NULL; }
/* filling with 0 */ - memset( new_cell, 0, sizeof( struct cell ) ); + memset( new_cell, 0, cell_size );
/* UAS */ new_cell->uas.response.my_T=new_cell; init_rb_timers(&new_cell->uas.response); + /* UAC */ + new_cell->uac = (struct ua_client*)((char*)new_cell + sizeof(struct cell) + + MD5_LEN - sizeof(((struct cell*)0)->md5)); /* timers */ init_cell_timers(new_cell);
diff --git a/modules/tm/h_table.h b/modules/tm/h_table.h index 42551bb..23d005f 100644 --- a/modules/tm/h_table.h +++ b/modules/tm/h_table.h @@ -427,7 +427,7 @@ typedef struct cell /* UA Server */ struct ua_server uas; /* UA Clients */ - struct ua_client uac[ MAX_BRANCHES ]; + struct ua_client *uac; /* store transaction state to be used for async transactions */ struct async_state async_backup; @@ -461,7 +461,7 @@ typedef struct cell #endif ticks_t end_of_life; /* maximum lifetime */
- /* nr of replied branch; 0..MAX_BRANCHES=branch value, + /* nr of replied branch; 0..sr_dst_max_branches=branch value, * -1 no reply, -2 local reply */ short relayed_reply_branch;
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c index 61b6e6a..1e61183 100644 --- a/modules/tm/t_fwd.c +++ b/modules/tm/t_fwd.c @@ -746,7 +746,7 @@ int add_blind_uac( /*struct cell *t*/ ) }
branch=t->nr_of_outgoings; - if (branch==MAX_BRANCHES) { + if (branch==sr_dst_max_branches) { LOG(L_ERR, "ERROR: add_blind_uac: " "maximum number of branches exceeded\n"); return -1; @@ -811,7 +811,7 @@ int add_uac( struct cell *t, struct sip_msg *request, str *uri, #endif /* TM_UAC_FLAGS */
branch=t->nr_of_outgoings; - if (branch==MAX_BRANCHES) { + if (branch==sr_dst_max_branches) { LOG(L_ERR, "ERROR: add_uac: maximum number of branches exceeded\n"); ret=ser_error=E_TOO_MANY_BRANCHES; goto error; @@ -898,7 +898,7 @@ static int add_uac_from_buf( struct cell *t, struct sip_msg *request, unsigned int len;
branch=t->nr_of_outgoings; - if (branch==MAX_BRANCHES) { + if (branch==sr_dst_max_branches) { LOG(L_ERR, "ERROR: add_uac_from_buf: maximum number of branches" " exceeded\n"); ret=ser_error=E_TOO_MANY_BRANCHES; @@ -1060,7 +1060,7 @@ int add_uac_dns_fallback(struct cell *t, struct sip_msg* msg, return ret; } } - if (t->nr_of_outgoings >= MAX_BRANCHES){ + if (t->nr_of_outgoings >= sr_dst_max_branches){ LOG(L_ERR, "ERROR: add_uac_dns_fallback: maximum number of " "branches exceeded\n"); if (lock_replies) diff --git a/modules/tm/t_lookup.c b/modules/tm/t_lookup.c index cb3a720..79b1083 100644 --- a/modules/tm/t_lookup.c +++ b/modules/tm/t_lookup.c @@ -936,7 +936,7 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch ) if (unlikely(reverse_hex2int(hashi, hashl, &hash_index)<0 ||hash_index>=TABLE_ENTRIES || reverse_hex2int(branchi, branchl, &branch_id)<0 - ||branch_id>=MAX_BRANCHES + || branch_id>=sr_dst_max_branches || loopl!=MD5_LEN) ) { DBG("DEBUG: t_reply_matching: poor reply labels %d label %d " diff --git a/modules/tm/timer.c b/modules/tm/timer.c index 6f1a597..7856570 100644 --- a/modules/tm/timer.c +++ b/modules/tm/timer.c @@ -491,7 +491,7 @@ inline static void final_response_handler( struct retr_buf* r_buf, #ifdef EXTRA_DEBUG DBG("DEBUG: final_response_handler:stop retr. and send CANCEL (%p)\n", t); #endif - if ((r_buf->branch < MAX_BRANCHES) && /* r_buf->branch is always >=0 */ + if ((r_buf->branch < sr_dst_max_branches) && /* r_buf->branch is always >=0 */ (t->uac[r_buf->branch].last_received==0) && (t->uac[r_buf->branch].request.buffer!=NULL) /* not a blind UAC */ ){ diff --git a/modules/tm/tm.c b/modules/tm/tm.c index 54bcc78..f3568c1 100644 --- a/modules/tm/tm.c +++ b/modules/tm/tm.c @@ -801,9 +801,9 @@ static int mod_init(void)
/* checking if we have sufficient bitmap capacity for given maximum number of branches */ - if (MAX_BRANCHES+1>31) { + if (sr_dst_max_branches+1>31) { LOG(L_CRIT, "Too many max UACs for UAC branch_bm_t bitmap: %d\n", - MAX_BRANCHES ); + sr_dst_max_branches ); return -1; }