diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-19 02:16:34 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-10-19 02:16:34 +0000 |
commit | a1cc2d302e73aff8d3faff4bf5f3a746865477b5 (patch) | |
tree | 7e2fbbf610dc7739fe1bc1c1874f73f43eabb7e8 /include | |
parent | a3d8c1a8731691427ca0039348fdc24f09ec54fe (diff) |
restore freeing of threadstorage objects without custom cleanup functions
allow custom threadstorage init functions to return failure
use a custom init function for chan_sip's temp_pvt, to improve performance a bit
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@45634 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/threadstorage.h | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/include/asterisk/threadstorage.h b/include/asterisk/threadstorage.h index 6964839cb..d13b616f0 100644 --- a/include/asterisk/threadstorage.h +++ b/include/asterisk/threadstorage.h @@ -42,7 +42,7 @@ struct ast_threadstorage { /*! The function that initializes the key */ void (*key_init)(void); /*! Custom initialization function specific to the object */ - void (*custom_init)(void *); + int (*custom_init)(void *); }; /*! @@ -58,13 +58,13 @@ struct ast_threadstorage { * \endcode */ #define AST_THREADSTORAGE(name) \ - AST_THREADSTORAGE_CUSTOM(name, NULL, NULL) + AST_THREADSTORAGE_CUSTOM(name, NULL, ast_free) /*! * \brief Define a thread storage variable, with custom initialization and cleanup * * \arg name The name of the thread storage object - * \arg init This is a custom that will be called after each thread specific + * \arg init This is a custom function that will be called after each thread specific * object is allocated, with the allocated block of memory passed * as the argument. * \arg cleanup This is a custom function that will be called instead of ast_free @@ -127,8 +127,10 @@ void *ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size), if (!(buf = pthread_getspecific(ts->key))) { if (!(buf = ast_calloc(1, init_size))) return NULL; - if (ts->custom_init) - ts->custom_init(buf); + if (ts->custom_init && ts->custom_init(buf)) { + free(buf); + return NULL; + } pthread_setspecific(ts->key, buf); } |