Changeset 83595 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Apr 6, 2020 6:21:34 PM (5 years ago)
- svn:sync-xref-src-repo-rev:
- 136989
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r83555 r83595 63 63 64 64 static int vgsvcGstCtrlSessionCleanupProcesses(const PVBOXSERVICECTRLSESSION pSession); 65 static int vgsvcGstCtrlSessionProcessRemoveInternal(PVBOXSERVICECTRLSESSION pSession, PVBOXSERVICECTRLPROCESS pProcess); 65 66 66 67 … … 90 91 91 92 92 static int vgsvcGstCtrlSessionFile Destroy(PVBOXSERVICECTRLFILE pFile)93 static int vgsvcGstCtrlSessionFileFree(PVBOXSERVICECTRLFILE pFile) 93 94 { 94 95 AssertPtrReturn(pFile, VERR_INVALID_POINTER); … … 425 426 { 426 427 VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->szName : "<Not found>", uHandle); 427 rc = vgsvcGstCtrlSessionFile Destroy(pFile);428 rc = vgsvcGstCtrlSessionFileFree(pFile); 428 429 } 429 430 else … … 1890 1891 1891 1892 /* Wait for all active threads to shutdown and destroy the active thread list. */ 1892 pProcess = RTListGetFirst(&pSession->lstProcesses, VBOXSERVICECTRLPROCESS, Node); 1893 while (pProcess) 1894 { 1895 PVBOXSERVICECTRLPROCESS pNext = RTListNodeGetNext(&pProcess->Node, VBOXSERVICECTRLPROCESS, Node); 1896 bool fLast = RTListNodeIsLast(&pSession->lstProcesses, &pProcess->Node); 1897 1898 int rc2 = RTCritSectLeave(&pSession->CritSect); 1899 AssertRC(rc2); 1900 1901 rc2 = VGSvcGstCtrlProcessWait(pProcess, 30 * 1000 /* Wait 30 seconds max. */, NULL /* rc */); 1902 1903 int rc3 = RTCritSectEnter(&pSession->CritSect); 1893 PVBOXSERVICECTRLPROCESS pProcessNext; 1894 RTListForEachSafe(&pSession->lstProcesses, pProcess, pProcessNext, VBOXSERVICECTRLPROCESS, Node) 1895 { 1896 int rc3 = RTCritSectLeave(&pSession->CritSect); 1904 1897 AssertRC(rc3); 1905 1898 1899 int rc2 = VGSvcGstCtrlProcessWait(pProcess, 30 * 1000 /* Wait 30 seconds max. */, NULL /* rc */); 1900 1901 rc3 = RTCritSectEnter(&pSession->CritSect); 1902 AssertRC(rc3); 1903 1906 1904 if (RT_SUCCESS(rc2)) 1907 VGSvcGstCtrlProcessFree(pProcess); 1908 1909 if (fLast) 1910 break; 1911 1912 pProcess = pNext; 1913 } 1914 1915 #ifdef DEBUG 1916 pProcess = RTListGetFirst(&pSession->lstProcesses, VBOXSERVICECTRLPROCESS, Node); 1917 while (pProcess) 1918 { 1919 PVBOXSERVICECTRLPROCESS pNext = RTListNodeGetNext(&pProcess->Node, VBOXSERVICECTRLPROCESS, Node); 1920 bool fLast = RTListNodeIsLast(&pSession->lstProcesses, &pProcess->Node); 1921 1922 VGSvcVerbose(1, "Process %p (PID %RU32) still in list\n", pProcess, pProcess->uPID); 1923 if (fLast) 1924 break; 1925 1926 pProcess = pNext; 1927 } 1928 #endif 1905 { 1906 rc2 = vgsvcGstCtrlSessionProcessRemoveInternal(pSession, pProcess); 1907 if (RT_SUCCESS(rc2)) 1908 { 1909 VGSvcGstCtrlProcessFree(pProcess); 1910 pProcess = NULL; 1911 } 1912 } 1913 } 1914 1915 AssertMsg(pSession->cProcesses == 0, 1916 ("Session process list still contains %RU32 when it should not\n", pSession->cProcesses)); 1929 1917 AssertMsg(RTListIsEmpty(&pSession->lstProcesses), 1930 (" Guest process list still contains entries when it should not\n"));1918 ("Session process list is not empty when it should\n")); 1931 1919 1932 1920 /* … … 1935 1923 VGSvcVerbose(0, "Closing all guest files ...\n"); 1936 1924 1937 PVBOXSERVICECTRLFILE pFile; 1938 pFile = RTListGetFirst(&pSession->lstFiles, VBOXSERVICECTRLFILE, Node); 1939 while (pFile) 1940 { 1941 PVBOXSERVICECTRLFILE pNext = RTListNodeGetNext(&pFile->Node, VBOXSERVICECTRLFILE, Node); 1942 bool fLast = RTListNodeIsLast(&pSession->lstFiles, &pFile->Node); 1943 1944 int rc2 = vgsvcGstCtrlSessionFileDestroy(pFile); 1925 PVBOXSERVICECTRLFILE pFile, pFileNext; 1926 RTListForEachSafe(&pSession->lstFiles, pFile, pFileNext, VBOXSERVICECTRLFILE, Node) 1927 { 1928 int rc2 = vgsvcGstCtrlSessionFileFree(pFile); 1945 1929 if (RT_FAILURE(rc2)) 1946 1930 { … … 1951 1935 } 1952 1936 1953 if (fLast)1954 break;1955 1956 pFile = pNext;1957 }1958 1959 AssertMsg(RTListIsEmpty(&pSession->lstFiles), ("Guest file list still contains entries when it should not\n"));1937 pFile = NULL; /* To make it obvious. */ 1938 } 1939 1940 AssertMsg(pSession->cFiles == 0, 1941 ("Session file list still contains %RU32 when it should not\n", pSession->cFiles)); 1942 AssertMsg(RTListIsEmpty(&pSession->lstFiles), 1943 ("Session file list is not empty when it should\n")); 1960 1944 1961 1945 int rc2 = RTCritSectLeave(&pSession->CritSect); … … 2033 2017 } 2034 2018 2019 /** 2020 * Removes a guest process from a session's process list. 2021 * Internal version, does not do locking. 2022 * 2023 * @return VBox status code. 2024 * @param pSession Guest session to remove process from. 2025 * @param pProcess Guest process to remove. 2026 */ 2027 static int vgsvcGstCtrlSessionProcessRemoveInternal(PVBOXSERVICECTRLSESSION pSession, PVBOXSERVICECTRLPROCESS pProcess) 2028 { 2029 VGSvcVerbose(3, "Removing process (PID %RU32) from session ID=%RU32\n", pProcess->uPID, pSession->StartupInfo.uSessionID); 2030 AssertReturn(pProcess->cRefs == 0, VERR_WRONG_ORDER); 2031 2032 RTListNodeRemove(&pProcess->Node); 2033 2034 AssertReturn(pSession->cProcesses, VERR_WRONG_ORDER); 2035 pSession->cProcesses--; 2036 VGSvcVerbose(3, "Now session ID=%RU32 has %RU32 processes total\n", 2037 pSession->StartupInfo.uSessionID, pSession->cProcesses); 2038 2039 return VINF_SUCCESS; 2040 } 2035 2041 2036 2042 /** … … 2049 2055 if (RT_SUCCESS(rc)) 2050 2056 { 2051 VGSvcVerbose(3, "Removing process (PID %RU32) from session ID=%RU32\n", pProcess->uPID, pSession->StartupInfo.uSessionID); 2052 AssertReturn(pProcess->cRefs == 0, VERR_WRONG_ORDER); 2053 2054 RTListNodeRemove(&pProcess->Node); 2055 2056 AssertReturn(pSession->cProcesses, VERR_WRONG_ORDER); 2057 pSession->cProcesses--; 2058 VGSvcVerbose(3, "Now session ID=%RU32 has %RU32 processes total\n", 2059 pSession->StartupInfo.uSessionID, pSession->cProcesses); 2057 rc = vgsvcGstCtrlSessionProcessRemoveInternal(pSession, pProcess); 2060 2058 2061 2059 int rc2 = RTCritSectLeave(&pSession->CritSect);
Note:
See TracChangeset
for help on using the changeset viewer.