Changeset 3851 for branches


Ignore:
Timestamp:
Mar 17, 2014, 5:20:45 AM (11 years ago)
Author:
bird
Message:

sharedpm.c: Fixed leak of pTerm of processes which didn't send any termination notification to their parent. Make sure we get inherit data, even locked, when the process is being freed or turned into a zombie. Use DosVerityPidTid to quickly weed out embryo process structures of non-libc processes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/lib/sys/sharedpm.c

    r3805 r3851  
    551551            SPM_ASSERT_PTR_NULL(pProcess->pPrev);
    552552            SPM_ASSERT_PTR_NULL(pProcess->pNext);
    553             if (    pProcess->pidParent == pidParent
    554                 &&  pProcess->cReferences == 0
    555                 &&  uTimestamp - pProcess->uTimestamp >= 1*60*1000)
     553            if (   pProcess->pidParent == pidParent
     554                && pProcess->cReferences == 0
     555                && (   uTimestamp - pProcess->uTimestamp >= 1*60*1000
     556                    || (   uTimestamp - pProcess->uTimestamp >= 8000
     557                        && pProcess->pid != -1
     558                        && DosVerifyPidTid(pProcess->pid, 1) == ERROR_INVALID_PROCID)
     559                   )
     560               )
    556561            {
    557562                __LIBC_PSPMPROCESS      pProcessNext = pProcess->pNext;
     
    27162721    LIBCLOG_ENTER("pProcess=%p\n", (void *)pProcess);
    27172722    LIBC_ASSERT(pProcess->enmState != __LIBC_PROCSTATE_FREE);
     2723
    27182724    /*
    27192725     * Dereference it.
     
    27412747         */
    27422748        /* inherited data */
    2743         if (pProcess->pInherit)
    2744         {
    2745             spmFree(pProcess->pInherit);
     2749        void *pv = pProcess->pInheritLocked;
     2750        if (!pv)
     2751            pv = pProcess->pInherit;
     2752        if (pv)
     2753        {
    27462754            pProcess->pInherit = NULL;
     2755            pProcess->pInheritLocked = NULL;
     2756            spmFree(pv);
    27472757        }
    27482758
     
    28952905    {
    28962906        pProcess = pProcessBest;
    2897         LIBCLOG_MSG("Found my embryo %p (pidParent=%#x pid=%#x cReferences=%d uTimestamp=%04x)\n",
    2898                     (void *)pProcess, pProcess->pidParent, pProcess->pid, pProcess->cReferences, pProcess->uTimestamp);
     2907        LIBCLOG_MSG("Found my embryo %p (pidParent=%#x pid=%#x cReferences=%d uTimestamp=%04x pInherit=%p/%p)\n",
     2908                    (void *)pProcess, pProcess->pidParent, pProcess->pid, pProcess->cReferences, pProcess->uTimestamp, pProcess->pInherit, pProcess->pInheritLocked);
    28992909
    29002910        /* set data. */
     
    30843094                  pProcess->pvForkHandle, (void *)pProcess->pNext, (void *)pProcess->pPrev);
    30853095    /*
     3096     * Free inheritance info.
     3097     */
     3098    void *pv = pProcess->pInheritLocked;
     3099    if (!pv)
     3100        pv = pProcess->pInherit;
     3101    if (pv)
     3102    {
     3103        pProcess->pInherit = NULL;
     3104        pProcess->pInheritLocked = NULL;
     3105        spmFree(pv);
     3106    }
     3107
     3108    /*
    30863109     * Free signals.
    30873110     */
     
    31053128        pNotify = pNotify->pNext;
    31063129        spmFreeChildNotify(pFree);
     3130    }
     3131
     3132    /*
     3133     * Parent notification.
     3134     */
     3135    if (pProcess->pTerm)
     3136    {
     3137        spmFreeChildNotify(pProcess->pTerm);
     3138        pProcess->pTerm = NULL;
    31073139    }
    31083140
     
    34853517
    34863518        /*
    3487          * Free embryos which are more than 5 min old.
     3519         * Free embryos which are more than 5 min old or which processes no longer exists.
    34883520         */
    34893521        uTimestamp = spmTimestamp();
     
    34973529                SPM_ASSERT_PTR_NULL(pProcess->pPrev);
    34983530                if (    pProcess->cReferences == 0
    3499                     &&  uTimestamp - pProcess->uTimestamp >= 5*60*1000)
     3531                    &&  (   uTimestamp - pProcess->uTimestamp >= 5*60*1000
     3532                         || (   pProcess->pid != -1
     3533                             && DosVerifyPidTid(pProcess->pid, 1) == ERROR_INVALID_PROCID)
     3534                        )
     3535                    )
    35003536                {
    35013537                    __LIBC_PSPMPROCESS      pProcessNext = pProcess->pNext;
Note: See TracChangeset for help on using the changeset viewer.