VirtualBox

Changeset 52413 in vbox for trunk/src


Ignore:
Timestamp:
Aug 19, 2014 12:48:42 PM (11 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
95585
Message:

VBoxSVC: resolve undesirable freeze on shutdown.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/EventImpl.cpp

    r50545 r52413  
    579579
    580580    RTSEMEVENT                    mQEvent;
     581    int32_t volatile              mWaitCnt;
    581582    RTCRITSECT                    mcsQLock;
    582583    PassiveQueue                  mQueue;
     
    725726                               BOOL aActive,
    726727                               EventSource *aOwner) :
    727     mActive(aActive), mOwner(aOwner), mRefCnt(0)
     728    mActive(aActive), mOwner(aOwner), mWaitCnt(0), mRefCnt(0)
    728729{
    729730    mListener = aListener;
     
    882883        // release lock while waiting, listener will not go away due to above holder
    883884        aAlock.release();
     885
     886        // In order to safely shutdown, count all waiting threads here.
     887        ASMAtomicIncS32(&mWaitCnt);
    884888        ::RTSemEventWait(mQEvent, aTimeout);
     889        ASMAtomicDecS32(&mWaitCnt);
     890
    885891        // reacquire lock
    886892        aAlock.acquire();
     
    918924        RTSEMEVENT tmp = mQEvent;
    919925        mQEvent = NIL_RTSEMEVENT;
     926
     927        /* On Darwin it is known that RTSemEventDestroy() returns 0 while
     928         * corresponding thread remains to be blocked after that. In order to prevent
     929         * undesireble freeze on shutdown, this workaround is used. */
     930        Log(("Wait for %d waiters to release.\n", ASMAtomicReadS32(&mWaitCnt)));
     931        while (ASMAtomicReadS32(&mWaitCnt) > 0)
     932        {
     933            ::RTSemEventSignal(tmp);
     934
     935            /* Are we already done? */
     936            if (ASMAtomicReadS32(&mWaitCnt) == 0)
     937                break;
     938
     939            RTThreadSleep(10);
     940        }
     941        Log(("All waiters just released the lock.\n"));
     942
    920943        ::RTSemEventDestroy(tmp);
    921944    }
  • trunk/src/libs/xpcom18a4/ipc/ipcd/extensions/dconnect/src/ipcDConnectService.cpp

    r52369 r52413  
    32293229    }
    32303230
     3231    /* Double-ckeck if we already allowed to quit. */
     3232    if ((tsStart + VBOX_XPCOM_SHUTDOWN_TIMEOUT_MS ) < RTTimeMilliTS() || mWorkers.Count() == 0)
     3233        break;
     3234
    32313235    // Relax a bit before the next round.
    32323236    RTThreadSleep(10);
     
    32353239  LOG(("There are %d thread(s) left.\n", mWorkers.Count()));
    32363240
    3237   // If there are some running threads left, just forget about them.
    3238   mWorkers.Clear();
     3241  // If there are some running threads left, terminate the process.
     3242  if (mWorkers.Count() > 0)
     3243    exit(1);
     3244
    32393245
    32403246  nsAutoMonitor::DestroyMonitor(mWaitingWorkersMon);
Note: See TracChangeset for help on using the changeset viewer.

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