Module: sip-router
Branch: master
Commit: f971c09ff103cfe61bbf8bf930905432ca528b95
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f971c09…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 23 15:04:41 2009 +0100
Kamailio compatiblity: Added pointer to a free function to tm callbacks
This patch adds a new pointer to the tm_callback structure. The
parameter contains pointer to a function which, if not NULL, will be
called to dispose the callback parameter when it is not needed anymore.
This is useful if the parameter given ti a transaction callback is a
complex data structure of it is stored on the heap and the memory needs
to be free when the corresponding transaction is being destroyed.
Patch contributed by Ovidiu Sas.
---
modules/tm/h_table.c | 3 +++
modules/tm/t_hooks.c | 9 ++++++---
modules/tm/t_hooks.h | 13 ++++++++++---
modules/tm/uac.c | 3 ++-
4 files changed, 21 insertions(+), 7 deletions(-)
diff --git a/modules/tm/h_table.c b/modules/tm/h_table.c
index 6b38496..11fb1a8 100644
--- a/modules/tm/h_table.c
+++ b/modules/tm/h_table.c
@@ -141,6 +141,9 @@ void free_cell( struct cell* dead_cell )
for( cbs=(struct tm_callback*)dead_cell->tmcb_hl.first ; cbs ; ) {
cbs_tmp = cbs;
cbs = cbs->next;
+ if (cbs_tmp->release) {
+ cbs_tmp->release(cbs_tmp->param);
+ }
shm_free_unsafe( cbs_tmp );
}
diff --git a/modules/tm/t_hooks.c b/modules/tm/t_hooks.c
index 788172a..6e149ea 100644
--- a/modules/tm/t_hooks.c
+++ b/modules/tm/t_hooks.c
@@ -117,7 +117,8 @@ void destroy_tmcb_lists()
/* lockless insert: should be always safe */
int insert_tmcb(struct tmcb_head_list *cb_list, int types,
- transaction_cb f, void *param )
+ transaction_cb f, void *param,
+ release_tmcb_param rel_func)
{
struct tm_callback *cbp;
struct tm_callback *old;
@@ -133,6 +134,7 @@ int insert_tmcb(struct tmcb_head_list *cb_list, int types,
/* ... and fill it up */
cbp->callback = f;
cbp->param = param;
+ cbp->release = rel_func;
cbp->types = types;
cbp->id=0;
old=(struct tm_callback*)cb_list->first;
@@ -164,7 +166,8 @@ int insert_tmcb(struct tmcb_head_list *cb_list, int types,
* from mod_init (before forking!).
*/
int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
- transaction_cb f, void *param )
+ transaction_cb f, void *param,
+ release_tmcb_param rel_func)
{
//struct cell* t;
struct tmcb_head_list *cb_list;
@@ -217,7 +220,7 @@ int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
cb_list = &(t->tmcb_hl);
}
- return insert_tmcb( cb_list, types, f, param );
+ return insert_tmcb( cb_list, types, f, param, rel_func );
}
diff --git a/modules/tm/t_hooks.h b/modules/tm/t_hooks.h
index 38721fb..b396737 100644
--- a/modules/tm/t_hooks.h
+++ b/modules/tm/t_hooks.h
@@ -385,9 +385,12 @@ do{ \
/* callback function prototype */
typedef void (transaction_cb) (struct cell* t, int type, struct tmcb_params*);
+/*! \brief function to release the callback param */
+typedef void (release_tmcb_param) (void* param);
/* register callback function prototype */
typedef int (*register_tmcb_f)(struct sip_msg* p_msg, struct cell *t,
- int cb_types, transaction_cb f, void *param);
+ int cb_types, transaction_cb f, void *param,
+ release_tmcb_param func);
struct tm_callback {
@@ -395,6 +398,8 @@ struct tm_callback {
int types; /* types of events that trigger the callback*/
transaction_cb* callback; /* callback function */
void *param; /* param to be passed to callback function */
+ release_tmcb_param* release; /**< Function to release the callback param
+ * when the callback is deleted */
struct tm_callback* next;
};
@@ -423,11 +428,13 @@ void destroy_tmcb_lists();
/* register a callback for several types of events */
int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types,
- transaction_cb f, void *param );
+ transaction_cb f, void *param,
+ release_tmcb_param rel_func);
/* inserts a callback into the a callback list */
int insert_tmcb(struct tmcb_head_list *cb_list, int types,
- transaction_cb f, void *param );
+ transaction_cb f, void *param,
+ release_tmcb_param rel_func);
/* run all transaction callbacks for an event type */
void run_trans_callbacks( int type , struct cell *trans,
diff --git a/modules/tm/uac.c b/modules/tm/uac.c
index 50089c0..6dfd0fc 100644
--- a/modules/tm/uac.c
+++ b/modules/tm/uac.c
@@ -319,7 +319,8 @@ static inline int t_uac_prepare(uac_req_t *uac_r,
/* Register the callbacks after everything is successful and nothing can fail.
Otherwise the callback parameter would be freed twise, once from TMCB_DESTROY,
and again because of the negative return code. */
- if(uac_r->cb && insert_tmcb(&(new_cell->tmcb_hl), uac_r->cb_flags, *(uac_r->cb), uac_r->cbp)!=1){
+ if(uac_r->cb && insert_tmcb(&(new_cell->tmcb_hl), uac_r->cb_flags,
+ *(uac_r->cb), uac_r->cbp, NULL)!=1){
ret=E_OUT_OF_MEM;
LOG(L_ERR, "t_uac: short of tmcb shmem\n");
goto error1;
Module: sip-router
Branch: janakj/kcore
Commit: 9b63900b14a17f46e45c8aad3e0f970dbc17b73f
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=9b63900…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 23 11:16:52 2009 +0100
Merge branch 'master' of ssh://janakj@git.sip-router.org/sip-router into sr
* 'master' of ssh://janakj@git.sip-router.org/sip-router:
New function to return the To tag for local reply
Allow parser syn'ced with kamailio version
New functions that can be used to search for a header with given type
---
Module: sip-router
Branch: janakj/kcore
Commit: 8a7db2aacd98e1ac0a13753a8cfe82cbd1de14d0
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8a7db2a…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 23 10:44:07 2009 +0100
Merge branch 'master' of ssh://janakj@git.sip-router.org/sip-router into sr
* 'master' of ssh://janakj@git.sip-router.org/sip-router:
tcp: minor optimization
sercmd: minor makefile fix
tcp internal: send timeout is now kept only in ticks
core: typo fix
tcp: typo & minor optimization
Support for auto_inv_100_reason tm parameter.
Rename Contact parameter select 'method' to 'methods'
Rename Contact parameter 'method' to 'methods'
make install: avoid re-linking lib dependent modules
build system: avoid libraries re-compiling
fixing missing $ in ser_mysql.sh script
Debian packaging - fixing path to mysql sql files in my_create.sh script
The fixup function prototypes of the config variables have been
Strip, prefix, rewriteuser, ... all the SET_* actions preserve the
core: check & fix Content-Length when sending on tcp
tcp: config option for the async write block size
tcp: config option for the read buffer size
tcp: dyn. config fix for tcp_con_lifetime
tcp: diff. connect timeout for async & states cleanup
---
Module: sip-router
Branch: janakj/kcore
Commit: 534aa29209a94390f6867b406cb7f69960bcb6c6
URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=534aa29…
Author: Jan Janak <jan(a)iptel.org>
Committer: Jan Janak <jan(a)iptel.org>
Date: Mon Mar 23 13:48:17 2009 +0100
Merge branch 'sr' into kcore
* sr: (39 commits)
New function to return the To tag for local reply
Allow parser syn'ced with kamailio version
New functions that can be used to search for a header with given type
tcp: minor optimization
sercmd: minor makefile fix
tcp internal: send timeout is now kept only in ticks
core: typo fix
tcp: typo & minor optimization
Support for auto_inv_100_reason tm parameter.
Rename Contact parameter select 'method' to 'methods'
Rename Contact parameter 'method' to 'methods'
make install: avoid re-linking lib dependent modules
Kamailio compatiblity: export last_retcode via a global variable
build system: avoid libraries re-compiling
Add support for SET_HOSTALL_T action.
Replace missing logging macros with va_arg support using static buffer.
Adding send_sock to the dlg_t structure.
Update to the refurbished event parser.
Refurbished event header field parser.
Extend the parser parameter with support for dialog event parameters.
...
---