Changeset 1828


Ignore:
Timestamp:
Mar 13, 2005, 11:47:21 AM (20 years ago)
Author:
bird
Message:

Socket duplication. Fixed various close bugs.

File:
1 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.18 to 1.19
    r1827 r1828  
    197197                    for (i = 0; i < c; i++)
    198198                    {
    199                         if (!TCPNAMEG44(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL))
     199                        int rc = TCPNAMEG44(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL, NULL);
     200                        if (rc)
    200201                        {
    201                             LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.4) handle! iFH=%d iSocket=%d\n",
    202                                                 iFH, u.pSockets->aHandles[i].usSocket);
     202                            LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.4) handle! rc=%d iFH=%d iSocket=%d\n",
     203                                                rc, iFH, u.pSockets->aHandles[i].usSocket);
    203204                            __libc_spmInheritRelease();
    204205                            return -1;
     
    211212                    for (i = 0; i < c; i++)
    212213                    {
    213                         if (!TCPNAMEG43(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL))
     214                        int rc = TCPNAMEG43(AllocFHEx)(iFH, u.pSockets->aHandles[i].usSocket, u.pSockets->aHandles[i].fFlags, 0, NULL, NULL);
     215                        if (rc)
    214216                        {
    215                             LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.3) handle! iFH=%d iSocket=%d\n",
    216                                                 iFH, u.pSockets->aHandles[i].usSocket);
     217                            LIBC_ASSERTM_FAILED("Failed to allocated inherited socket (4.3) handle! rc=%d iFH=%d iSocket=%d\n",
     218                                                rc, iFH, u.pSockets->aHandles[i].usSocket);
    217219                            __libc_spmInheritRelease();
    218220                            return -1;
     
    791793            {
    792794                /*
    793                  * If not OS/2 filehandle, we have to make a fake handle.
     795                 * Send the close call to any non-OS/2 handle.
    794796                 */
    795                 if (pOps) /** @todo check out the fh duplication with respect to close. */
    796                     rc = fhOpenDummy(-1, &fh);
    797 
     797                __LIBC_PFH  pFHOld = gpapFHs[fh];
     798                if (    pFHOld
     799                    &&  pFHOld->pOps
     800                    &&  pFHOld->pOps->pfnClose)
     801                    rc = pFHOld->pOps->pfnClose(pFHOld, fh);
    798802                if (!rc)
    799803                {
    800804                    /*
    801                      * Free any old filehandle which death we didn't catch
    802                      * and insert the new one.
     805                     * If not OS/2 filehandle, make a fake handle.
    803806                     */
    804                     if (gpapFHs[fh])
    805                         fhFreeHandle(gpapFHs[fh]);
    806                     gpapFHs[fh] = pFH;
     807                    if (pOps)
     808                        rc = fhOpenDummy(fh, &fh);
     809                    if (!rc)
     810                    {
     811                        /*
     812                         * Free any old filehandle (replaced during dup2 or closed outside
     813                         * this libc) and insert the new one.
     814                         */
     815                        if (pFHOld)
     816                            fhFreeHandle(pFHOld);
     817                        gpapFHs[fh] = pFH;
     818                    }
    807819                }
    808820            }
     
    899911     * were successful or if the handle has become invalid.
    900912     */
    901     if (!rc || rc == ERROR_INVALID_HANDLE || rc == -EBADF)
     913    if (    !rc
     914        ||  rc == ERROR_INVALID_HANDLE
     915        ||  rc == -EBADF
     916        ||  rc == -ENOTSOCK)
    902917    {
    903918        int rc2;
     
    919934         * we will free it now.
    920935         */
    921         if (!rc || rc == ERROR_INVALID_HANDLE)
     936        if (    !rc2
     937            ||  rc2 == ERROR_INVALID_HANDLE
     938            ||  pFH->pOps)
    922939        {
    923940            gpapFHs[fh] = NULL;
     
    12831300                    if (pFH->pOps && pFH->pOps->pfnForkChild)
    12841301                    {
    1285                         rc = pFH->pOps->pfnForkChild(pFH, iFH, pForkHandle, __LIBC_FORK_OP_FORK_PARENT);
     1302                        rc = pFH->pOps->pfnForkChild(pFH, iFH, pForkHandle, __LIBC_FORK_OP_FORK_CHILD);
    12861303                        if (rc)
    12871304                        {
Note: See TracChangeset for help on using the changeset viewer.