Changeset 28409 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Apr 16, 2010 12:04:53 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxService
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r28402 r28409 242 242 it != g_GuestControlExecThreads.end(); it++) 243 243 { 244 PVBOXSERVICECTRLTHREAD pThread = (*it); 245 AssertPtr(pThread); 246 ASMAtomicXchgBool(&pThread->fShutdown, true); 244 ASMAtomicXchgBool(&(*it)->fShutdown, true); 247 245 } 248 246 … … 250 248 it != g_GuestControlExecThreads.end(); it++) 251 249 { 252 PVBOXSERVICECTRLTHREAD pThread = (*it); 253 if (pThread->Thread != NIL_RTTHREAD) 254 { 255 int rc2 = RTThreadWait(pThread->Thread, 30 * 1000 /* Wait 30 second */, NULL); 250 if ((*it)->Thread != NIL_RTTHREAD) 251 { 252 int rc2 = RTThreadWait((*it)->Thread, 30 * 1000 /* Wait 30 second */, NULL); 256 253 if (RT_FAILURE(rc2)) 257 VBoxServiceError("Control: Thread (PID: %u) failed to stop; rc2=%Rrc\n", pThread->uPID, rc2); 258 } 259 VBoxServiceControlExecDestroyThread(pThread); 260 } 261 254 VBoxServiceError("Control: Thread (PID: %u) failed to stop; rc2=%Rrc\n", (*it)->uPID, rc2); 255 } 256 VBoxServiceControlExecDestroyThreadData((*it)); 257 } 258 259 for (GuestCtrlExecListIter it = g_GuestControlExecThreads.begin(); 260 it != g_GuestControlExecThreads.end(); it++) 261 RTMemFree((*it)); 262 263 g_GuestControlExecThreads.clear(); 262 264 VbglR3GuestCtrlDisconnect(g_GuestControlSvcClientID); 263 265 g_GuestControlSvcClientID = 0; -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
r28402 r28409 528 528 529 529 /** Allocates and gives back a thread data struct which then can be used by the worker thread. */ 530 PVBOXSERVICECTRLTHREAD VBoxServiceControlExecAllocateThreadData(uint32_t u32ContextID, 531 const char *pszCmd, uint32_t uFlags, 532 const char *pszArgs, uint32_t uNumArgs, 533 const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars, 534 const char *pszStdIn, const char *pszStdOut, const char *pszStdErr, 535 const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS) 536 { 537 PVBOXSERVICECTRLTHREAD pThread = (PVBOXSERVICECTRLTHREAD)RTMemAlloc(sizeof(VBOXSERVICECTRLTHREAD)); 538 if (pThread == NULL) 539 return NULL; 530 int VBoxServiceControlExecAllocateThreadData(PVBOXSERVICECTRLTHREAD pThread, 531 uint32_t u32ContextID, 532 const char *pszCmd, uint32_t uFlags, 533 const char *pszArgs, uint32_t uNumArgs, 534 const char *pszEnv, uint32_t cbEnv, uint32_t uNumEnvVars, 535 const char *pszStdIn, const char *pszStdOut, const char *pszStdErr, 536 const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS) 537 { 538 AssertPtr(pThread); 540 539 541 540 pThread->fShutdown = false; … … 593 592 || (uTimeLimitMS == 0)) ? 594 593 RT_INDEFINITE_WAIT : uTimeLimitMS; 595 return pThread;594 return rc; 596 595 } 597 596 598 597 /** Frees an allocated thread data structure along with all its allocated parameters. */ 599 void VBoxServiceControlExecDestroyThread (PVBOXSERVICECTRLTHREAD pThread)598 void VBoxServiceControlExecDestroyThreadData(PVBOXSERVICECTRLTHREAD pThread) 600 599 { 601 600 AssertPtr(pThread); … … 613 612 RTStrFree(pThread->pszUser); 614 613 RTStrFree(pThread->pszPassword); 615 616 RTMemFree(pThread);617 614 } 618 615 … … 771 768 const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS) 772 769 { 773 PVBOXSERVICECTRLTHREAD pThread = 774 VBoxServiceControlExecAllocateThreadData(uContextID, 775 pszCmd, uFlags, 776 pszArgs, uNumArgs, 777 pszEnv, cbEnv, uNumEnvVars, 778 pszStdIn, pszStdOut, pszStdErr, 779 pszUser, pszPassword, 780 uTimeLimitMS); 781 int rc = VINF_SUCCESS; 770 PVBOXSERVICECTRLTHREAD pThread = (PVBOXSERVICECTRLTHREAD)RTMemAlloc(sizeof(VBOXSERVICECTRLTHREAD)); 771 772 int rc; 782 773 if (pThread) 783 774 { 784 rc = RTThreadCreate(&pThread->Thread, VBoxServiceControlExecThread, 785 (void *)(PVBOXSERVICECTRLTHREAD*)pThread, 0, 786 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "Exec"); 787 if (RT_FAILURE(rc)) 788 { 789 VBoxServiceError("Control: RTThreadCreate failed, rc=%Rrc\n, pThread=%p\n", 790 rc, pThread); 791 } 792 else 793 { 794 /* Wait for the thread to initialize. */ 795 RTThreadUserWait(pThread->Thread, 60 * 1000); 796 if (pThread->fShutdown) 797 { 798 VBoxServiceError("Control: Thread for process \"%s\" failed to start!\n", pszCmd); 799 rc = VERR_GENERAL_FAILURE; 775 rc = VBoxServiceControlExecAllocateThreadData(pThread, 776 uContextID, 777 pszCmd, uFlags, 778 pszArgs, uNumArgs, 779 pszEnv, cbEnv, uNumEnvVars, 780 pszStdIn, pszStdOut, pszStdErr, 781 pszUser, pszPassword, 782 uTimeLimitMS); 783 if (RT_SUCCESS(rc)) 784 { 785 rc = RTThreadCreate(&pThread->Thread, VBoxServiceControlExecThread, 786 (void *)(PVBOXSERVICECTRLTHREAD*)pThread, 0, 787 RTTHREADTYPE_DEFAULT, RTTHREADFLAGS_WAITABLE, "Exec"); 788 if (RT_FAILURE(rc)) 789 { 790 VBoxServiceError("Control: RTThreadCreate failed, rc=%Rrc\n, pThread=%p\n", 791 rc, pThread); 800 792 } 801 793 else 802 794 { 803 g_GuestControlExecThreads.push_back(pThread); 804 } 805 } 806 807 if (RT_FAILURE(rc)) 808 { 809 /* Only destroy thread data on failure; otherwise it's destroyed in the thread handler. */ 810 VBoxServiceControlExecDestroyThread(pThread); 795 /* Wait for the thread to initialize. */ 796 RTThreadUserWait(pThread->Thread, 60 * 1000); 797 if (pThread->fShutdown) 798 { 799 VBoxServiceError("Control: Thread for process \"%s\" failed to start!\n", pszCmd); 800 rc = VERR_GENERAL_FAILURE; 801 } 802 else 803 { 804 g_GuestControlExecThreads.push_back(pThread); 805 } 806 } 807 808 if (RT_FAILURE(rc)) 809 { 810 /* Only destroy thread data on failure; otherwise it's destroyed in the thread handler. */ 811 VBoxServiceControlExecDestroyThreadData(pThread); 812 RTMemFree(pThread); 813 } 811 814 } 812 815 } -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceInternal.h
r28402 r28409 239 239 const char *pszStdIn, const char *pszStdOut, const char *pszStdErr, 240 240 const char *pszUser, const char *pszPassword, uint32_t uTimeLimitMS); 241 extern void VBoxServiceControlExecDestroyThread (PVBOXSERVICECTRLTHREAD pThread);241 extern void VBoxServiceControlExecDestroyThreadData(PVBOXSERVICECTRLTHREAD pThread); 242 242 #endif 243 243
Note:
See TracChangeset
for help on using the changeset viewer.