Proper synchronization for access to destructor hash table
This commit is contained in:
		| @ -765,11 +765,17 @@ bool refcount_context_add_destructor(const RefcountContext *ctx, void *obj, | |||||||
|     } |     } | ||||||
|     entry->callback = callback; |     entry->callback = callback; | ||||||
|     entry->user_data = user_data; |     entry->user_data = user_data; | ||||||
|     if (!ht_insert(ENTRY->destructors, key, entry)) { |     if (!lock_entry_mtx(ENTRY)) { | ||||||
|         refcount_free(&ctx->alloc, entry); |         refcount_free(&ctx->alloc, entry); | ||||||
|         return false; |         return false; | ||||||
|     } |     } | ||||||
|     return true; |     bool success = true; | ||||||
|  |     if (!ht_insert(ENTRY->destructors, key, entry)) { | ||||||
|  |         refcount_free(&ctx->alloc, entry); | ||||||
|  |         success = false; | ||||||
|  |     } | ||||||
|  |     unlock_entry_mtx(ENTRY); | ||||||
|  |     return success; | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @ -782,5 +788,10 @@ bool refcount_context_add_destructor(const RefcountContext *ctx, void *obj, | |||||||
|  */ |  */ | ||||||
| bool refcount_context_remove_destructor(const RefcountContext *ctx, void *obj, | bool refcount_context_remove_destructor(const RefcountContext *ctx, void *obj, | ||||||
|                                         void *key) { |                                         void *key) { | ||||||
|     return ht_remove(ENTRY->destructors, key); |     if (!lock_entry_mtx(ENTRY)) { | ||||||
|  |         return false; | ||||||
|  |     } | ||||||
|  |     bool success = ht_remove(ENTRY->destructors, key); | ||||||
|  |     unlock_entry_mtx(ENTRY); | ||||||
|  |     return success; | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user