You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by we...@apache.org on 2013/08/06 12:40:14 UTC

git commit: updated refs/heads/master to 5cb090e

Updated Branches:
  refs/heads/master eac3631ab -> 5cb090ed4


CLOUDSTACK-2729: move unlock to finally block to handle failed libvirt operations


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/5cb090ed
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/5cb090ed
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/5cb090ed

Branch: refs/heads/master
Commit: 5cb090ed40816950d0c9dbb62135240a7c8b1e3d
Parents: eac3631
Author: Wei Zhou <w....@leaseweb.com>
Authored: Tue Aug 6 12:40:06 2013 +0200
Committer: Wei Zhou <w....@leaseweb.com>
Committed: Tue Aug 6 12:40:06 2013 +0200

----------------------------------------------------------------------
 .../kvm/storage/LibvirtStorageAdaptor.java        | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5cb090ed/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
index 7f143f9..ca0d3c0 100644
--- a/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
+++ b/plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/storage/LibvirtStorageAdaptor.java
@@ -1175,10 +1175,13 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         }
         String lockFile = _mountPoint + File.separator + pool.getUUIDString() + File.separator + _lockfile;
         if (lock(lockFile, 30)) {
-            pool.refresh(0);
-            unlock(lockFile);
+            try {
+                pool.refresh(0);
+            } finally {
+                unlock(lockFile);
+            }
         } else {
-            throw new CloudRuntimeException("Can not get file lock to refresh the pool" + pool.getUUIDString());
+            throw new CloudRuntimeException("Can not get file lock to refresh the pool " + pool.getUUIDString());
         }
     }
 
@@ -1190,10 +1193,13 @@ public class LibvirtStorageAdaptor implements StorageAdaptor {
         }
         String lockFile = pool.getLocalPath() + File.separator + _lockfile;
         if (lock(lockFile, 30)) {
-            vol.delete(0);
-            unlock(lockFile);
+            try {
+                vol.delete(0);
+            } finally {
+                unlock(lockFile);
+            }
         } else {
-            throw new CloudRuntimeException("Can not get file lock to delete the volume" + vol.getPath());
+            throw new CloudRuntimeException("Can not get file lock to delete the volume " + vol.getPath());
         }
     }