VirtualBox

Changeset 93048 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Dec 21, 2021 2:30:00 PM (3 years ago)
Author:
vboxsync
Message:

Guest Control/Host Service: Make sure that the host gets notified about still associated guest sessions going down. See comment for more details.

File:
1 edited

Legend:

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

    r90805 r93048  
    10481048
    10491049    /*
     1050     * If it's the master disconnecting, we need to reset related globals.
     1051     */
     1052    if (idClient == pThis->m_idMasterClient)
     1053    {
     1054        pThis->m_pMasterClient  = NULL;
     1055        pThis->m_idMasterClient = UINT32_MAX;
     1056
     1057        GstCtrlPreparedSession *pCur, *pNext;
     1058        RTListForEachSafe(&pThis->m_PreparedSessions, pCur, pNext, GstCtrlPreparedSession, ListEntry)
     1059        {
     1060            RTListNodeRemove(&pCur->ListEntry);
     1061            RTMemFree(pCur);
     1062        }
     1063        pThis->m_cPreparedSessions = 0;
     1064
     1065        /* Make sure that the host gets notified about still associated guest sessions going down.
     1066         *
     1067         * Some guest OSes (like OL8) do reboot / shut down quite abruptly so that
     1068         * VBoxService does not have the chance to do so instead.
     1069         *
     1070         * Note: We do this only when the master disconnects as a last meassure, as this otherwise
     1071         *       would overwrite formerly sent session statuses on the host.
     1072         */
     1073        ClientStateMap::const_iterator itClientState = pThis->m_SessionIdMap.begin();
     1074        while (itClientState != pThis->m_SessionIdMap.end())
     1075        {
     1076            VBOXHGCMSVCPARM aParms[4];
     1077            HGCMSvcSetU32(&aParms[0], VBOX_GUESTCTRL_CONTEXTID_MAKE(pCur->idSession, 0 /* uObject */, 0 /* uCount */));
     1078            HGCMSvcSetU32(&aParms[1], GUEST_SESSION_NOTIFYTYPE_DWN); /* type */
     1079            HGCMSvcSetU32(&aParms[2], VINF_SUCCESS);                 /* result */
     1080
     1081            int rc2 = pThis->hostCallback(GUEST_MSG_SESSION_NOTIFY, 3, aParms);
     1082            LogFlowFunc(("Notified host about session ID=%RU32 going down -> %Rrc\n", pClient->m_idSession, rc2));
     1083            RT_NOREF(rc2);
     1084
     1085            ++itClientState;
     1086            /* Note: Don't erase the client state -- this will be done when the actual client is disconnecting. */
     1087        }
     1088    }
     1089    else
     1090        Assert(pClient != pThis->m_pMasterClient);
     1091
     1092    /*
    10501093     * Delete the client state.
    10511094     */
     
    10541097        pThis->m_SessionIdMap.erase(pClient->m_idSession);
    10551098    pClient->~ClientState();
    1056 
    1057     /*
    1058      * If it's the master disconnecting, we need to reset related globals.
    1059      */
    1060     if (idClient == pThis->m_idMasterClient)
    1061     {
    1062         pThis->m_pMasterClient  = NULL;
    1063         pThis->m_idMasterClient = UINT32_MAX;
    1064 
    1065         GstCtrlPreparedSession *pCur, *pNext;
    1066         RTListForEachSafe(&pThis->m_PreparedSessions, pCur, pNext, GstCtrlPreparedSession, ListEntry)
    1067         {
    1068             RTListNodeRemove(&pCur->ListEntry);
    1069             RTMemFree(pCur);
    1070         }
    1071         pThis->m_cPreparedSessions = 0;
    1072     }
    1073     else
    1074         Assert(pClient != pThis->m_pMasterClient);
    10751099
    10761100    if (pThis->m_ClientStateMap.empty())
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