Commit 2b703026 authored by Mark Andrews's avatar Mark Andrews
Browse files

check isc_mutext_init and destoy mutex when done

parent d3347bd0
......@@ -77,12 +77,14 @@ dns_badcache_init(isc_mem_t *mctx, unsigned int size, dns_badcache_t **bcp) {
memset(bc, 0, sizeof(dns_badcache_t));
isc_mem_attach(mctx, &bc->mctx);
isc_mutex_init(&bc->lock);
result = isc_mutex_init(&bc->lock);
if (result != ISC_R_SUCCESS)
goto cleanup;
bc->table = isc_mem_get(bc->mctx, sizeof(*bc->table) * size);
if (bc->table == NULL) {
result = ISC_R_NOMEMORY;
goto cleanup;
goto destroy_lock;
}
bc->size = bc->minsize = size;
......@@ -95,6 +97,8 @@ dns_badcache_init(isc_mem_t *mctx, unsigned int size, dns_badcache_t **bcp) {
*bcp = bc;
return (ISC_R_SUCCESS);
destroy_lock:
DESTROYLOCK(&bc->lock);
cleanup:
isc_mem_putanddetach(&bc->mctx, bc, sizeof(dns_badcache_t));
return (result);
......@@ -110,6 +114,7 @@ dns_badcache_destroy(dns_badcache_t **bcp) {
dns_badcache_flush(bc);
bc->magic = 0;
DESTROYLOCK(&bc->lock);
isc_mem_put(bc->mctx, bc->table, sizeof(dns_bcentry_t *) * bc->size);
isc_mem_putanddetach(&bc->mctx, bc, sizeof(dns_badcache_t));
*bcp = NULL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment