Changeset 70390 in vbox for trunk/src/VBox/Additions
- Timestamp:
- Dec 29, 2017 4:54:17 PM (7 years ago)
- svn:sync-xref-src-repo-rev:
- 119995
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.h
r69500 r70390 244 244 * needs (or is asked) to shutdown. */ 245 245 bool volatile fShutdown; 246 /** Whether the guest process thread was stopped 247 * or not. */ 246 /** Whether the guest process thread was stopped or not. */ 248 247 bool volatile fStopped; 249 /** Whether the guest process thread was started 250 * or not. */ 248 /** Whether the guest process thread was started or not. */ 251 249 bool fStarted; 252 250 /** Client ID. */ … … 276 274 * guest process' stdout.*/ 277 275 RTPIPE hPipeStdErrR; 278 /** The notification pipe associated with this guest process. 276 277 /** The write end of the notification pipe that is used to poke the thread 278 * monitoring the process. 279 279 * This is NIL_RTPIPE for output pipes. */ 280 280 RTPIPE hNotificationPipeW; 281 /** The other end of hNotificationPipeW . */281 /** The other end of hNotificationPipeW, read by vgsvcGstCtrlProcessProcLoop(). */ 282 282 RTPIPE hNotificationPipeR; 283 283 } VBOXSERVICECTRLPROCESS; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlProcess.cpp
r69500 r70390 58 58 static DECLCALLBACK(int) vgsvcGstCtrlProcessOnOutput(PVBOXSERVICECTRLPROCESS pThis, const PVBGLR3GUESTCTRLCMDCTX pHostCtx, 59 59 uint32_t uHandle, uint32_t cbToRead, uint32_t uFlags); 60 static DECLCALLBACK(int) vgsvcGstCtrlProcessOnTerm(PVBOXSERVICECTRLPROCESS pThis);61 60 62 61 … … 254 253 if (RT_SUCCESS(rc)) 255 254 { 255 pProcess->Thread = NIL_RTTHREAD; 256 256 VGSvcVerbose(3, "[PID %RU32]: Thread shutdown complete, thread rc=%Rrc\n", pProcess->uPID, rcThread); 257 257 if (prc) … … 1485 1485 */ 1486 1486 char **papszArgs; 1487 uint32_t uNumArgs = 0; /* Initialize in case of RTGetOptArgvFromString() is failing ... */1488 rc = RTGetOptArgvFromString(&papszArgs, (int*)&uNumArgs,1489 (pProcess->StartupInfo.uNumArgs > 0)? pProcess->StartupInfo.szArgs : "",1487 int cArgs = 0; /* Initialize in case of RTGetOptArgvFromString() is failing ... */ 1488 rc = RTGetOptArgvFromString(&papszArgs, &cArgs, 1489 pProcess->StartupInfo.uNumArgs > 0 ? pProcess->StartupInfo.szArgs : "", 1490 1490 RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL); 1491 1491 /* Did we get the same result? */ 1492 Assert( pProcess->StartupInfo.uNumArgs == uNumArgs + 1 /* Take argv[0] into account */);1492 Assert((int)pProcess->StartupInfo.uNumArgs == cArgs + 1 /* Take argv[0] into account */); 1493 1493 1494 1494 /* … … 1652 1652 * So, NIL the handles to avoid closing them again. 1653 1653 */ 1654 /** @todo r=bird: Can't see how hNotificationPipeR could be closed here! Found (and fixed) 1655 * confused comments documenting hNotificationPipeW, probably related. */ 1654 1656 if (RT_FAILURE(RTPollSetQueryHandle(pProcess->hPollSet, 1655 1657 VBOXSERVICECTRLPIPEID_IPC_NOTIFY, NULL))) … … 1725 1727 RTMemFree(papszEnv); 1726 1728 } 1727 if ( uNumArgs)1729 if (cArgs) 1728 1730 RTGetOptArgvFree(papszArgs); 1729 1731 … … 1739 1741 1740 1742 /* Finally, update stopped status. */ 1741 ASMAtomicXchgBool(&pProcess->fStopped, true); 1743 ASMAtomicWriteBool(&pProcess->fStopped, true); 1744 ASMAtomicWriteBool(&pProcess->fShutdown, true); 1742 1745 1743 1746 return rc; … … 1826 1829 AssertRC(rc); 1827 1830 if ( ASMAtomicReadBool(&pProcess->fShutdown) 1831 || ASMAtomicReadBool(&pProcess->fStopped) 1828 1832 || RT_FAILURE(rc)) 1829 1833 { 1830 1834 VGSvcError("Thread for process '%s' failed to start, rc=%Rrc\n", pStartupInfo->szCmd, rc); 1835 int rc2 = RTThreadWait(pProcess->Thread, RT_MS_1SEC * 30, NULL); 1836 if (RT_SUCCESS(rc2)) 1837 pProcess->Thread = NIL_RTTHREAD; 1831 1838 VGSvcGstCtrlProcessFree(pProcess); 1832 1839 } … … 2054 2061 /* Wake up the process' notification pipe to get 2055 2062 * the request being processed. */ 2056 Assert(pProcess->hNotificationPipeW != NIL_RTPIPE );2063 Assert(pProcess->hNotificationPipeW != NIL_RTPIPE || pProcess->fShutdown /* latter in case of race */); 2057 2064 size_t cbWritten = 0; 2058 2065 rc = RTPipeWrite(pProcess->hNotificationPipeW, "i", 1, &cbWritten); … … 2122 2129 bool fPendingClose, void *pvBuf, uint32_t cbBuf) 2123 2130 { 2124 if (!ASMAtomicReadBool(&pProcess->fShutdown) )2131 if (!ASMAtomicReadBool(&pProcess->fShutdown) && !ASMAtomicReadBool(&pProcess->fStopped)) 2125 2132 return vgsvcGstCtrlProcessRequestAsync(pProcess, pHostCtx, (PFNRT)vgsvcGstCtrlProcessOnInput, 2126 2133 5 /* cArgs */, pProcess, pHostCtx, fPendingClose, pvBuf, cbBuf); … … 2133 2140 uint32_t uHandle, uint32_t cbToRead, uint32_t fFlags) 2134 2141 { 2135 if (!ASMAtomicReadBool(&pProcess->fShutdown) )2142 if (!ASMAtomicReadBool(&pProcess->fShutdown) && !ASMAtomicReadBool(&pProcess->fStopped)) 2136 2143 return vgsvcGstCtrlProcessRequestAsync(pProcess, pHostCtx, (PFNRT)vgsvcGstCtrlProcessOnOutput, 2137 2144 5 /* cArgs */, pProcess, pHostCtx, uHandle, cbToRead, fFlags); … … 2143 2150 int VGSvcGstCtrlProcessHandleTerm(PVBOXSERVICECTRLPROCESS pProcess) 2144 2151 { 2145 if (!ASMAtomicReadBool(&pProcess->fShutdown) )2152 if (!ASMAtomicReadBool(&pProcess->fShutdown) && !ASMAtomicReadBool(&pProcess->fStopped)) 2146 2153 return vgsvcGstCtrlProcessRequestAsync(pProcess, NULL /* pHostCtx */, (PFNRT)vgsvcGstCtrlProcessOnTerm, 2147 2154 1 /* cArgs */, pProcess); -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceToolBox.h
r69500 r70390 26 26 RT_C_DECLS_END 27 27 28 #endif /* ___VBoxServiceToolBox_h */28 #endif /* !___VBoxServiceToolBox_h */ 29 29
Note:
See TracChangeset
for help on using the changeset viewer.