VirtualBox

Changeset 932 in vbox


Ignore:
Timestamp:
Feb 15, 2007 6:25:10 PM (18 years ago)
Author:
vboxsync
Message:

Added RTTcpServerDisconnectClient, this fixed the assertion mentioned in defect 1833.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/tcp.h

    r204 r932  
    116116
    117117/**
     118 * Terminate the open connection to the server.
     119 *
     120 * @returns iprt status code.
     121 * @param   pServer         Handle to the server.
     122 */
     123RTR3DECL(int) RTTcpServerDisconnectClient(PRTTCPSERVER pServer);
     124
     125/**
    118126 * Connect (as a client) to a TCP Server.
    119127 *
  • trunk/src/VBox/Runtime/r3/tcp.cpp

    r1 r932  
    434434
    435435
     436/**
     437 * Closes the client socket.
     438 */
     439static int rtTcpServerDestroyClientSock(RTSOCKET volatile *pSock, const char *pszMsg)
     440{
     441    RTSOCKET Sock = rtTcpAtomicXchgSock(pSock, NIL_RTSOCKET);
     442    if (Sock != NIL_RTSOCKET)
     443    {
     444       shutdown(Sock, SHUT_RDWR);
     445    }
     446    return rtTcpClose(Sock, pszMsg);
     447}
     448
    436449
    437450/**
     
    479492        rtTcpAtomicXchgSock(&pServer->SockClient, Socket);
    480493        rc = pServer->pfnServe(Socket, pServer->pvUser);
    481         rtTcpClose(rtTcpAtomicXchgSock(&pServer->SockClient, NIL_RTSOCKET), "Listener: client");
     494        rtTcpServerDestroyClientSock(&pServer->SockClient, "Listener: client");
    482495
    483496        /*
     
    554567
    555568/**
     569 * Terminate the open connection to the server.
     570 *
     571 * @returns iprt status code.
     572 * @param   pServer         Handle to the server.
     573 */
     574RTR3DECL(int) RTTcpServerDisconnectClient(PRTTCPSERVER pServer)
     575{
     576    /*
     577     * Validate input.
     578     */
     579    if (    !pServer
     580        ||  pServer->enmState <= RTTCPSERVERSTATE_INVALID
     581        ||  pServer->enmState >= RTTCPSERVERSTATE_FREED)
     582    {
     583        AssertMsgFailed(("Invalid parameter!\n"));
     584        return VERR_INVALID_PARAMETER;
     585    }
     586
     587    return rtTcpServerDestroyClientSock(&pServer->SockClient, "DisconnectClient: client");
     588}
     589
     590
     591/**
    556592 * Closes down and frees a TCP Server.
    557593 * This will also terminate any open connections to the server.
     
    594630                {
    595631                    /* client */
    596                     RTSOCKET SockClient = rtTcpAtomicXchgSock(&pServer->SockClient, NIL_RTSOCKET);
    597                     if (SockClient != NIL_RTSOCKET)
    598                     {
    599                         shutdown(SockClient, SHUT_RDWR);
    600                         rtTcpClose(SockClient, "Destroyer: client");
    601                     }
     632                    rtTcpServerDestroyClientSock(&pServer->SockClient, "Destroyer: client");
     633
    602634                    bool fRc = rtTcpServerSetState(pServer, RTTCPSERVERSTATE_DESTROYING, RTTCPSERVERSTATE_SIGNALING);
    603635                    Assert(fRc); NOREF(fRc);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette