[ofa-general] [PATCH] uDAPL v2: scm: update CM code to shutdown before closing socket
Arlin Davis
arlin.r.davis at intel.com
Fri Jun 12 09:39:44 PDT 2009
connect req/reply data could be lost without calling
shutdown on the socket before closing. Update provider
to shutdown socket before closing. Add definition for
SHUT_RW for windows.
Signed-off-by: Arlin Davis <arlin.r.davis at intel.com>
---
---
dapl/openib_scm/dapl_ib_cm.c | 8 +++++++-
dapl/openib_scm/windows/openib_osd.h | 1 +
2 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/dapl/openib_scm/dapl_ib_cm.c b/dapl/openib_scm/dapl_ib_cm.c
index 9cad5be..db0a25b 100644
--- a/dapl/openib_scm/dapl_ib_cm.c
+++ b/dapl/openib_scm/dapl_ib_cm.c
@@ -261,8 +261,10 @@ static void dapli_cm_destroy(struct ib_cm_handle *cm_ptr)
/* cleanup, never made it to work queue */
if (cm_ptr->state == SCM_INIT) {
- if (cm_ptr->socket != DAPL_INVALID_SOCKET)
+ if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+ shutdown(cm_ptr->socket, SHUT_RDWR);
closesocket(cm_ptr->socket);
+ }
dapl_os_free(cm_ptr, sizeof(*cm_ptr));
return;
}
@@ -274,6 +276,7 @@ static void dapli_cm_destroy(struct ib_cm_handle *cm_ptr)
/* close socket if still active */
if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+ shutdown(cm_ptr->socket, SHUT_RDWR);
closesocket(cm_ptr->socket);
cm_ptr->socket = DAPL_INVALID_SOCKET;
}
@@ -328,6 +331,7 @@ static DAT_RETURN dapli_socket_disconnect(dp_ib_cm_handle_t cm_ptr)
dapl_log(DAPL_DBG_TYPE_WARN,
" cm_disc: write error = %s\n",
strerror(errno));
+ shutdown(cm_ptr->socket, SHUT_RDWR);
closesocket(cm_ptr->socket);
cm_ptr->socket = DAPL_INVALID_SOCKET;
}
@@ -1202,6 +1206,7 @@ dapls_ib_remove_conn_listener(IN DAPL_IA * ia_ptr, IN DAPL_SP * sp_ptr)
/* close accepted socket, free cm_srvc_handle and return */
if (cm_ptr != NULL) {
if (cm_ptr->socket != DAPL_INVALID_SOCKET) {
+ shutdown(cm_ptr->socket, SHUT_RDWR);
closesocket(cm_ptr->socket);
cm_ptr->socket = DAPL_INVALID_SOCKET;
}
@@ -1305,6 +1310,7 @@ dapls_ib_reject_connection(IN dp_ib_cm_handle_t cm_ptr,
writev(cm_ptr->socket, iov, 1);
}
+ shutdown(cm_ptr->socket, SHUT_RDWR);
closesocket(cm_ptr->socket);
cm_ptr->socket = DAPL_INVALID_SOCKET;
}
diff --git a/dapl/openib_scm/windows/openib_osd.h b/dapl/openib_scm/windows/openib_osd.h
index 7eb3df3..9b0f089 100644
--- a/dapl/openib_scm/windows/openib_osd.h
+++ b/dapl/openib_scm/windows/openib_osd.h
@@ -16,6 +16,7 @@
#define DAPL_SOCKET SOCKET
#define DAPL_INVALID_SOCKET INVALID_SOCKET
+#define SHUT_RDWR SD_BOTH
/* allow casting to WSABUF */
struct iovec
--
1.5.2.5
More information about the general
mailing list