mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 07:35:18 +00:00
Address JSON thread safety issues.
In tracking down some unit tests failures, I ended up reading the fine print[1] regarding Jansson's thread safety. In short: 1. Ref-counting is non-atomic. 2. json_dumps() and friends are not thread safe. This patch adds locking where necessary to our ast_json_* wrapper API, with documentation in json.h describing the thread safety limitations of the API. [1]: http://www.digip.org/jansson/doc/2.4/portability.html#thread-safety Review: https://reviewboard.asterisk.org/r/2716/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396119 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -55,7 +55,7 @@ static size_t alloc_count;
|
||||
*/
|
||||
static void *json_debug_malloc(size_t size)
|
||||
{
|
||||
void *p = ast_malloc(size);
|
||||
void *p = ast_json_malloc(size);
|
||||
if (p) {
|
||||
++alloc_count;
|
||||
}
|
||||
@@ -67,7 +67,7 @@ static void json_debug_free(void *p)
|
||||
if (p) {
|
||||
--alloc_count;
|
||||
}
|
||||
ast_free(p);
|
||||
ast_json_free(p);
|
||||
}
|
||||
|
||||
static int json_test_init(struct ast_test_info *info, struct ast_test *test)
|
||||
|
Reference in New Issue
Block a user