[OpenSER-Devel] cancelling per branch

Zappasodi Daniele Daniele.Zappasodi at seltatel.it
Tue Jul 8 11:08:29 CEST 2008


Hello,
I need something similar to the t_uac_cancel fifo command, but when there are more branches (parallel forking) it should offer the opportunity to select the branches to cancel.
I have already posted this question to the serusers list with a negative answer so I have tried to change the code in tm module. 
First of all is it possible to achieve the same behaviour writing a new module and importing the tm API? (sorry if I ask it again, but I really would prefer to not touch the tm)
Anyway I have tried to change the function mi_tm_cancel and I have added a third input parameter, the branch id. 
I have replaced the following code:
	cancel_uacs( trans, ~0/*all branches*/);

with something like this:
	...
	branch_param=-1;
	if ( node->next->next )
		if(node->next->next->value.s)
			branch_param=atoi(node->next->next->value.s);
	
	if(branch_param>=0 && branch_param<MAX_BRANCHES)
	{
		n=0;
		cancel_bitmap=0;
		LM_DBG("cancelling transaction only for %d\n",branch_param);
		for( i=trans->first_branch ; i<trans->nr_of_outgoings ; i++ ) {
			if(i==branch_param)
				cancel_bitmap |= 1<<i ;
			else
				if (should_cancel_branch(trans, i)) 
					n++;
		}
		cancel_uacs( trans, cancel_bitmap);
		if(n==0)				// ??????
			UNREF(trans);
	}
	else
	{
		cancel_uacs( trans, ~0/*all branches*/);
		UNREF(trans);
	...

Can someone give me some help or comments about this code?
It seems to work, but I'm afraid of memory releasing. In particular I don't understand what UNREF(trans) does: does it delete the transaction so I must call it only if there aren't other branches (as I have tried to done in my code, but I'm not sure if it is correct) or it must be called everytime?

regards 
Daniele

**********************************************************************
The information in this message is confidential and may be legally
privileged. It is intended solely for the addressee. Access to this message
by anyone else is unauthorized. If you are not the intended recipient, any
disclosure, copying, or distribution of the message, or any action or
omission taken by you in reliance on it, is prohibited and may be unlawful.
Please immediately contact the sender if you have received this message inerror.

**********************************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openser.org/pipermail/devel/attachments/20080708/adbe1673/attachment.htm 


More information about the Devel mailing list