Changeset 39843 in vbox for trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
- Timestamp:
- Jan 23, 2012 6:38:18 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 75849
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControl.cpp
r39659 r39843 187 187 } 188 188 else if (RT_FAILURE(rc)) 189 VBoxServiceVerbose(3, "Control: Getting host message failed with %Rrc\n", rc); /* VERR_GEN_IO_FAILURE seems to be normal if ran 189 VBoxServiceVerbose(3, "Control: Getting host message failed with %Rrc\n", rc); /* VERR_GEN_IO_FAILURE seems to be normal if ran into timeout. */ 190 190 if (RT_SUCCESS(rc)) 191 191 { … … 360 360 361 361 int rc = VINF_SUCCESS; 362 363 VBOXSERVICECTRLREQUEST ctrlRequest; 364 ctrlRequest.uCID = uCID; 365 ctrlRequest.cbData = cbBuf; 366 ctrlRequest.pvData = (uint8_t*)pvBuf; 367 362 VBOXSERVICECTRLREQUESTTYPE reqType; 368 363 switch (uHandleId) 369 364 { 370 365 case OUTPUT_HANDLE_ID_STDERR: 371 ctrlRequest.enmType = VBOXSERVICECTRLREQUEST_STDERR_READ;366 reqType = VBOXSERVICECTRLREQUEST_STDERR_READ; 372 367 break; 373 368 374 369 case OUTPUT_HANDLE_ID_STDOUT: 375 370 case OUTPUT_HANDLE_ID_STDOUT_DEPRECATED: 376 ctrlRequest.enmType = VBOXSERVICECTRLREQUEST_STDOUT_READ;371 reqType = VBOXSERVICECTRLREQUEST_STDOUT_READ; 377 372 break; 378 373 … … 382 377 } 383 378 379 PVBOXSERVICECTRLREQUEST pRequest; 384 380 if (RT_SUCCESS(rc)) 385 rc = VBoxServiceControlThreadPerform(uPID, &ctrlRequest); 386 387 if (RT_SUCCESS(rc)) 388 { 389 if (pcbRead) 390 *pcbRead = ctrlRequest.cbData; 391 } 392 else /* Something went wrong, nothing read. */ 393 *pcbRead = 0; 381 { 382 rc = VBoxServiceControlThreadRequestAllocEx(&pRequest, reqType, 383 pvBuf, cbBuf, uCID); 384 if (RT_SUCCESS(rc)) 385 rc = VBoxServiceControlThreadPerform(uPID, pRequest); 386 387 if (RT_SUCCESS(rc)) 388 { 389 if (pcbRead) 390 *pcbRead = pRequest->cbData; 391 } 392 393 VBoxServiceControlThreadRequestFree(pRequest); 394 } 394 395 395 396 return rc; … … 416 417 /* pcbWritten is optional. */ 417 418 418 int rc = VINF_SUCCESS; 419 420 VBOXSERVICECTRLREQUEST ctrlRequest; 421 ctrlRequest.uCID = uCID; 422 ctrlRequest.cbData = cbBuf; 423 ctrlRequest.pvData = pvBuf; 424 ctrlRequest.enmType = fPendingClose 425 ? VBOXSERVICECTRLREQUEST_STDIN_WRITE_EOF : VBOXSERVICECTRLREQUEST_STDIN_WRITE; 419 PVBOXSERVICECTRLREQUEST pRequest; 420 int rc = VBoxServiceControlThreadRequestAllocEx(&pRequest, 421 fPendingClose 422 ? VBOXSERVICECTRLREQUEST_STDIN_WRITE_EOF 423 : VBOXSERVICECTRLREQUEST_STDIN_WRITE, 424 pvBuf, cbBuf, uCID); 426 425 if (RT_SUCCESS(rc)) 427 rc = VBoxServiceControlThreadPerform(uPID, &ctrlRequest); 428 429 if (RT_SUCCESS(rc)) 430 { 431 if (pcbWritten) 432 *pcbWritten = ctrlRequest.cbData; 426 { 427 rc = VBoxServiceControlThreadPerform(uPID, pRequest); 428 if (RT_SUCCESS(rc)) 429 { 430 if (pcbWritten) 431 *pcbWritten = pRequest->cbData; 432 } 433 434 VBoxServiceControlThreadRequestFree(pRequest); 433 435 } 434 436 … … 559 561 if (RT_SUCCESS(rc)) 560 562 { 561 uint32_t cbRead = 0;562 563 uint8_t *pBuf = (uint8_t*)RTMemAlloc(_64K); 563 564 if (pBuf) 564 565 { 566 uint32_t cbRead = 0; 565 567 rc = VBoxServiceControlExecGetOutput(uPID, uContextID, uHandleID, RT_INDEFINITE_WAIT /* Timeout */, 566 568 pBuf, _64K /* cbSize */, &cbRead); 569 VBoxServiceVerbose(3, "Control: Got output returned with rc=%Rrc (PID=%u, CID=%u, cbRead=%u, uHandle=%u, uFlags=%u)\n", 570 rc, uPID, uContextID, cbRead, uHandleID, uFlags); 567 571 568 572 /** Note: Don't convert/touch/modify/whatever the output data here! This might be binary 569 573 * data which the host needs to work with -- so just pass through all data unfiltered! */ 570 574 571 if (RT_SUCCESS(rc))572 VBoxServiceVerbose(2, "Control: Got output, PID=%u, CID=%u, cbRead=%u, uHandle=%u, uFlags=%u\n",573 uPID, uContextID, cbRead, uHandleID, uFlags);574 else if (rc == VERR_NOT_FOUND)575 VBoxServiceVerbose(2, "Control: PID=%u not found, CID=%u, uHandle=%u\n",576 uPID, uContextID, uHandleID, rc);577 else578 VBoxServiceError("Control: Failed to retrieve output for PID=%u, CID=%u, uHandle=%u, rc=%Rrc\n",579 uPID, uContextID, uHandleID, rc);580 575 /* Note: Since the context ID is unique the request *has* to be completed here, 581 576 * regardless whether we got data or not! Otherwise the progress object 582 577 * on the host never will get completed! */ 583 /* cbRead now contains actual size. */584 578 int rc2 = VbglR3GuestCtrlExecSendOut(idClient, uContextID, uPID, uHandleID, uFlags, 585 579 pBuf, cbRead); … … 656 650 657 651 #ifdef DEBUG 658 659 660 661 662 652 PVBOXSERVICECTRLTHREAD pThreadCur; 653 uint32_t cThreads = 0; 654 RTListForEach(&g_GuestControlThreads, pThreadCur, VBOXSERVICECTRLTHREAD, Node) 655 cThreads++; 656 VBoxServiceVerbose(4, "Control: Guest process threads left=%u\n", cThreads); 663 657 #endif 664 658 AssertMsg(RTListIsEmpty(&g_GuestControlThreads), … … 717 711 RTListForEach(&g_GuestControlThreads, pThread, VBOXSERVICECTRLTHREAD, Node) 718 712 { 719 VBOXSERVICECTRLTHREADSTATUS enmStatus = VBoxServiceControlThreadGetStatus(pThread); 720 if (enmStatus == VBOXSERVICECTRLTHREADSTATUS_STARTED) 721 uProcsRunning++; 722 else if (enmStatus == VBOXSERVICECTRLTHREADSTATUS_STOPPED) 723 uProcsStopped++; 724 else 725 AssertMsgFailed(("Control: Guest process neither started nor stopped!?\n")); 713 VBoxServiceControlThreadActive(pThread) 714 ? uProcsRunning++ 715 : uProcsStopped++; 726 716 } 727 717
Note:
See TracChangeset
for help on using the changeset viewer.