1
1

Merge pull request #3235 from rhc54/topic/tcp

Stop segfault in BTL/TCP
Этот коммит содержится в:
Ralph Castain 2017-03-24 12:38:31 -07:00 коммит произвёл GitHub
родитель 88a4a163ae 470452cba0
Коммит 6ef079cdab

Просмотреть файл

@ -11,7 +11,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2008-2010 Oracle and/or its affiliates. All rights reserved * Copyright (c) 2008-2010 Oracle and/or its affiliates. All rights reserved
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved * Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
* Copyright (c) 2014-2016 Research Organization for Information Science * Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights * Copyright (c) 2015-2016 Los Alamos National Security, LLC. All rights
@ -828,24 +828,27 @@ void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr
/* No further use of this socket. Close it */ /* No further use of this socket. Close it */
CLOSE_THE_SOCKET(sd); CLOSE_THE_SOCKET(sd);
{ {
size_t len = 1024; char *addr_str=NULL, *tmp, pnet[1024];
char* addr_str = (char*)malloc(len);
if( NULL != addr_str ) {
memset(addr_str, 0, len);
for (size_t i = 0; i < btl_proc->proc_endpoint_count; i++) { for (size_t i = 0; i < btl_proc->proc_endpoint_count; i++) {
mca_btl_base_endpoint_t* btl_endpoint = btl_proc->proc_endpoints[i]; mca_btl_base_endpoint_t* btl_endpoint = btl_proc->proc_endpoints[i];
if (btl_endpoint->endpoint_addr->addr_family != addr->sa_family) { if (btl_endpoint->endpoint_addr->addr_family != addr->sa_family) {
continue; continue;
} }
if (AF_INET == addr->sa_family) {
if (addr_str[0] != '\0') { inet_ntop(AF_INET, (void*)(struct in_addr*)&btl_endpoint->endpoint_addr->addr_inet, pnet, 1024);
strncat(addr_str, ", ", len); } else if (AF_INET6 == addr->sa_family) {
len -= 2; inet_ntop(AF_INET6, (void*)(struct in6_addr*)&btl_endpoint->endpoint_addr->addr_inet, pnet, 1024);
} else {
/* unrecognized family */
continue;
} }
strncat(addr_str, inet_ntop(AF_INET6, (void*)(struct in6_addr*)&btl_endpoint->endpoint_addr->addr_inet, if (NULL == addr_str) {
addr_str + 1024 - len, INET6_ADDRSTRLEN), len); (void)asprintf(&tmp, "\n\t%s", pnet);
len = 1024 - strlen(addr_str); } else {
(void)asprintf(&tmp, "%s\n\t%s", addr_str, pnet);
free(addr_str);
} }
addr_str = tmp;
} }
opal_show_help("help-mpi-btl-tcp.txt", "dropped inbound connection", opal_show_help("help-mpi-btl-tcp.txt", "dropped inbound connection",
true, opal_process_info.nodename, true, opal_process_info.nodename,
@ -853,9 +856,11 @@ void mca_btl_tcp_proc_accept(mca_btl_tcp_proc_t* btl_proc, struct sockaddr* addr
btl_proc->proc_opal->proc_hostname, btl_proc->proc_opal->proc_hostname,
OPAL_NAME_PRINT(btl_proc->proc_opal->proc_name), OPAL_NAME_PRINT(btl_proc->proc_opal->proc_name),
opal_net_get_hostname((struct sockaddr*)addr), opal_net_get_hostname((struct sockaddr*)addr),
addr_str); (NULL == addr_str) ? "NONE" : addr_str);
if (NULL != addr_str) {
free(addr_str); free(addr_str);
} }
}
OPAL_THREAD_UNLOCK(&btl_proc->proc_lock); OPAL_THREAD_UNLOCK(&btl_proc->proc_lock);
} }