>From 510492a32b6427d265b812b3923de5910d96d310 Mon Sep 17 00:00:00 2001 From: Malahal Naineni <mala...@us.ibm.com> Date: Sat, 17 Oct 2015 08:29:26 -0500 Subject: [PATCH] Call destroy on mutexes and condition variables
We should destroy them before freeing the memory. Supresses valgrind errors. --- src/clnt_vc.c | 3 +++ src/rpc_ctx.c | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/clnt_vc.c b/src/clnt_vc.c index 4c614d1..c893605 100644 --- a/src/clnt_vc.c +++ b/src/clnt_vc.c @@ -316,6 +316,7 @@ clnt_vc_ncreate2(int fd, /* open file descriptor */ if (cs) { mem_free(cs, sizeof(struct ct_serialized)); } + mutex_destroy(&clnt->cl_lock); mem_free(clnt, sizeof(CLIENT)); } if (rec) { @@ -800,6 +801,7 @@ clnt_vc_release(CLIENT *clnt, u_int flags) mem_free(clnt->cl_netid, strlen(clnt->cl_netid) + 1); if (clnt->cl_tp && clnt->cl_tp[0]) mem_free(clnt->cl_tp, strlen(clnt->cl_tp) + 1); + mutex_destroy(&clnt->cl_lock); mem_free(clnt, sizeof(CLIENT)); REC_LOCK(rec); @@ -861,6 +863,7 @@ clnt_vc_destroy(CLIENT *clnt) mem_free(clnt->cl_netid, strlen(clnt->cl_netid) + 1); if (clnt->cl_tp && clnt->cl_tp[0]) mem_free(clnt->cl_tp, strlen(clnt->cl_tp) + 1); + mutex_destroy(&clnt->cl_lock); mem_free(clnt, sizeof(CLIENT)); if (xd_refcnt == 0) { diff --git a/src/rpc_ctx.c b/src/rpc_ctx.c index 3590422..6c99927 100644 --- a/src/rpc_ctx.c +++ b/src/rpc_ctx.c @@ -85,6 +85,8 @@ alloc_rpc_call_ctx(CLIENT *clnt, rpcproc_t proc, xdrproc_t xdr_args, "%s: call ctx insert failed (xid %d client %p)", __func__, ctx->xid, clnt); REC_UNLOCK(rec); + mutex_destroy(&ctx->we.mtx); + cond_destroy(&ctx->we.cv); mem_free(ctx, sizeof(rpc_ctx_t)); ctx = NULL; goto out; @@ -248,5 +250,7 @@ free_rpc_call_ctx(rpc_ctx_t *ctx, uint32_t flags) if (ctx->msg) free_rpc_msg(ctx->msg); + mutex_destroy(&ctx->we.mtx); + cond_destroy(&ctx->we.cv); mem_free(ctx, sizeof(rpc_ctx_t)); } -- 1.8.3.1 ------------------------------------------------------------------------------ _______________________________________________ Nfs-ganesha-devel mailing list Nfs-ganesha-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/nfs-ganesha-devel