Changeset 3372 for trunk


Ignore:
Timestamp:
May 27, 2007, 12:37:44 PM (18 years ago)
Author:
bird
Message:

Fixes #166.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libc/src/kNIX/os2/tcpipver.c

    r2929 r3372  
    155155
    156156static void TCPNAME(Cleanup)(void);
    157 static int  tcpipForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation);
    158157
    159158
     
    227226                __libc_spmSocketRef(pSocketFH->iSocket);
    228227            }
     228            /** @todo deal with EALREADY, it will leave an unclosed and soon to be invalid handle behind... */
    229229        }
    230230    }
     
    241241         * Please note that removesocketfromlist returns a boolean success indicator and proably no errno.
    242242         */
     243        int iSavedTcpipErrno = TCPNAME(imp_sock_errno)();
     244        TCPNAME(imp_set_errno)(0);
    243245        rc = TCPNAME(imp_removesocketfromlist)(pSocketFH->iSocket);
    244246        if (!rc)
     
    247249            rc = -EBADF; /* this is an internal error, it should *NOT* happen! */
    248250        }
     251        else
     252            rc = 0;
     253        TCPNAME(imp_set_errno)(iSavedTcpipErrno);
    249254    }
    250255
    251256    /*
    252      * Unlink from our list.
     257     * Unlink from our list (rc list must correspond to __libc_FHClose!).
    253258     */
    254     if (rc != -EBADF && rc != -ENOTSOCK && rc != -EALREADY)
    255     {
     259    if (    !rc
     260        ||  rc == -EBADF
     261        ||  rc == -ENOTSOCK)
     262    {
     263        LIBCLOG_MSG("Unlinking pSocketFH=%p:{iSocket=%d} fh=%d\n", pSocketFH, pSocketFH->iSocket, fh);
    256264        _smutex_request(&gsmtxSockets);
    257265        if (pSocketFH->pNext)
     
    856864 *                      list for the current process.
    857865 *                      If clear we only increment the global reference counter.
    858  * @param   pfh         Where to store the filename.
     866 * @param   pfh         Where to store the file handle.
    859867 * @param   ppFHSocket  Where to store the allocated socket handle. Optional.
    860868 */
    861869int TCPNAMEG(AllocFHEx)(int fh, int iSocket, unsigned fFlags, int fNew, int *pfh, PLIBCSOCKETFH *ppFHSocket)
    862870{
    863     LIBCLOG_ENTER("iSocket=%d\n", iSocket);
     871    LIBCLOG_ENTER("fh=%d iSocket=%d fFlags=%#x fNew=%d pfh=%p:{%d} ppFHSocket=%p\n", fh, iSocket, fFlags, fNew, (void *)pfh, pfh ? *pfh : -2, (void *)ppFHSocket);
    864872    __LIBC_PFH         pFHLibc;
    865873    int rc = __libc_FHAllocate(sizeof(LIBCSOCKETFH), &gSocketOps, iSocket, fh, fFlags, &pFHLibc);
     
    906914        else
    907915            __libc_FHPut(pFHLibc);
    908         LIBCLOG_RETURN_INT(0);
     916        LIBCLOG_RETURN_MSG(0, "ret 0 *pfh=%d *ppFHSocket=%p\n", pfh ? *pfh : -2, pFH);
    909917    }
    910918    LIBCLOG_ERROR_RETURN_P(rc);
     
    12121220        HMODULE hmod;
    12131221        char    szErr[16];
    1214         rc = DosLoadModule((PSZ)szErr, sizeof(szErr), (PCSZ)gszDllName, &hmod);
     1222        rc = DosLoadModuleEx((PSZ)szErr, sizeof(szErr), (PCSZ)gszDllName, &hmod);
    12151223        if (rc)
    12161224        {
     
    13881396             * Please note that removesocketfromlist is returning a boolean success indicator and probably no errno.
    13891397             */
     1398            TCPNAME(imp_set_errno)(0);
    13901399            rc = TCPNAME(imp_removesocketfromlist)(pFH->iSocket);
    13911400            LIBC_ASSERTM(rc == 1, "removesocketfromlist(%d) -> rc=%d sock_errno()->%d\n", pFH->iSocket, rc, TCPNAME(imp_sock_errno)());
     
    13981407}
    13991408
    1400 
    1401 #undef  __LIBC_LOG_GROUP
    1402 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_FORK
    1403 
    1404 _FORK_CHILD1(0xffffff00, tcpipForkChild1)
    1405 
    1406 /**
    1407  * Reload the DLL in the child process.
    1408  *
    1409  * @returns 0 on success.
    1410  * @returns negative errno on failure.
    1411  * @param   pForkHandle     Pointer to fork handle.
    1412  * @param   enmOperation    Callback operation.
    1413  */
    1414 static int tcpipForkChild1(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation)
    1415 {
    1416     LIBCLOG_ENTER("pForkHandle=%p enmOperation=%d\n", (void *)pForkHandle, enmOperation);
    1417     int rc;
    1418     switch (enmOperation)
    1419     {
    1420         case __LIBC_FORK_OP_FORK_CHILD:
    1421         {
    1422             rc = 0;
    1423             if (ghmod)
    1424                 rc = __libc_tcpipForkLoadModule(ghmod, gszDllName);
    1425             break;
    1426         }
    1427 
    1428         default:
    1429             rc = 0;
    1430             break;
    1431     }
    1432 
    1433     LIBCLOG_RETURN_INT(rc);
    1434 }
    1435 
    1436 
Note: See TracChangeset for help on using the changeset viewer.