- Timestamp:
- Dec 2, 2018 5:46:10 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 127081
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/GuestControl/service.cpp
r75876 r75877 865 865 void *mpvHostData; 866 866 /** Map containing all connected clients, key is HGCM client ID. */ 867 ClientStateMap mClientStateMap; /**< @todo Use VBOXHGCMSVCFNTABLE::cbClient for this! */ 867 ClientStateMap m_ClientStateMap; 868 /** Session ID -> client state. */ 869 ClientStateMap m_SessionIdMap; 868 870 /** The current master client, NULL if none. */ 869 871 ClientState *m_pMasterClient; … … 956 958 AssertPtrReturn(pThis, VERR_INVALID_POINTER); 957 959 958 AssertMsg(pThis->m ClientStateMap.find(idClient) == pThis->mClientStateMap.end(),960 AssertMsg(pThis->m_ClientStateMap.find(idClient) == pThis->m_ClientStateMap.end(), 959 961 ("Client with ID=%RU32 already connected when it should not\n", idClient)); 960 962 … … 973 975 try 974 976 { 975 pThis->m ClientStateMap[idClient] = pClient;977 pThis->m_ClientStateMap[idClient] = pClient; 976 978 } 977 979 catch (std::bad_alloc &) … … 1018 1020 ClientState *pClient = reinterpret_cast<ClientState *>(pvClient); 1019 1021 AssertPtrReturn(pClient, VERR_INVALID_POINTER); 1020 LogFlowFunc(("[Client %RU32] Disconnected (%zu clients total)\n", idClient, pThis->m ClientStateMap.size()));1022 LogFlowFunc(("[Client %RU32] Disconnected (%zu clients total)\n", idClient, pThis->m_ClientStateMap.size())); 1021 1023 1022 1024 /* … … 1041 1043 * Delete the client state. 1042 1044 */ 1043 pThis->mClientStateMap.erase(idClient); 1045 pThis->m_ClientStateMap.erase(idClient); 1046 if (pClient->m_idSession != UINT32_MAX) 1047 pThis->m_SessionIdMap.erase(pClient->m_idSession); 1044 1048 pClient->~ClientState(); 1045 1049 pClient = NULL; … … 1064 1068 Assert(pClient != pThis->m_pMasterClient); 1065 1069 1066 if (pThis->m ClientStateMap.empty())1070 if (pThis->m_ClientStateMap.empty()) 1067 1071 pThis->m_fLegacyMode = true; 1068 1072 … … 1718 1722 { 1719 1723 /* 1720 * We've got a match. Try complete the request and 1724 * We've got a match. 1725 * Try insert it into the sessio ID map and complete the request. 1721 1726 */ 1727 try 1728 { 1729 m_SessionIdMap[idSession] = pClient; 1730 } 1731 catch (std::bad_alloc &) 1732 { 1733 LogFunc(("Out of memory!\n")); 1734 return VERR_NO_MEMORY; 1735 } 1736 1722 1737 int rc = mpHelpers->pfnCallComplete(hCall, VINF_SUCCESS); 1723 1738 if (RT_SUCCESS(rc)) … … 1731 1746 } 1732 1747 else 1748 { 1733 1749 LogFunc(("pfnCallComplete -> %Rrc\n", rc)); 1750 m_SessionIdMap.erase(idSession); 1751 } 1734 1752 return VINF_HGCM_ASYNC_EXECUTE; /* The caller must not complete it. */ 1735 1753 } … … 1829 1847 ASSERT_GUEST_LOGREL_MSG_RETURN(idSession > 0, ("idSession=%u (%#x)\n", idSession, uValue), VERR_OUT_OF_RANGE); 1830 1848 1831 for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It) 1832 ASSERT_GUEST_LOGREL_MSG_RETURN(It->second->m_idSession != idSession, 1833 ("idSession=%u uValue=%#x idClient=%u; conflicting with client %u\n", 1834 idSession, uValue, pClient->m_idClient, It->second->m_idClient), 1835 VERR_DUPLICATE); 1849 ClientStateMap::iterator ItConflict = m_SessionIdMap.find(idSession); 1850 ASSERT_GUEST_LOGREL_MSG_RETURN(ItConflict == m_SessionIdMap.end(), 1851 ("idSession=%u uValue=%#x idClient=%u; conflicting with client %u\n", 1852 idSession, uValue, pClient->m_idClient, ItConflict->second->m_idClient), 1853 VERR_DUPLICATE); 1854 1836 1855 /* Commit it. */ 1856 try 1857 { 1858 m_SessionIdMap[idSession] = pClient; 1859 } 1860 catch (std::bad_alloc &) 1861 { 1862 LogFunc(("Out of memory\n")); 1863 return VERR_NO_MEMORY; 1864 } 1837 1865 pClient->m_idSession = idSession; 1838 1866 } … … 2101 2129 * the guest is not running/system is messed up somehow. 2102 2130 */ 2103 if (m ClientStateMap.empty())2131 if (m_ClientStateMap.empty()) 2104 2132 { 2105 2133 LogFlow(("GstCtrlService::hostProcessCommand: VERR_NOT_FOUND!\n")); … … 2132 2160 { 2133 2161 LogFlowFunc(("Handling host command m_idContextAndDst=%#RX64, idFunction=%RU32, cParms=%RU32, paParms=%p, cClients=%zu\n", 2134 pHostCmd->m_idContextAndDst, idFunction, cParms, paParms, m ClientStateMap.size()));2162 pHostCmd->m_idContextAndDst, idFunction, cParms, paParms, m_ClientStateMap.size())); 2135 2163 2136 2164 /* … … 2138 2166 * session ID doesn't match any particular client it goes to the master. 2139 2167 */ 2140 AssertMsg(!m ClientStateMap.empty(), ("Client state map is empty when it should not be!\n"));2168 AssertMsg(!m_ClientStateMap.empty(), ("Client state map is empty when it should not be!\n")); 2141 2169 2142 2170 /* Dispatch to the session. */ 2143 2171 if (fDestinations & VBOX_GUESTCTRL_DST_SESSION) 2144 2172 { 2145 rc = VWRN_NOT_FOUND;2146 2173 uint32_t const idSession = VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHostCmd->m_idContext); 2147 for (ClientStateMap::iterator It = mClientStateMap.begin(); It != mClientStateMap.end(); ++It) 2174 ClientStateMap::iterator It = m_SessionIdMap.find(idSession); 2175 if (It != m_SessionIdMap.end()) 2148 2176 { 2149 2177 ClientState *pClient = It->second; 2150 if (pClient->m_idSession == idSession) 2151 { 2152 RTListAppend(&pClient->m_HostCmdList, &pHostCmd->m_ListEntry); 2153 pHostCmd = pHostCmd2; 2154 pHostCmd2 = NULL; 2155 2156 int rc2 = pClient->Wakeup(); 2157 LogFlowFunc(("Woke up client ID=%RU32 -> rc=%Rrc\n", pClient->m_idClient, rc2)); 2158 RT_NOREF(rc2); 2159 rc = VINF_SUCCESS; 2160 break; 2161 } 2178 Assert(pClient->m_idSession == idSession); 2179 RTListAppend(&pClient->m_HostCmdList, &pHostCmd->m_ListEntry); 2180 pHostCmd = pHostCmd2; 2181 pHostCmd2 = NULL; 2182 2183 int rc2 = pClient->Wakeup(); 2184 LogFlowFunc(("Woke up client ID=%RU32 -> rc=%Rrc\n", pClient->m_idClient, rc2)); 2185 RT_NOREF(rc2); 2186 rc = VINF_SUCCESS; 2187 } 2188 else 2189 { 2190 LogFunc(("No client with session ID %u was found! (idFunction=%d %s)\n", 2191 idSession, idFunction, GstCtrlHostFnName((eHostFn)idFunction))); 2192 rc = !(fDestinations & VBOX_GUESTCTRL_DST_ROOT_SVC) ? VERR_NOT_FOUND : VWRN_NOT_FOUND; 2162 2193 } 2163 2194 }
Note:
See TracChangeset
for help on using the changeset viewer.