Changeset 53323 in vbox
- Timestamp:
- Nov 13, 2014 2:52:50 PM (10 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/VirtualBoxImpl.h
r52596 r53323 338 338 HRESULT i_registerDHCPServer(DHCPServer *aDHCPServer, 339 339 bool aSaveRegistry = true); 340 HRESULT i_unregisterDHCPServer(DHCPServer *aDHCPServer, 341 bool aSaveRegistry = true); 340 HRESULT i_unregisterDHCPServer(DHCPServer *aDHCPServer); 342 341 HRESULT i_registerNATNetwork(NATNetwork *aNATNetwork, 343 342 bool aSaveRegistry = true); -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r52934 r53323 4785 4785 IDHCPServer *aP = aServer; 4786 4786 4787 HRESULT rc = i_unregisterDHCPServer(static_cast<DHCPServer *>(aP) , true);4787 HRESULT rc = i_unregisterDHCPServer(static_cast<DHCPServer *>(aP)); 4788 4788 4789 4789 return rc; … … 4813 4813 AssertComRCReturn(autoCaller.rc(), autoCaller.rc()); 4814 4814 4815 // Acquire a lock on the VirtualBox object early to avoid lock order issues 4816 // when we call i_saveSettings() later on. 4817 AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS); 4815 4818 // need it below, in findDHCPServerByNetworkName (reading) and in 4816 4819 // m->allDHCPServers.addChild, so need to get it here to avoid lock … … 4835 4838 4836 4839 m->allDHCPServers.addChild(aDHCPServer); 4840 // we need to release the list lock before we attempt to acquire locks 4841 // on other objects in i_saveSettings (see @bugref{7500}) 4842 alock.release(); 4837 4843 4838 4844 if (aSaveSettings) 4839 4845 { 4840 AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS);4846 // we acquired the lock on 'this' earlier to avoid lock order issues 4841 4847 rc = i_saveSettings(); 4842 vboxLock.release();4843 4848 4844 4849 if (FAILED(rc)) 4845 i_unregisterDHCPServer(aDHCPServer, false /* aSaveSettings */); 4850 { 4851 alock.acquire(); 4852 m->allDHCPServers.removeChild(aDHCPServer); 4853 } 4846 4854 } 4847 4855 … … 4853 4861 * 4854 4862 * @param aDHCPServer DHCP server object to remove. 4855 * @param aSaveSettings @c true to save settings to disk (default). 4856 * 4857 * When @a aSaveSettings is @c true, this operation may fail because of the 4858 * failed #saveSettings() method it calls. In this case, the DHCP server 4859 * will NOT be removed from the settingsi when this method returns. 4863 * 4864 * This operation may fail because of the failed #saveSettings() method it 4865 * calls. In this case, the DHCP server will NOT be removed from the settings 4866 * when this method returns. 4860 4867 * 4861 4868 * @note Locks this object for writing. 4862 4869 */ 4863 HRESULT VirtualBox::i_unregisterDHCPServer(DHCPServer *aDHCPServer, 4864 bool aSaveSettings /*= true*/) 4870 HRESULT VirtualBox::i_unregisterDHCPServer(DHCPServer *aDHCPServer) 4865 4871 { 4866 4872 AssertReturn(aDHCPServer != NULL, E_INVALIDARG); … … 4872 4878 AssertComRCReturn(dhcpServerCaller.rc(), dhcpServerCaller.rc()); 4873 4879 4880 AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS); 4881 AutoWriteLock alock(m->allDHCPServers.getLockHandle() COMMA_LOCKVAL_SRC_POS); 4874 4882 m->allDHCPServers.removeChild(aDHCPServer); 4875 4876 HRESULT rc = S_OK;4877 4878 if (aSaveSettings) 4879 {4880 AutoWriteLock vboxLock(this COMMA_LOCKVAL_SRC_POS); 4881 rc = i_saveSettings();4882 vboxLock.release();4883 4884 if (FAILED(rc))4885 rc = i_registerDHCPServer(aDHCPServer, false /* aSaveSettings */);4883 // we need to release the list lock before we attempt to acquire locks 4884 // on other objects in i_saveSettings (see @bugref{7500}) 4885 alock.release(); 4886 4887 HRESULT rc = i_saveSettings(); 4888 4889 // undo the changes if we failed to save them 4890 if (FAILED(rc)) 4891 { 4892 alock.acquire(); 4893 m->allDHCPServers.addChild(aDHCPServer); 4886 4894 } 4887 4895
Note:
See TracChangeset
for help on using the changeset viewer.