Changeset 42897 in vbox for trunk/src/VBox/Main
- Timestamp:
- Aug 21, 2012 10:03:52 AM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/GuestCtrlImplPrivate.h
r42693 r42897 37 37 #endif 38 38 39 #ifdef LOG_GROUP40 #undef LOG_GROUP41 #endif42 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL43 #include <VBox/log.h>44 45 39 /** Maximum number of guest sessions a VM can have. */ 46 40 #define VBOX_GUESTCTRL_MAX_SESSIONS 255 47 /** Maximum of guest processes a guest session can have. */ 48 #define VBOX_GUESTCTRL_MAX_PROCESSES 255 41 /** Maximum number of guest objects (processes, files, ...) 42 * a guest session can have. */ 43 #define VBOX_GUESTCTRL_MAX_OBJECTS 255 49 44 /** Maximum of callback contexts a guest process can have. */ 50 45 #define VBOX_GUESTCTRL_MAX_CONTEXTS _64K - 1 51 46 52 /** Builds a context ID out of the session ID, processID and an47 /** Builds a context ID out of the session ID, object ID and an 53 48 * increasing count. */ 54 #define VBOX_GUESTCTRL_CONTEXTID_MAKE(uSession, u Process, uCount) \49 #define VBOX_GUESTCTRL_CONTEXTID_MAKE(uSession, uObject, uCount) \ 55 50 ( (uint32_t)((uSession) & 0xff) << 24 \ 56 | (uint32_t)((u Process)& 0xff) << 16 \51 | (uint32_t)((uObject) & 0xff) << 16 \ 57 52 | (uint32_t)((uCount) & 0xffff) \ 58 53 ) … … 61 56 ((uContextID) >> 24) 62 57 /** Gets the process ID out of a context ID. */ 63 #define VBOX_GUESTCTRL_CONTEXTID_GET_ PROCESS(uContextID) \58 #define VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID) \ 64 59 (((uContextID) >> 16) & 0xff) 65 60 /** Gets the conext count of a process out of a context ID. */ -
trunk/src/VBox/Main/include/GuestDirectoryImpl.h
r42673 r42897 73 73 struct Data 74 74 { 75 GuestSession *m Parent;75 GuestSession *mSession; 76 76 Utf8Str mName; 77 77 Utf8Str mFilter; … … 83 83 /** The guest process which is responsible for 84 84 * getting the stdout stream. */ 85 ComObjPtr<GuestProcess>mProcess;85 GuestProcess *mProcess; 86 86 } mData; 87 87 }; -
trunk/src/VBox/Main/include/GuestFileImpl.h
r42818 r42897 83 83 { 84 84 /** The associate session this file belongs to. */ 85 ComObjPtr<GuestSession> mSession; 86 /** The process object this file is bound to. */ 87 ComObjPtr<GuestProcess> mProcess; 85 GuestSession *mSession; 88 86 uint32_t mCreationMode; 89 87 uint32_t mDisposition; -
trunk/src/VBox/Main/include/GuestImpl.h
r42864 r42897 139 139 uint32_t getAdditionsVersion(void) { return mData.mAdditionsVersionFull; } 140 140 Console *getConsole(void) { return mParent; } 141 int session Close(ComObjPtr<GuestSession>pSession);141 int sessionRemove(GuestSession *pSession); 142 142 int sessionCreate(const Utf8Str &strUser, const Utf8Str &strPassword, const Utf8Str &strDomain, 143 143 const Utf8Str &strSessionName, ComObjPtr<GuestSession> &pGuestSession); -
trunk/src/VBox/Main/include/GuestProcessImpl.h
r42818 r42897 75 75 inline bool callbackExists(uint32_t uContextID); 76 76 inline int checkPID(uint32_t uPID); 77 void close(void);78 77 Utf8Str errorMsg(void) { return mData.mErrorMsg; } 79 78 bool isReady(void); 80 ULONG getPID(void) { return mData.mPID; }81 79 ULONG getProcessID(void) { return mData.mProcessID; } 82 80 int rc(void) { return mData.mRC; } … … 113 111 struct Data 114 112 { 115 /** Pointer to parent session. */ 113 /** Pointer to parent session. Per definition 114 * this objects *always* lives shorter than the 115 * parent. */ 116 116 GuestSession *mParent; 117 117 /** Pointer to the console object. Needed -
trunk/src/VBox/Main/src-client/GuestCtrlImpl.cpp
r42864 r42897 41 41 42 42 #include <memory> 43 44 #ifdef LOG_GROUP 45 #undef LOG_GROUP 46 #endif 47 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 48 #include <VBox/log.h> 49 43 50 44 51 // public methods only for internal purposes … … 84 91 85 92 #ifdef DEBUG 86 LogFlowFunc(("CID=%RU32, uSession=%RU32, u Process=%RU32, uCount=%RU32\n",93 LogFlowFunc(("CID=%RU32, uSession=%RU32, uObject=%RU32, uCount=%RU32\n", 87 94 pHeader->u32ContextID, 88 95 VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(pHeader->u32ContextID), 89 VBOX_GUESTCTRL_CONTEXTID_GET_ PROCESS(pHeader->u32ContextID),96 VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(pHeader->u32ContextID), 90 97 VBOX_GUESTCTRL_CONTEXTID_GET_COUNT(pHeader->u32ContextID))); 91 98 #endif … … 240 247 } 241 248 242 int Guest::sessionClose(ComObjPtr<GuestSession> pSession) 243 { 249 int Guest::sessionRemove(GuestSession *pSession) 250 { 251 LogFlowThisFuncEnter(); 252 244 253 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 254 255 int rc = VERR_NOT_FOUND; 256 257 LogFlowFunc(("Closing session (ID=%RU32) ...\n", pSession->getId())); 245 258 246 259 for (GuestSessions::iterator itSessions = mData.mGuestSessions.begin(); … … 249 262 if (pSession == itSessions->second) 250 263 { 264 LogFlowFunc(("Removing session (pSession=%p, ID=%RU32) (now total %ld sessions)\n", 265 itSessions->second, itSessions->second->getId(), mData.mGuestSessions.size() - 1)); 266 251 267 mData.mGuestSessions.erase(itSessions); 252 return VINF_SUCCESS; 253 } 254 } 255 256 return VERR_NOT_FOUND; 268 269 rc = VINF_SUCCESS; 270 break; 271 } 272 } 273 274 LogFlowFuncLeaveRC(rc); 275 return rc; 257 276 } 258 277 … … 299 318 mData.mGuestSessions[uNewSessionID] = pGuestSession; 300 319 301 LogFlowFunc(("Added new session with session ID=%RU32 (now %ld sessions total)\n",302 uNewSessionID, mData.mGuestSessions.size()));320 LogFlowFunc(("Added new session (pSession=%p, ID=%RU32), now %ld sessions total\n", 321 pGuestSession, uNewSessionID, mData.mGuestSessions.size())); 303 322 } 304 323 catch (int rc2) -
trunk/src/VBox/Main/src-client/GuestCtrlPrivate.cpp
r42716 r42897 27 27 # include <iprt/file.h> 28 28 #endif /* DEBUG */ 29 30 #ifdef LOG_GROUP 31 #undef LOG_GROUP 32 #endif 33 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 34 #include <VBox/log.h> 29 35 30 36 /****************************************************************************** -
trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp
r42846 r42897 30 30 #include <VBox/com/array.h> 31 31 32 #ifdef LOG_GROUP 33 #undef LOG_GROUP 34 #endif 35 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 36 #include <VBox/log.h> 37 32 38 33 39 // constructor / destructor … … 63 69 AssertReturn(autoInitSpan.isOk(), E_FAIL); 64 70 65 mData.m Parent= aSession;66 mData.mName = strPath;67 mData.mFilter = strFilter;68 mData.mFlags = uFlags;71 mData.mSession = aSession; 72 mData.mName = strPath; 73 mData.mFilter = strFilter; 74 mData.mFlags = uFlags; 69 75 70 76 /* Start the directory process on the guest. */ … … 89 95 * it later in subsequent read() calls. 90 96 */ 91 int rc = mData.mParent->processCreateExInteral(procInfo, mData.mProcess); 97 ComObjPtr<GuestProcess> pProcess; 98 int rc = mData.mSession->processCreateExInteral(procInfo, pProcess); 92 99 if (RT_SUCCESS(rc)) 93 rc = mData.mProcess->startProcessAsync();100 rc = pProcess->startProcessAsync(); 94 101 95 102 LogFlowThisFunc(("rc=%Rrc\n", rc)); … … 97 104 if (RT_SUCCESS(rc)) 98 105 { 106 mData.mProcess = pProcess; 107 99 108 /* Confirm a successful initialization when it's the case. */ 100 109 autoInitSpan.setSucceeded(); … … 119 128 return; 120 129 121 if (!mData.mProcess.isNull()) 122 mData.mProcess->uninit(); 130 LogFlowThisFuncLeave(); 123 131 } 124 132 … … 181 189 } 182 190 183 184 191 // implementation of public methods 185 192 ///////////////////////////////////////////////////////////////////////////// … … 192 199 LogFlowThisFuncEnter(); 193 200 201 AutoCaller autoCaller(this); 202 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 203 204 AssertPtr(mData.mSession); 205 int rc = mData.mSession->directoryRemoveFromList(this); 206 if (mData.mProcess) 207 { 208 int rc2 = mData.mSession->processRemoveFromList(mData.mProcess); 209 if (RT_SUCCESS(rc)) 210 rc = rc2; 211 } 212 213 /* 214 * Release autocaller before calling uninit. 215 */ 216 autoCaller.release(); 217 194 218 uninit(); 195 219 196 LogFlow ThisFuncLeave();220 LogFlowFuncLeaveRC(rc); 197 221 return S_OK; 198 222 #endif /* VBOX_WITH_GUEST_CONTROL */ -
trunk/src/VBox/Main/src-client/GuestFileImpl.cpp
r42848 r42897 30 30 #include <VBox/com/array.h> 31 31 32 #ifdef LOG_GROUP 33 #undef LOG_GROUP 34 #endif 35 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 36 #include <VBox/log.h> 37 32 38 33 39 // constructor / destructor … … 36 42 DEFINE_EMPTY_CTOR_DTOR(GuestFile) 37 43 38 HRESULT GuestFile::FinalConstruct( )44 HRESULT GuestFile::FinalConstruct(void) 39 45 { 40 46 LogFlowThisFunc(("\n")); … … 90 96 return; 91 97 92 mData.mSession->fileClose(this);98 LogFlowThisFuncLeave(); 93 99 } 94 100 … … 229 235 LogFlowThisFuncEnter(); 230 236 237 AutoCaller autoCaller(this); 238 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 239 240 AssertPtr(mData.mSession); 241 int rc = mData.mSession->fileRemoveFromList(this); 242 243 /* 244 * Release autocaller before calling uninit. 245 */ 246 autoCaller.release(); 247 231 248 uninit(); 232 249 233 LogFlow ThisFuncLeave();250 LogFlowFuncLeaveRC(rc); 234 251 return S_OK; 235 252 #endif /* VBOX_WITH_GUEST_CONTROL */ -
trunk/src/VBox/Main/src-client/GuestFsObjInfoImpl.cpp
r42673 r42897 29 29 #include <VBox/com/array.h> 30 30 31 #ifdef LOG_GROUP 32 #undef LOG_GROUP 33 #endif 34 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 35 #include <VBox/log.h> 36 31 37 32 38 // constructor / destructor -
trunk/src/VBox/Main/src-client/GuestImpl.cpp
r42867 r42897 139 139 140 140 #ifdef VBOX_WITH_GUEST_CONTROL 141 LogFlowThisFunc(("Closing sessions (%RU64 total)\n", 142 mData.mGuestSessions.size())); 141 143 GuestSessions::iterator itSessions = mData.mGuestSessions.begin(); 142 144 while (itSessions != mData.mGuestSessions.end()) 143 145 { 144 if (!itSessions->second.isNull()) 145 itSessions->second->uninit(); 146 #ifdef DEBUG 147 ULONG cRefs = itSessions->second->AddRef(); 148 LogFlowThisFunc(("pSession=%p, cRefs=%RU32\n", itSessions->second, cRefs > 0 ? cRefs - 1 : 0)); 149 itSessions->second->Release(); 150 #endif 151 itSessions->second->uninit(); 146 152 itSessions++; 147 153 } … … 158 164 159 165 unconst(mParent) = NULL; 166 167 LogFlowFuncLeave(); 160 168 } 161 169 -
trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp
r42846 r42897 45 45 #include <VBox/com/array.h> 46 46 47 48 struct GuestProcessTask 49 { 47 #ifdef LOG_GROUP 48 #undef LOG_GROUP 49 #endif 50 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 51 #include <VBox/log.h> 52 53 54 class GuestProcessTask 55 { 56 public: 57 50 58 GuestProcessTask(GuestProcess *pProcess) 51 59 : mProcess(pProcess), … … 55 63 56 64 int rc(void) const { return mRC; } 57 bool isOk(void) const { return RT_SUCCESS(rc()); } 65 bool isOk(void) const { return RT_SUCCESS(mRC); } 66 const ComObjPtr<GuestProcess> &Process(void) const { return mProcess; } 67 68 protected: 58 69 59 70 const ComObjPtr<GuestProcess> mProcess; 60 61 private:62 71 int mRC; 63 72 }; 64 73 65 struct GuestProcessStartTask : public GuestProcessTask 66 { 74 class GuestProcessStartTask : public GuestProcessTask 75 { 76 public: 77 67 78 GuestProcessStartTask(GuestProcess *pProcess) 68 79 : GuestProcessTask(pProcess) { } … … 133 144 void GuestProcess::uninit(void) 134 145 { 135 LogFlowThisFunc(("\n")); 146 LogFlowThisFunc(("mCmd=%s, PID=%RU32\n", 147 mData.mProcess.mCommand.c_str(), mData.mPID)); 136 148 137 149 /* Enclose the state transition Ready->InUninit->NotReady. */ … … 140 152 return; 141 153 142 #ifndef VBOX_WITH_GUEST_CONTROL 154 int vrc = VINF_SUCCESS; 155 156 #ifdef VBOX_WITH_GUEST_CONTROL 143 157 /* 144 158 * Cancel all callbacks + waiters. … … 151 165 AssertPtr(pCallback); 152 166 int rc2 = pCallback->Cancel(); 153 AssertRC(rc2); 167 if (RT_SUCCESS(vrc)) 168 vrc = rc2; 154 169 } 155 170 mData.mCallbacks.clear(); … … 158 173 { 159 174 int rc2 = mData.mWaitEvent->Cancel(); 160 AssertRC(rc2); 175 if (RT_SUCCESS(vrc)) 176 vrc = rc2; 161 177 } 162 178 163 179 mData.mStatus = ProcessStatus_Down; /** @todo Correct? */ 164 165 /* Remove the reference from the session's process list. */166 AssertPtr(mData.mParent);167 mData.mParent->processClose(this);168 180 #endif 169 181 170 LogFlow ThisFuncLeave();182 LogFlowFuncLeaveRC(vrc); 171 183 } 172 184 … … 531 543 532 544 return VINF_SUCCESS; 533 }534 535 /* Do not hold any locks here because the lock validator will be unhappy536 * when being in uninit(). */537 void GuestProcess::close(void)538 {539 LogFlowThisFuncEnter();540 541 uninit();542 543 LogFlowThisFuncLeave();544 545 } 545 546 … … 1166 1167 LogFlowThisFuncEnter(); 1167 1168 1168 /* Asynchronously start the process on the guest by kicking off a 1169 * worker thread. */ 1170 std::auto_ptr<GuestProcessStartTask> pTask(new GuestProcessStartTask(this)); 1171 AssertReturn(pTask->isOk(), pTask->rc()); 1172 1173 int vrc = RTThreadCreate(NULL, GuestProcess::startProcessThread, 1174 (void *)pTask.get(), 0, 1175 RTTHREADTYPE_MAIN_WORKER, 0, 1176 "gctlPrcStart"); 1177 if (RT_SUCCESS(vrc)) 1178 { 1179 /* pTask is now owned by startProcessThread(), so release it. */ 1180 pTask.release(); 1169 int vrc; 1170 1171 try 1172 { 1173 /* Asynchronously start the process on the guest by kicking off a 1174 * worker thread. */ 1175 std::auto_ptr<GuestProcessStartTask> pTask(new GuestProcessStartTask(this)); 1176 AssertReturn(pTask->isOk(), pTask->rc()); 1177 1178 vrc = RTThreadCreate(NULL, GuestProcess::startProcessThread, 1179 (void *)pTask.get(), 0, 1180 RTTHREADTYPE_MAIN_WORKER, 0, 1181 "gctlPrcStart"); 1182 if (RT_SUCCESS(vrc)) 1183 { 1184 /* pTask is now owned by startProcessThread(), so release it. */ 1185 pTask.release(); 1186 } 1187 } 1188 catch(std::bad_alloc &) 1189 { 1190 vrc = VERR_NO_MEMORY; 1181 1191 } 1182 1192 … … 1185 1195 } 1186 1196 1197 /* static */ 1187 1198 DECLCALLBACK(int) GuestProcess::startProcessThread(RTTHREAD Thread, void *pvUser) 1188 1199 { … … 1192 1203 AssertPtr(pTask.get()); 1193 1204 1194 const ComObjPtr<GuestProcess> pProcess(pTask-> mProcess);1205 const ComObjPtr<GuestProcess> pProcess(pTask->Process()); 1195 1206 Assert(!pProcess.isNull()); 1196 1207 … … 1274 1285 /* Filter out waits which are *not* supported using 1275 1286 * older guest control Guest Additions. */ 1276 AssertPtr(mData.mParent);1277 1287 if (mData.mParent->getProtocolVersion() < 2) 1278 1288 { … … 1355 1365 int vrc = mData.mWaitEvent->Wait(uTimeoutMS); 1356 1366 if (RT_SUCCESS(vrc)) 1367 { 1357 1368 waitRes = mData.mWaitEvent->GetResult(); 1369 } 1370 else if (vrc == VERR_TIMEOUT) 1371 { 1372 waitRes.mRC = VINF_SUCCESS; 1373 waitRes.mResult = ProcessWaitResult_Timeout; 1374 1375 vrc = VINF_SUCCESS; 1376 } 1358 1377 1359 1378 alock.acquire(); /* Get the lock again. */ … … 1570 1589 } 1571 1590 1591 AssertPtr(mData.mParent); 1592 mData.mParent->processRemoveFromList(this); 1593 1594 /* 1595 * Release autocaller before calling uninit. 1596 */ 1597 autoCaller.release(); 1598 1599 uninit(); 1600 1572 1601 LogFlowFuncLeaveRC(vrc); 1573 1602 return hr; … … 1601 1630 else 1602 1631 { 1603 if (vrc == VERR_TIMEOUT) 1604 hr = setError(VBOX_E_IPRT_ERROR, 1605 tr("Process \"%s\" (PID %RU32) did not respond within time (%RU32ms)"), 1606 mData.mProcess.mCommand.c_str(), mData.mPID, aTimeoutMS); 1607 else 1608 hr = setError(VBOX_E_IPRT_ERROR, 1609 tr("Waiting for process \"%s\" (PID %RU32) failed with vrc=%Rrc"), 1610 mData.mProcess.mCommand.c_str(), mData.mPID, vrc); 1632 hr = setError(VBOX_E_IPRT_ERROR, 1633 tr("Waiting for process \"%s\" (PID %RU32) failed with vrc=%Rrc"), 1634 mData.mProcess.mCommand.c_str(), mData.mPID, vrc); 1611 1635 } 1612 1636 LogFlowFuncLeaveRC(vrc); -
trunk/src/VBox/Main/src-client/GuestSessionImpl.cpp
r42846 r42897 37 37 #include <VBox/version.h> 38 38 39 40 /* 41 * If the following define is enabled the Guest Additions update code also 42 * checks for locations which were not supposed to happen due to not resolving 43 * environment variables in VBoxService toolbox arguments. So a file copied 44 * to "%TEMP%\foo.exe" became "C:\Windows\EMPfoo.exe". 45 */ 46 #define VBOX_SERVICE_ENVARG_BUG 39 #ifdef LOG_GROUP 40 #undef LOG_GROUP 41 #endif 42 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 43 #include <VBox/log.h> 44 47 45 48 46 // constructor / destructor … … 87 85 mData.mCredentials.mDomain = aDomain; 88 86 mData.mName = aName; 87 mData.mNumObjects = 0; 89 88 90 89 /* Confirm a successful initialization when it's the case. */ … … 108 107 return; 109 108 110 #ifdef VBOX_WITH_GUEST_CONTROL 109 int rc = VINF_SUCCESS; 110 111 #ifndef VBOX_WITH_GUEST_CONTROL 112 LogFlowThisFunc(("Closing directories (%RU64 total)\n", 113 mData.mDirectories.size())); 111 114 for (SessionDirectories::iterator itDirs = mData.mDirectories.begin(); 112 115 itDirs != mData.mDirectories.end(); ++itDirs) 113 116 { 117 #ifdef DEBUG 118 ULONG cRefs = (*itDirs)->AddRef(); 119 LogFlowThisFunc(("pFile=%p, cRefs=%RU32\n", (*itDirs), cRefs)); 120 (*itDirs)->Release(); 121 #endif 114 122 (*itDirs)->uninit(); 115 (*itDirs).setNull();116 123 } 117 124 mData.mDirectories.clear(); 118 125 126 LogFlowThisFunc(("Closing files (%RU64 total)\n", 127 mData.mFiles.size())); 119 128 for (SessionFiles::iterator itFiles = mData.mFiles.begin(); 120 129 itFiles != mData.mFiles.end(); ++itFiles) 121 130 { 131 #ifdef DEBUG 132 ULONG cRefs = (*itFiles)->AddRef(); 133 LogFlowThisFunc(("pFile=%p, cRefs=%RU32\n", (*itFiles), cRefs)); 134 (*itFiles)->Release(); 135 #endif 122 136 (*itFiles)->uninit(); 123 (*itFiles).setNull();124 137 } 125 138 mData.mFiles.clear(); 126 139 140 LogFlowThisFunc(("Closing processes (%RU64 total)\n", 141 mData.mProcesses.size())); 127 142 for (SessionProcesses::iterator itProcs = mData.mProcesses.begin(); 128 143 itProcs != mData.mProcesses.end(); ++itProcs) 129 144 { 130 itProcs->second->close(); 131 } 132 133 for (SessionProcesses::iterator itProcs = mData.mProcesses.begin(); 134 itProcs != mData.mProcesses.end(); ++itProcs) 135 { 145 #ifdef DEBUG 146 ULONG cRefs = itProcs->second->AddRef(); 147 LogFlowThisFunc(("pProcess=%p, cRefs=%RU32\n", itProcs->second, cRefs)); 148 itProcs->second->Release(); 149 #endif 136 150 itProcs->second->uninit(); 137 itProcs->second.setNull();138 151 } 139 152 mData.mProcesses.clear(); 140 153 141 mData.mParent->sessionClose(this); 142 143 LogFlowThisFuncLeave(); 154 LogFlowThisFunc(("mNumObjects=%RU32\n", mData.mNumObjects)); 144 155 #endif 156 LogFlowFuncLeaveRC(rc); 145 157 } 146 158 … … 399 411 ///////////////////////////////////////////////////////////////////////////// 400 412 401 int GuestSession::directory Close(ComObjPtr<GuestDirectory>pDirectory)413 int GuestSession::directoryRemoveFromList(GuestDirectory *pDirectory) 402 414 { 403 415 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 408 420 if (pDirectory == (*itDirs)) 409 421 { 422 Bstr strName; 423 HRESULT hr = (*itDirs)->COMGETTER(DirectoryName)(strName.asOutParam()); 424 ComAssertComRC(hr); 425 426 Assert(mData.mDirectories.size()); 427 LogFlowFunc(("Removing directory \"%s\" (Session: %RU32) (now total %ld directories)\n", 428 Utf8Str(strName).c_str(), mData.mNumObjects - 1)); 429 410 430 mData.mDirectories.erase(itDirs); 411 431 return VINF_SUCCESS; … … 629 649 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 630 650 631 uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_ PROCESS(uContextID);651 uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID); 632 652 #ifdef DEBUG 633 653 LogFlowFunc(("uProcessID=%RU32 (%RU32 total)\n", … … 652 672 } 653 673 654 int GuestSession::file Close(ComObjPtr<GuestFile>pFile)674 int GuestSession::fileRemoveFromList(GuestFile *pFile) 655 675 { 656 676 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); … … 661 681 if (pFile == (*itFiles)) 662 682 { 683 Bstr strName; 684 HRESULT hr = (*itFiles)->COMGETTER(FileName)(strName.asOutParam()); 685 ComAssertComRC(hr); 686 687 Assert(mData.mNumObjects); 688 LogFlowThisFunc(("Removing file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n", 689 Utf8Str(strName).c_str(), mData.mId, mData.mFiles.size() - 1, mData.mNumObjects - 1)); 690 #ifdef DEBUG 691 ULONG cRefs = pFile->AddRef(); 692 LogFlowThisFunc(("pObject=%p, cRefs=%RU32\n", pFile, cRefs)); 693 pFile->Release(); 694 #endif 663 695 mData.mFiles.erase(itFiles); 696 mData.mNumObjects--; 664 697 return VINF_SUCCESS; 665 698 } … … 772 805 /* Add the created directory to our vector. */ 773 806 mData.mFiles.push_back(pFile); 774 775 LogFlowFunc(("Added new file \"%s\" (Session: %RU32\n", 776 strPath.c_str(), mData.mId)); 807 mData.mNumObjects++; 808 Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS); 809 810 LogFlowFunc(("Added new file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n", 811 strPath.c_str(), mData.mId, mData.mProcesses.size(), mData.mNumObjects)); 777 812 778 813 LogFlowFuncLeaveRC(rc); … … 900 935 } 901 936 902 int GuestSession::processClose(ComObjPtr<GuestProcess> pProcess) 903 { 937 int GuestSession::processRemoveFromList(GuestProcess *pProcess) 938 { 939 LogFlowThisFuncEnter(); 940 904 941 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 942 943 int rc = VERR_NOT_FOUND; 944 945 ULONG uPID; 946 HRESULT hr = pProcess->COMGETTER(PID)(&uPID); 947 948 LogFlowFunc(("Closing process (PID=%RU32) ...\n", uPID)); 905 949 906 950 for (SessionProcesses::iterator itProcs = mData.mProcesses.begin(); … … 909 953 if (pProcess == itProcs->second) 910 954 { 911 LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes)\n", 912 mData.mId, itProcs->second->getProcessID(), itProcs->second->getPID(), mData.mProcesses.size() - 1)); 955 GuestProcess *pCurProc = itProcs->second; 956 AssertPtr(pCurProc); 957 958 hr = pCurProc->COMGETTER(PID)(&uPID); 959 ComAssertComRC(hr); 960 961 Assert(mData.mNumObjects); 962 LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes, %ld objects)\n", 963 mData.mId, pCurProc->getProcessID(), uPID, mData.mProcesses.size() - 1, mData.mNumObjects - 1)); 913 964 914 965 mData.mProcesses.erase(itProcs); 915 return VINF_SUCCESS; 916 } 917 } 918 919 return VERR_NOT_FOUND; 966 mData.mNumObjects--; 967 968 rc = VINF_SUCCESS; 969 break; 970 } 971 } 972 973 LogFlowFuncLeaveRC(rc); 974 return rc; 920 975 } 921 976 … … 970 1025 971 1026 int rc = VERR_MAX_PROCS_REACHED; 972 if (mData.m Processes.size() >= VBOX_GUESTCTRL_MAX_PROCESSES)1027 if (mData.mNumObjects >= VBOX_GUESTCTRL_MAX_OBJECTS) 973 1028 return rc; 974 1029 … … 989 1044 } 990 1045 uNewProcessID++; 991 if (uNewProcessID == VBOX_GUESTCTRL_MAX_ PROCESSES)1046 if (uNewProcessID == VBOX_GUESTCTRL_MAX_OBJECTS) 992 1047 uNewProcessID = 0; 993 1048 … … 1011 1066 /* Add the created process to our map. */ 1012 1067 mData.mProcesses[uNewProcessID] = pProcess; 1013 1014 LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes)\n", 1015 mData.mId, uNewProcessID, mData.mProcesses.size())); 1068 mData.mNumObjects++; 1069 Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS); 1070 1071 LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes, %ld objects)\n", 1072 mData.mId, uNewProcessID, mData.mProcesses.size(), mData.mNumObjects)); 1016 1073 1017 1074 return rc; … … 1035 1092 /* pProcess is optional. */ 1036 1093 1037 SessionProcesses::iterator it = mData.mProcesses.begin();1038 for (; it != mData.mProcesses.end(); it++)1039 { 1040 ComObjPtr<GuestProcess> pCurProc = it ->second;1094 SessionProcesses::iterator itProcs = mData.mProcesses.begin(); 1095 for (; itProcs != mData.mProcesses.end(); itProcs++) 1096 { 1097 ComObjPtr<GuestProcess> pCurProc = itProcs->second; 1041 1098 AutoCaller procCaller(pCurProc); 1042 1099 if (procCaller.rc()) 1043 1100 return VERR_COM_INVALID_OBJECT_STATE; 1044 1101 1045 if (it->second->getPID() == uPID) 1102 ULONG uCurPID; 1103 HRESULT hr = pCurProc->COMGETTER(PID)(&uCurPID); 1104 ComAssertComRC(hr); 1105 1106 if (uCurPID == uPID) 1046 1107 { 1047 1108 if (pProcess) … … 1132 1193 LogFlowThisFuncEnter(); 1133 1194 1195 AutoCaller autoCaller(this); 1196 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1197 1198 /* Remove ourselves from the session list. */ 1199 mData.mParent->sessionRemove(this); 1200 1201 /* 1202 * Release autocaller before calling uninit. 1203 */ 1204 autoCaller.release(); 1205 1134 1206 uninit(); 1135 1207 1136 LogFlowFuncLeave RC(S_OK);1208 LogFlowFuncLeave(); 1137 1209 return S_OK; 1138 1210 #endif /* VBOX_WITH_GUEST_CONTROL */ … … 1351 1423 1352 1424 GuestFsObjData objData; 1353 int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);1425 int rc = directoryQueryInfoInternal(Utf8Str(aPath), objData); 1354 1426 if (RT_SUCCESS(rc)) 1355 1427 { … … 1413 1485 else 1414 1486 { 1415 rc = directory Close(pDirectory);1487 rc = directoryRemoveFromList(pDirectory); 1416 1488 if (RT_FAILURE(rc)) 1417 1489 hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc); … … 1987 2059 { 1988 2060 case VERR_MAX_PROCS_REACHED: 1989 hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest processes per session (%ld) reached"),1990 VBOX_GUESTCTRL_MAX_PROCESSES);2061 hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest objects per session (%ld) reached"), 2062 VBOX_GUESTCTRL_MAX_OBJECTS); 1991 2063 break; 1992 2064 -
trunk/src/VBox/Main/src-client/GuestSessionImplTasks.cpp
r42810 r42897 33 33 #include <iprt/env.h> 34 34 #include <iprt/file.h> /* For CopyTo/From. */ 35 36 #ifdef LOG_GROUP 37 #undef LOG_GROUP 38 #endif 39 #define LOG_GROUP LOG_GROUP_GUEST_CONTROL 40 #include <VBox/log.h> 35 41 36 42 … … 400 406 } 401 407 402 pProcess->close(); 408 if (!pProcess.isNull()) 409 pProcess->uninit(); 403 410 } /* processCreateExInteral */ 404 411 … … 632 639 } 633 640 634 pProcess->close(); 641 if (!pProcess.isNull()) 642 pProcess->uninit(); 635 643 } 636 644 … … 844 852 845 853 if (!pProcess.isNull()) 846 pProcess-> close();854 pProcess->uninit(); 847 855 848 856 return rc; -
trunk/src/VBox/Main/testcase/tstGuestCtrlContextID.cpp
r42215 r42897 59 59 { 60 60 uint32_t s = RTRandU32Ex(0, VBOX_GUESTCTRL_MAX_SESSIONS); 61 uint32_t p = RTRandU32Ex(0, VBOX_GUESTCTRL_MAX_ PROCESSES);61 uint32_t p = RTRandU32Ex(0, VBOX_GUESTCTRL_MAX_OBJECTS); 62 62 uint32_t c = RTRandU32Ex(0, VBOX_GUESTCTRL_MAX_CONTEXTS); 63 63 … … 69 69 s, p, c, VBOX_GUESTCTRL_CONTEXTID_GET_SESSION(uContextID), s, uContextID); 70 70 } 71 else if (p != VBOX_GUESTCTRL_CONTEXTID_GET_ PROCESS(uContextID))71 else if (p != VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID)) 72 72 { 73 RTTestFailed(hTest, "%d,%d,%d: Processis %d, expected %d -> %RU64\n",74 s, p, c, VBOX_GUESTCTRL_CONTEXTID_GET_ PROCESS(uContextID), p, uContextID);73 RTTestFailed(hTest, "%d,%d,%d: Object is %d, expected %d -> %RU64\n", 74 s, p, c, VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(uContextID), p, uContextID); 75 75 } 76 76 if (c != VBOX_GUESTCTRL_CONTEXTID_GET_COUNT(uContextID))
Note:
See TracChangeset
for help on using the changeset viewer.