Changeset 106880 in vbox for trunk/src/VBox/Main/src-server
- Timestamp:
- Nov 8, 2024 8:36:27 AM (2 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r106077 r106880 109 109 #include "VBoxEvents.h" 110 110 111 #include "ObjectsTracker.h" 112 111 113 #include <QMTranslator.h> 112 114 … … 130 132 // 131 133 //////////////////////////////////////////////////////////////////////////////// 134 135 extern TrackedObjectsCollector gTrackedObjectsCollector; 132 136 133 137 // static … … 265 269 typedef std::map<RTPROCESS, WatchedClientProcess *> WatchedClientProcessMap; 266 270 #endif 267 268 271 269 272 typedef ObjectsList<Medium> MediaOList; … … 331 334 , cRefsCrypto(0) 332 335 , pCryptoIf(NULL) 336 , objectTrackerTask(NULL) 333 337 { 334 338 #if defined(RT_OS_WINDOWS) && defined(VBOXSVC_WITH_CLIENT_WATCHER) … … 468 472 RTCRITSECT CritSectModCrypto; 469 473 /** @} */ 474 475 /** The tracked object collector (better if it'll be a singleton) */ 476 ObjectTracker *objectTrackerTask; 470 477 }; 471 478 … … 561 568 562 569 LogFlowThisFunc(("Version: %s, Package: %s, API Version: %s\n", sVersion.c_str(), sPackageType.c_str(), sAPIVersion.c_str())); 570 571 /* Try to start Object tracker thread as earlier as possible */ 572 { 573 int vrc = 0; 574 if(gTrackedObjectsCollector.init()) 575 { 576 LogRel(("Starting the Object tracker thread\n")); 577 try 578 { 579 m->objectTrackerTask = new ObjectTracker(); 580 if (!m->objectTrackerTask->init()) // some init procedure 581 vrc = E_FAIL; 582 else 583 vrc = m->objectTrackerTask->createThread(); 584 } 585 catch (...) 586 { 587 LogRel(("Exception during starting the Object tracker thread\n")); 588 if (m->objectTrackerTask) 589 { 590 delete m->objectTrackerTask; 591 m->objectTrackerTask = NULL; 592 } 593 vrc = E_FAIL; 594 } 595 } 596 597 if(RT_SUCCESS(vrc)) 598 LogRel(("Successfully started the Object tracker thread\n")); 599 else 600 LogRel(("Failed to start the Object tracker thread (%Rrc)\n", vrc)); 601 } 563 602 564 603 /* Important: DO NOT USE any kind of "early return" (except the single … … 1075 1114 else 1076 1115 m->allMachines.uninitAll(); 1116 1077 1117 m->allFloppyImages.uninitAll(); 1078 1118 m->allDVDImages.uninitAll(); 1079 1119 m->allHardDisks.uninitAll(); 1080 1120 m->allDHCPServers.uninitAll(); 1081 1082 m->mapProgressOperations.clear();1083 1084 1121 m->allGuestOSTypes.uninitAll(); 1085 1122 … … 1130 1167 1131 1168 RTCritSectDelete(&m->CritSectModCrypto); 1169 1170 m->mapProgressOperations.clear(); 1171 /* 1172 * Call gTrackedObjectsCollector uninitialization before ExtPackManager uninitialization!!! 1173 * Otherwise, this results in an error when releasing resources (in ComPtr::cleanup). 1174 */ 1175 if (m->objectTrackerTask) 1176 { 1177 LogRel(("BACKEND: Terminating the object tracker...\n")); 1178 m->objectTrackerTask->finish();//set the termination flag in the thread 1179 delete m->objectTrackerTask;//waiting the thread termination is going in the m_objectTrackerTask destructor 1180 gTrackedObjectsCollector.uninit(); 1181 } 1132 1182 1133 1183 #ifdef VBOX_WITH_EXTPACK … … 6389 6439 } 6390 6440 6391 6392 6441 HRESULT VirtualBox::findProgressById(const com::Guid &aId, 6393 6442 ComPtr<IProgress> &aProgressObject) … … 6410 6459 } 6411 6460 6461 HRESULT VirtualBox::getTrackedObject (const com::Utf8Str& aTrObjId, 6462 ComPtr<IUnknown> &aPIface) 6463 { 6464 TrackedObjectData trObjData; 6465 HRESULT hrc = gTrackedObjectsCollector.getObj(aTrObjId, trObjData); 6466 if (SUCCEEDED(hrc)) 6467 trObjData.getInterface().queryInterfaceTo(aPIface.asOutParam()); 6468 6469 return hrc; 6470 } 6471 6472 6473 std::map <com::Utf8Str, com::Utf8Str> lMapInterfaceNameToIID = { 6474 {"IProgress", Guid(IID_IProgress).toString()}, 6475 {"ISession", Guid(IID_ISession).toString()}, 6476 {"IMedium", Guid(IID_IMedium).toString()}, 6477 {"IMachine", Guid(IID_IMachine).toString()} 6478 }; 6479 6480 /** 6481 * Get the tracked object Ids list by the interface name. 6482 * 6483 * @param aName Interface name (like "IProgress", "ISession", "IMedium" etc) 6484 * @param aObjIdsList The list of Ids of the found objects 6485 * 6486 * @return The list of the found objects Ids 6487 */ 6488 HRESULT VirtualBox::getTrackedObjectIds (const com::Utf8Str& aName, 6489 std::vector<com::Utf8Str> &aObjIdsList) 6490 { 6491 HRESULT hrc = S_OK; 6492 6493 try 6494 { 6495 /* Check the supported tracked classes to avoid "out of range" exception */ 6496 if (lMapInterfaceNameToIID.count(aName)) 6497 { 6498 hrc = gTrackedObjectsCollector.getObjIdsByClassIID(lMapInterfaceNameToIID.at(aName), aObjIdsList); 6499 if (FAILED(hrc)) 6500 hrc = setError(VBOX_E_OBJECT_NOT_FOUND, tr("No objects were found for the passed interface name '%s'."), 6501 aName.c_str()); 6502 } 6503 else 6504 hrc = setError(E_INVALIDARG, tr("The objects of the passed interface '%s' are not tracked at moment."), aName.c_str()); 6505 } 6506 catch (...) 6507 { 6508 hrc = setError(E_FAIL, tr("The unknown exception in the VirtualBox::getTrackedObjectIds().")); 6509 } 6510 6511 return hrc; 6512 } 6412 6513 6413 6514 /**
Note:
See TracChangeset
for help on using the changeset viewer.