Skip to content

Commit

Permalink
Lock for user data since serialize locks objects when reading it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerilk committed Nov 7, 2023
1 parent e6ef739 commit 5d92a92
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cconfigspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ ccs_object_set_user_data(ccs_object_t object, void *user_data)
{
CCS_CHECK_BASE_OBJ(object);
_ccs_object_internal_t *obj = (_ccs_object_internal_t *)object;
CCS_ATOMIC_STORE(obj->user_data, user_data);
CCS_RWLOCK_WRLOCK(obj->lock);
obj->user_data = user_data;
CCS_RWLOCK_UNLOCK(obj->lock);
return CCS_RESULT_SUCCESS;
}

Expand All @@ -165,7 +167,9 @@ ccs_object_get_user_data(ccs_object_t object, void **user_data_ret)
CCS_CHECK_BASE_OBJ(object);
CCS_CHECK_PTR(user_data_ret);
_ccs_object_internal_t *obj = (_ccs_object_internal_t *)object;
*user_data_ret = CCS_ATOMIC_LOAD(obj->user_data);
CCS_RWLOCK_RDLOCK(obj->lock);
*user_data_ret = obj->user_data;
CCS_RWLOCK_UNLOCK(obj->lock);
return CCS_RESULT_SUCCESS;
}

Expand Down

0 comments on commit 5d92a92

Please sign in to comment.