[WSD] Rework connection establishment/tear down
authorftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 27 Sep 2005 00:57:44 +0000 (00:57 +0000)
committerftillier <ftillier@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Tue, 27 Sep 2005 00:57:44 +0000 (00:57 +0000)
- Split IBSPAccept into two functions, one to check if connection should be
accepted, the other to actually accept the connection.
- Moved MRA into CF_DEFER case in IBSPAccept.
- Fixed IBSPAccept error case flow to properly cleanup.
- Moved allocation of incoming connection request to listen case only.
- Don't wait for RTU in IBSPAccept, continue optimistically assuming we'll
get the RTU.  If we get a REJ, we'll tear down the socket and report an error.
- Close the switch socket from within IBSPAccept (or IBSPSocket for
duplication) before destroying the QP to prevent the QP destroy callback from
invoking the upcall to destroy the socket.
- Reduce lock contention and thrashing during socket cleanup/disconnection.

Signed-off-by: Fab Tillier (ftillier@silverstorm.com)
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@97 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

ulp/wsd/user/ib_cm.c
ulp/wsd/user/ibsp_iblow.c
ulp/wsd/user/ibspdll.c
ulp/wsd/user/ibspstruct.h
ulp/wsd/user/misc.c

index 08e1f5a..7c28c0b 100644 (file)
@@ -110,28 +110,12 @@ cm_req_callback(
        struct ibsp_socket_info *socket_info =\r
                (struct ibsp_socket_info * __ptr64)p_cm_req_rec->context;\r
        struct listen_incoming *incoming;\r
-       ib_cm_mra_t             mra;\r
 \r
        IBSP_ENTER( IBSP_DBG_CM );\r
 \r
        CL_ASSERT( socket_info );\r
        CL_ASSERT( p_cm_req_rec->p_req_pdata );\r
 \r
-       incoming = HeapAlloc( g_ibsp.heap, 0, sizeof(struct listen_incoming) );\r
-       if( !incoming )\r
-       {\r
-               /* Low on memory. */\r
-               IBSP_ERROR( ("HeapAlloc failed, rejecting\n") );\r
-               ib_reject( p_cm_req_rec->h_cm_req, IB_REJ_INSUF_RESOURCES );\r
-               IBSP_EXIT( IBSP_DBG_CM );\r
-               return;\r
-       }\r
-\r
-       incoming->cm_req_received = *p_cm_req_rec;\r
-       cl_memcpy( &incoming->params, p_cm_req_rec->p_req_pdata,\r
-               sizeof(struct cm_req_params) );\r
-       incoming->cm_req_received.p_req_pdata = (const uint8_t*)&incoming->params;\r
-\r
        cl_spinlock_acquire( &socket_info->mutex );\r
 \r
        switch( socket_info->socket_state )\r
@@ -143,20 +127,28 @@ cm_req_callback(
                        /* Already too many connection requests are queued */\r
                        IBSP_TRACE1( IBSP_DBG_CM,\r
                                ("already too many incoming connections, rejecting\n") );\r
-                       HeapFree( g_ibsp.heap, 0, incoming );\r
                        ib_reject( p_cm_req_rec->h_cm_req, IB_REJ_USER_DEFINED );\r
                        break;\r
                }\r
 \r
+               incoming = HeapAlloc( g_ibsp.heap, 0, sizeof(struct listen_incoming) );\r
+               if( !incoming )\r
+               {\r
+                       /* Low on memory. */\r
+                       IBSP_ERROR( ("HeapAlloc failed, rejecting\n") );\r
+                       ib_reject( p_cm_req_rec->h_cm_req, IB_REJ_INSUF_RESOURCES );\r
+                       IBSP_EXIT( IBSP_DBG_CM );\r
+                       return;\r
+               }\r
+\r
+               incoming->cm_req_received = *p_cm_req_rec;\r
+               cl_memcpy( &incoming->params, p_cm_req_rec->p_req_pdata,\r
+                       sizeof(struct cm_req_params) );\r
+               incoming->cm_req_received.p_req_pdata = (const uint8_t*)&incoming->params;\r
+\r
                /* Add to the waiting list */\r
                cl_qlist_insert_tail( &socket_info->listen.list, &incoming->item );\r
 \r
-               /* Send MRA */\r
-               mra.mra_length = 0;\r
-               mra.p_mra_pdata = NULL;\r
-               mra.svc_timeout = 0x15;\r
-               ib_cm_mra( p_cm_req_rec->h_cm_req, &mra );\r
-\r
                ibsp_post_select_event( socket_info, FD_ACCEPT, 0 );\r
                break;\r
 \r
@@ -164,23 +156,12 @@ cm_req_callback(
                {\r
                        int ret;\r
 \r
-                       HeapFree( g_ibsp.heap, 0, incoming );\r
-\r
                        wait_cq_drain( socket_info );\r
 \r
                        /* Non-blocking cancel since we're in CM callback context */\r
                        ib_cm_cancel( socket_info->listen.handle, NULL );\r
                        socket_info->listen.handle = NULL;\r
 \r
-#if 0\r
-                       cl_spinlock_release( &socket_info->mutex );\r
-                       IBSP_ERROR_EXIT( ("rejecting\n") );\r
-                       ib_reject( p_cm_req_rec->h_cm_req, IB_REJ_USER_DEFINED );\r
-                       ibsp_dup_overlap_abort( socket_info );\r
-                       return;\r
-#endif\r
-\r
-\r
                        ret = ib_accept( socket_info, p_cm_req_rec );\r
                        if( ret )\r
                        {\r
@@ -200,7 +181,6 @@ cm_req_callback(
 \r
        default:\r
                IBSP_ERROR( ("socket is not listening anymore\n") );\r
-               HeapFree( g_ibsp.heap, 0, incoming );\r
                /* We're closing down - let some other listen match. */\r
                ib_reject( p_cm_req_rec->h_cm_req, IB_REJ_INVALID_SID );\r
                break;\r
@@ -310,12 +290,7 @@ cm_rtu_callback(
 \r
        cl_spinlock_acquire( &socket_info->mutex );\r
 \r
-       if( socket_info->socket_state == IBSP_ACCEPT )\r
-       {\r
-               IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CONNECTED );\r
-               SetEvent( socket_info->h_event );\r
-       }\r
-       else if( socket_info->socket_state == IBSP_DUPLICATING_REMOTE )\r
+       if( socket_info->socket_state == IBSP_DUPLICATING_REMOTE )\r
        {\r
                struct _recv_wr         *wr;\r
                ib_api_status_t         status;\r
@@ -397,7 +372,7 @@ cm_rtu_callback(
                socket_info->qp_error = 0;\r
                IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CONNECTED );\r
        }\r
-       else\r
+       else if( socket_info->socket_state != IBSP_CONNECTED )\r
        {\r
                /* The Socket might be closing */\r
                IBSP_ERROR(\r
@@ -411,6 +386,26 @@ cm_rtu_callback(
 }\r
 \r
 \r
+/* Force the QP to error state to flush posted work requests. */\r
+static inline void\r
+__flush_qp(\r
+       IN                              struct ibsp_socket_info         *p_socket )\r
+{\r
+       ib_qp_mod_t                     qp_mod;\r
+       ib_api_status_t         status;\r
+\r
+       memset( &qp_mod, 0, sizeof(qp_mod) );\r
+       qp_mod.req_state = IB_QPS_ERROR;\r
+       status = ib_modify_qp( p_socket->qp, &qp_mod );\r
+       if( status != IB_SUCCESS )\r
+       {\r
+               IBSP_ERROR( ("ib_modify_qp returned %s\n", ib_get_err_str( status )) );\r
+               p_socket->send_cnt = 0;\r
+               p_socket->recv_cnt = 0;\r
+       }\r
+}\r
+\r
+\r
 /*\r
  * A user-specified callback that is invoked after receiving a connection\r
  * rejection message (REJ).\r
@@ -442,12 +437,17 @@ cm_rej_callback(
                        ibsp_post_select_event( socket_info, FD_CONNECT, WSAECONNREFUSED );\r
                break;\r
 \r
-       case IBSP_ACCEPT:\r
-               /* Remove from connection map. */\r
-               ibsp_conn_remove( socket_info );\r
+       case IBSP_CONNECTED:\r
+               /*\r
+                * DISCONNECTED is a terminal state.  We'll remove the connection\r
+                * when the socket gets destroyed.\r
+                */\r
+               IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DISCONNECTED );\r
 \r
-               IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_CREATE );\r
-               /* Fall through. */\r
+               socket_info->qp_error = WSAECONNABORTED;\r
+\r
+               __flush_qp( socket_info );\r
+               break;\r
 \r
        case IBSP_DUPLICATING_NEW:\r
                /* Leave in that state. IBSPSocket will eventually return \r
@@ -541,8 +541,10 @@ cm_dreq_callback(
                default:\r
                        /* Right now, treat anything as a normal disconnect. */\r
                        IBSP_CHANGE_SOCKET_STATE( socket_info, IBSP_DISCONNECTED );\r
-                       /* We changed the state - remove from connection map. */\r
-                       ibsp_conn_remove( socket_info );\r
+                       /*\r
+                        * DISCONNECTED is a terminal state.  We'll remove the connection\r
+                        * when the socket gets destroyed.\r
+                        */\r
                        socket_info->qp_error = WSAECONNRESET;\r
                }\r
 \r
@@ -934,7 +936,6 @@ ib_disconnect(
 {\r
        ib_api_status_t         status;\r
        ib_cm_dreq_t            cm_dreq;\r
-       ib_qp_mod_t                     qp_mod;\r
 \r
        IBSP_ENTER( IBSP_DBG_CM );\r
 \r
@@ -967,16 +968,8 @@ ib_disconnect(
         * interrupt transfers.\r
         */\r
 \r
-       /* Force the QP to error state to flush posted receives. */\r
-       memset( &qp_mod, 0, sizeof(qp_mod) );\r
-       qp_mod.req_state = IB_QPS_ERROR;\r
-       status = ib_modify_qp( socket_info->qp, &qp_mod );\r
-       if( status != IB_SUCCESS )\r
-       {\r
-               IBSP_ERROR( ("ib_modify_qp returned %s\n", ib_get_err_str( status )) );\r
-               socket_info->send_cnt = 0;\r
-               socket_info->recv_cnt = 0;\r
-       }\r
+       /* Move the QP to error to flush any work requests. */\r
+       __flush_qp( socket_info );\r
 \r
        IBSP_EXIT( IBSP_DBG_CM );\r
 }\r
index 1acd063..0091137 100644 (file)
@@ -1094,40 +1094,34 @@ shutdown_and_destroy_socket_info(
                ib_listen_cancel( socket_info );\r
        }\r
 \r
+       cl_spinlock_acquire( &g_ibsp.socket_info_mutex );\r
+       cl_qlist_remove_item( &g_ibsp.socket_info_list, &socket_info->item );\r
+\r
        switch( old_state )\r
        {\r
        case IBSP_CREATE:\r
-               /* Nothing to do. */\r
-               break;\r
-\r
-       case IBSP_CONNECT:\r
-               ibsp_conn_remove( socket_info );\r
-               break;\r
-\r
-       case IBSP_ACCEPT:\r
-               ibsp_conn_remove( socket_info );\r
-               break;\r
-\r
        case IBSP_LISTEN:\r
+               /* Nothing to do. */\r
                break;\r
 \r
        case IBSP_CONNECTED:\r
                {\r
                        struct disconnect_reason reason;\r
 \r
-                       /* We changed the state - remove from connection map. */\r
-                       ibsp_conn_remove( socket_info );\r
-\r
                        memset( &reason, 0, sizeof(reason) );\r
                        reason.type = DISC_SHUTDOWN;\r
                        ib_disconnect( socket_info, &reason );\r
                }\r
-               break;\r
+               /* Fall through. */\r
 \r
+       case IBSP_CONNECT:\r
        case IBSP_DISCONNECTED:\r
-               /* Nothing to do. */\r
+               /* We changed the state - remove from connection map. */\r
+               CL_ASSERT( socket_info->conn_item.p_map );\r
+               cl_rbmap_remove_item( &g_ibsp.conn_map, &socket_info->conn_item );\r
                break;\r
        }\r
+       cl_spinlock_release( &g_ibsp.socket_info_mutex );\r
 \r
        /* Flush all completions. */\r
        if( socket_info->dup_cnt )\r
index e7bf41b..23a14d9 100644 (file)
@@ -221,6 +221,94 @@ DllMain(
 }\r
 \r
 \r
+static SOCKET\r
+accept_socket(\r
+       IN                              struct ibsp_socket_info         *p_socket,\r
+       IN                              struct listen_incoming          *p_incoming,\r
+       IN                              struct ibsp_port                        *p_port,\r
+               OUT                     LPINT                                           lpErrno )\r
+{\r
+       struct ibsp_socket_info *new_socket_info;\r
+       int ret;\r
+\r
+       IBSP_ENTER( IBSP_DBG_CONN );\r
+\r
+       /* Create a new socket here  */\r
+       new_socket_info = create_socket_info( lpErrno );\r
+       if( !new_socket_info )\r
+       {\r
+               ib_reject(\r
+                       p_incoming->cm_req_received.h_cm_req, IB_REJ_INSUF_RESOURCES );\r
+\r
+               IBSP_ERROR_EXIT( ("create_socket_info failed (%d)\n", *lpErrno) );\r
+               return INVALID_SOCKET;\r
+       }\r
+\r
+       /* Time to allocate our IB QP */\r
+       new_socket_info->port = p_port;\r
+       *lpErrno = ib_create_socket( new_socket_info );\r
+       if( *lpErrno )\r
+       {\r
+               deref_socket_info( new_socket_info );\r
+\r
+               ib_reject(\r
+                       p_incoming->cm_req_received.h_cm_req, IB_REJ_INSUF_QP );\r
+\r
+               IBSP_ERROR_EXIT( ("ib_create_socket failed (%d)\n", *lpErrno) );\r
+               return INVALID_SOCKET;\r
+       }\r
+\r
+       /* Store the IP address and port number in the socket context */\r
+       new_socket_info->local_addr = p_incoming->params.dest;\r
+\r
+       /* Copy the socket context info from parent socket context */\r
+       new_socket_info->socket_options = p_socket->socket_options;\r
+\r
+       IBSP_TRACE( IBSP_DBG_CONN,\r
+               ("The socket address of connecting entity is\n") );\r
+       DebugPrintSockAddr( IBSP_DBG_CONN, gdbg_lvl, &p_incoming->params.source );\r
+\r
+       new_socket_info->peer_addr = p_incoming->params.source;\r
+\r
+       cl_spinlock_acquire( &new_socket_info->mutex );\r
+       /* Update the state of the socket context */\r
+       IBSP_CHANGE_SOCKET_STATE( new_socket_info, IBSP_CONNECTED );\r
+\r
+       *lpErrno = ib_accept( new_socket_info, &p_incoming->cm_req_received );\r
+       if( *lpErrno )\r
+       {\r
+               IBSP_CHANGE_SOCKET_STATE( new_socket_info, IBSP_CREATE );\r
+               cl_spinlock_release( &new_socket_info->mutex );\r
+\r
+               if( *lpErrno == WSAEADDRINUSE )\r
+               {\r
+                       /* Be nice and reject that connection. */\r
+                       ib_reject( p_incoming->cm_req_received.h_cm_req, IB_REJ_INSUF_QP );\r
+               }\r
+\r
+               g_ibsp.up_call_table.lpWPUCloseSocketHandle(\r
+                       new_socket_info->switch_socket, &ret );\r
+               new_socket_info->switch_socket = INVALID_SOCKET;\r
+               STAT_DEC( wpusocket_num );\r
+\r
+               ib_destroy_socket( new_socket_info );\r
+               deref_socket_info( new_socket_info );\r
+               return INVALID_SOCKET;\r
+       }\r
+\r
+       cl_spinlock_acquire( &g_ibsp.socket_info_mutex );\r
+       cl_qlist_insert_tail(\r
+               &g_ibsp.socket_info_list, &new_socket_info->item );\r
+       cl_spinlock_release( &g_ibsp.socket_info_mutex );\r
+\r
+       cl_spinlock_release( &new_socket_info->mutex );\r
+\r
+       IBSP_TRACE_EXIT( IBSP_DBG_CONN,\r
+               ("returns new socket (0x%p)\n", new_socket_info) );\r
+       return (SOCKET)new_socket_info;\r
+}\r
+\r
+\r
 /* Function: IBSPAccept\r
  *\r
  *  Description:\r
@@ -240,12 +328,11 @@ IBSPAccept(
                OUT                     LPINT                                           lpErrno )\r
 {\r
        struct ibsp_socket_info *socket_info = (struct ibsp_socket_info *)s;\r
-       struct ibsp_socket_info *new_socket_info;\r
-       int ret;\r
        WSABUF caller_id;\r
        WSABUF callee_id;\r
        struct listen_incoming *incoming;\r
        struct ibsp_port *port;\r
+       ib_cm_mra_t             mra;\r
 \r
        IBSP_ENTER( IBSP_DBG_CONN );\r
 \r
@@ -290,17 +377,23 @@ IBSPAccept(
        IBSP_TRACE( IBSP_DBG_CONN,\r
                ("IBSPAccept: Found pending connection on this socket\n") );\r
 \r
-       incoming = PARENT_STRUCT(cl_qlist_head( &socket_info->listen.list ),\r
+       incoming = PARENT_STRUCT(cl_qlist_remove_head( &socket_info->listen.list ),\r
                                                         struct listen_incoming, item);\r
+\r
+       /* Signal the event again if there are more connection requests. */\r
+       if( cl_qlist_count( &socket_info->listen.list ) )\r
+               ibsp_post_select_event( socket_info, FD_ACCEPT, 0 );\r
+       cl_spinlock_release( &socket_info->mutex );\r
+\r
        port = socket_info->port;\r
 \r
        /* Find the destination IP address */\r
-       if( port == NULL )\r
+       if( !port )\r
        {\r
                /* The socket was bound to INADDR_ANY. We must find the correct port\r
                 * for the new socket. */\r
                port = get_port_from_ip_address( incoming->params.dest.sin_addr );\r
-               if( port == NULL )\r
+               if( !port )\r
                {\r
                        IBSP_ERROR(\r
                                ("incoming destination IP address not local (%s)\n",\r
@@ -318,10 +411,6 @@ IBSPAccept(
                        ib_gid_get_guid( &incoming->cm_req_received.primary_path.sgid )) );\r
 \r
 reject:\r
-               /* The request is invalid. Remove it from the list and reject it. */\r
-               cl_qlist_remove_item( &socket_info->listen.list, &incoming->item );\r
-               cl_spinlock_release( &socket_info->mutex );\r
-\r
                ib_reject( incoming->cm_req_received.h_cm_req, IB_REJ_INSUF_QP );\r
 \r
                HeapFree( g_ibsp.heap, 0, incoming );\r
@@ -352,15 +441,16 @@ reject:
                incoming->params.dest.sin_family) );\r
 \r
        /* Call the conditional function */\r
-       ret = lpfnCondition( &caller_id, NULL, NULL, NULL,\r
-               &callee_id, NULL, NULL, dwCallbackData );\r
-\r
-       switch( ret )\r
+       switch( lpfnCondition( &caller_id, NULL, NULL, NULL,\r
+               &callee_id, NULL, NULL, dwCallbackData ) )\r
        {\r
-       case CF_REJECT:\r
-               cl_qlist_remove_item( &socket_info->listen.list, &incoming->item );\r
-               cl_spinlock_release( &socket_info->mutex );\r
+       default:\r
+               /* Should never happen */\r
+               IBSP_ERROR(\r
+                       ("Conditional routine returned undocumented code\n") );\r
+               /* Fall through. */\r
 \r
+       case CF_REJECT:\r
                IBSP_TRACE1( IBSP_DBG_CONN,\r
                        ("Conditional routine returned CF_REJECT\n") );\r
 \r
@@ -372,182 +462,40 @@ reject:
                return INVALID_SOCKET;\r
 \r
        case CF_DEFER:\r
+               /* Send MRA */\r
+               mra.mra_length = 0;\r
+               mra.p_mra_pdata = NULL;\r
+               mra.svc_timeout = 0x15;\r
+               ib_cm_mra( incoming->cm_req_received.h_cm_req, &mra );\r
+\r
+               /* Put the item back at the head of the list. */\r
+               cl_spinlock_acquire( &socket_info->mutex );\r
+               cl_qlist_insert_head( &socket_info->listen.list, &incoming->item );\r
                cl_spinlock_release( &socket_info->mutex );\r
 \r
                IBSP_TRACE1( IBSP_DBG_CONN,\r
                        ("Conditional routine returned CF_DEFER\n") );\r
-               /* TODO: Send MRA */\r
+\r
                *lpErrno = WSATRY_AGAIN;\r
                IBSP_EXIT( IBSP_DBG_CONN );\r
                return INVALID_SOCKET;\r
 \r
        case CF_ACCEPT:\r
                break;\r
-\r
-       default:\r
-               /* Should never happen */\r
-               cl_spinlock_release( &socket_info->mutex );\r
-               IBSP_ERROR(\r
-                       ("Conditional routine returned undocumented code (%d)\n", ret) );\r
-               CL_ASSERT( 0 );\r
-               *lpErrno = WSAECONNREFUSED;\r
-               IBSP_EXIT( IBSP_DBG_CONN );\r
-               return INVALID_SOCKET;\r
        }\r
 \r
-       /* Create a new socket here  */\r
-       new_socket_info = create_socket_info( lpErrno );\r
-       if( !new_socket_info )\r
+       s = accept_socket( socket_info, incoming, port, lpErrno );\r
+       if( s != INVALID_SOCKET )\r
        {\r
-               cl_spinlock_release( &socket_info->mutex );\r
-\r
-               IBSP_ERROR_EXIT( ("create_socket_info failed (%d)\n", *lpErrno) );\r
-               return INVALID_SOCKET;\r
+               /* Store the client socket address information */\r
+               memcpy( addr, &incoming->params.source, sizeof(struct sockaddr_in) );\r
+               *addrlen = sizeof(struct sockaddr_in);\r
        }\r
 \r
-       /* Time to allocate our IB QP */\r
-       new_socket_info->port = port;\r
-       *lpErrno = ib_create_socket( new_socket_info );\r
-       if( *lpErrno )\r
-       {\r
-               cl_spinlock_release( &socket_info->mutex );\r
-               deref_socket_info( new_socket_info );\r
-\r
-               IBSP_ERROR_EXIT( ("ib_create socket failed with %d\n", *lpErrno) );\r
-               return INVALID_SOCKET;\r
-       }\r
-\r
-       /* Store the IP address and port number in the socket context */\r
-       new_socket_info->local_addr = incoming->params.dest;\r
-\r
-       cl_qlist_remove_item( &socket_info->listen.list, &incoming->item );\r
-       /* Signal the event again if there are more connection requests. */\r
-       if( cl_qlist_count( &socket_info->listen.list ) )\r
-               ibsp_post_select_event( socket_info, FD_ACCEPT, 0 );\r
-\r
-       cl_spinlock_release( &socket_info->mutex );\r
-\r
-       /* Copy the socket context info from parent socket context */\r
-       new_socket_info->socket_options = socket_info->socket_options;\r
-\r
-       /* Store the client socket address information */\r
-       memcpy( addr, &incoming->params.source, sizeof(struct sockaddr_in) );\r
-       *addrlen = sizeof(struct sockaddr_in);\r
-\r
-       IBSP_TRACE( IBSP_DBG_CONN,\r
-               ("The socket address of connecting entity is\n") );\r
-       DebugPrintSockAddr( IBSP_DBG_CONN, gdbg_lvl, &incoming->params.source );\r
-\r
-       new_socket_info->peer_addr = incoming->params.source;\r
-\r
-       new_socket_info->h_event = CreateEvent( NULL, FALSE, FALSE, NULL );\r
-\r
-       cl_spinlock_acquire( &new_socket_info->mutex );\r
-       /* Update the state of the socket context */\r
-       IBSP_CHANGE_SOCKET_STATE( new_socket_info, IBSP_ACCEPT );\r
-\r
-       ret = ib_accept( new_socket_info, &incoming->cm_req_received );\r
-       if( ret )\r
-       {\r
-               IBSP_CHANGE_SOCKET_STATE( new_socket_info, IBSP_CREATE );\r
-               cl_spinlock_release( &new_socket_info->mutex );\r
-\r
-               if( g_ibsp.up_call_table.lpWPUCloseSocketHandle(\r
-                       new_socket_info->switch_socket, &ret ) == SOCKET_ERROR )\r
-               {\r
-                       IBSP_ERROR( ("WPUCloseSocketHandle failed: %d\n", ret) );\r
-               }\r
-               else\r
-               {\r
-                       STAT_DEC( wpusocket_num );\r
-               }\r
-               new_socket_info->switch_socket = INVALID_SOCKET;\r
-\r
-               CloseHandle( new_socket_info->h_event );\r
-\r
-               ib_destroy_socket( new_socket_info );\r
-\r
-               deref_socket_info( new_socket_info );\r
-\r
-               /* Be nice and reject that connection. */\r
-               ib_reject( incoming->cm_req_received.h_cm_req, IB_REJ_INSUF_QP );\r
-\r
-               HeapFree( g_ibsp.heap, 0, incoming );\r
-               *lpErrno = ret;\r
-\r
-               IBSP_ERROR_EXIT( ("ib_accept failed (%d)\n", ret) );\r
-\r
-               return INVALID_SOCKET;\r
-       }\r
-       else\r
-       {\r
-               cl_spinlock_release( &new_socket_info->mutex );\r
-               HeapFree( g_ibsp.heap, 0, incoming );\r
-\r
-               if( WaitForSingleObject( new_socket_info->h_event, INFINITE ) == WAIT_OBJECT_0 )\r
-               {\r
-                       CloseHandle( new_socket_info->h_event );\r
-                       new_socket_info->h_event = NULL;\r
-\r
-                       cl_spinlock_acquire( &new_socket_info->mutex );\r
+       HeapFree( g_ibsp.heap, 0, incoming );\r
 \r
-                       if( new_socket_info->socket_state == IBSP_CONNECTED )\r
-                       {\r
-                               cl_spinlock_acquire( &g_ibsp.socket_info_mutex );\r
-                               cl_qlist_insert_tail( &g_ibsp.socket_info_list, &new_socket_info->item );\r
-                               cl_spinlock_release( &g_ibsp.socket_info_mutex );\r
-\r
-                               cl_spinlock_release( &new_socket_info->mutex );\r
-                       }\r
-                       else\r
-                       {\r
-                               IBSP_ERROR(\r
-                                       ("ib_accept failed - socket state is %s\n",\r
-                                       IBSP_SOCKET_STATE_STR( new_socket_info->socket_state )) );\r
-\r
-                               cl_spinlock_release( &new_socket_info->mutex );\r
-\r
-                               /* The accept failed (by a REJ for instance). */\r
-\r
-                               /* Free the socket descriptor */\r
-                               if( g_ibsp.up_call_table.lpWPUCloseSocketHandle(\r
-                                       new_socket_info->switch_socket, lpErrno ) == SOCKET_ERROR )\r
-                               {\r
-                                       IBSP_ERROR(\r
-                                               ("WPUCloseSocketHandle failed: %d\n", *lpErrno) );\r
-                               }\r
-                               else\r
-                               {\r
-                                       STAT_DEC( wpusocket_num );\r
-                               }\r
-                               new_socket_info->switch_socket = INVALID_SOCKET;\r
-\r
-                               ib_destroy_socket( new_socket_info );\r
-                               deref_socket_info( new_socket_info );\r
-\r
-                               *lpErrno = WSAEACCES;\r
-\r
-                               new_socket_info = (struct ibsp_socket_info *)INVALID_SOCKET;\r
-                       }\r
-\r
-                       IBSP_TRACE_EXIT( IBSP_DBG_CONN,\r
-                               ("returns new SocketID (0x%x)\n", new_socket_info) );\r
-\r
-                       return (SOCKET) new_socket_info;\r
-               }\r
-               else\r
-               {\r
-                       CloseHandle( new_socket_info->h_event );\r
-                       new_socket_info->h_event = NULL;\r
-\r
-                       IBSP_ERROR_EXIT( ("wait for ib_accept failed\n") );\r
-\r
-                       *lpErrno = WSAEACCES;\r
-                       return INVALID_SOCKET;\r
-               }\r
-       }\r
-\r
-       /* Unreachable */\r
+       IBSP_EXIT( IBSP_DBG_CONN );\r
+       return s;\r
 }\r
 \r
 \r
@@ -691,10 +639,6 @@ IBSPCloseSocket(
        cl_atomic_inc( &g_ibsp.CloseSocket_count );\r
 #endif\r
 \r
-       cl_spinlock_acquire( &g_ibsp.socket_info_mutex );\r
-       cl_qlist_remove_item( &g_ibsp.socket_info_list, &socket_info->item );\r
-       cl_spinlock_release( &g_ibsp.socket_info_mutex );\r
-\r
        shutdown_and_destroy_socket_info( socket_info );\r
 \r
        IBSP_EXIT( IBSP_DBG_CONN );\r
@@ -2111,20 +2055,6 @@ IBSPSocket(
                        socket_info, lpProtocolInfo->dwProviderReserved );\r
                if( *lpErrno )\r
                {\r
-                       int error;\r
-\r
-                       if( g_ibsp.up_call_table.lpWPUCloseSocketHandle(\r
-                               socket_info->switch_socket, &error ) == SOCKET_ERROR )\r
-                       {\r
-                               IBSP_ERROR( ("WPUCloseSocketHandle failed: %d\n", error) );\r
-                       }\r
-                       else\r
-                       {\r
-                               STAT_DEC( wpusocket_num );\r
-                       }\r
-\r
-                       socket_info->switch_socket = INVALID_SOCKET;\r
-\r
                        deref_socket_info( socket_info );\r
                        IBSP_ERROR(\r
                                ("setup_duplicate_socket failed with %d\n", *lpErrno) );\r
index 45dc6dd..ceb4ce8 100644 (file)
@@ -42,7 +42,6 @@ enum ibsp_socket_state
        IBSP_BIND,\r
        IBSP_CONNECT,\r
        IBSP_LISTEN,\r
-       IBSP_ACCEPT,\r
        IBSP_CONNECTED,\r
        IBSP_DUPLICATING_OLD,           /* duplicating socket on the original controlling process */\r
        IBSP_DUPLICATING_NEW,           /* duplicating socket on the new controlling process */\r
index 5c7da13..1bf4598 100644 (file)
@@ -36,7 +36,6 @@ char *ibsp_socket_state_str[IBSP_NUM_STATES] = {
        "IBSP_BIND",\r
        "IBSP_CONNECT",\r
        "IBSP_LISTEN",\r
-       "IBSP_ACCEPT",\r
        "IBSP_CONNECTED",\r
        "IBSP_DUPLICATING_OLD",\r
        "IBSP_DUPLICATING_NEW",\r