rpc: fix gf_process_reserved_ports

this patch also does minor code cleanups.

Change-Id: I0d005bd0f9baaaae498aa1df4faa6fcb65fa7a6e
BUG: 1198849
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed-on: http://review.gluster.org/13997
Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
This commit is contained in:
Prasanna Kumar Kalever 2016-04-26 21:42:23 +05:30 committed by Jeff Darcy
parent 49796290c9
commit 88a386b9c8
3 changed files with 13 additions and 15 deletions

View File

@ -2980,6 +2980,12 @@ int
gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
{
int ret = -1;
int i = 0;
for (i = 0; i < GF_PORT_MAX; i++) {
*(ports + i) = _gf_false;
}
#if defined GF_LINUX_HOST_OS
char *ports_info = NULL;
char *tmp = NULL;
@ -3005,7 +3011,11 @@ gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
out:
GF_FREE (ports_info);
#else /* FIXME: Non Linux Host */
ret = 0;
#endif /* GF_LINUX_HOST_OS */
return ret;
}

View File

@ -56,15 +56,9 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id,
{
int32_t ret = -1;
uint16_t port = ceiling - 1;
/* by default assume none of the ports are blocked and all are available */
gf_boolean_t ports[GF_PORT_MAX] = {_gf_false,};
int i = 0;
gf_boolean_t ports[GF_PORT_MAX];
ret = gf_process_reserved_ports (ports, ceiling);
if (ret != 0) {
for (i = 0; i < GF_PORT_MAX; i++)
ports[i] = _gf_false;
}
while (port) {
/* ignore the reserved ports */

View File

@ -44,19 +44,13 @@ af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr,
{
int32_t ret = -1;
uint16_t port = ceiling - 1;
// by default assume none of the ports are blocked and all are available
gf_boolean_t ports[GF_PORT_MAX] = {_gf_false,};
int i = 0;
gf_boolean_t ports[GF_PORT_MAX];
ret = gf_process_reserved_ports (ports, ceiling);
if (ret != 0) {
for (i = 0; i < GF_PORT_MAX; i++)
ports[i] = _gf_false;
}
while (port)
{
// ignore the reserved ports
/* ignore the reserved ports */
if (ports[port] == _gf_true) {
port--;
continue;