VirtualBox

Changeset 75874 in vbox


Ignore:
Timestamp:
Dec 2, 2018 4:51:02 PM (6 years ago)
Author:
vboxsync
Message:

GuestControl: Added pointer to the master client so we don't have to search for it everytime it gets a message. Also a couple of build fixes for previous cleanup commit. bugref:9313

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/GuestControl/service.cpp

    r75873 r75874  
    859859    /** Map containing all connected clients, key is HGCM client ID. */
    860860    ClientStateMap  mClientStateMap; /**< @todo Use VBOXHGCMSVCFNTABLE::cbClient for this! */
     861    /** The current master client, NULL if none. */
     862    ClientState    *m_pMasterClient;
    861863    /** The master HGCM client ID, UINT32_MAX if none. */
    862864    uint32_t        m_idMasterClient;
     
    873875        , mpfnHostCallback(NULL)
    874876        , mpvHostData(NULL)
     877        , m_pMasterClient(NULL)
    875878        , m_idMasterClient(UINT32_MAX)
    876879        , m_fLegacyMode(true)
     
    953956     */
    954957    ClientState *pClient;
    955     try
     958    //try - can't currently throw anything.
    956959    {
    957960        pClient = new (pvClient) ClientState(pThis->mpHelpers, idClient);
    958961    }
    959     catch (std::bad_alloc &)
    960     {
    961         return VERR_NO_MEMORY;
    962     }
     962    //catch (std::bad_alloc &)
     963    //{
     964    //    return VERR_NO_MEMORY;
     965    //}
    963966    try
    964967    {
     
    976979     * one through the door.
    977980     */
    978 /** @todo make picking the master more dynamic/flexible. */
     981/** @todo make picking the master more dynamic/flexible? */
    979982    if (   pThis->m_fLegacyMode
    980983        && pThis->m_idMasterClient == UINT32_MAX)
     
    984987        {
    985988            LogFunc(("Picking %u as master for now.\n", idClient));
     989            pThis->m_pMasterClient  = pClient;
    986990            pThis->m_idMasterClient = idClient;
    987991            pClient->m_fIsMaster = true;
     
    10391043    if (idClient == pThis->m_idMasterClient)
    10401044    {
     1045        pThis->m_pMasterClient  = NULL;
    10411046        pThis->m_idMasterClient = UINT32_MAX;
     1047
    10421048        GstCtrlPreparedSession *pCur, *pNext;
    10431049        RTListForEachSafe(&pThis->m_PreparedSessions, pCur, pNext, GstCtrlPreparedSession, ListEntry)
     
    10481054        pThis->m_cPreparedSessions = 0;
    10491055    }
     1056    else
     1057        Assert(pClient != pThis->m_pMasterClient);
    10501058
    10511059    if (pThis->mClientStateMap.empty())
     
    11191127    if (RT_SUCCESS(rc))
    11201128    {
     1129        m_pMasterClient  = pClient;
    11211130        m_idMasterClient = pClient->m_idClient;
    11221131        m_fLegacyMode    = false;
     
    15511560    ASSERT_GUEST_RETURN(!m_fLegacyMode, VERR_ACCESS_DENIED);
    15521561    Assert(m_idMasterClient == pClient->m_idClient);
     1562    Assert(m_pMasterClient == pClient);
    15531563
    15541564    /* Now that we know it's the master, we can check for session ID duplicates. */
     
    16141624    ASSERT_GUEST_RETURN(!m_fLegacyMode, VERR_ACCESS_DENIED);
    16151625    Assert(m_idMasterClient == pClient->m_idClient);
     1626    Assert(m_pMasterClient == pClient);
    16161627
    16171628    /*
     
    16851696    ASSERT_GUEST_RETURN(!m_fLegacyMode, VERR_ACCESS_DENIED);
    16861697    Assert(m_idMasterClient != pClient->m_idClient);
     1698    Assert(m_pMasterClient != pClient);
    16871699    ASSERT_GUEST_RETURN(pClient->m_idSession == UINT32_MAX, VERR_RESOURCE_BUSY);
    16881700
     
    21492161            {
    21502162                Assert(pHostCmd);
    2151                 ClientStateMapIter It = mClientStateMap.find(m_idMasterClient);
    2152                 if (It != mClientStateMap.end())
     2163                if (m_pMasterClient)
    21532164                {
    2154                     ClientState *pClient = It->second;
    2155                     RTListAppend(&pClient->m_HostCmdList, &pHostCmd->m_ListEntry);
     2165                    RTListAppend(&m_pMasterClient->m_HostCmdList, &pHostCmd->m_ListEntry);
    21562166                    pHostCmd = NULL;
    21572167
    2158                     int rc2 = pClient->Wakeup();
    2159                     LogFlowFunc(("Woke up client ID=%RU32 (master) -> rc=%Rrc\n", pClient->m_idClient, rc2));
     2168                    int rc2 = m_pMasterClient->Wakeup();
     2169                    LogFlowFunc(("Woke up client ID=%RU32 (master) -> rc=%Rrc\n", m_pMasterClient->m_idClient, rc2));
     2170                    NOREF(rc2);
    21602171                }
    21612172                else
     
    22062217    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
    22072218
     2219    /* Note! We don't need to save the idSession here because it's only used
     2220             for sessions and the sessions are not persistent across a state
     2221             save/restore.  The Main objects aren't there.  Clients shuts down.
     2222             Only the root service survives, so remember who that is and its mode. */
     2223
    22082224    SSMR3PutU32(pSSM, 1);
    22092225    SSMR3PutBool(pSSM, pThis->m_fLegacyMode);
     
    22182234GstCtrlService::svcLoadState(void *pvService, uint32_t idClient, void *pvClient, PSSMHANDLE pSSM, uint32_t uVersion)
    22192235{
    2220     RT_NOREF(pvClient);
    22212236    SELF *pThis = reinterpret_cast<SELF *>(pvService);
    22222237    AssertPtrReturn(pThis, VERR_INVALID_POINTER);
     2238    ClientState *pClient = reinterpret_cast<ClientState *>(pvClient);
     2239    AssertReturn(pClient, VERR_INVALID_CLIENT_ID);
     2240    Assert(pClient->m_idClient == idClient);
    22232241
    22242242    if (uVersion >= HGCM_SAVED_STATE_VERSION)
     
    22382256        rc = SSMR3GetBool(pSSM, &fIsMaster);
    22392257        AssertRCReturn(rc, rc);
     2258
     2259        pClient->m_fIsMaster = fIsMaster;
    22402260        if (fIsMaster)
     2261        {
     2262            pThis->m_pMasterClient  = pClient;
    22412263            pThis->m_idMasterClient = idClient;
    2242         ClientStateMapIter It = pThis->mClientStateMap.find(idClient);
    2243         if (It != pThis->mClientStateMap.end())
    2244             It->second->m_fIsMaster = fIsMaster;
    2245         else
    2246             AssertFailed();
     2264        }
    22472265    }
    22482266    else
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