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
This commit is contained in:
Joshua Colp
2015-12-14 14:04:15 -04:00
parent 280adca0a5
commit a9d6fc571d
10 changed files with 49 additions and 39 deletions

View File

@@ -852,10 +852,10 @@ static void publish_reload_message(const char *name, enum ast_module_reload_resu
event_object = ast_json_pack("{s: s, s: s}",
"Module", S_OR(name, "All"),
"Status", res_buffer);
json_object = ast_json_pack("{s: s, s: i, s: O}",
json_object = ast_json_pack("{s: s, s: i, s: o}",
"type", "Reload",
"class_type", EVENT_FLAG_SYSTEM,
"event", event_object);
"event", ast_json_ref(event_object));
if (!json_object) {
return;