Commit 61542b29 authored by penoff's avatar penoff
Browse files

reorder and set port in order to also work with Linux stack when MPICH_SCTP_MULTIHOME_FILE is set

parent d7574d54
......@@ -150,6 +150,19 @@ int sctp_open_dgm_socket2(int num_stream, int block_mode,
goto fn_fail;
}
/* retrieve port value if wasn't specified */
if(!port){
/* Can reuse addr since bind already succeeded. */
len = sizeof(addr);
if (getsockname(*fd, (struct sockaddr *) &addr, &len)) {
goto fn_fail;
}
*real_port = (int) ntohs(addr.sin_port);
port = *real_port;
} else
*real_port = port;
env = getenv("MPICH_SCTP_MULTIHOME_FILE");
if (env != NULL && *env != '\0') {
rc = bind_from_file(env, *fd, port);
......@@ -163,18 +176,6 @@ int sctp_open_dgm_socket2(int num_stream, int block_mode,
goto fn_fail;
}
/* retrieve port value if wasn't specified */
if(!port){
/* Can reuse addr since bind already succeeded. */
len = sizeof(addr);
if (getsockname(*fd, (struct sockaddr *) &addr, &len)) {
goto fn_fail;
}
*real_port = (int) ntohs(addr.sin_port);
} else
*real_port = port;
/* register events */
if (setsockopt(*fd, IPPROTO_SCTP, SCTP_EVENTS, evnts, sizeof(*evnts))) {
perror("setsockopt error SCTP_EVENTS");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment