The dapl connect call takes as input an address (sockaddr) and a port number as separate input parameters. It modifies the sockaddr address to set the port number before trying to connect. This leads to a situation in dapltest with multiple threads that reference the same buffer for their address, but specify different port numbers, where the different threads end up trying to connect to the same remote port.
To solve this, do not modify the caller's address buffer and instead use a local buffer. This fixes an issue seen running multithreaded tests with dapltest. Signed-off-by: Sean Hefty <[email protected]> --- dapl/openib_scm/dapl_ib_cm.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dapl/openib_scm/dapl_ib_cm.c b/dapl/openib_scm/dapl_ib_cm.c index 88e65e7..6db2b4a 100644 --- a/dapl/openib_scm/dapl_ib_cm.c +++ b/dapl/openib_scm/dapl_ib_cm.c @@ -436,6 +436,7 @@ dapli_socket_connect(DAPL_EP *ep_ptr, dp_ib_cm_handle_t cm_ptr; int ret; DAPL_IA *ia_ptr = ep_ptr->header.owner_ia; + struct sockaddr_in addr; dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: r_qual %d p_size=%d\n", r_qual,p_size); @@ -458,14 +459,15 @@ dapli_socket_connect(DAPL_EP *ep_ptr, goto bail; } - ((struct sockaddr_in*)r_addr)->sin_port = htons(r_qual); - ret = dapl_connect_socket(cm_ptr->socket, (struct sockaddr *) r_addr, - sizeof(*r_addr)); + dapl_os_memcpy(&addr, r_addr, sizeof(addr)); + addr.sin_port = htons(r_qual); + ret = dapl_connect_socket(cm_ptr->socket, (struct sockaddr *) &addr, + sizeof(addr)); if (ret && ret != EAGAIN) { dapl_log(DAPL_DBG_TYPE_ERR, " socket connect ERROR: %s -> %s r_qual %d\n", strerror(errno), - inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr), + inet_ntoa(addr.sin_addr), (unsigned int)r_qual); dapli_cm_destroy(cm_ptr); return DAT_INVALID_ADDRESS; @@ -498,7 +500,7 @@ dapli_socket_connect(DAPL_EP *ep_ptr, dapl_dbg_log(DAPL_DBG_TYPE_EP, " connect: socket %d to %s r_qual %d pending\n", cm_ptr->socket, - inet_ntoa(((struct sockaddr_in *)r_addr)->sin_addr), + inet_ntoa(addr.sin_addr), (unsigned int)r_qual); dapli_cm_queue(cm_ptr); -- 1.5.2.5 _______________________________________________ general mailing list [email protected] http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general To unsubscribe, please visit http://openib.org/mailman/listinfo/openib-general
