Changeset 28297 in vbox for trunk/src/VBox
- Timestamp:
- Apr 14, 2010 12:17:11 PM (15 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExec.cpp
r28286 r28297 265 265 */ 266 266 AssertPtr(pData); 267 VBoxServiceVerbose(3, "Control: Process started: PID=%u, CID=%u\n", 268 pData->uPID, pData->uContextID); 267 269 rc = VbglR3GuestCtrlExecReportStatus(pData->uClientID, pData->uContextID, 268 270 pData->uPID, PROC_STS_STARTED, 0 /* u32Flags */, … … 451 453 } 452 454 453 VBoxServiceVerbose(3, "Control: Process ended: PID=%u, Status=%u, Flags=%u\n",454 pData->uPID, uStatus, uFlags);455 VBoxServiceVerbose(3, "Control: Process ended: PID=%u, CID=%u, Status=%u, Flags=%u\n", 456 pData->uPID, pData->uContextID, uStatus, uFlags); 455 457 rc = VbglR3GuestCtrlExecReportStatus(pData->uClientID, pData->uContextID, 456 458 pData->uPID, uStatus, uFlags, … … 528 530 /* ClientID will be assigned when thread is started! */ 529 531 pData->uContextID = u32ContextID; 532 pData->uPID = 0; /* Don't have a PID yet. */ 530 533 pData->pszCmd = RTStrDup(pszCmd); 531 534 pData->uFlags = uFlags; … … 679 682 if (RT_SUCCESS(rc)) 680 683 { 681 VBoxServiceVerbose(3, "Control: Process \"%s\" started.\n", pData->pszCmd);682 /** @todo Dump a bit more info here. */683 684 684 /* 685 685 * Close the child ends of any pipes and redirected files. … … 735 735 736 736 VbglR3GuestCtrlDisconnect(pData->uClientID); 737 VBoxServiceVerbose(3, "Control: Thread of process \"%s\" ended with rc=%Rrc\n", pData->pszCmd, rc); 737 VBoxServiceVerbose(3, "Control: Thread of process \"%s\" (PID: %u) ended with rc=%Rrc\n", 738 pData->pszCmd, pData->uPID, rc); 738 739 739 740 /* -
trunk/src/VBox/Main/GuestImpl.cpp
r28288 r28297 109 109 { 110 110 LogFlowThisFunc(("\n")); 111 112 #ifdef VBOX_WITH_GUEST_CONTROL 113 /* Clean up callback data. */ 114 CallbackListIter it; 115 for (it = mCallbackList.begin(); it != mCallbackList.end(); it++) 116 removeCtrlCallbackContext(it); 117 #endif 111 118 112 119 /* Enclose the state transition Ready->InUninit->NotReady */ … … 487 494 int rc = VINF_SUCCESS; 488 495 489 /* bool bFound = false; 490 for (int i=0; i<mList.size(); i++) 491 { 492 } 493 if(pData->hdr.u32ContextID == it->hdr.u32ContextID) 494 { 495 }*/ 496 /*pExt->pid = pCBData->pid; 497 pExt->status = pCBData->status; 498 pExt->flags = pCBData->flags;*/ 499 /** @todo Copy void* buffer! */ 500 496 AssertPtr(pData); 497 CallbackListIter it = getCtrlCallbackContext(pData->hdr.u32ContextID); 498 if (it != mCallbackList.end()) 499 { 500 PHOSTEXECCALLBACKDATA pCBData = (HOSTEXECCALLBACKDATA*)it->pvData; 501 AssertPtr(pCBData); 502 503 pCBData->u32PID = pData->u32PID; 504 pCBData->u32Status = pData->u32Status; 505 pCBData->u32Flags = pData->u32Flags; 506 /* @todo Copy void* buffer contents! */ 507 508 ASMAtomicWriteBool(&it->bCalled, true); 509 } 501 510 return rc; 502 511 } 503 512 504 void Guest::freeCtrlCallbackContextData(CallbackContext *pContext) 505 { 506 AssertPtr(pContext); 507 if (pContext->cbData) 508 { 509 RTMemFree(pContext->pvData); 510 pContext->cbData = 0; 511 pContext->pvData = NULL; 512 } 513 Guest::CallbackListIter Guest::getCtrlCallbackContext(uint32_t u32ContextID) 514 { 515 CallbackListIter it; 516 for (it = mCallbackList.begin(); it != mCallbackList.end(); it++) 517 { 518 if (it->mContextID == u32ContextID) 519 return (it); 520 } 521 return it; 522 } 523 524 void Guest::removeCtrlCallbackContext(Guest::CallbackListIter it) 525 { 526 if (it->cbData) 527 { 528 RTMemFree(it->pvData); 529 it->cbData = 0; 530 it->pvData = NULL; 531 } 532 mCallbackList.erase(it); 513 533 } 514 534 … … 520 540 CallbackContext context; 521 541 context.mContextID = uNewContext; 542 context.bCalled = false; 522 543 context.pvData = pvData; 523 544 context.cbData = cbData; 524 545 525 546 mCallbackList.push_back(context); 526 if (mCallbackList.size() > 256) 527 { 528 freeCtrlCallbackContextData(&mCallbackList.front()); 529 mCallbackList.pop_front(); 530 } 547 if (mCallbackList.size() > 256) /* Don't let the container size get too big! */ 548 removeCtrlCallbackContext(mCallbackList.begin()); 549 531 550 return uNewContext; 532 551 } … … 592 611 if (RT_SUCCESS(vrc)) 593 612 { 613 uint32_t uContextID = 0; 614 594 615 char *pszArgs = NULL; 595 616 if (uNumArgs > 0) … … 623 644 PHOSTEXECCALLBACKDATA pData = (HOSTEXECCALLBACKDATA*)RTMemAlloc(sizeof(HOSTEXECCALLBACKDATA)); 624 645 AssertPtr(pData); 625 uint32_t uContextID = addCtrlCallbackContext(pData, sizeof(HOSTEXECCALLBACKDATA)); 646 uContextID = addCtrlCallbackContext(pData, sizeof(HOSTEXECCALLBACKDATA)); 647 Assert(uContextID > 0); 626 648 627 649 VBOXHGCMSVCPARM paParms[15]; … … 664 686 * get the PID. 665 687 */ 666 #if 0 688 CallbackListIter it = getCtrlCallbackContext(uContextID); 667 689 uint64_t u64Started = RTTimeMilliTS(); 668 690 do … … 679 701 } 680 702 RTThreadSleep(100); 681 } while ( !callbackData.called);703 } while (it != mCallbackList.end() && !it->bCalled); 682 704 683 705 /* Did we get some status? */ 684 if (callbackData.called) 706 PHOSTEXECCALLBACKDATA pData = (HOSTEXECCALLBACKDATA*)it->pvData; 707 Assert(it->cbData, sizeof(HOSTEXECCALLBACKDATA)); 708 AssertPtr(pData); 709 if (it->bCalled) 685 710 { 686 switch ( callbackData.status)711 switch (pData->u32Status) 687 712 { 688 713 case PROC_STS_STARTED: 689 *aPID = callbackData.pid;714 *aPID = pData->u32PID; 690 715 break; 691 716 692 717 case PROC_STS_ERROR: 693 vrc = callbackData.flags; /* flags member contains IPRT error code. */718 vrc = pData->u32Flags; /* u32Flags member contains IPRT error code. */ 694 719 break; 695 720 … … 699 724 } 700 725 } 726 removeCtrlCallbackContext(it); 701 727 702 728 if (RT_FAILURE(vrc)) … … 713 739 } 714 740 } 715 #endif716 741 #if 0 717 742 progress.queryInterfaceTo(aProgress); -
trunk/src/VBox/Main/include/GuestImpl.h
r28286 r28297 118 118 119 119 # ifdef VBOX_WITH_GUEST_CONTROL 120 121 120 struct CallbackContext 122 121 { 123 uint32_t mContextID; 124 void *pvData; 125 uint32_t cbData; 122 uint32_t mContextID; 123 void *pvData; 124 uint32_t cbData; 125 /** Atomic flag whether callback was called. */ 126 volatile bool bCalled; 126 127 }; 128 typedef std::list< CallbackContext > CallbackList; 129 typedef std::list< CallbackContext >::iterator CallbackListIter; 130 typedef std::list< CallbackContext >::const_iterator CallbackListIterConst; 127 131 128 132 int prepareExecuteArgs(const char *pszArgs, void **ppvList, uint32_t *pcbList, uint32_t *pcArgs); … … 130 134 /** Handler for guest execution control notifications. */ 131 135 int notifyCtrlExec(uint32_t u32Function, PHOSTEXECCALLBACKDATA pData); 132 void freeCtrlCallbackContextData(CallbackContext *pContext); 136 CallbackListIter getCtrlCallbackContext(uint32_t u32ContextID); 137 void removeCtrlCallbackContext(CallbackListIter it); 133 138 uint32_t addCtrlCallbackContext(void *pvData, uint32_t cbData); 134 139 # endif … … 158 163 159 164 volatile uint32_t mNextContextID; 160 typedef std::list< CallbackContext > CallbackList;161 165 CallbackList mCallbackList; 162 166 # endif
Note:
See TracChangeset
for help on using the changeset viewer.