[sr-dev] [kamailio/kamailio] cnxcc: remove duplicated entries with a same CID value (#2383)

Jose Luis Verdeguer notifications at github.com
Wed Jul 1 13:03:19 CEST 2020


I've been reviewing the code another time.

There are 3 different functions to control credit, time and channels: __set_max_credit(), __set_max_time() and __set_max_channels(). All of them do the same:

**function __set_max_money()**:
credit_data = __get_or_create_credit_data_entry(client_id, CREDIT_MONEY)
call = __alloc_new_call_by_time(client_id) // Allocate new call for client
__add_call_by_cid(cid, call, CREDIT_MONEY) // Allocate new CID_BY_CLIENT for client

**function __set_max_time()**:
credit_data = __get_or_create_credit_data_entry(client_id, CREDIT_TIME)
call = __alloc_new_call_by_time(client_id) // Allocate new call for client
__add_call_by_cid(cid, call, CREDIT_TIME)  // Allocate new CID_BY_CLIENT for client

**function __set_max_channel()**:
credit_data = __get_or_create_credit_data_entry(client_id, CREDIT_CHANNEL)
call = __alloc_new_call_by_time(client_id)   // Allocate new call for client
__add_call_by_cid(cid, call, CREDIT_CHANNEL) // Allocate new CID_BY_CLIENT for client

If credit is exhausted, the function **__terminate_all()** is called to kill all active calls for this client. This works fine:

__terminate_all(pointer_client_id) -> ki_terminate_all(client_id) -> terminate_all_calls(credit_data):
       foreach(call_list) { 
         terminate_call(call) 
       }

On the other hand, when a dialog is finished, the function called is **__stop_billing()**:

__dialog_terminated_callback() -> __stop_billing(callid) -> __delete_call(call, credit_data) -> __free_call(call)

In this case, there is no loop to delete and free all calls for this client with a same CID. Only remove the first match found. 
If the module has prepared to handle several times the same CID (by client), when dialog is finished, it should check and remove all calls with of this client with a same CID. Currently the module is not working in this way and I'm sure that nobody is using it to charge more than 1 times each CID, because it doesn't work. If anyone is trying to charge a call twice, is having problems because only one call by cid is terminated.

However, if you think that this feature could be important (being able to charge the same call more than once), it will be necessary to fix that, because currently it doesn't work.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2383#issuecomment-652352229
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20200701/ed352b76/attachment.html>


More information about the sr-dev mailing list