VirtualBox

Changeset 71634 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Apr 3, 2018 5:45:44 PM (7 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Use the session ID for Guest::i_sessionRemove() and avoid searching for it (as the primary key in the session map is the ID anyway).

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

Legend:

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

    r71406 r71634  
    105105#ifdef VBOX_WITH_GUEST_CONTROL
    106106    int         i_dispatchToSession(PVBOXGUESTCTRLHOSTCBCTX pCtxCb, PVBOXGUESTCTRLHOSTCALLBACK pSvcCb);
    107     int         i_sessionRemove(GuestSession *pSession);
     107    int         i_sessionRemove(uint32_t uSessionID);
    108108    int         i_sessionCreate(const GuestSessionStartupInfo &ssInfo, const GuestCredentials &guestCreds,
    109109                                ComObjPtr<GuestSession> &pGuestSession);
  • trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp

    r71560 r71634  
    224224}
    225225
    226 int Guest::i_sessionRemove(GuestSession *pSession)
    227 {
    228     AssertPtrReturn(pSession, VERR_INVALID_POINTER);
    229 
     226int Guest::i_sessionRemove(uint32_t uSessionID)
     227{
    230228    LogFlowThisFuncEnter();
    231229
     
    234232    int rc = VERR_NOT_FOUND;
    235233
    236     LogFlowThisFunc(("Removing session (ID=%RU32) ...\n", pSession->i_getId()));
    237 
    238     GuestSessions::iterator itSessions = mData.mGuestSessions.begin();
    239     while (itSessions != mData.mGuestSessions.end())
    240     {
    241         if (pSession == itSessions->second)
    242         {
    243 #ifdef DEBUG_andy
    244             ULONG cRefs = pSession->AddRef();
    245             Assert(cRefs >= 2);
    246             LogFlowThisFunc(("pCurSession=%p, cRefs=%RU32\n", pSession, cRefs - 2));
    247             pSession->Release();
    248 #endif
    249             /* Make sure to consume the pointer before the one of the
    250              * iterator gets released. */
    251             ComObjPtr<GuestSession> pCurSession = pSession;
    252 
    253             LogFlowThisFunc(("Removing session (pSession=%p, ID=%RU32) (now total %ld sessions)\n",
    254                              pSession, pSession->i_getId(), mData.mGuestSessions.size() - 1));
    255 
    256             rc = pSession->i_onRemove();
    257             mData.mGuestSessions.erase(itSessions);
    258 
    259             alock.release(); /* Release lock before firing off event. */
    260 
    261             fireGuestSessionRegisteredEvent(mEventSource, pCurSession,
    262                                             false /* Unregistered */);
    263             pCurSession.setNull();
    264             break;
    265         }
    266 
    267         ++itSessions;
    268     }
     234    LogFlowThisFunc(("Removing session (ID=%RU32) ...\n", uSessionID));
     235
     236    GuestSessions::const_iterator itSessions = mData.mGuestSessions.find(uSessionID);
     237    if (itSessions == mData.mGuestSessions.end())
     238        return VERR_NOT_FOUND;
     239
     240    /* Make sure to consume the pointer before the one of the
     241     * iterator gets released. */
     242    ComObjPtr<GuestSession> pSession = itSessions->second;
     243
     244    LogFlowThisFunc(("Removing session %RU32 (now total %ld sessions)\n",
     245                     pSession, uSessionID, mData.mGuestSessions.size() ? mData.mGuestSessions.size() - 1 : 0));
     246
     247    rc = pSession->i_onRemove();
     248    mData.mGuestSessions.erase(itSessions);
     249
     250    alock.release(); /* Release lock before firing off event. */
     251
     252    fireGuestSessionRegisteredEvent(mEventSource, pSession, false /* Unregistered */);
     253    pSession.setNull();
    269254
    270255    LogFlowFuncLeaveRC(rc);
  • trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp

    r71560 r71634  
    25342534
    25352535    /* Remove ourselves from the session list. */
    2536     int rc2 = mParent->i_sessionRemove(this);
     2536    AssertPtr(mParent);
     2537    int rc2 = mParent->i_sessionRemove(mData.mSession.mID);
    25372538    if (rc2 == VERR_NOT_FOUND) /* Not finding the session anymore isn't critical. */
    25382539        rc2 = VINF_SUCCESS;
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