From d17d9a92886429b185b7bc2e02e429fc43d39652 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Mon, 14 Dec 2015 14:04:15 -0400 Subject: json: Audit ast_json_* usage for thread safety. The JSON library Asterisk uses, jansson, is not thread safe for us in a few ways. To help with this wrappers for JSON object reference count increasing and decreasing were added which use a global lock to ensure they don't clobber over each other. This does not extend to reference count manipulation within the jansson library itself. This means you can't safely use the object borrowing specifier (O) in ast_json_pack and you can't share JSON instances between objects. This change removes uses of the O specifier and replaces them with the o specifier and an explicit ast_json_ref. Some cases of instance sharing have also been removed. ASTERISK-25601 #close Change-Id: I06550d8b0cc1bfeb56cab580a4e608ae4f1ec7d1 --- main/stasis.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'main/stasis.c') diff --git a/main/stasis.c b/main/stasis.c index e168ce93b..fe940d351 100644 --- a/main/stasis.c +++ b/main/stasis.c @@ -1274,8 +1274,8 @@ static struct ast_json *multi_user_event_to_json( ast_json_object_set(out, "type", ast_json_string_create("ChannelUserevent")); ast_json_object_set(out, "timestamp", ast_json_timeval(*tv, NULL)); - ast_json_object_set(out, "eventname", ast_json_ref(ast_json_object_get(blob, "eventname"))); - ast_json_object_set(out, "userevent", ast_json_ref(blob)); /* eventname gets duplicated, that's ok */ + ast_json_object_set(out, "eventname", ast_json_string_create(ast_json_string_get((ast_json_object_get(blob, "eventname"))))); + ast_json_object_set(out, "userevent", ast_json_deep_copy(blob)); for (type = 0; type < STASIS_UMOS_MAX; ++type) { for (i = 0; i < AST_VECTOR_SIZE(&multi->snapshots[type]); ++i) { -- cgit v1.2.3