Description: templates: don't fail on busy flock
 Just wait until the lock is available.  That is a nicer behavior
 for concurrent lxc-creates.
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Forwarded: yes
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1007483

Index: lxc-0.8.0~rc1/templates/lxc-altlinux.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-altlinux.in	2012-03-01 21:42:19.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-altlinux.in	2012-06-11 16:13:33.057526360 +0000
@@ -198,7 +198,7 @@
 {
     mkdir -p /var/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
Index: lxc-0.8.0~rc1/templates/lxc-debian.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-debian.in	2012-06-11 15:13:42.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-debian.in	2012-06-11 16:13:41.093526201 +0000
@@ -153,7 +153,7 @@
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
Index: lxc-0.8.0~rc1/templates/lxc-fedora.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-fedora.in	2012-06-11 15:13:42.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-fedora.in	2012-06-11 16:13:48.873526476 +0000
@@ -190,7 +190,7 @@
 {
     mkdir -p /var/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -281,7 +281,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.8.0~rc1/templates/lxc-lenny.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-lenny.in	2012-06-11 15:13:42.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-lenny.in	2012-06-11 16:13:56.801534092 +0000
@@ -142,7 +142,7 @@
     rootfs=$1
     mkdir -p @LOCALSTATEDIR@/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -225,7 +225,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.8.0~rc1/templates/lxc-opensuse.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-opensuse.in	2012-06-11 15:13:42.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-opensuse.in	2012-06-11 16:14:02.077525043 +0000
@@ -217,7 +217,7 @@
     rootfs=$1
     mkdir -p /var/lock/subsys/
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? -ne 0 ]; then
 	    echo "Cache repository is busy."
 	    return 1
@@ -305,7 +305,7 @@
 
     # lock, so we won't purge while someone is creating a repository
     (
-	flock -n -x 200
+	flock -x 200
 	if [ $? != 0 ]; then
 	    echo "Cache repository is busy."
 	    exit 1
Index: lxc-0.8.0~rc1/templates/lxc-ubuntu-cloud.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-ubuntu-cloud.in	2012-06-11 15:13:42.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-ubuntu-cloud.in	2012-06-11 16:12:51.481524346 +0000
@@ -294,7 +294,7 @@
 
 mkdir -p /var/lock/subsys/
 (
-    flock -n -x 200
+    flock -x 200
 
     cd $cache
     if [ $flushcache -eq 1 ]; then
Index: lxc-0.8.0~rc1/templates/lxc-ubuntu.in
===================================================================
--- lxc-0.8.0~rc1.orig/templates/lxc-ubuntu.in	2012-06-11 15:13:42.000000000 +0000
+++ lxc-0.8.0~rc1/templates/lxc-ubuntu.in	2012-06-11 16:12:37.029527081 +0000
@@ -229,7 +229,7 @@
     mkdir -p /var/lock/subsys/
 
     (
-        flock -n -x 200
+        flock -x 200
         if [ $? -ne 0 ]; then
             echo "Cache repository is busy."
             return 1
