Changeset 1586


Ignore:
Timestamp:
Nov 1, 2004, 3:26:32 AM (21 years ago)
Author:
bird
Message:

Tried to fix the add/remove socket list stuff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/sys/tcpipver.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1585 r1586  
    160160static int TCPNAME(imp_send)(int, const void *, int, int);
    161161static int TCPNAME(imp_removesocketfromlist)(int);
     162static int TCPNAME(imp_addsockettolist)(int);
    162163#ifdef TCPV40HDRS
    163164static int TCPNAME(imp_bsdselect)(int, fd_set *, fd_set *, fd_set *, struct timeval *);
     
    228229        }
    229230    }
    230     else if (rc < 0)
     231    else if (rc > 0)
     232    {
     233        /*
     234         * Someone is using the socket, we'll remove it from the list of
     235         * sockets owned by this process to prevent it from being closed.
     236         */
     237        rc = TCPNAME(imp_removesocketfromlist)(pSocketFH->iSocket);
     238        if (rc)
     239        {
     240            LIBC_ASSERTM(!rc, "removesocketfromlist(%d) -> rc=%d sock_errno()->%d\n", pSocketFH->iSocket, rc, TCPNAME(imp_sock_errno)());
     241            rc = -__libc_TcpipGetSocketErrno();
     242        }
     243    }
     244    else
    231245        rc = -EBADF;
    232246
     
    755769    LIBCLOG_ENTER("pFH=%p:{iSocket=%d} fh=%d\n", (void *)pFH, ((PLIBCSOCKETFH)pFH)->iSocket, fh);
    756770    PLIBCSOCKETFH   pSocketFH = (PLIBCSOCKETFH)pFH;
    757     __libc_spmSocketRef(pSocketFH->iSocket);
     771    int rc = __libc_spmSocketRef(pSocketFH->iSocket);
     772    LIBC_ASSERTM(rc > 0, "__libc_spmSocketDeref(%d) -> rc=%d\n", pSocketFH->iSocket, rc);
    758773    LIBCLOG_RETURN_INT(0);
     774    rc = rc;
    759775}
    760776
     
    823839
    824840        /*
    825          * New: Set usage counter to 1 and remove from tcpip cleanup list.
    826          * Existing: Increment reference counter
     841         * New: Set usage counter to 1.
     842         * Existing: Increment reference counter and add to socket list.
    827843         */
    828844        if (fNew)
    829845        {
    830             __libc_spmSocketNew(iSocket);
    831             TCPNAME(imp_removesocketfromlist)(iSocket); /* We do our own cleanup! */
     846            rc = __libc_spmSocketNew(iSocket);
     847            LIBC_ASSERTM(!rc, "__libc_spmSocketNew(%d) -> rc=%d\n", iSocket, rc);
    832848        }
    833849        else
    834             __libc_spmSocketRef(iSocket);
     850        {
     851            rc = __libc_spmSocketRef(iSocket);
     852            LIBC_ASSERTM(rc > 0, "__libc_spmSocketRef(%d) -> rc=%d\n", iSocket, rc);
     853            rc = TCPNAME(imp_addsockettolist)(iSocket);
     854            LIBC_ASSERTM(!rc, "addsockettolist(%d) -> rc=%d\n", iSocket, rc);
     855        }
    835856        LIBCLOG_RETURN_P(pFH);
    836857    }
     
    10941115# define ORD_RECV                       10
    10951116# define ORD_SEND                       13
     1117# define ORD_ADDSOCKETTOLIST            27
    10961118# define ORD_REMOVESOCKETFROMLIST       28
    10971119# define ORD_BSDSELECT                  32
     
    11041126# define ORD_RECV                       10
    11051127# define ORD_SEND                       13
     1128# define ORD_ADDSOCKETTOLIST            27
    11061129# define ORD_REMOVESOCKETFROMLIST       28
    11071130# define ORD_BSDSELECT                  32
     
    12131236}
    12141237
     1238static int     TCPNAME(imp_addsockettolist)(int s)
     1239{
     1240    static int (*TCPCALL pfn)(int s);
     1241    if (!pfn && TCPNAME(get_imp)(ORD_ADDSOCKETTOLIST, (void **)(void *)&pfn))
     1242        return -1;
     1243    return pfn(s);
     1244}
     1245
    12151246static int     TCPNAME(imp_removesocketfromlist)(int s)
    12161247{
     
    12741305        if (!rc)
    12751306        {
     1307            /*
     1308             * Close the socket, noone needs it.
     1309             */
    12761310            rc = TCPNAME(imp_soclose)(pFH->iSocket);
    12771311            LIBC_ASSERTM(!rc, "soclose(%d) -> rc=%d sock_errno()->%d\n", pFH->iSocket, rc, TCPNAME(imp_sock_errno)());
     1312        }
     1313        else
     1314        {
     1315            /*
     1316             * If in use by other process, we'll remove it from the list of sockets
     1317             * owned by this process to prevent it from begin closed.
     1318             */
     1319            rc = TCPNAME(imp_removesocketfromlist)(pFH->iSocket);
     1320            LIBC_ASSERTM(!rc, "removesocketfromlist(%d) -> rc=%d sock_errno()->%d\n", pFH->iSocket, rc, TCPNAME(imp_sock_errno)());
    12781321        }
    12791322
Note: See TracChangeset for help on using the changeset viewer.