summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-08-14 04:31:38 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-08-15 11:28:31 -0700
commit78814d4a5451b4fbd83fa286a866d6e520f92d74 (patch)
tree6d6f92ad4f02817a9e4f23494cca9771ee295b64 /xlators/mgmt/glusterd
parent57af0c92e351516c4056404ce0f2255c06b3c032 (diff)
portmapper: minor fixes
* in bind, initialize the array index to port * in search, check if brickname is NULL Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1363 (crash is pmap_registry_search()) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1363
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-pmap.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-pmap.c b/xlators/mgmt/glusterd/src/glusterd-pmap.c
index 12e43ca31..b61545345 100644
--- a/xlators/mgmt/glusterd/src/glusterd-pmap.c
+++ b/xlators/mgmt/glusterd/src/glusterd-pmap.c
@@ -57,7 +57,7 @@ pmap_port_isfree (int port)
ret = bind (sock, (struct sockaddr *)&sin, sizeof (sin));
close (sock);
- return ret == 0 ? 1 : 0;
+ return (ret == 0) ? 1 : 0;
}
@@ -113,6 +113,8 @@ pmap_registry_search (xlator_t *this, const char *brickname)
pmap = pmap_registry_get (this);
for (p = pmap->base_port; p < 65535; p++) {
+ if (!pmap->ports[p].brickname)
+ continue;
if (strcmp (pmap->ports[p].brickname, brickname) == 0) {
port = p;
break;
@@ -156,11 +158,16 @@ pmap_registry_bind (xlator_t *this, int port, const char *brickname)
pmap = pmap_registry_get (this);
+ if (port > 65535)
+ goto out;
+
+ p = port;
pmap->ports[p].used = 1;
if (pmap->ports[p].brickname)
free (pmap->ports[p].brickname);
pmap->ports[p].brickname = strdup (brickname);
+out:
return 0;
}
@@ -203,7 +210,9 @@ gluster_pmap_portbybrick (rpcsvc_request_t *req)
port = pmap_registry_search (THIS, brick);
- rsp.op_ret = 0;
+ if (!port)
+ rsp.op_ret = -1;
+
rsp.port = port;
fail: