VirtualBox

Changeset 49976 in vbox


Ignore:
Timestamp:
Dec 18, 2013 2:58:43 PM (11 years ago)
Author:
vboxsync
Message:

Main/Machine+ClientWatcher: fix for the generic watcher, it missed crashes of spawning sessions (e.g. launching a GUI VM if the DISPLAY variable isn't set), 4.3 regression

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/MachineImpl.h

    r49644 r49976  
    791791    { return isSessionOpen(aMachine, aControl, true /* aAllowClosing */); }
    792792
    793 #ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
    794793    bool checkForSpawnFailure();
    795 #endif /* !VBOX_WITH_GENERIC_SESSION_WATCHER */
    796794
    797795    HRESULT prepareRegister();
  • trunk/src/VBox/Main/src-server/ClientWatcher.cpp

    r48561 r49976  
    692692#elif defined(VBOX_WITH_GENERIC_SESSION_WATCHER)
    693693
    694     bool update = false;
    695694    bool updateSpawned = false;
    696695
     
    733732                break;
    734733
    735             if (RT_SUCCESS(rc) || update || updateSpawned)
     734            /** @todo this quite big effort for catching machines in spawning
     735             * state which can't be caught by the token mechanism (as the token
     736             * can't be in the other process yet) could be eliminated if the
     737             * reaping is made smarter, having cross-reference information
     738             * from the pid to the corresponding machine object. Both cases do
     739             * more or less the same thing anyway. */
     740            if (RT_SUCCESS(rc) || updateSpawned)
    736741            {
    737742                /* RT_SUCCESS(rc) means an update event is signaled */
    738743
    739 #if 0
    740744                // get reference to the machines list in VirtualBox
    741745                VirtualBox::MachinesOList &allMachines = that->mVirtualBox->getMachinesList();
     
    744748                AutoReadLock thatLock(allMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS);
    745749
    746                 if (RT_SUCCESS(rc) || update)
    747                 {
    748                     /* obtain a new set of opened machines */
    749                     machines.clear();
     750                if (RT_SUCCESS(rc) || updateSpawned)
     751                {
     752                    /* obtain a new set of spawned machines */
     753                    spawnedMachines.clear();
    750754
    751755                    for (MachinesOList::iterator it = allMachines.begin();
     
    753757                         ++it)
    754758                    {
    755                         ComObjPtr<SessionMachine> sm;
    756                         if ((*it)->isSessionOpenOrClosing(sm))
    757                             machines.push_back(sm);
    758                     }
    759 
    760                     cnt = machines.size();
    761                     LogFlowFunc(("UPDATE: direct session count = %d\n", cnt));
    762                 }
    763 
    764                 if (RT_SUCCESS(rc) || updateSpawned)
    765                 {
    766                     /* obtain a new set of spawned machines */
    767                     spawnedMachines.clear();
    768 
    769                     for (MachinesOList::iterator it = allMachines.begin();
    770                          it != allMachines.end();
    771                          ++it)
    772                     {
    773759                        if ((*it)->isSessionSpawning())
    774760                            spawnedMachines.push_back(*it);
     
    779765                }
    780766
     767                NOREF(cnt);
    781768                // machines lock unwinds here
    782 #else
    783                 NOREF(cnt);
    784 #endif
    785             }
    786 
    787 #if 0
    788             update = false;
    789             for (size_t i = 0; i < cnt; ++i)
    790                 update |= (machines[i])->checkForDeath();
     769            }
    791770
    792771            updateSpawned = false;
    793772            for (size_t i = 0; i < cntSpawned; ++i)
    794773                updateSpawned |= (spawnedMachines[i])->checkForSpawnFailure();
    795 #else
    796             NOREF(cntSpawned);
    797 #endif
    798774
    799775            /* reap child processes */
  • trunk/src/VBox/Main/src-server/MachineImpl.cpp

    r49960 r49976  
    82138213        /* restore the session state */
    82148214        mData->mSession.mState = SessionState_Unlocked;
     8215        alock.release();
     8216        mParent->addProcessToReap(pid);
    82158217        /* The failure may occur w/o any error info (from RPC), so provide one */
    82168218        return setError(VBOX_E_VM_ERROR,
     
    82258227    mData->mSession.mState = SessionState_Spawning;
    82268228    mData->mSession.mType = strFrontend;
     8229
     8230    alock.release();
     8231    mParent->addProcessToReap(pid);
    82278232
    82288233    LogFlowThisFuncLeave();
     
    82968301}
    82978302
    8298 #ifndef VBOX_WITH_GENERIC_SESSION_WATCHER
    82998303/**
    83008304 * Called from the client watcher thread to check for unexpected client process
     
    83908394    return false;
    83918395}
    8392 #endif /* !VBOX_WITH_GENERIC_SESSION_WATCHER */
    83938396
    83948397/**
     
    1298512988
    1298612989    // we need to lock this object in uninit() because the lock is shared
    12987     // with mPeer (as well as data we modify below). mParent->addProcessToReap()
    12988     // and others need mParent lock, and USB needs host lock.
     12990    // with mPeer (as well as data we modify below). mParent lock is needed
     12991    // by several calls to it, and USB needs host lock.
    1298912992    AutoMultiWriteLock3 multilock(mParent, mParent->host(), this COMMA_LOCKVAL_SRC_POS);
    1299012993
     
    1304513048        mConsoleTaskData.mSnapshot->uninit();
    1304613049        releaseSavedStateFile(strStateFile, NULL /* pSnapshotToIgnore */ );
    13047     }
    13048 
    13049     if (!mData->mSession.mType.isEmpty())
    13050     {
    13051         /* mType is not null when this machine's process has been started by
    13052          * Machine::LaunchVMProcess(), therefore it is our child.  We
    13053          * need to queue the PID to reap the process (and avoid zombies on
    13054          * Linux). */
    13055         Assert(mData->mSession.mPID != NIL_RTPROCESS);
    13056         mParent->addProcessToReap(mData->mSession.mPID);
    1305713050    }
    1305813051
Note: See TracChangeset for help on using the changeset viewer.

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