summaryrefslogtreecommitdiff
path: root/res/res_stasis.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2015-12-14 14:04:15 -0400
committerJoshua Colp <jcolp@digium.com>2015-12-16 15:21:14 -0600
commitd17d9a92886429b185b7bc2e02e429fc43d39652 (patch)
tree689dceca969ae2a0e0b1bcc7074784f5eb98cb34 /res/res_stasis.c
parent093f14d7f3e6a84fc2e6baf2ff950a915e9f91d8 (diff)
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
Diffstat (limited to 'res/res_stasis.c')
-rw-r--r--res/res_stasis.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/res/res_stasis.c b/res/res_stasis.c
index abca895ee..63c565d44 100644
--- a/res/res_stasis.c
+++ b/res/res_stasis.c
@@ -150,10 +150,10 @@ static struct ast_json *stasis_start_to_json(struct stasis_message *message,
return NULL;
}
- msg = ast_json_pack("{s: s, s: O, s: O, s: o}",
+ msg = ast_json_pack("{s: s, s: o, s: o, s: o}",
"type", "StasisStart",
- "timestamp", ast_json_object_get(payload->blob, "timestamp"),
- "args", ast_json_object_get(payload->blob, "args"),
+ "timestamp", ast_json_copy(ast_json_object_get(payload->blob, "timestamp")),
+ "args", ast_json_deep_copy(ast_json_object_get(payload->blob, "args")),
"channel", ast_channel_snapshot_to_json(payload->channel, NULL));
if (!msg) {
ast_log(LOG_ERROR, "Failed to pack JSON for StasisStart message\n");