Changeset 39313 in vbox for trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExecThread.cpp
- Timestamp:
- Nov 15, 2011 2:43:38 PM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 74874
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlExecThread.cpp
r39300 r39313 164 164 AssertPtrReturn(pThread, VERR_INVALID_POINTER); 165 165 166 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Signalling shutdown ...\n",166 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Signalling shutdown ...\n", 167 167 pThread->uPID); 168 168 … … 176 176 int rc = VBoxServiceControlThreadPerform(pThread->uPID, &ctrlRequest); 177 177 if (RT_FAILURE(rc)) 178 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Sending quit request failed with rc=%Rrc\n",178 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Sending quit request failed with rc=%Rrc\n", 179 179 pThread->uPID, rc); 180 180 return rc; … … 197 197 && !ASMAtomicReadBool(&pThread->fStopped)) /* Only shutdown threads which aren't yet. */ 198 198 { 199 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Waiting for shutdown ...\n",199 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Waiting for shutdown ...\n", 200 200 pThread->uPID); 201 201 … … 205 205 if (RT_FAILURE(rcThread)) 206 206 { 207 VBoxServiceError("Control Exec: [PID %u]: Shutdown returned error rc=%Rrc\n",207 VBoxServiceError("ControlThead: [PID %u]: Shutdown returned error rc=%Rrc\n", 208 208 pThread->uPID, rcThread); 209 209 if (RT_SUCCESS(rc)) … … 225 225 return; 226 226 227 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Freeing thread data ...\n",227 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Freeing thread data ...\n", 228 228 pThread->uPID); 229 229 … … 316 316 317 317 #ifdef DEBUG_andy 318 VBoxServiceVerbose(4, "Control Exec: HandleOutputEvent fPollEvt=0x%x, idPollHnd=%u\n",318 VBoxServiceVerbose(4, "ControlThead: HandleOutputEvent fPollEvt=0x%x, idPollHnd=%u\n", 319 319 fPollEvt, idPollHnd); 320 320 #endif … … 342 342 { 343 343 #ifdef DEBUG_andy 344 VBoxServiceVerbose(4, "Control Exec: HandleIPCRequest\n");344 VBoxServiceVerbose(4, "ControlThead: HandleIPCRequest\n"); 345 345 #endif 346 346 … … 358 358 int rc = RTPipeRead(pThread->hNotificationPipeR, abBuf, sizeof(abBuf), &cbIgnore); 359 359 if (RT_FAILURE(rc)) 360 VBoxServiceError("Control Exec: Draining IPC notification pipe failed with rc=%Rrc\n", rc);360 VBoxServiceError("ControlThead: Draining IPC notification pipe failed with rc=%Rrc\n", rc); 361 361 362 362 int rcReq = VINF_SUCCESS; /* Actual request result. */ … … 438 438 ? rcReq : rc; 439 439 440 VBoxServiceVerbose(4, "Control Exec: Handled IPC request with rcReq=%Rrc, enmType=%u, cbData=%u\n",440 VBoxServiceVerbose(4, "ControlThead: Handled IPC request with rcReq=%Rrc, enmType=%u, cbData=%u\n", 441 441 rcReq, pRequest->enmType, pRequest->cbData); 442 442 … … 498 498 if (RT_FAILURE(rc)) 499 499 { 500 VBoxServiceError("Control Exec: Unable to assign PID to new thread, rc=%Rrc\n", rc);500 VBoxServiceError("ControlThead: Unable to assign PID to new thread, rc=%Rrc\n", rc); 501 501 return rc; 502 502 } … … 506 506 * and that it's now OK to send input to the process. 507 507 */ 508 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Process started, CID=%u, User=%s\n",508 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Process started, CID=%u, User=%s\n", 509 509 pThread->uPID, pThread->uContextID, pThread->pszUser); 510 510 rc = VbglR3GuestCtrlExecReportStatus(pThread->uClientID, pThread->uContextID, … … 531 531 if (RT_SUCCESS(rc2)) 532 532 { 533 /*VBoxServiceVerbose(4, "Control Exec: [PID %u}: RTPollNoResume idPollHnd=%u\n",533 /*VBoxServiceVerbose(4, "ControlThead: [PID %u}: RTPollNoResume idPollHnd=%u\n", 534 534 pThread->uPID, idPollHnd);*/ 535 535 switch (idPollHnd) … … 608 608 if (cMsElapsed >= cMsTimeout) 609 609 { 610 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Timed out (%ums elapsed > %ums timeout), killing ...",610 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Timed out (%ums elapsed > %ums timeout), killing ...", 611 611 pThread->uPID, cMsElapsed, cMsTimeout); 612 612 … … 644 644 if (MsProcessKilled == UINT64_MAX) 645 645 { 646 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Is still alive and not killed yet\n",646 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Is still alive and not killed yet\n", 647 647 pThread->uPID); 648 648 … … 654 654 for (size_t i = 0; i < 10; i++) 655 655 { 656 VBoxServiceVerbose(4, "Control Exec: [PID %u]: Kill attempt %d/10: Waiting to exit ...\n",656 VBoxServiceVerbose(4, "ControlThead: [PID %u]: Kill attempt %d/10: Waiting to exit ...\n", 657 657 pThread->uPID, i + 1); 658 658 rc2 = RTProcWait(hProcess, RTPROCWAIT_FLAGS_NOBLOCK, &ProcessStatus); 659 659 if (RT_SUCCESS(rc2)) 660 660 { 661 VBoxServiceVerbose(4, "Control Exec: [PID %u]: Kill attempt %d/10: Exited\n",661 VBoxServiceVerbose(4, "ControlThead: [PID %u]: Kill attempt %d/10: Exited\n", 662 662 pThread->uPID, i + 1); 663 663 fProcessAlive = false; … … 666 666 if (i >= 5) 667 667 { 668 VBoxServiceVerbose(4, "Control Exec: [PID %u]: Kill attempt %d/10: Trying to terminate ...\n",668 VBoxServiceVerbose(4, "ControlThead: [PID %u]: Kill attempt %d/10: Trying to terminate ...\n", 669 669 pThread->uPID, i + 1); 670 670 RTProcTerminate(hProcess); … … 674 674 675 675 if (fProcessAlive) 676 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Could not be killed\n", pThread->uPID);676 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Could not be killed\n", pThread->uPID); 677 677 } 678 678 … … 688 688 if ( fProcessTimedOut && !fProcessAlive && MsProcessKilled != UINT64_MAX) 689 689 { 690 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Timed out and got killed\n",690 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Timed out and got killed\n", 691 691 pThread->uPID); 692 692 uStatus = PROC_STS_TOK; … … 694 694 else if (fProcessTimedOut && fProcessAlive && MsProcessKilled != UINT64_MAX) 695 695 { 696 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Timed out and did *not* get killed\n",696 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Timed out and did *not* get killed\n", 697 697 pThread->uPID); 698 698 uStatus = PROC_STS_TOA; … … 700 700 else if (pThread->fShutdown && (fProcessAlive || MsProcessKilled != UINT64_MAX)) 701 701 { 702 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Got terminated because system/service is about to shutdown\n",702 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Got terminated because system/service is about to shutdown\n", 703 703 pThread->uPID); 704 704 uStatus = PROC_STS_DWN; /* Service is stopping, process was killed. */ … … 707 707 else if (fProcessAlive) 708 708 { 709 VBoxServiceError("Control Exec: [PID %u]: Is alive when it should not!\n",709 VBoxServiceError("ControlThead: [PID %u]: Is alive when it should not!\n", 710 710 pThread->uPID); 711 711 } 712 712 else if (MsProcessKilled != UINT64_MAX) 713 713 { 714 VBoxServiceError("Control Exec: [PID %u]: Has been killed when it should not!\n",714 VBoxServiceError("ControlThead: [PID %u]: Has been killed when it should not!\n", 715 715 pThread->uPID); 716 716 } 717 717 else if (ProcessStatus.enmReason == RTPROCEXITREASON_NORMAL) 718 718 { 719 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Ended with RTPROCEXITREASON_NORMAL (%u)\n",719 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Ended with RTPROCEXITREASON_NORMAL (%u)\n", 720 720 pThread->uPID, ProcessStatus.iStatus); 721 721 … … 725 725 else if (ProcessStatus.enmReason == RTPROCEXITREASON_SIGNAL) 726 726 { 727 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Ended with RTPROCEXITREASON_SIGNAL (%u)\n",727 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Ended with RTPROCEXITREASON_SIGNAL (%u)\n", 728 728 pThread->uPID, ProcessStatus.iStatus); 729 729 … … 733 733 else if (ProcessStatus.enmReason == RTPROCEXITREASON_ABEND) 734 734 { 735 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Ended with RTPROCEXITREASON_ABEND (%u)\n",735 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Ended with RTPROCEXITREASON_ABEND (%u)\n", 736 736 pThread->uPID, ProcessStatus.iStatus); 737 737 … … 740 740 } 741 741 else 742 VBoxServiceVerbose(1, "Control Exec: [PID %u]: Handling process status %u not implemented\n",742 VBoxServiceVerbose(1, "ControlThead: [PID %u]: Handling process status %u not implemented\n", 743 743 pThread->uPID, ProcessStatus.enmReason); 744 744 745 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Sending final status, ClientID=%u, CID=%u, Status=%u, Flags=0x%x\n",745 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Sending final status, ClientID=%u, CID=%u, Status=%u, Flags=0x%x\n", 746 746 pThread->uPID, pThread->uClientID, pThread->uContextID, uStatus, uFlags); 747 747 rc = VbglR3GuestCtrlExecReportStatus(pThread->uClientID, pThread->uContextID, … … 749 749 NULL /* pvData */, 0 /* cbData */); 750 750 if (RT_FAILURE(rc)) 751 VBoxServiceError("Control Exec: [PID %u]: Error reporting final status to host; rc=%Rrc\n",751 VBoxServiceError("ControlThead: [PID %u]: Error reporting final status to host; rc=%Rrc\n", 752 752 pThread->uPID, rc); 753 753 754 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Process loop ended with rc=%Rrc\n",754 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Process loop ended with rc=%Rrc\n", 755 755 pThread->uPID, rc); 756 756 } 757 757 else 758 VBoxServiceError("Control Exec: [PID %u]: Loop failed with rc=%Rrc\n",758 VBoxServiceError("ControlThead: [PID %u]: Loop failed with rc=%Rrc\n", 759 759 pThread->uPID, rc); 760 760 return rc; … … 833 833 #endif 834 834 #ifdef DEBUG 835 VBoxServiceVerbose(3, "Control Exec: VBoxServiceControlExecMakeFullPath: %s -> %s\n",835 VBoxServiceVerbose(3, "ControlThead: VBoxServiceControlExecMakeFullPath: %s -> %s\n", 836 836 pszPath, pszExpanded); 837 837 #endif … … 870 870 rc = VBoxServiceControlThreadMakeFullPath(pszExecResolved, pszResolved, cbResolved); 871 871 #ifdef DEBUG 872 VBoxServiceVerbose(3, "Control Exec: VBoxServiceControlExecResolveExecutable: %s -> %s\n",872 VBoxServiceVerbose(3, "ControlThead: VBoxServiceControlExecResolveExecutable: %s -> %s\n", 873 873 pszFileName, pszResolved); 874 874 #endif … … 1041 1041 uProcFlags |= RTPROC_FLAGS_SERVICE; 1042 1042 #ifdef DEBUG 1043 VBoxServiceVerbose(3, "Control Exec: Command: %s\n", szExecExp);1043 VBoxServiceVerbose(3, "ControlThead: Command: %s\n", szExecExp); 1044 1044 for (size_t i = 0; papszArgsExp[i]; i++) 1045 VBoxServiceVerbose(3, "Control Exec:\targv[%ld]: %s\n", i, papszArgsExp[i]);1045 VBoxServiceVerbose(3, "ControlThead:\targv[%ld]: %s\n", i, papszArgsExp[i]); 1046 1046 #endif 1047 1047 /* Do normal execution. */ … … 1066 1066 { 1067 1067 AssertPtrReturn(pThread, VERR_INVALID_POINTER); 1068 VBoxServiceVerbose(3, "Control Exec: Thread of process \"%s\" started\n", pThread->pszCmd);1068 VBoxServiceVerbose(3, "ControlThead: Thread of process \"%s\" started\n", pThread->pszCmd); 1069 1069 1070 1070 int rc = VbglR3GuestCtrlConnect(&pThread->uClientID); 1071 1071 if (RT_FAILURE(rc)) 1072 1072 { 1073 VBoxServiceError("Control Exec: Thread failed to connect to the guest control service, aborted! Error: %Rrc\n", rc);1073 VBoxServiceError("ControlThead: Thread failed to connect to the guest control service, aborted! Error: %Rrc\n", rc); 1074 1074 RTThreadUserSignal(RTThreadSelf()); 1075 1075 return rc; 1076 1076 } 1077 VBoxServiceVerbose(3, "Control Exec: Guest process \"%s\" got client ID=%u\n",1077 VBoxServiceVerbose(3, "ControlThead: Guest process \"%s\" got client ID=%u\n", 1078 1078 pThread->pszCmd, pThread->uClientID); 1079 1079 … … 1148 1148 &hProcess); 1149 1149 if (RT_FAILURE(rc)) 1150 VBoxServiceError("Control Exec: Error starting process, rc=%Rrc\n", rc);1150 VBoxServiceError("ControlThead: Error starting process, rc=%Rrc\n", rc); 1151 1151 /* 1152 1152 * Tell the control thread that it can continue … … 1203 1203 else /* Something went wrong; report error! */ 1204 1204 { 1205 VBoxServiceError("Control Exec: Could not start process '%s' (CID: %u)! Error: %Rrc\n",1205 VBoxServiceError("ControlThead: Could not start process '%s' (CID: %u)! Error: %Rrc\n", 1206 1206 pThread->pszCmd, pThread->uContextID, rc); 1207 1207 … … 1210 1210 NULL /* pvData */, 0 /* cbData */); 1211 1211 if (RT_FAILURE(rc2)) 1212 VBoxServiceError("Control Exec: Could not report process start error! Error: %Rrc (process error %Rrc)\n",1212 VBoxServiceError("ControlThead: Could not report process start error! Error: %Rrc (process error %Rrc)\n", 1213 1213 rc2, rc); 1214 1214 } … … 1238 1238 if (pThread->uClientID) 1239 1239 { 1240 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Cancelling pending waits (client ID=%u)\n",1240 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Cancelling pending waits (client ID=%u)\n", 1241 1241 pThread->uPID, pThread->uClientID); 1242 1242 int rc2 = VbglR3GuestCtrlCancelPendingWaits(pThread->uClientID); 1243 1243 if (RT_FAILURE(rc2)) 1244 1244 { 1245 VBoxServiceError("Control Exec: [PID %u]: Cancelling pending waits failed; rc=%Rrc\n",1245 VBoxServiceError("ControlThead: [PID %u]: Cancelling pending waits failed; rc=%Rrc\n", 1246 1246 pThread->uPID, rc2); 1247 1247 if (RT_SUCCESS(rc)) … … 1250 1250 1251 1251 /* Disconnect from guest control service. */ 1252 VBoxServiceError("ControlThead: [PID %u]: Disconnecting (client ID=%u) ...\n", 1253 pThread->uPID, pThread->uClientID); 1252 1254 VbglR3GuestCtrlDisconnect(pThread->uClientID); 1253 1255 pThread->uClientID = 0; 1254 1256 } 1255 1257 1256 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Thread of process \"%s\" ended with rc=%Rrc\n",1258 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Thread of process \"%s\" ended with rc=%Rrc\n", 1257 1259 pThread->uPID, pThread->pszCmd, rc); 1258 1260 … … 1346 1348 if (RT_FAILURE(rc)) 1347 1349 { 1348 VBoxServiceError("Control Exec: RTThreadCreate failed, rc=%Rrc\n, pThread=%p\n",1350 VBoxServiceError("ControlThead: RTThreadCreate failed, rc=%Rrc\n, pThread=%p\n", 1349 1351 rc, pThread); 1350 1352 } 1351 1353 else 1352 1354 { 1353 VBoxServiceVerbose(4, "Control Exec: Waiting for thread to initialize ...\n");1355 VBoxServiceVerbose(4, "ControlThead: Waiting for thread to initialize ...\n"); 1354 1356 1355 1357 /* Wait for the thread to initialize. */ … … 1357 1359 if (ASMAtomicReadBool(&pThread->fShutdown)) 1358 1360 { 1359 VBoxServiceError("Control Exec: Thread for process \"%s\" failed to start!\n", pszCmd);1361 VBoxServiceError("ControlThead: Thread for process \"%s\" failed to start!\n", pszCmd); 1360 1362 rc = VERR_GENERAL_FAILURE; 1361 1363 } … … 1400 1402 PVBOXSERVICECTRLTHREAD pNext = RTListNodeGetNext(&pOldThread->Node, VBOXSERVICECTRLTHREAD, Node); 1401 1403 1402 VBoxServiceVerbose(3, "Control Exec: PID %u was used before, shutting down stale exec thread ...\n",1404 VBoxServiceVerbose(3, "ControlThead: PID %u was used before, shutting down stale exec thread ...\n", 1403 1405 uPID); 1404 1406 rc = vboxServiceControlThreadShutdown(pOldThread); 1405 1407 if (RT_FAILURE(rc)) 1406 1408 { 1407 VBoxServiceVerbose(3, "Control Exec: Unable to shut down stale exec thread, rc=%Rrc\n", rc);1409 VBoxServiceVerbose(3, "ControlThead: Unable to shut down stale exec thread, rc=%Rrc\n", rc); 1408 1410 /* Keep going. */ 1409 1411 } … … 1431 1433 /* Rest in pRequest is optional (based on the request type). */ 1432 1434 1433 VBoxServiceVerbose(4, "Control Exec: Performing PID=%u, enmType=%u, pvData=0x%p, cbData=%u ...\n",1435 VBoxServiceVerbose(4, "ControlThead: Performing PID=%u, enmType=%u, pvData=0x%p, cbData=%u ...\n", 1434 1436 uPID, pRequest->enmType, pRequest->pvData, pRequest->cbData); 1435 1437 … … 1462 1464 if (RT_SUCCESS(rc) && cbWritten) 1463 1465 { 1464 VBoxServiceVerbose(4, "Control Exec: [PID %u]: Waiting for response on enmType=%u, pvData=0x%p, cbData=%u\n",1466 VBoxServiceVerbose(4, "ControlThead: [PID %u]: Waiting for response on enmType=%u, pvData=0x%p, cbData=%u\n", 1465 1467 uPID, pRequest->enmType, pRequest->pvData, pRequest->cbData); 1466 1468 /* Wait on the request to get completed (or we are asked to abort/shutdown). */ … … 1468 1470 if (RT_SUCCESS(rc)) 1469 1471 { 1470 VBoxServiceVerbose(4, "Control Exec: [PID %u]: Performed with rc=%Rrc, cbData=%u\n",1472 VBoxServiceVerbose(4, "ControlThead: [PID %u]: Performed with rc=%Rrc, cbData=%u\n", 1471 1473 uPID, pRequest->rc, pRequest->cbData); 1472 1474 … … 1480 1482 rc2 = RTSemEventMultiReset(pThread->RequestEvent); 1481 1483 if (RT_FAILURE(rc2)) 1482 VBoxServiceError("Control Exec: Unable to reset request event, rc=%Rrc\n", rc2);1484 VBoxServiceError("ControlThead: Unable to reset request event, rc=%Rrc\n", rc2); 1483 1485 1484 1486 rc2 = RTCritSectLeave(&pThread->CritSect); … … 1492 1494 rc = VERR_NOT_FOUND; 1493 1495 1494 VBoxServiceVerbose(4, "Control Exec: Performed PID=%u, enmType=%u, pvData=0x%p, cbData=%u with rc=%Rrc\n",1496 VBoxServiceVerbose(4, "ControlThead: Performed PID=%u, enmType=%u, pvData=0x%p, cbData=%u with rc=%Rrc\n", 1495 1497 uPID, pRequest->enmType, pRequest->pvData, pRequest->cbData, rc); 1496 1498 return rc; … … 1511 1513 if (RT_SUCCESS(rc)) 1512 1514 { 1513 VBoxServiceVerbose(3, "Control Exec: [PID %u]: Shutting down ...\n",1515 VBoxServiceVerbose(3, "ControlThead: [PID %u]: Shutting down ...\n", 1514 1516 pThread->uPID); 1515 1517
Note:
See TracChangeset
for help on using the changeset viewer.