VirtualBox

Changeset 49502 in vbox


Ignore:
Timestamp:
Nov 15, 2013 1:11:13 PM (11 years ago)
Author:
vboxsync
Message:

FE/VBoxManage: GuestCtrl: Don't use signal handlers for closing active guest sessions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageGuestCtrl.cpp

    r49439 r49502  
    6363using namespace com;
    6464
    65 /** Set by the signal handler. */
    66 static volatile bool         g_fGuestCtrlCanceled = false;
    67 /** Our global session object which is also used in the
    68  *  signal handler to abort operations properly. */
    69 static ComPtr<IGuestSession> g_pGuestSession = NULL;
     65/** Set by the signal handler when current guest control
     66 *  action shall be aborted. */
     67static volatile bool g_fGuestCtrlCanceled = false;
    7068
    7169/**
     
    403401        case CTRL_C_EVENT:
    404402            ASMAtomicWriteBool(&g_fGuestCtrlCanceled, true);
    405             if (!g_pGuestSession.isNull())
    406                 g_pGuestSession->Close();
    407403            fEventHandled = TRUE;
    408404            break;
     
    419415 *
    420416 * This can be executed on any thread in the process, on Windows it may even be
    421  * a thread dedicated to delivering this signal.  Do not doing anything
     417 * a thread dedicated to delivering this signal.  Don't do anything
    422418 * unnecessary here.
    423419 */
     
    426422    NOREF(iSignal);
    427423    ASMAtomicWriteBool(&g_fGuestCtrlCanceled, true);
    428     if (!g_pGuestSession.isNull())
    429         g_pGuestSession->Close();
    430424}
    431425#endif
     
    727721                     && pCtx->fVerbose)
    728722                RTPrintf("Guest session detached\n");
    729 
     723#ifdef DEBUG
     724            ULONG cRefs = pCtx->pGuestSession->AddRef();
     725            RTPrintf("cRefs=%RU32\n", cRefs - 1);
     726            pCtx->pGuestSession->Release();
     727#endif
    730728            pCtx->pGuestSession.setNull();
    731729        }
    732730
    733         g_pGuestSession.setNull();
    734731        if (pCtx->handlerArg.session)
    735732            CHECK_ERROR(pCtx->handlerArg.session, UnlockMachine());
     
    992989                && !(uFlags & CTLCMDCTX_FLAGS_NO_SIGNAL_HANDLER))
    993990            {
    994                 /* Add session to global for being accessible by the
    995                  * signal handler. */
    996                 g_pGuestSession = pCtx->pGuestSession;
    997 
    998991                ctrlSignalHandlerInstall();
    999992            }
     
    13411334                cMsTimeLeft = ctrlExecGetRemainingTime(u64StartMS, cMsTimeout);
    13421335                CHECK_ERROR_BREAK(pProcess, WaitForArray(ComSafeArrayAsInParam(aWaitFlags),
    1343                                                          cMsTimeLeft, &waitResult));
     1336                                                         500 /* ms */, &waitResult));
    13441337                switch (waitResult)
    13451338                {
     
    13741367                        break;
    13751368                    }
     1369                    case ProcessWaitResult_Timeout:
     1370                        /* Fall through is intentional. */
    13761371                    default:
    13771372                        /* Ignore all other results, let the timeout expire */
     
    14671462         */
    14681463        fCloseSession = !fDetached;
     1464
     1465        /*
     1466         * If execution was aborted from the host side (signal handler),
     1467         * close the guest session in any case.
     1468         */
     1469        if (g_fGuestCtrlCanceled)
     1470            fCloseSession = true;
    14691471    }
    14701472    else /* Close session on error. */
     
    37263728    HRESULT rc = S_OK;
    37273729
    3728     ComPtr<IGuestSession> pSession;
    37293730    do
    37303731    {
     
    37383739        for (size_t i = 0; i < cSessions; i++)
    37393740        {
    3740             pSession = collSessions[i];
     3741            ComPtr<IGuestSession> pSession = collSessions[i];
    37413742            Assert(!pSession.isNull());
    37423743
     
    37693770                    RTPrintf("Guest session successfully closed\n");
    37703771
    3771                 pSession->Release();
     3772                pSession.setNull();
    37723773            }
    37733774        }
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