- Timestamp:
- Dec 11, 2008 5:27:02 PM (16 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r15064 r15318 932 932 CheckComRCReturnRC (rc); 933 933 934 /* 935 * we can safely cast child to Machine * here because only Machine 936 * implementations of IMachine can be among our children 937 */ 934 /* We need the children map lock here to keep the getDependentChild() result 935 * valid until we finish */ 936 AutoReadLock chLock (childrenLock()); 937 938 /* We can safely cast child to Machine * here because only Machine 939 * implementations of IMachine can be among our children. */ 938 940 Machine *machine = static_cast <Machine *> (getDependentChild (aMachine)); 939 if (!machine) 940 { 941 /* 942 * this machine was not created by CreateMachine() 943 * or opened by OpenMachine() or loaded during startup 944 */ 941 if (machine == NULL) 942 { 943 /* this machine was not created by CreateMachine() or opened by 944 * OpenMachine() or loaded during startup */ 945 945 return setError (VBOX_E_INVALID_OBJECT_STATE, 946 946 tr ("The machine named '%ls' is not created within this " … … 3589 3589 * @param aTo Where to store a reference to the underlying object. 3590 3590 * 3591 * @note Locks this objectfor reading.3591 * @note Locks #childrenLock() for reading. 3592 3592 */ 3593 3593 HRESULT VirtualBox::cast (IHardDisk2 *aFrom, ComObjPtr <HardDisk2> &aTo) … … 3598 3598 AssertComRCReturn (autoCaller.rc(), autoCaller.rc()); 3599 3599 3600 AutoReadLock alock (this); 3600 /* We need the children map lock here to keep the getDependentChild() result 3601 * valid until we finish */ 3602 AutoReadLock chLock (childrenLock()); 3601 3603 3602 3604 VirtualBoxBase *child = getDependentChild (aFrom); -
trunk/src/VBox/Main/include/HardDisk2Impl.h
r15051 r15318 224 224 * object lock. 225 225 */ 226 RWLockHandle *treeLock() { return mVirtualBox->hardDiskTree Handle(); }226 RWLockHandle *treeLock() { return mVirtualBox->hardDiskTreeLockHandle(); } 227 227 228 228 /** Reimplements VirtualBoxWithTypedChildren::childrenLock() to return -
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r15051 r15318 362 362 * object lock. 363 363 */ 364 RWLockHandle *hardDiskTree Handle() { return &mHardDiskTreeHandle; }364 RWLockHandle *hardDiskTreeLockHandle() { return &mHardDiskTreeLockHandle; } 365 365 366 366 /* for VirtualBoxSupportErrorInfoImpl */ … … 380 380 381 381 typedef std::map <Guid, ComObjPtr <HardDisk2> > HardDisk2Map; 382 383 /** 384 * Reimplements VirtualBoxWithTypedChildren::childrenLock() to return a 385 * dedicated lock instead of the main object lock. The dedicated lock for 386 * child map operations frees callers of init() methods of these children 387 * from acquiring a write parent (VirtualBox) lock (which would be mandatory 388 * otherwise). Since VirtualBox has a lot of heterogenous children which 389 * init() methods are called here and there, it definitely makes sense. 390 */ 391 RWLockHandle *childrenLock() { return &mChildrenMapLockHandle; } 382 392 383 393 HRESULT checkMediaForConflicts2 (const Guid &aId, const Bstr &aLocation, … … 490 500 RWLockHandle mSafeLock; 491 501 492 RWLockHandle mHardDiskTreeHandle; 502 RWLockHandle mHardDiskTreeLockHandle; 503 RWLockHandle mChildrenMapLockHandle; 493 504 494 505 static Bstr sVersion;
Note:
See TracChangeset
for help on using the changeset viewer.