Changeset 75541 in vbox for trunk/src/VBox/Main/src-client
- Timestamp:
- Nov 17, 2018 3:50:40 AM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 126699
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/HGCM.cpp
r75539 r75541 438 438 { 439 439 public: 440 HGCMMsgCall() {} 441 442 HGCMMsgCall(HGCMThread *pThread) 443 { 444 InitializeCore(SVC_MSG_GUESTCALL, pThread); 445 Initialize(); 446 } 447 ~HGCMMsgCall() { Log(("~HGCMMsgCall %p\n", this)); } 448 440 449 /* client identifier */ 441 450 uint32_t u32ClientId; … … 947 956 948 957 /* Execute the load request on the service thread. */ 949 HGCMM SGHANDLE hMsg;950 rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_LOAD, hgcmMessageAllocSvc);958 HGCMMsgCore *pCoreMsg; 959 rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_LOAD, hgcmMessageAllocSvc); 951 960 952 961 if (RT_SUCCESS(rc)) 953 962 { 954 HGCMMsgSvcLoad *pMsg = (HGCMMsgSvcLoad *) hgcmObjReference(hMsg, HGCMOBJ_MSG);955 AssertRelease(pMsg); 963 HGCMMsgSvcLoad *pMsg = (HGCMMsgSvcLoad *)pCoreMsg; 964 956 965 pMsg->pUVM = pUVM; 957 hgcmObjDereference(pMsg); 958 959 rc = hgcmMsgSend(hMsg); 966 967 rc = hgcmMsgSend(pMsg); 960 968 } 961 969 } … … 975 983 LogFlowFunc(("%s\n", m_pszSvcName)); 976 984 977 HGCMM SGHANDLE hMsg;978 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_UNLOAD, hgcmMessageAllocSvc);985 HGCMMsgCore *pMsg; 986 int rc = hgcmMsgAlloc(m_pThread, &pMsg, SVC_MSG_UNLOAD, hgcmMessageAllocSvc); 979 987 980 988 if (RT_SUCCESS(rc)) 981 989 { 982 rc = hgcmMsgSend( hMsg);990 rc = hgcmMsgSend(pMsg); 983 991 984 992 if (RT_SUCCESS(rc)) … … 1001 1009 LogFlowFunc(("%s\n", m_pszSvcName)); 1002 1010 1003 HGCMM SGHANDLE hMsg;1004 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_SAVESTATE, hgcmMessageAllocSvc);1011 HGCMMsgCore *pCoreMsg; 1012 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_SAVESTATE, hgcmMessageAllocSvc); 1005 1013 1006 1014 if (RT_SUCCESS(rc)) 1007 1015 { 1008 HGCMMsgLoadSaveStateClient *pMsg = (HGCMMsgLoadSaveStateClient *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1009 AssertRelease(pMsg); 1016 HGCMMsgLoadSaveStateClient *pMsg = (HGCMMsgLoadSaveStateClient *)pCoreMsg; 1010 1017 1011 1018 pMsg->u32ClientId = u32ClientId; 1012 1019 pMsg->pSSM = pSSM; 1013 1020 1014 hgcmObjDereference(pMsg); 1015 1016 rc = hgcmMsgSend(hMsg); 1021 rc = hgcmMsgSend(pMsg); 1017 1022 } 1018 1023 … … 1025 1030 LogFlowFunc(("%s\n", m_pszSvcName)); 1026 1031 1027 HGCMM SGHANDLE hMsg;1028 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_LOADSTATE, hgcmMessageAllocSvc);1032 HGCMMsgCore *pCoreMsg; 1033 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_LOADSTATE, hgcmMessageAllocSvc); 1029 1034 1030 1035 if (RT_SUCCESS(rc)) 1031 1036 { 1032 HGCMMsgLoadSaveStateClient *pMsg = (HGCMMsgLoadSaveStateClient *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1033 1034 AssertRelease(pMsg); 1037 HGCMMsgLoadSaveStateClient *pMsg = (HGCMMsgLoadSaveStateClient *)pCoreMsg; 1035 1038 1036 1039 pMsg->u32ClientId = u32ClientId; 1037 1040 pMsg->pSSM = pSSM; 1038 1041 1039 hgcmObjDereference(pMsg); 1040 1041 rc = hgcmMsgSend(hMsg); 1042 rc = hgcmMsgSend(pMsg); 1042 1043 } 1043 1044 … … 1471 1472 { 1472 1473 /* Call the service. */ 1473 HGCMM SGHANDLE hMsg;1474 1475 rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_CONNECT, hgcmMessageAllocSvc);1474 HGCMMsgCore *pCoreMsg; 1475 1476 rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_CONNECT, hgcmMessageAllocSvc); 1476 1477 1477 1478 if (RT_SUCCESS(rc)) 1478 1479 { 1479 HGCMMsgSvcConnect *pMsg = (HGCMMsgSvcConnect *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1480 AssertRelease(pMsg); 1480 HGCMMsgSvcConnect *pMsg = (HGCMMsgSvcConnect *)pCoreMsg; 1481 1481 1482 1482 pMsg->u32ClientId = handle; 1483 1483 1484 hgcmObjDereference(pMsg); 1485 1486 rc = hgcmMsgSend(hMsg); 1484 rc = hgcmMsgSend(pMsg); 1487 1485 1488 1486 if (RT_SUCCESS(rc)) … … 1498 1496 uint32_t *paClientIdsNew; 1499 1497 1500 paClientIdsNew = (uint32_t *)RTMemRealloc(m_paClientIds, (m_cClientsAllocated + cDelta) *1501 sizeof(m_paClientIds[0]));1498 paClientIdsNew = (uint32_t *)RTMemRealloc(m_paClientIds, 1499 (m_cClientsAllocated + cDelta) * sizeof(m_paClientIds[0])); 1502 1500 Assert(paClientIdsNew); 1503 1501 … … 1556 1554 { 1557 1555 /* Call the service. */ 1558 HGCMM SGHANDLE hMsg;1559 1560 rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_DISCONNECT, hgcmMessageAllocSvc);1556 HGCMMsgCore *pCoreMsg; 1557 1558 rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_DISCONNECT, hgcmMessageAllocSvc); 1561 1559 1562 1560 if (RT_SUCCESS(rc)) 1563 1561 { 1564 HGCMMsgSvcDisconnect *pMsg = (HGCMMsgSvcDisconnect *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1565 AssertRelease(pMsg); 1562 HGCMMsgSvcDisconnect *pMsg = (HGCMMsgSvcDisconnect *)pCoreMsg; 1566 1563 1567 1564 pMsg->u32ClientId = u32ClientId; 1568 1565 1569 hgcmObjDereference(pMsg); 1570 1571 rc = hgcmMsgSend(hMsg); 1566 rc = hgcmMsgSend(pMsg); 1572 1567 } 1573 1568 else … … 1611 1606 1612 1607 /* Forward the message to the service thread. */ 1613 HGCMM SGHANDLE hMsg = 0;1614 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_REGEXT, hgcmMessageAllocSvc);1608 HGCMMsgCore *pCoreMsg; 1609 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_REGEXT, hgcmMessageAllocSvc); 1615 1610 1616 1611 if (RT_SUCCESS(rc)) 1617 1612 { 1618 HGCMMsgSvcRegisterExtension *pMsg = (HGCMMsgSvcRegisterExtension *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1619 AssertRelease(pMsg); 1613 HGCMMsgSvcRegisterExtension *pMsg = (HGCMMsgSvcRegisterExtension *)pCoreMsg; 1620 1614 1621 1615 pMsg->handle = handle; … … 1623 1617 pMsg->pvExtension = pvExtension; 1624 1618 1625 hgcmObjDereference(pMsg); 1626 1627 rc = hgcmMsgSend(hMsg); 1619 rc = hgcmMsgSend(pMsg); 1628 1620 } 1629 1621 … … 1635 1627 { 1636 1628 /* Forward the message to the service thread. */ 1637 HGCMM SGHANDLE hMsg = 0;1638 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_UNREGEXT, hgcmMessageAllocSvc);1629 HGCMMsgCore *pCoreMsg; 1630 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_UNREGEXT, hgcmMessageAllocSvc); 1639 1631 1640 1632 if (RT_SUCCESS(rc)) 1641 1633 { 1642 HGCMMsgSvcUnregisterExtension *pMsg = (HGCMMsgSvcUnregisterExtension *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1643 AssertRelease(pMsg); 1634 HGCMMsgSvcUnregisterExtension *pMsg = (HGCMMsgSvcUnregisterExtension *)pCoreMsg; 1644 1635 1645 1636 pMsg->handle = handle; 1646 1637 1647 hgcmObjDereference(pMsg); 1648 1649 rc = hgcmMsgSend(hMsg); 1638 rc = hgcmMsgSend(pMsg); 1650 1639 } 1651 1640 … … 1653 1642 } 1654 1643 1655 /* Perform a guest call to the service.1644 /** Perform a guest call to the service. 1656 1645 * 1657 1646 * @param pHGCMPort The port to be used for completion confirmation. … … 1663 1652 * @param tsArrival The STAM_GET_TS() value when the request arrived. 1664 1653 * @return VBox rc. 1654 * @retval VINF_HGCM_ASYNC_EXECUTE on success. 1665 1655 */ 1666 1656 int HGCMService::GuestCall(PPDMIHGCMPORT pHGCMPort, PVBOXHGCMCMD pCmd, uint32_t u32ClientId, uint32_t u32Function, 1667 1657 uint32_t cParms, VBOXHGCMSVCPARM paParms[], uint64_t tsArrival) 1668 1658 { 1669 HGCMMSGHANDLE hMsg = 0;1670 1671 1659 LogFlow(("MAIN::HGCMService::Call\n")); 1672 1660 1673 int rc = hgcmMsgAlloc(m_pThread, &hMsg, SVC_MSG_GUESTCALL, hgcmMessageAllocSvc); 1674 1675 if (RT_SUCCESS(rc)) 1676 { 1677 HGCMMsgCall *pMsg = (HGCMMsgCall *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1678 1679 AssertRelease(pMsg); 1680 1681 pMsg->pCmd = pCmd; 1682 pMsg->pHGCMPort = pHGCMPort; 1683 1661 int rc; 1662 HGCMMsgCall *pMsg = new (std::nothrow) HGCMMsgCall(m_pThread); 1663 if (pMsg) 1664 { 1665 pMsg->Reference(); 1666 1667 pMsg->pCmd = pCmd; 1668 pMsg->pHGCMPort = pHGCMPort; 1684 1669 pMsg->u32ClientId = u32ClientId; 1685 1670 pMsg->u32Function = u32Function; … … 1688 1673 pMsg->tsArrival = tsArrival; 1689 1674 1690 hgcmObjDereference(pMsg); 1691 1692 rc = hgcmMsgPost(hMsg, hgcmMsgCompletionCallback); 1675 rc = hgcmMsgPost(pMsg, hgcmMsgCompletionCallback); 1693 1676 } 1694 1677 else 1695 1678 { 1696 Log(("MAIN::HGCMService::Call: Message allocation failed: %Rrc\n", rc)); 1679 Log(("MAIN::HGCMService::Call: Message allocation failed\n")); 1680 rc = VERR_NO_MEMORY; 1697 1681 } 1698 1682 … … 1701 1685 } 1702 1686 1703 /* Perform a host call the service.1687 /** Perform a host call the service. 1704 1688 * 1705 1689 * @param u32Function The function number. … … 1713 1697 m_pszSvcName, u32Function, cParms, paParms)); 1714 1698 1715 HGCMM SGHANDLE hMsg = 0;1716 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_HOSTCALL, hgcmMessageAllocSvc);1699 HGCMMsgCore *pCoreMsg; 1700 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_HOSTCALL, hgcmMessageAllocSvc); 1717 1701 1718 1702 if (RT_SUCCESS(rc)) 1719 1703 { 1720 HGCMMsgHostCallSvc *pMsg = (HGCMMsgHostCallSvc *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1721 AssertRelease(pMsg); 1704 HGCMMsgHostCallSvc *pMsg = (HGCMMsgHostCallSvc *)pCoreMsg; 1722 1705 1723 1706 pMsg->u32Function = u32Function; … … 1725 1708 pMsg->paParms = paParms; 1726 1709 1727 hgcmObjDereference(pMsg); 1728 1729 rc = hgcmMsgSend(hMsg); 1710 rc = hgcmMsgSend(pMsg); 1730 1711 } 1731 1712 … … 1735 1716 1736 1717 #ifdef VBOX_WITH_CRHGSMI 1718 1737 1719 static DECLCALLBACK(void) hgcmMsgFastCallCompletionCallback(int32_t result, HGCMMsgCore *pMsgCore) 1738 1720 { … … 1742 1724 HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pMsgCore; 1743 1725 if (pMsg->pfnCompletion) 1744 {1745 1726 pMsg->pfnCompletion(result, pMsg->u32Function, &pMsg->Param, pMsg->pvCompletion); 1746 }1747 1727 } 1748 1728 … … 1770 1750 m_pszSvcName, u32Function, pParm)); 1771 1751 1772 HGCMM SGHANDLE hMsg = 0;1773 int rc = hgcmMsgAlloc(m_pThread, & hMsg, SVC_MSG_HOSTFASTCALLASYNC, hgcmMessageAllocSvc);1752 HGCMMsgCore *pCoreMsg; 1753 int rc = hgcmMsgAlloc(m_pThread, &pCoreMsg, SVC_MSG_HOSTFASTCALLASYNC, hgcmMessageAllocSvc); 1774 1754 1775 1755 if (RT_SUCCESS(rc)) 1776 1756 { 1777 HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 1778 AssertRelease(pMsg); 1757 HGCMMsgHostFastCallAsyncSvc *pMsg = (HGCMMsgHostFastCallAsyncSvc *)pCoreMsg; 1779 1758 1780 1759 pMsg->u32Function = u32Function; … … 1783 1762 pMsg->pvCompletion = pvCompletion; 1784 1763 1785 hgcmObjDereference(pMsg); 1786 1787 rc = hgcmMsgPost(hMsg, hgcmMsgFastCallCompletionCallback); 1764 rc = hgcmMsgPost(pMsg, hgcmMsgFastCallCompletionCallback); 1788 1765 } 1789 1766 … … 1791 1768 return rc; 1792 1769 } 1793 #endif 1770 1771 #endif /* VBOX_WITH_CRHGSMI */ 1794 1772 1795 1773 /* … … 1922 1900 case HGCM_MSG_UNREGEXT: return new HGCMMsgMainUnregisterExtension(); 1923 1901 #ifdef VBOX_WITH_CRHGSMI 1924 case HGCM_MSG_SVCAQUIRE: return new HGCMMsgMainSvcAcquire();1902 case HGCM_MSG_SVCAQUIRE: return new HGCMMsgMainSvcAcquire(); 1925 1903 case HGCM_MSG_SVCRELEASE: return new HGCMMsgMainSvcRelease(); 1926 1904 #endif … … 2217 2195 2218 2196 /* Forward the request to the main hgcm thread. */ 2219 HGCMMSGHANDLE hMsg = 0; 2220 2221 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_LOAD, hgcmMainMessageAlloc); 2197 HGCMMsgCore *pCoreMsg; 2198 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_LOAD, hgcmMainMessageAlloc); 2222 2199 2223 2200 if (RT_SUCCESS(rc)) 2224 2201 { 2225 2202 /* Initialize the message. Since the message is synchronous, use the supplied pointers. */ 2226 HGCMMsgMainLoad *pMsg = (HGCMMsgMainLoad *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2227 AssertRelease(pMsg); 2203 HGCMMsgMainLoad *pMsg = (HGCMMsgMainLoad *)pCoreMsg; 2228 2204 2229 2205 pMsg->pszServiceLibrary = pszServiceLibrary; … … 2231 2207 pMsg->pUVM = pUVM; 2232 2208 2233 hgcmObjDereference(pMsg); 2234 2235 rc = hgcmMsgSend(hMsg); 2209 rc = hgcmMsgSend(pMsg); 2236 2210 } 2237 2211 … … 2261 2235 2262 2236 /* Forward the request to the main hgcm thread. */ 2263 HGCMMSGHANDLE hMsg = 0; 2264 2265 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_REGEXT, hgcmMainMessageAlloc); 2237 HGCMMsgCore *pCoreMsg; 2238 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_REGEXT, hgcmMainMessageAlloc); 2266 2239 2267 2240 if (RT_SUCCESS(rc)) 2268 2241 { 2269 2242 /* Initialize the message. Since the message is synchronous, use the supplied pointers. */ 2270 HGCMMsgMainRegisterExtension *pMsg = (HGCMMsgMainRegisterExtension *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2271 AssertRelease(pMsg); 2243 HGCMMsgMainRegisterExtension *pMsg = (HGCMMsgMainRegisterExtension *)pCoreMsg; 2272 2244 2273 2245 pMsg->pHandle = pHandle; … … 2276 2248 pMsg->pvExtension = pvExtension; 2277 2249 2278 hgcmObjDereference(pMsg); 2279 2280 rc = hgcmMsgSend(hMsg); 2250 rc = hgcmMsgSend(pMsg); 2281 2251 } 2282 2252 … … 2290 2260 2291 2261 /* Forward the request to the main hgcm thread. */ 2292 HGCMMSGHANDLE hMsg = 0; 2293 2294 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_UNREGEXT, hgcmMainMessageAlloc); 2262 HGCMMsgCore *pCoreMsg; 2263 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_UNREGEXT, hgcmMainMessageAlloc); 2295 2264 2296 2265 if (RT_SUCCESS(rc)) 2297 2266 { 2298 2267 /* Initialize the message. */ 2299 HGCMMsgMainUnregisterExtension *pMsg = (HGCMMsgMainUnregisterExtension *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2300 AssertRelease(pMsg); 2268 HGCMMsgMainUnregisterExtension *pMsg = (HGCMMsgMainUnregisterExtension *)pCoreMsg; 2301 2269 2302 2270 pMsg->handle = handle; 2303 2271 2304 hgcmObjDereference(pMsg); 2305 2306 rc = hgcmMsgSend(hMsg); 2272 rc = hgcmMsgSend(pMsg); 2307 2273 } 2308 2274 … … 2333 2299 2334 2300 /* Forward the request to the main hgcm thread. */ 2335 HGCMMSGHANDLE hMsg = 0; 2336 2337 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_CONNECT, hgcmMainMessageAlloc); 2301 HGCMMsgCore *pCoreMsg; 2302 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_CONNECT, hgcmMainMessageAlloc); 2338 2303 2339 2304 if (RT_SUCCESS(rc)) … … 2343 2308 * use the supplied pointers. 2344 2309 */ 2345 HGCMMsgMainConnect *pMsg = (HGCMMsgMainConnect *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2346 AssertRelease(pMsg); 2310 HGCMMsgMainConnect *pMsg = (HGCMMsgMainConnect *)pCoreMsg; 2347 2311 2348 2312 pMsg->pHGCMPort = pHGCMPort; … … 2351 2315 pMsg->pu32ClientId = pu32ClientId; 2352 2316 2353 hgcmObjDereference(pMsg); 2354 2355 rc = hgcmMsgPost(hMsg, hgcmMsgCompletionCallback); 2317 rc = hgcmMsgPost(pMsg, hgcmMsgCompletionCallback); 2356 2318 } 2357 2319 … … 2380 2342 2381 2343 /* Forward the request to the main hgcm thread. */ 2382 HGCMMSGHANDLE hMsg = 0; 2383 2384 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_DISCONNECT, hgcmMainMessageAlloc); 2344 HGCMMsgCore *pCoreMsg; 2345 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_DISCONNECT, hgcmMainMessageAlloc); 2385 2346 2386 2347 if (RT_SUCCESS(rc)) 2387 2348 { 2388 2349 /* Initialize the message. */ 2389 HGCMMsgMainDisconnect *pMsg = (HGCMMsgMainDisconnect *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2390 AssertRelease(pMsg); 2350 HGCMMsgMainDisconnect *pMsg = (HGCMMsgMainDisconnect *)pCoreMsg; 2391 2351 2392 2352 pMsg->pCmd = pCmd; … … 2394 2354 pMsg->u32ClientId = u32ClientId; 2395 2355 2396 hgcmObjDereference(pMsg); 2397 2398 rc = hgcmMsgPost(hMsg, hgcmMsgCompletionCallback); 2356 rc = hgcmMsgPost(pMsg, hgcmMsgCompletionCallback); 2399 2357 } 2400 2358 … … 2414 2372 LogFlowFunc(("pSSM = %p, u32MsgId = %d\n", pSSM, u32MsgId)); 2415 2373 2416 HGCMMSGHANDLE hMsg = 0; 2417 2418 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, u32MsgId, hgcmMainMessageAlloc); 2374 HGCMMsgCore *pCoreMsg; 2375 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, u32MsgId, hgcmMainMessageAlloc); 2419 2376 2420 2377 if (RT_SUCCESS(rc)) 2421 2378 { 2422 HGCMMsgMainLoadSaveState *pMsg = (HGCMMsgMainLoadSaveState *) hgcmObjReference(hMsg, HGCMOBJ_MSG);2379 HGCMMsgMainLoadSaveState *pMsg = (HGCMMsgMainLoadSaveState *)pCoreMsg; 2423 2380 AssertRelease(pMsg); 2424 2381 2425 2382 pMsg->pSSM = pSSM; 2426 2383 2427 hgcmObjDereference(pMsg); 2428 2429 rc = hgcmMsgSend(hMsg); 2384 rc = hgcmMsgSend(pMsg); 2430 2385 } 2431 2386 … … 2521 2476 } 2522 2477 2523 HGCMMSGHANDLE hMsg = 0;2524 2525 2478 /* Host calls go to main HGCM thread that resolves the service name to the 2526 2479 * service instance pointer and then, using the service pointer, forwards … … 2529 2482 * other non-time-critical functions. 2530 2483 */ 2531 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_HOSTCALL, hgcmMainMessageAlloc); 2484 HGCMMsgCore *pCoreMsg; 2485 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_HOSTCALL, hgcmMainMessageAlloc); 2532 2486 2533 2487 if (RT_SUCCESS(rc)) 2534 2488 { 2535 HGCMMsgMainHostCall *pMsg = (HGCMMsgMainHostCall *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2536 AssertRelease(pMsg); 2489 HGCMMsgMainHostCall *pMsg = (HGCMMsgMainHostCall *)pCoreMsg; 2537 2490 2538 2491 pMsg->pszServiceName = (char *)pszServiceName; … … 2541 2494 pMsg->paParms = paParms; 2542 2495 2543 hgcmObjDereference(pMsg); 2544 2545 rc = hgcmMsgSend(hMsg); 2496 rc = hgcmMsgSend(pMsg); 2546 2497 } 2547 2498 … … 2564 2515 return VERR_INVALID_PARAMETER; 2565 2516 } 2566 2567 HGCMMSGHANDLE hMsg = 0;2568 2517 2569 2518 /* Host calls go to main HGCM thread that resolves the service name to the … … 2573 2522 * other non-time-critical functions. 2574 2523 */ 2575 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_SVCAQUIRE, hgcmMainMessageAlloc); 2524 HGCMMsgCore *pCoreMsg; 2525 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_SVCAQUIRE, hgcmMainMessageAlloc); 2576 2526 2577 2527 if (RT_SUCCESS(rc)) 2578 2528 { 2579 HGCMMsgMainSvcAcquire *pMsg = (HGCMMsgMainSvcAcquire *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2580 AssertRelease(pMsg); 2529 HGCMMsgMainSvcAcquire *pMsg = (HGCMMsgMainSvcAcquire *)pCoreMsg; 2581 2530 2582 2531 pMsg->pszServiceName = (char *)pszServiceName; 2583 2532 pMsg->pService = NULL; 2584 2533 2585 rc = hgcmMsgSend(hMsg); 2534 pMsg->Reference(); 2535 2536 rc = hgcmMsgSend(pMsg); 2586 2537 if (RT_SUCCESS(rc)) 2587 2538 { … … 2589 2540 *phSvc = (HGCMCVSHANDLE)pMsg->pService; 2590 2541 } 2591 2592 hgcmObjDereference(pMsg); 2542 pMsg->Dereference(); 2593 2543 } 2594 2544 … … 2605 2555 return VERR_INVALID_PARAMETER; 2606 2556 } 2607 2608 HGCMMSGHANDLE hMsg = 0;2609 2557 2610 2558 /* Host calls go to main HGCM thread that resolves the service name to the … … 2614 2562 * other non-time-critical functions. 2615 2563 */ 2616 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_SVCRELEASE, hgcmMainMessageAlloc); 2564 HGCMMsgCore *pCoreMsg; 2565 int rc = hgcmMsgAlloc(g_pHgcmThread, &pCoreMsg, HGCM_MSG_SVCRELEASE, hgcmMainMessageAlloc); 2617 2566 2618 2567 if (RT_SUCCESS(rc)) 2619 2568 { 2620 HGCMMsgMainSvcRelease *pMsg = (HGCMMsgMainSvcRelease *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 2621 AssertRelease(pMsg); 2569 HGCMMsgMainSvcRelease *pMsg = (HGCMMsgMainSvcRelease *)pCoreMsg; 2622 2570 2623 2571 pMsg->pService = (HGCMService *)hSvc; 2624 2572 2625 hgcmObjDereference(pMsg); 2626 2627 rc = hgcmMsgSend(hMsg); 2573 rc = hgcmMsgSend(pMsg); 2628 2574 } 2629 2575 … … 2658 2604 */ 2659 2605 2660 HGCMMSGHANDLE hMsg = 0; 2661 2662 int rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_RESET, hgcmMainMessageAlloc); 2606 HGCMMsgCore *pMsg; 2607 int rc = hgcmMsgAlloc(g_pHgcmThread, &pMsg, HGCM_MSG_RESET, hgcmMainMessageAlloc); 2663 2608 2664 2609 if (RT_SUCCESS(rc)) 2665 { 2666 rc = hgcmMsgSend(hMsg); 2667 } 2610 rc = hgcmMsgSend(pMsg); 2668 2611 2669 2612 LogFlowFunc(("rc = %Rrc\n", rc)); … … 2686 2629 2687 2630 if (RT_FAILURE(rc)) 2688 {2689 2631 LogRel(("Failed to start HGCM thread. HGCM services will be unavailable!!! rc = %Rrc\n", rc)); 2690 }2691 2632 } 2692 2633 … … 2708 2649 { 2709 2650 /* Send the quit message to the main hgcmThread. */ 2710 HGCMMSGHANDLE hMsg = 0; 2711 2712 rc = hgcmMsgAlloc(g_pHgcmThread, &hMsg, HGCM_MSG_QUIT, hgcmMainMessageAlloc); 2651 HGCMMsgCore *pMsg; 2652 rc = hgcmMsgAlloc(g_pHgcmThread, &pMsg, HGCM_MSG_QUIT, hgcmMainMessageAlloc); 2713 2653 2714 2654 if (RT_SUCCESS(rc)) 2715 2655 { 2716 rc = hgcmMsgSend( hMsg);2656 rc = hgcmMsgSend(pMsg); 2717 2657 2718 2658 if (RT_SUCCESS(rc)) … … 2720 2660 /* Wait for the thread termination. */ 2721 2661 hgcmThreadWait(g_pHgcmThread); 2722 g_pHgcmThread = 0;2662 g_pHgcmThread = NULL; 2723 2663 2724 2664 hgcmThreadUninit(); … … 2730 2670 return rc; 2731 2671 } 2672 -
trunk/src/VBox/Main/src-client/HGCMObjects.cpp
r75539 r75541 246 246 } 247 247 248 void hgcmObjDereference(HGCM ReferencedObject *pObject)248 void hgcmObjDereference(HGCMObject *pObject) 249 249 { 250 250 LogFlow(("MAIN::hgcmObjDereference: pObject %p\n", pObject)); -
trunk/src/VBox/Main/src-client/HGCMThread.cpp
r75540 r75541 145 145 int Initialize(const char *pszThreadName, PFNHGCMTHREAD pfnThread, void *pvUser, const char *pszStatsSubDir, PUVM pUVM); 146 146 147 int MsgAlloc(HGCMM SGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage);147 int MsgAlloc(HGCMMsgCore **pMsg, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage); 148 148 int MsgGet(HGCMMsgCore **ppMsg); 149 149 int MsgPost(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback, bool bWait); … … 364 364 365 365 366 int HGCMThread::MsgAlloc(HGCMM SGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage)366 int HGCMThread::MsgAlloc(HGCMMsgCore **ppMsg, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage) 367 367 { 368 368 /** @todo Implement this free list / cache thingy. */ … … 375 375 /* We have to allocate a new memory block. */ 376 376 pmsg = pfnNewMessage(u32MsgId); 377 378 if (pmsg == NULL) 377 if (pmsg != NULL) 378 pmsg->Reference(); /* (it's created with zero references) */ 379 else 379 380 return VERR_NO_MEMORY; 380 381 } … … 388 389 LogFlow(("MAIN::hgcmMsgAlloc: allocated message %p\n", pmsg)); 389 390 390 /** Get handle of the message. The message will be also referenced 391 * until the handle is deleted. 392 */ 393 *pHandle = hgcmObjGenerateHandle(pmsg); 391 *ppMsg = pmsg; 394 392 395 393 if (fFromFreeList) … … 558 556 } 559 557 560 void HGCMThread::MsgComplete 558 void HGCMThread::MsgComplete(HGCMMsgCore *pMsg, int32_t result) 561 559 { 562 560 LogFlow(("HGCMThread::MsgComplete: thread = %p, pMsg = %p\n", this, pMsg)); … … 610 608 pMsg->m_fu32Flags |= HGCM_MSG_F_PROCESSED; 611 609 612 hgcmObjDeleteHandle(pMsg->Handle());610 pMsg->Dereference(); 613 611 614 612 Leave(); … … 681 679 } 682 680 683 int hgcmMsgAlloc(HGCMThread *pThread, HGCMMSGHANDLE *pHandle, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage) 684 { 685 LogFlow(("hgcmMsgAlloc: pThread = %p, pHandle = %p, sizeof (HGCMMsgCore) = %d\n", 686 pThread, pHandle, sizeof (HGCMMsgCore))); 681 int hgcmMsgAlloc(HGCMThread *pThread, HGCMMsgCore **ppMsg, uint32_t u32MsgId, PFNHGCMNEWMSGALLOC pfnNewMessage) 682 { 683 LogFlow(("hgcmMsgAlloc: pThread = %p, ppMsg = %p, sizeof (HGCMMsgCore) = %d\n", pThread, ppMsg, sizeof(HGCMMsgCore))); 687 684 688 685 AssertReturn(pThread, VERR_INVALID_HANDLE); 689 AssertReturn(pHandle, VERR_INVALID_PARAMETER); 690 691 int rc = pThread->MsgAlloc(pHandle, u32MsgId, pfnNewMessage); 692 693 LogFlow(("MAIN::hgcmMsgAlloc: handle 0x%08X, rc = %Rrc\n", *pHandle, rc)); 694 return rc; 695 } 696 697 static int hgcmMsgPostInternal(HGCMMSGHANDLE hMsg, PHGCMMSGCALLBACK pfnCallback, bool fWait) 698 { 699 LogFlow(("MAIN::hgcmMsgPostInternal: hMsg = 0x%08X, pfnCallback = %p, fWait = %d\n", hMsg, pfnCallback, fWait)); 700 701 int rc = VINF_SUCCESS; 702 703 HGCMMsgCore *pMsg = (HGCMMsgCore *)hgcmObjReference(hMsg, HGCMOBJ_MSG); 704 705 if (!pMsg) 706 { 707 rc = VERR_INVALID_HANDLE; 708 } 709 else 710 { 711 rc = pMsg->Thread()->MsgPost(pMsg, pfnCallback, fWait); 712 713 hgcmObjDereference(pMsg); 714 } 715 716 LogFlow(("MAIN::hgcmMsgPostInternal: hMsg 0x%08X, rc = %Rrc\n", hMsg, rc)); 717 return rc; 718 } 719 720 721 /** Post message to worker thread with a flag indication if this is a Send or Post. 722 * 723 * @returns VINF_HGCM_ASYNC_EXECUTE 724 * @thread any 725 */ 726 int hgcmMsgPost(HGCMMSGHANDLE hMsg, PHGCMMSGCALLBACK pfnCallback) 727 { 728 int rc = hgcmMsgPostInternal(hMsg, pfnCallback, false); 686 AssertReturn(ppMsg, VERR_INVALID_PARAMETER); 687 688 int rc = pThread->MsgAlloc(ppMsg, u32MsgId, pfnNewMessage); 689 690 LogFlow(("MAIN::hgcmMsgAlloc: *ppMsg = %p, rc = %Rrc\n", *ppMsg, rc)); 691 return rc; 692 } 693 694 DECLINLINE(int) hgcmMsgPostInternal(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback, bool fWait) 695 { 696 LogFlow(("MAIN::hgcmMsgPostInternal: pMsg = %p, pfnCallback = %p, fWait = %d\n", pMsg, pfnCallback, fWait)); 697 Assert(pMsg); 698 699 pMsg->Reference(); /* paranoia? */ 700 701 int rc = pMsg->Thread()->MsgPost(pMsg, pfnCallback, fWait); 702 703 pMsg->Dereference(); 704 705 LogFlow(("MAIN::hgcmMsgPostInternal: pMsg %p, rc = %Rrc\n", pMsg, rc)); 706 return rc; 707 } 708 709 int hgcmMsgPost(HGCMMsgCore *pMsg, PHGCMMSGCALLBACK pfnCallback) 710 { 711 int rc = hgcmMsgPostInternal(pMsg, pfnCallback, false); 729 712 730 713 if (RT_SUCCESS(rc)) … … 734 717 } 735 718 736 /** Send message to worker thread. Sending thread will block until message is processed. 737 * 738 * @thread any 739 */ 740 int hgcmMsgSend (HGCMMSGHANDLE hMsg) 741 { 742 return hgcmMsgPostInternal (hMsg, NULL, true); 743 } 744 719 int hgcmMsgSend(HGCMMsgCore *pMsg) 720 { 721 return hgcmMsgPostInternal(pMsg, NULL, true); 722 } 745 723 746 724 int hgcmMsgGet(HGCMThread *pThread, HGCMMsgCore **ppMsg) … … 761 739 } 762 740 763 764 741 void hgcmMsgComplete(HGCMMsgCore *pMsg, int32_t u32Result) 765 742 { … … 773 750 } 774 751 775 776 752 int hgcmThreadInit(void) 777 753 {
Note:
See TracChangeset
for help on using the changeset viewer.