Changeset 25310 in vbox for trunk/src/VBox/Main/VirtualBoxImpl.cpp
- Timestamp:
- Dec 10, 2009 5:06:44 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 55876
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/VirtualBoxImpl.cpp
r25194 r25310 271 271 * but in the current locking mess this avoids that some code gets a 272 272 * read lock and later calls code which wants the same write lock. */ 273 AutoWriteLock lock(this );273 AutoWriteLock lock(this COMMA_LOCKVAL_SRC_POS); 274 274 275 275 // allocate our instance data … … 770 770 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 771 771 772 AutoReadLock al(m->ollMachines.getLockHandle() );772 AutoReadLock al(m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS); 773 773 SafeIfaceArray<IMachine> machines(m->ollMachines.getList()); 774 774 machines.detachTo(ComSafeArrayOutArg(aMachines)); … … 785 785 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 786 786 787 AutoReadLock al(m->ollHardDisks.getLockHandle() );787 AutoReadLock al(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS); 788 788 SafeIfaceArray<IMedium> hardDisks(m->ollHardDisks.getList()); 789 789 hardDisks.detachTo(ComSafeArrayOutArg(aHardDisks)); … … 800 800 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 801 801 802 AutoReadLock al(m->ollDVDImages.getLockHandle() );802 AutoReadLock al(m->ollDVDImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 803 803 SafeIfaceArray<IMedium> images(m->ollDVDImages.getList()); 804 804 images.detachTo(ComSafeArrayOutArg(aDVDImages)); … … 815 815 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 816 816 817 AutoReadLock al(m->ollFloppyImages.getLockHandle() );817 AutoReadLock al(m->ollFloppyImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 818 818 SafeIfaceArray<IMedium> images(m->ollFloppyImages.getList()); 819 819 images.detachTo(ComSafeArrayOutArg(aFloppyImages)); … … 830 830 831 831 /* protect mProgressOperations */ 832 AutoReadLock safeLock(m->mtxProgressOperations );832 AutoReadLock safeLock(m->mtxProgressOperations COMMA_LOCKVAL_SRC_POS); 833 833 SafeIfaceArray<IProgress> progress(m->mapProgressOperations); 834 834 progress.detachTo(ComSafeArrayOutArg(aOperations)); … … 844 844 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 845 845 846 AutoReadLock al(m->ollGuestOSTypes.getLockHandle() );846 AutoReadLock al(m->ollGuestOSTypes.getLockHandle() COMMA_LOCKVAL_SRC_POS); 847 847 SafeIfaceArray<IGuestOSType> ostypes(m->ollGuestOSTypes.getList()); 848 848 ostypes.detachTo(ComSafeArrayOutArg(aGuestOSTypes)); … … 892 892 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 893 893 894 AutoReadLock al(m->ollDHCPServers.getLockHandle() );894 AutoReadLock al(m->ollDHCPServers.getLockHandle() COMMA_LOCKVAL_SRC_POS); 895 895 SafeIfaceArray<IDHCPServer> svrs (m->ollDHCPServers.getList()); 896 896 svrs.detachTo(ComSafeArrayOutArg(aDHCPServers)); … … 1209 1209 ComObjPtr<Machine> pMachineFound; 1210 1210 1211 AutoReadLock al(m->ollMachines.getLockHandle() );1211 AutoReadLock al(m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS); 1212 1212 for (MachinesOList::iterator it = m->ollMachines.begin(); 1213 1213 it != m->ollMachines.end(); … … 1221 1221 if (machCaller.state() == Machine::Ready) 1222 1222 { 1223 AutoReadLock machLock(pMachine2 );1223 AutoReadLock machLock(pMachine2 COMMA_LOCKVAL_SRC_POS); 1224 1224 if (pMachine2->getName() == aName) 1225 1225 { … … 1261 1261 1262 1262 // trySetRegistered needs VirtualBox object write lock 1263 AutoWriteLock alock(this );1263 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1264 1264 rc = pMachine->trySetRegistered(FALSE); 1265 1265 if (FAILED(rc)) return rc; … … 1573 1573 *aType = NULL; 1574 1574 1575 AutoReadLock alock(m->ollGuestOSTypes.getLockHandle() );1575 AutoReadLock alock(m->ollGuestOSTypes.getLockHandle() COMMA_LOCKVAL_SRC_POS); 1576 1576 for (GuestOSTypesOList::iterator it = m->ollGuestOSTypes.begin(); 1577 1577 it != m->ollGuestOSTypes.end(); … … 1627 1627 if (FAILED(autoCaller.rc())) return autoCaller.rc(); 1628 1628 1629 AutoReadLock alock (this);1629 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 1630 1630 1631 1631 com::SafeArray<BSTR> saKeys(m->pMainConfigFile->mapExtraDataItems.size()); … … 1693 1693 // look up the old value first; if nothing's changed then we need not do anything 1694 1694 { 1695 AutoReadLock alock(this ); // hold read lock only while looking up1695 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); // hold read lock only while looking up 1696 1696 settings::ExtraDataItemsMap::const_iterator it = m->pMainConfigFile->mapExtraDataItems.find(strKey); 1697 1697 if (it != m->pMainConfigFile->mapExtraDataItems.end()) … … 1728 1728 // data is changing and change not vetoed: then write it out under the lock 1729 1729 1730 AutoWriteLock alock(this );1730 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1731 1731 1732 1732 if (strValue.isEmpty()) … … 1913 1913 #endif 1914 1914 1915 AutoWriteLock alock(this );1915 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1916 1916 m->llCallbacks.push_back (CallbackList::value_type (aCallback)); 1917 1917 … … 1931 1931 HRESULT rc = S_OK; 1932 1932 1933 AutoWriteLock alock(this );1933 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 1934 1934 1935 1935 CallbackList::iterator it; … … 1962 1962 { 1963 1963 { 1964 AutoReadLock al(m->ollHardDisks.getLockHandle() );1964 AutoReadLock al(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS); 1965 1965 for (MediaList::const_iterator mt = m->ollHardDisks.begin(); 1966 1966 mt != m->ollHardDisks.end(); … … 1972 1972 } 1973 1973 { 1974 AutoReadLock al(m->ollDVDImages.getLockHandle() );1974 AutoReadLock al(m->ollDVDImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 1975 1975 for (MediaList::const_iterator mt = m->ollDVDImages.begin(); 1976 1976 mt != m->ollDVDImages.end(); … … 2041 2041 2042 2042 /* protect mProgressOperations */ 2043 AutoWriteLock safeLock(m->mtxProgressOperations );2043 AutoWriteLock safeLock(m->mtxProgressOperations COMMA_LOCKVAL_SRC_POS); 2044 2044 2045 2045 m->mapProgressOperations.insert (ProgressMap::value_type (Guid(id), aProgress)); … … 2063 2063 2064 2064 /* protect mProgressOperations */ 2065 AutoWriteLock safeLock(m->mtxProgressOperations );2065 AutoWriteLock safeLock(m->mtxProgressOperations COMMA_LOCKVAL_SRC_POS); 2066 2066 2067 2067 size_t cnt = m->mapProgressOperations.erase (aId); … … 2344 2344 /// @todo (dmik) Win32? 2345 2345 #ifndef RT_OS_WINDOWS 2346 AutoWriteLock alock(this );2346 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 2347 2347 m->llProcesses.push_back (pid); 2348 2348 #endif … … 2428 2428 CallbackList list; 2429 2429 { 2430 AutoReadLock alock(this );2430 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2431 2431 list = m->llCallbacks; 2432 2432 } … … 2658 2658 aControls->clear(); 2659 2659 2660 AutoReadLock alock(this );2660 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 2661 2661 2662 2662 for (MachinesOList::iterator it = m->ollMachines.begin(); … … 2702 2702 2703 2703 { 2704 AutoReadLock al(m->ollMachines.getLockHandle() );2704 AutoReadLock al(m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2705 2705 2706 2706 for (MachinesOList::iterator it = m->ollMachines.begin(); … … 2755 2755 // we use the hard disks map, but it is protected by the 2756 2756 // hard disk _list_ lock handle 2757 AutoReadLock alock(m->ollHardDisks.getLockHandle() );2757 AutoReadLock alock(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2758 2758 2759 2759 /* first, look up by UUID in the map if UUID is provided */ … … 2846 2846 } 2847 2847 2848 AutoReadLock alock(m->ollDVDImages.getLockHandle() );2848 AutoReadLock alock(m->ollDVDImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2849 2849 2850 2850 bool found = false; … … 2855 2855 { 2856 2856 /* no AutoCaller, registered image life time is bound to this */ 2857 AutoReadLock imageLock (*it);2857 AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS); 2858 2858 2859 2859 found = (aId && (*it)->getId() == *aId) || … … 2922 2922 } 2923 2923 2924 AutoReadLock alock(m->ollFloppyImages.getLockHandle() );2924 AutoReadLock alock(m->ollFloppyImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2925 2925 2926 2926 bool found = false; … … 2931 2931 { 2932 2932 /* no AutoCaller, registered image life time is bound to this */ 2933 AutoReadLock imageLock (*it);2933 AutoReadLock imageLock(*it COMMA_LOCKVAL_SRC_POS); 2934 2934 2935 2935 found = (aId && (*it)->getId() == *aId) || … … 2978 2978 } 2979 2979 2980 AutoReadLock alock(m->ollGuestOSTypes.getLockHandle() );2980 AutoReadLock alock(m->ollGuestOSTypes.getLockHandle() COMMA_LOCKVAL_SRC_POS); 2981 2981 for (GuestOSTypesOList::const_iterator it = m->ollGuestOSTypes.begin(); 2982 2982 it != m->ollGuestOSTypes.end(); … … 3019 3019 const Utf8Str& VirtualBox::getDefaultMachineFolder() const 3020 3020 { 3021 AutoReadLock propsLock(m->pSystemProperties );3021 AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS); 3022 3022 return m->pSystemProperties->m_strDefaultMachineFolder; 3023 3023 } … … 3030 3030 const Utf8Str& VirtualBox::getDefaultHardDiskFolder() const 3031 3031 { 3032 AutoReadLock propsLock(m->pSystemProperties );3032 AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS); 3033 3033 return m->pSystemProperties->m_strDefaultHardDiskFolder; 3034 3034 } … … 3041 3041 const Utf8Str& VirtualBox::getDefaultHardDiskFormat() const 3042 3042 { 3043 AutoReadLock propsLock(m->pSystemProperties );3043 AutoReadLock propsLock(m->pSystemProperties COMMA_LOCKVAL_SRC_POS); 3044 3044 return m->pSystemProperties->m_strDefaultHardDiskFormat; 3045 3045 } … … 3132 3132 AssertReturn(!aId.isEmpty() && !aLocation.isEmpty(), E_FAIL); 3133 3133 3134 AutoReadLock alock(this );3134 AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS); 3135 3135 3136 3136 HRESULT rc = S_OK; … … 3144 3144 { 3145 3145 /* Note: no AutoCaller since bound to this */ 3146 AutoReadLock mediaLock(hardDisk );3146 AutoReadLock mediaLock(hardDisk COMMA_LOCKVAL_SRC_POS); 3147 3147 aConflict = Utf8StrFmt(tr("hard disk '%s' with UUID {%RTuuid}"), 3148 3148 hardDisk->getLocationFull().raw(), … … 3158 3158 { 3159 3159 /* Note: no AutoCaller since bound to this */ 3160 AutoReadLock mediaLock (image);3160 AutoReadLock mediaLock(image COMMA_LOCKVAL_SRC_POS); 3161 3161 aConflict = Utf8StrFmt(tr("CD/DVD image '%s' with UUID {%RTuuid}"), 3162 3162 image->getLocationFull().raw(), … … 3172 3172 { 3173 3173 /* Note: no AutoCaller since bound to this */ 3174 AutoReadLock mediaLock (image);3174 AutoReadLock mediaLock(image COMMA_LOCKVAL_SRC_POS); 3175 3175 aConflict = Utf8StrFmt(tr("floppy image '%s' with UUID {%RTuuid}"), 3176 3176 image->getLocationFull().raw(), … … 3202 3202 settings::MachinesRegistry machinesTemp; 3203 3203 { 3204 AutoReadLock al(m->ollMachines.getLockHandle() );3204 AutoReadLock al(m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3205 3205 for (MachinesOList::iterator it = m->ollMachines.begin(); 3206 3206 it != m->ollMachines.end(); … … 3216 3216 settings::MediaList hardDisksTemp; 3217 3217 { 3218 AutoReadLock al(m->ollHardDisks.getLockHandle() );3218 AutoReadLock al(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3219 3219 for (MediaList::const_iterator it = m->ollHardDisks.begin(); 3220 3220 it != m->ollHardDisks.end(); … … 3231 3231 settings::MediaList dvdsTemp; 3232 3232 { 3233 AutoReadLock al(m->ollDVDImages.getLockHandle() );3233 AutoReadLock al(m->ollDVDImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3234 3234 for (MediaList::const_iterator it = m->ollDVDImages.begin(); 3235 3235 it != m->ollDVDImages.end(); … … 3246 3246 settings::MediaList floppiesTemp; 3247 3247 { 3248 AutoReadLock al(m->ollFloppyImages.getLockHandle() );3248 AutoReadLock al(m->ollFloppyImages.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3249 3249 for (MediaList::const_iterator it = m->ollFloppyImages.begin(); 3250 3250 it != m->ollFloppyImages.end(); … … 3260 3260 settings::DHCPServersList dhcpServersTemp; 3261 3261 { 3262 AutoReadLock al(m->ollDHCPServers.getLockHandle() );3262 AutoReadLock al(m->ollDHCPServers.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3263 3263 for (DHCPServersOList::const_iterator it = m->ollDHCPServers.begin(); 3264 3264 it != m->ollDHCPServers.end(); … … 3273 3273 3274 3274 /* finally, lock VirtualBox object for writing */ 3275 AutoWriteLock alock(this );3275 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 3276 3276 3277 3277 /* now copy the temp data to the config file under the VirtualBox lock */ … … 3354 3354 // trySetRegistered needs VirtualBox object write lock; 3355 3355 // it will commit and save machine settings 3356 AutoWriteLock alock(this );3356 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 3357 3357 rc = aMachine->trySetRegistered(TRUE); 3358 3358 if (FAILED(rc)) return rc; … … 3398 3398 ComObjPtr<Medium> pParent; 3399 3399 { 3400 AutoReadLock hardDiskLock(aHardDisk );3400 AutoReadLock hardDiskLock(aHardDisk COMMA_LOCKVAL_SRC_POS); 3401 3401 id = aHardDisk->getId(); 3402 3402 strLocationFull = aHardDisk->getLocationFull(); … … 3407 3407 { 3408 3408 // lock the hard disk lists (list + map) while checking for conflicts 3409 AutoWriteLock al(m->ollHardDisks.getLockHandle() );3409 AutoWriteLock al(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3410 3410 3411 3411 Utf8Str strConflict; … … 3470 3470 ComObjPtr<Medium> pParent; 3471 3471 { 3472 AutoReadLock hardDiskLock(aHardDisk );3472 AutoReadLock hardDiskLock(aHardDisk COMMA_LOCKVAL_SRC_POS); 3473 3473 id = aHardDisk->getId(); 3474 3474 pParent = aHardDisk->getParent(); … … 3477 3477 { 3478 3478 // lock the hard disk lists (list + map) 3479 AutoWriteLock al(m->ollHardDisks.getLockHandle() );3479 AutoWriteLock al(m->ollHardDisks.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3480 3480 3481 3481 // remove base (root) hard disks from the list … … 3534 3534 ComObjPtr<Medium> pParent; 3535 3535 { 3536 AutoReadLock al(argImage );3536 AutoReadLock al(argImage COMMA_LOCKVAL_SRC_POS); 3537 3537 id = argImage->getId(); 3538 3538 strLocationFull = argImage->getLocationFull(); … … 3546 3546 { 3547 3547 // lock the images lists (list + map) while checking for conflicts 3548 AutoWriteLock al(oll.getLockHandle() );3548 AutoWriteLock al(oll.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3549 3549 3550 3550 Utf8Str strConflict; … … 3608 3608 ComObjPtr<Medium> pParent; 3609 3609 { 3610 AutoReadLock al(argImage );3610 AutoReadLock al(argImage COMMA_LOCKVAL_SRC_POS); 3611 3611 id = argImage->getId(); 3612 3612 pParent = argImage->getParent(); … … 3864 3864 3865 3865 // lock the machines list for reading 3866 AutoReadLock thatLock(that->m->ollMachines.getLockHandle() );3866 AutoReadLock thatLock(that->m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS); 3867 3867 3868 3868 /* obtain a new set of opened machines */ … … 3996 3996 #ifdef DEBUG 3997 3997 { 3998 AutoReadLock machineLock(machines[semId] );3998 AutoReadLock machineLock(machines[semId] COMMA_LOCKVAL_SRC_POS); 3999 3999 LogFlowFunc (("released mutex: machine='%ls'\n", 4000 4000 machines[semId]->name().raw())); … … 4026 4026 #ifdef DEBUG 4027 4027 { 4028 AutoReadLock machineLock(machines[semId] );4028 AutoReadLock machineLock(machines[semId] COMMA_LOCKVAL_SRC_POS); 4029 4029 LogFlowFunc(("mutex owner dead: machine='%ls'\n", 4030 4030 machines[i]->name().raw())); … … 4053 4053 if (update || updateSpawned) 4054 4054 { 4055 AutoReadLock thatLock (that);4055 AutoReadLock thatLock(that COMMA_LOCKVAL_SRC_POS); 4056 4056 4057 4057 if (update) … … 4158 4158 4159 4159 // lock the machines list for reading 4160 AutoReadLock thatLock(that->m->ollMachines.getLockHandle() );4160 AutoReadLock thatLock(that->m->ollMachines.getLockHandle() COMMA_LOCKVAL_SRC_POS); 4161 4161 4162 4162 if (RT_SUCCESS(rc) || update) … … 4208 4208 /* reap child processes */ 4209 4209 { 4210 AutoWriteLock alock(that );4210 AutoWriteLock alock(that COMMA_LOCKVAL_SRC_POS); 4211 4211 if (that->m->llProcesses.size()) 4212 4212 { … … 4322 4322 { 4323 4323 /* Make a copy to release the lock before iterating */ 4324 AutoReadLock alock(mVirtualBox );4324 AutoReadLock alock(mVirtualBox COMMA_LOCKVAL_SRC_POS); 4325 4325 callbacks = mVirtualBox->m->llCallbacks; 4326 4326 /* We don't need mVirtualBox any more, so release it */ … … 4374 4374 ComPtr<DHCPServer> found; 4375 4375 4376 AutoReadLock alock(m->ollDHCPServers.getLockHandle() );4376 AutoReadLock alock(m->ollDHCPServers.getLockHandle() COMMA_LOCKVAL_SRC_POS); 4377 4377 4378 4378 for (DHCPServersOList::const_iterator it = m->ollDHCPServers.begin(); … … 4483 4483 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 4484 4484 4485 AutoWriteLock alock(this );4485 AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS); 4486 4486 4487 4487 AutoCaller dhcpServerCaller (aDHCPServer);
Note:
See TracChangeset
for help on using the changeset viewer.