summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib
diff options
context:
space:
mode:
authorSantosh Kumar Pradhan <spradhan@redhat.com>2014-01-02 20:55:59 +0530
committerVijay Bellur <vbellur@redhat.com>2014-01-03 22:17:35 -0800
commit825b976ee30a53e89fe747b4a3ba8f2eb862047c (patch)
tree6afaffa74e6411dc9fb448456cc920dd95ba7871 /rpc/rpc-lib
parent311e3868bfdb3f2c1535d5a7cb8f759195457612 (diff)
gNFS: Small memory leak in rpcsvc_drc_init()
1. The routine rpcsvc_drc_init() is only used while initialization of NFS xlator. It should just check for nfs.drc option and init DRC feature accordingly. If it's set to OFF, then rpcsvc_drc_init() allocates memory for svc.drc and set ret value to 0 and goes to out: block where drc is leaked. 2. rpcsvc_drc_init() should just allocate svc.drc and init it. Here svc.drc can never be valid. 3. If svc.drc gets init'd here, no point of checking for drc type here. Change-Id: I4085771cdb8c9c15d1b9c548b77929a37f27c124 BUG: 1047902 Signed-off-by: Santosh Kumar Pradhan <spradhan@redhat.com> Reviewed-on: http://review.gluster.org/6628 Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'rpc/rpc-lib')
-rw-r--r--rpc/rpc-lib/src/rpc-drc.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/rpc/rpc-lib/src/rpc-drc.c b/rpc/rpc-lib/src/rpc-drc.c
index e7ba114dd..7e77e038e 100644
--- a/rpc/rpc-lib/src/rpc-drc.c
+++ b/rpc/rpc-lib/src/rpc-drc.c
@@ -712,38 +712,30 @@ rpcsvc_drc_init (rpcsvc_t *svc, dict_t *options)
GF_ASSERT (svc);
GF_ASSERT (options);
- if (!svc->drc) {
- drc = GF_CALLOC (1, sizeof (rpcsvc_drc_globals_t),
- gf_common_mt_drc_globals_t);
- if (!drc)
- return -1;
-
- svc->drc = drc;
- LOCK_INIT (&drc->lock);
- } else {
- drc = svc->drc;
- }
-
- LOCK (&drc->lock);
- if (drc->type != DRC_TYPE_NONE) {
- ret = 0;
- goto out;
- }
-
/* Toggle DRC on/off, when more drc types(persistent/cluster)
are added, we shouldn't treat this as boolean */
ret = dict_get_str_boolean (options, "nfs.drc", _gf_true);
if (ret == -1) {
- gf_log (GF_RPCSVC, GF_LOG_INFO, "drc user options need second look");
+ gf_log (GF_RPCSVC, GF_LOG_INFO,
+ "drc user options need second look");
ret = _gf_true;
}
- if (ret == _gf_false) {
- /* drc off */
- gf_log (GF_RPCSVC, GF_LOG_INFO, "DRC is manually turned OFF");
- ret = 0;
- goto out;
- }
+ gf_log (GF_RPCSVC, GF_LOG_INFO, "DRC is turned %s", (ret?"ON":"OFF"));
+
+ /*DRC off, nothing to do */
+ if (ret == _gf_false)
+ return (0);
+
+ drc = GF_CALLOC (1, sizeof (rpcsvc_drc_globals_t),
+ gf_common_mt_drc_globals_t);
+ if (!drc)
+ return (-1);
+
+ LOCK_INIT (&drc->lock);
+ svc->drc = drc;
+
+ LOCK (&drc->lock);
/* Specify type of DRC to be used */
ret = dict_get_uint32 (options, "nfs.drc-type", &drc_type);