Skip to content

Commit 4957a66

Browse files
authored
Merge pull request #5822 from jsquyres/pr/v3.1.x/fix-tcp-btl-show-help-ip-address
v3.1.x: btl/tcp: output the IP address correctly
2 parents 2c80256 + c8e2395 commit 4957a66

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

opal/mca/btl/tcp/btl_tcp_proc.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -871,17 +871,22 @@ void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr
871871
/* No further use of this socket. Close it */
872872
CLOSE_THE_SOCKET(sd);
873873
{
874-
char *addr_str = NULL, *tmp, *pnet;
874+
char *addr_str = NULL, *tmp;
875+
char ip[128];
876+
ip[sizeof(ip) - 1] = '\0';
877+
875878
for (size_t i = 0; i < btl_proc->proc_endpoint_count; i++) {
876879
mca_btl_base_endpoint_t* btl_endpoint = btl_proc->proc_endpoints[i];
877880
if (btl_endpoint->endpoint_addr->addr_family != addr->sa_family) {
878881
continue;
879882
}
880-
pnet = opal_net_get_hostname((struct sockaddr*)&btl_endpoint->endpoint_addr->addr_inet);
883+
inet_ntop(btl_endpoint->endpoint_addr->addr_family,
884+
(void*) &(btl_endpoint->endpoint_addr->addr_inet),
885+
ip, sizeof(ip) - 1);
881886
if (NULL == addr_str) {
882-
(void)asprintf(&tmp, "\n\t%s", pnet);
887+
(void)asprintf(&tmp, "\n\t%s", ip);
883888
} else {
884-
(void)asprintf(&tmp, "%s\n\t%s", addr_str, pnet);
889+
(void)asprintf(&tmp, "%s\n\t%s", addr_str, ip);
885890
free(addr_str);
886891
}
887892
addr_str = tmp;

0 commit comments

Comments
 (0)