mtev_json_object ref counting should be atomic
rileyberton opened this issue · 0 comments
rileyberton commented
extern struct mtev_json_object* mtev_json_object_get(struct mtev_json_object *jso)
{
if(jso) {
jso->_ref_count++;
}
return jso;
}
extern void mtev_json_object_put(struct mtev_json_object *jso)
{
if(jso) {
jso->_ref_count--;
if(!jso->_ref_count) jso->_delete(jso);
}
}
Object shared among many threads, get/put pattern results in a bad ref count and either a leak or a crash when jso
is freed while there are still references to it.
Ref counting should probably be atomic (ck_pr_inc/dec_64
or similar)