Changeset 49440 in vbox for trunk/src/VBox/Main
- Timestamp:
- Nov 11, 2013 3:44:53 PM (11 years ago)
- Location:
- trunk/src/VBox/Main/src-client
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r49350 r49440 907 907 *puContextID = uNewContextID; 908 908 909 #if 0 909 910 LogFlowThisFunc(("mNextContextID=%RU32, uSessionID=%RU32, uObjectID=%RU32, uCount=%RU32, uNewContextID=%RU32\n", 910 911 mNextContextID, uSessionID, uObjectID, uCount, uNewContextID)); 912 #endif 911 913 return VINF_SUCCESS; 912 914 } … … 937 939 GuestWaitEvent *pEvent = new GuestWaitEvent(uContextID, lstEvents); 938 940 AssertPtr(pEvent); 941 942 LogFlowThisFunc(("New event=%p, CID=%RU32\n", pEvent, uContextID)); 939 943 940 944 /* Insert event into matching event group. This is for faster per-group … … 975 979 if (RT_SUCCESS(rc)) 976 980 { 977 GuestEventGroup::iterator itGroup s= mWaitEventGroups.find(aType);978 if (itGroup s!= mWaitEventGroups.end())979 { 980 for (GuestWaitEvents::iterator itEvents = itGroups->second.begin();981 itEvents != itGroups->second.end(); itEvents++)981 GuestEventGroup::iterator itGroup = mWaitEventGroups.find(aType); 982 if (itGroup != mWaitEventGroups.end()) 983 { 984 GuestWaitEvents::iterator itEvents = itGroup->second.begin(); 985 while (itEvents != itGroup->second.end()) 982 986 { 983 987 #ifdef DEBUG 984 LogFlowThisFunc(("Signalling event=%p, type=%ld (CID %RU32: Ses ion=%RU32, Object=%RU32, Count=%RU32) ...\n",988 LogFlowThisFunc(("Signalling event=%p, type=%ld (CID %RU32: Session=%RU32, Object=%RU32, Count=%RU32) ...\n", 985 989 itEvents->second, aType, itEvents->first, 986 990 VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(itEvents->first), … … 993 997 if (RT_SUCCESS(rc)) 994 998 rc = rc2; 999 1000 if (RT_SUCCESS(rc2)) 1001 { 1002 /* Remove the event from all other event groups (except the 1003 * original one!) because it was signalled. */ 1004 AssertPtr(itEvents->second); 1005 const GuestEventTypes evTypes = itEvents->second->Types(); 1006 for (GuestEventTypes::const_iterator itType = evTypes.begin(); 1007 itType != evTypes.end(); itType++) 1008 { 1009 if ((*itType) != aType) /* Only remove all other groups. */ 1010 { 1011 /* Get current event group. */ 1012 GuestEventGroup::iterator evGroup = mWaitEventGroups.find((*itType)); 1013 Assert(evGroup != mWaitEventGroups.end()); 1014 1015 /* Lookup event in event group. */ 1016 GuestWaitEvents::iterator evEvent = evGroup->second.find(itEvents->first /* Context ID */); 1017 Assert(evEvent != evGroup->second.end()); 1018 1019 LogFlowThisFunc(("Removing event=%p (type %ld)\n", evEvent->second, (*itType))); 1020 evGroup->second.erase(evEvent); 1021 1022 LogFlowThisFunc(("%zu events for type=%ld left\n", 1023 evGroup->second.size(), aType)); 1024 } 1025 } 1026 1027 /* Remove the event from the passed-in event group. */ 1028 itGroup->second.erase(itEvents++); 1029 } 1030 else 1031 itEvents++; 995 1032 #ifdef DEBUG 996 1033 cEvents++; … … 1052 1089 if (RT_SUCCESS(rc)) 1053 1090 { 1091 LogFlowThisFunc(("pEvent=%p\n", pEvent)); 1092 1054 1093 const GuestEventTypes lstTypes = pEvent->Types(); 1055 1094 for (GuestEventTypes::const_iterator itEvents = lstTypes.begin(); … … 1062 1101 if (itCurEvent->second == pEvent) 1063 1102 { 1064 mWaitEventGroups[(*itEvents)].erase(itCurEvent );1103 mWaitEventGroups[(*itEvents)].erase(itCurEvent++); 1065 1104 break; 1066 1105 } … … 1201 1240 const GuestWaitEventPayload *pPayload) 1202 1241 { 1203 AssertReturn(!mfAborted, VERR_CANCELLED); 1242 if (ASMAtomicReadBool(&mfAborted)) 1243 return VERR_CANCELLED; 1204 1244 1205 1245 #ifdef VBOX_STRICT … … 1282 1322 ASMAtomicWriteBool(&mfAborted, true); 1283 1323 1324 #ifdef DEBUG_andy 1325 LogFlowThisFunc(("Cancelling %p ...\n")); 1326 #endif 1284 1327 return RTSemEventSignal(mEventSem); 1285 1328 } -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r49389 r49440 986 986 AssertPtrReturn(pEvent, VERR_INVALID_POINTER); 987 987 988 VBoxEventType_T evtType; 989 ComPtr<IEvent> pIEvent; 988 990 int vrc = waitForEvent(pEvent, uTimeoutMS, 989 NULL /* Event type */, NULL /* IEvent */); 990 if (RT_SUCCESS(vrc)) 991 { 992 Assert(pEvent->Payload().Size() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 993 const PCALLBACKDATA_FILE_NOTIFY pvCbData = 994 (PCALLBACKDATA_FILE_NOTIFY)pEvent->Payload().Raw(); 995 Assert(pvCbData->uType == GUEST_FILE_NOTIFYTYPE_SEEK); 996 997 if (puOffset) 998 *puOffset = pvCbData->u.seek.uOffActual; 991 &evtType, pIEvent.asOutParam()); 992 if (RT_SUCCESS(vrc)) 993 { 994 if (evtType == VBoxEventType_OnGuestFileOffsetChanged) 995 { 996 if (puOffset) 997 { 998 ComPtr<IGuestFileOffsetChangedEvent> pFileEvent = pIEvent; 999 Assert(!pFileEvent.isNull()); 1000 1001 HRESULT hr = pFileEvent->COMGETTER(Offset)((LONG64*)puOffset); 1002 ComAssertComRC(hr); 1003 } 1004 } 1005 else 1006 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED; 999 1007 } 1000 1008 … … 1008 1016 AssertPtrReturn(pEvent, VERR_INVALID_POINTER); 1009 1017 1018 VBoxEventType_T evtType; 1019 ComPtr<IEvent> pIEvent; 1010 1020 int vrc = waitForEvent(pEvent, uTimeoutMS, 1011 NULL /* Event type */, NULL /* IEvent */); 1012 if (RT_SUCCESS(vrc)) 1013 { 1014 Assert(pEvent->Payload().Size() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 1015 const PCALLBACKDATA_FILE_NOTIFY pvCbData = 1016 (PCALLBACKDATA_FILE_NOTIFY)pEvent->Payload().Raw(); 1017 Assert(pvCbData->uType == GUEST_FILE_NOTIFYTYPE_READ); 1018 1019 uint32_t cbRead = pvCbData->u.read.cbData; 1020 if ( cbRead 1021 && cbRead <= cbData) 1022 { 1023 memcpy(pvData, 1024 pvCbData->u.read.pvData, cbRead); 1021 &evtType, pIEvent.asOutParam()); 1022 if (RT_SUCCESS(vrc)) 1023 { 1024 if (evtType == VBoxEventType_OnGuestFileRead) 1025 { 1026 ComPtr<IGuestFileReadEvent> pFileEvent = pIEvent; 1027 Assert(!pFileEvent.isNull()); 1028 1029 HRESULT hr; 1030 if (pvData) 1031 { 1032 com::SafeArray <BYTE> data; 1033 hr = pFileEvent->COMGETTER(Data)(ComSafeArrayAsOutParam(data)); 1034 ComAssertComRC(hr); 1035 size_t cbRead = data.size(); 1036 if ( cbRead 1037 && cbRead <= cbData) 1038 { 1039 memcpy(pvData, data.raw(), data.size()); 1040 } 1041 else 1042 vrc = VERR_BUFFER_OVERFLOW; 1043 } 1044 if (pcbRead) 1045 { 1046 hr = pFileEvent->COMGETTER(Processed)((ULONG*)pcbRead); 1047 ComAssertComRC(hr); 1048 } 1025 1049 } 1026 1050 else 1027 vrc = VERR_BUFFER_OVERFLOW; 1028 1029 if (pcbRead) 1030 *pcbRead = cbRead; 1051 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED; 1031 1052 } 1032 1053 … … 1038 1059 { 1039 1060 AssertPtrReturn(pEvent, VERR_INVALID_POINTER); 1040 1061 /* pFileStatus is optional. */ 1062 1063 VBoxEventType_T evtType; 1064 ComPtr<IEvent> pIEvent; 1041 1065 int vrc = waitForEvent(pEvent, uTimeoutMS, 1042 NULL /* Event type */, NULL /* IEvent */); 1043 if (RT_SUCCESS(vrc)) 1044 { 1045 Assert(pEvent->Payload().Size() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 1046 const PCALLBACKDATA_FILE_NOTIFY pvCbData = 1047 (PCALLBACKDATA_FILE_NOTIFY)pEvent->Payload().Raw(); 1048 /* Note: pvCbData->uType can be different types. */; 1049 1050 1066 &evtType, pIEvent.asOutParam()); 1067 if (RT_SUCCESS(vrc)) 1068 { 1069 Assert(evtType == VBoxEventType_OnGuestFileStateChanged); 1070 ComPtr<IGuestFileStateChangedEvent> pFileEvent = pIEvent; 1071 Assert(!pFileEvent.isNull()); 1072 1073 HRESULT hr; 1074 if (pFileStatus) 1075 { 1076 hr = pFileEvent->COMGETTER(Status)(pFileStatus); 1077 ComAssertComRC(hr); 1078 } 1079 1080 ComPtr<IVirtualBoxErrorInfo> errorInfo; 1081 hr = pFileEvent->COMGETTER(Error)(errorInfo.asOutParam()); 1082 ComAssertComRC(hr); 1083 1084 LONG lGuestRc; 1085 hr = errorInfo->COMGETTER(ResultDetail)(&lGuestRc); 1086 ComAssertComRC(hr); 1087 1088 LogFlowThisFunc(("resultDetail=%RI32 (%Rrc)\n", 1089 lGuestRc, lGuestRc)); 1090 1091 if (RT_FAILURE((int)lGuestRc)) 1092 vrc = VERR_GSTCTL_GUEST_ERROR; 1051 1093 1052 1094 if (pGuestRc) 1053 *pGuestRc = pvCbData->rc; /* int vs. uint32_t */1095 *pGuestRc = (int)lGuestRc; 1054 1096 } 1055 1097 … … 1062 1104 AssertPtrReturn(pEvent, VERR_INVALID_POINTER); 1063 1105 1106 VBoxEventType_T evtType; 1107 ComPtr<IEvent> pIEvent; 1064 1108 int vrc = waitForEvent(pEvent, uTimeoutMS, 1065 NULL /* Event type */, NULL /* IEvent */); 1066 if (RT_SUCCESS(vrc)) 1067 { 1068 Assert(pEvent->Payload().Size() == sizeof(CALLBACKDATA_FILE_NOTIFY)); 1069 const PCALLBACKDATA_FILE_NOTIFY pvCbData = 1070 (PCALLBACKDATA_FILE_NOTIFY)pEvent->Payload().Raw(); 1071 Assert(pvCbData->uType == GUEST_FILE_NOTIFYTYPE_WRITE); 1072 1073 if (pcbWritten) 1074 *pcbWritten = pvCbData->u.write.cbWritten; 1109 &evtType, pIEvent.asOutParam()); 1110 if (RT_SUCCESS(vrc)) 1111 { 1112 if (evtType == VBoxEventType_OnGuestFileWrite) 1113 { 1114 if (pcbWritten) 1115 { 1116 ComPtr<IGuestFileWriteEvent> pFileEvent = pIEvent; 1117 Assert(!pFileEvent.isNull()); 1118 1119 HRESULT hr = pFileEvent->COMGETTER(Processed)((ULONG*)pcbWritten); 1120 ComAssertComRC(hr); 1121 } 1122 } 1123 else 1124 vrc = VWRN_GSTCTL_OBJECTSTATE_CHANGED; 1075 1125 } 1076 1126 -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r49405 r49440 118 118 int rc2 = mProcess->signalWaitEvent(aType, aEvent); 119 119 #ifdef DEBUG 120 LogFlowThisFunc(("Signalling events of type=%ld, p rocess=%p resulted in rc=%Rrc\n",120 LogFlowThisFunc(("Signalling events of type=%ld, pProcess=%p resulted in rc=%Rrc\n", 121 121 aType, &mProcess, rc2)); 122 122 #endif … … 1238 1238 if (mData.mStatus != ProcessStatus_Started) 1239 1239 { 1240 LogFlowThisFunc(("Process not started (yet), nothing to terminate\n")); 1240 LogFlowThisFunc(("Process not started state (state is %ld), skipping termination\n", 1241 mData.mStatus)); 1241 1242 return VINF_SUCCESS; /* Nothing to do (anymore). */ 1242 1243 } … … 1298 1299 case ProcessStatus_TerminatedSignal: 1299 1300 case ProcessStatus_TerminatedAbnormally: 1301 case ProcessStatus_Down: 1302 /* Nothing to wait for anymore. */ 1300 1303 waitResult = ProcessWaitResult_Terminate; 1301 1304 break; 1302 case ProcessStatus_Down:1303 waitResult = ProcessWaitResult_Terminate;1304 break;1305 1305 1306 1306 case ProcessStatus_TimedOutKilled: 1307 /* Fall through is intentional. */1308 1307 case ProcessStatus_TimedOutAbnormally: 1308 /* Dito. */ 1309 1309 waitResult = ProcessWaitResult_Timeout; 1310 1310 break; 1311 1311 1312 case ProcessStatus_Error:1313 waitResult = ProcessWaitResult_Error;1314 break;1315 1316 1312 case ProcessStatus_Started: 1317 {1318 1313 switch (oldStatus) 1319 1314 { 1315 case ProcessStatus_Undefined: 1320 1316 case ProcessStatus_Starting: 1317 /* Also wait for process start. */ 1321 1318 if (fWaitFlags & ProcessWaitForFlag_Start) 1322 {1323 1319 waitResult = ProcessWaitResult_Start; 1324 }1325 1320 else 1326 1321 { 1327 1322 /* 1328 * If ProcessCreateFlag_WaitForProcessStartOnly was specified on process creation the1329 * caller is not interested in getting further process statuses -- so just don't notify1330 * anything here anymore and return.1331 */1323 * If ProcessCreateFlag_WaitForProcessStartOnly was specified on process creation the 1324 * caller is not interested in getting further process statuses -- so just don't notify 1325 * anything here anymore and return. 1326 */ 1332 1327 if (uProcFlags & ProcessCreateFlag_WaitForProcessStartOnly) 1333 1328 waitResult = ProcessWaitResult_Start; … … 1335 1330 break; 1336 1331 1332 case ProcessStatus_Started: 1333 /* Only wait for process start. */ 1334 if (fWaitFlags == ProcessWaitForFlag_Start) 1335 waitResult = ProcessWaitResult_Start; 1336 break; 1337 1337 1338 default: 1338 /* No result available (yet). */ 1339 AssertMsgFailed(("Unhandled old status %ld before new status 'started'\n", 1340 oldStatus)); 1341 waitResult = ProcessWaitResult_Start; 1339 1342 break; 1340 1343 } 1341 1344 break; 1342 } 1345 1346 case ProcessStatus_Error: 1347 /* Nothing to wait for anymore. */ 1348 waitResult = ProcessWaitResult_Error; 1349 break; 1343 1350 1344 1351 case ProcessStatus_Undefined: 1345 1352 case ProcessStatus_Starting: 1346 /* No result available yet. */ 1347 break; 1348 1349 default: 1350 AssertMsgFailed(("Unhandled process status %ld\n", newStatus)); 1353 /* No result available yet, leave wait 1354 * flags untouched. */ 1351 1355 break; 1352 1356 } … … 1409 1413 if (pGuestRc) 1410 1414 *pGuestRc = mData.mLastError; /* Return last set error. */ 1415 LogFlowThisFunc(("Process is in error state (guestRc=%Rrc)\n", mData.mLastError)); 1411 1416 return VERR_GSTCTL_GUEST_ERROR; 1412 1417 } … … 1419 1424 if (pGuestRc) 1420 1425 *pGuestRc = mData.mLastError; /* Return last set error (if any). */ 1426 LogFlowThisFunc(("Nothing to wait for (guestRc=%Rrc)\n", mData.mLastError)); 1421 1427 return RT_SUCCESS(mData.mLastError) ? VINF_SUCCESS : VERR_GSTCTL_GUEST_ERROR; 1422 1428 } 1423 1424 alock.release(); /* Release lock before waiting. */1425 1429 1426 1430 /* Adjust timeout. Passing 0 means RT_INDEFINITE_WAIT. */ … … 1445 1449 if (RT_FAILURE(vrc)) 1446 1450 return vrc; 1451 1452 alock.release(); /* Release lock before waiting. */ 1447 1453 1448 1454 /* … … 1499 1505 ComPtr<IEvent> pIEvent; 1500 1506 int vrc = waitForEvent(pEvent, uTimeoutMS, 1501 1507 &evtType, pIEvent.asOutParam()); 1502 1508 if (RT_SUCCESS(vrc)) 1503 1509 { … … 1545 1551 { 1546 1552 vrc = waitForEvent(pEvent, uTimeoutMS, 1547 1553 &evtType, pIEvent.asOutParam()); 1548 1554 if (RT_SUCCESS(vrc)) 1549 1555 { … … 1640 1646 ComAssertComRC(hr); 1641 1647 1642 LogFlowThisFunc((" procStatus=%RU32, resultDetail=%RI32 (rc=%Rrc)\n",1648 LogFlowThisFunc(("Got procStatus=%RU32, guestRc=%RI32 (%Rrc)\n", 1643 1649 procStatus, lGuestRc, lGuestRc)); 1644 1650 … … 1772 1778 ReturnComNotImplemented(); 1773 1779 #else 1780 LogFlowThisFuncEnter(); 1781 1774 1782 if (aToRead == 0) 1775 1783 return setError(E_INVALIDARG, tr("The size to read is zero")); -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r49349 r49440 317 317 /* Startup process. */ 318 318 ComObjPtr<GuestProcess> pProcess; int guestRc; 319 rc = pSession->processCreateExInteral(procInfo, pProcess);320 319 if (RT_SUCCESS(rc)) 320 rc = pSession->processCreateExInteral(procInfo, pProcess); 321 if (RT_SUCCESS(rc)) 322 { 323 Assert(!pProcess.isNull()); 321 324 rc = pProcess->startProcess(30 * 1000 /* 30s timeout */, 322 325 &guestRc); 326 } 327 323 328 if (RT_FAILURE(rc)) 324 329 { … … 772 777 * to the destination -> access denied. */ 773 778 setProgressErrorMsg(VBOX_E_IPRT_ERROR, 774 Utf8StrFmt(GuestSession::tr(" Access denied when copying file \"%s\" to \"%s\""),779 Utf8StrFmt(GuestSession::tr("Unable to write \"%s\" to \"%s\": Access denied"), 775 780 mSource.c_str(), mDest.c_str())); 776 781 rc = VERR_GENERAL_FAILURE; /* Fudge. */
Note:
See TracChangeset
for help on using the changeset viewer.