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:
parent
49796290c9
commit
88a386b9c8
@ -2980,6 +2980,12 @@ int
|
|||||||
gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
|
gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < GF_PORT_MAX; i++) {
|
||||||
|
*(ports + i) = _gf_false;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined GF_LINUX_HOST_OS
|
#if defined GF_LINUX_HOST_OS
|
||||||
char *ports_info = NULL;
|
char *ports_info = NULL;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
@ -3005,7 +3011,11 @@ gf_process_reserved_ports (gf_boolean_t *ports, uint32_t ceiling)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
GF_FREE (ports_info);
|
GF_FREE (ports_info);
|
||||||
|
|
||||||
|
#else /* FIXME: Non Linux Host */
|
||||||
|
ret = 0;
|
||||||
#endif /* GF_LINUX_HOST_OS */
|
#endif /* GF_LINUX_HOST_OS */
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,15 +56,9 @@ af_inet_bind_to_port_lt_ceiling (struct rdma_cm_id *cm_id,
|
|||||||
{
|
{
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
uint16_t port = ceiling - 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_boolean_t ports[GF_PORT_MAX] = {_gf_false,};
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
ret = gf_process_reserved_ports (ports, ceiling);
|
ret = gf_process_reserved_ports (ports, ceiling);
|
||||||
if (ret != 0) {
|
|
||||||
for (i = 0; i < GF_PORT_MAX; i++)
|
|
||||||
ports[i] = _gf_false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (port) {
|
while (port) {
|
||||||
/* ignore the reserved ports */
|
/* ignore the reserved ports */
|
||||||
|
@ -44,19 +44,13 @@ af_inet_bind_to_port_lt_ceiling (int fd, struct sockaddr *sockaddr,
|
|||||||
{
|
{
|
||||||
int32_t ret = -1;
|
int32_t ret = -1;
|
||||||
uint16_t port = ceiling - 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_boolean_t ports[GF_PORT_MAX] = {_gf_false,};
|
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
ret = gf_process_reserved_ports (ports, ceiling);
|
ret = gf_process_reserved_ports (ports, ceiling);
|
||||||
if (ret != 0) {
|
|
||||||
for (i = 0; i < GF_PORT_MAX; i++)
|
|
||||||
ports[i] = _gf_false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (port)
|
while (port)
|
||||||
{
|
{
|
||||||
// ignore the reserved ports
|
/* ignore the reserved ports */
|
||||||
if (ports[port] == _gf_true) {
|
if (ports[port] == _gf_true) {
|
||||||
port--;
|
port--;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user