From 3d0953aa99eed434a1977de3131b264c48fca64b Mon Sep 17 00:00:00 2001 From: Prasanna Kumar Kalever Date: Mon, 18 Sep 2017 19:49:10 +0530 Subject: rpc: switch to MT-safe block RPC routines blockResponse * block_delete_1(blockDelete *argp, CLIENT *clnt) { static blockResponse clnt_res; <<<<<<-------- Same memory is used by everyone memset((char *)&clnt_res, 0, sizeof(clnt_res)); <<<<<---- Here memset is happening if (clnt_call (clnt, BLOCK_DELETE, (xdrproc_t) xdr_blockDelete, (caddr_t) argp, (xdrproc_t) xdr_blockResponse, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); <<<<<---- ptr to this memory is returned. } So while Thread-1 is returned "return (&clnt_res);" another thread could be doing "memset((char *)&clnt_res, 0, sizeof(clnt_res));" This seem to be a day-1 gluster-blockd bug from the looks of it. Change-Id: I3fc76d7814c4fe5b286577586ec44d752dcc73f0 Signed-off-by: Prasanna Kumar Kalever Signed-off-by: Pranith Kumar K --- utils/utils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'utils/utils.h') diff --git a/utils/utils.h b/utils/utils.h index d3b1027..ce1ef52 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -278,6 +278,18 @@ extern struct gbConf gbConf; GB_FREE(tmp); \ } while (0) +# define GB_RPC_CALL(op, blk, reply, rqstp, ret) \ + do { \ + blockResponse *resp = block_##op##_1_svc_st(blk, rqstp); \ + if (resp) { \ + memcpy(reply, resp, sizeof(*reply)); \ + GB_FREE(resp); \ + ret = true; \ + } else { \ + ret = false; \ + } \ + } while (0) + # define CALLOC(x) \ calloc(1, x) -- cgit