[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ha-dev
Subject:    [Linux-ha-dev] [PATCH 1 of 2] Low: RA: VirtualDomain: stop wasting
From:       Florian Haas <florian.haas () linbit ! com>
Date:       2009-08-10 15:48:22
Message-ID: ed7c50f07c92f3048400.1249919302 () singlemalt ! linbit
[Download RAW message or body]

# HG changeset patch
# User Florian Haas <florian.haas@linbit.com>
# Date 1249911933 -7200
# Node ID ed7c50f07c92f30484008f6d8a7ccbd24261b06b
# Parent  45bb33149bf52c8433eb5e6ce5546651cea18195
Low: RA: VirtualDomain: stop wasting time unnecessarily

Remove a few useless unconditional invocations of sleep.

diff -r 45bb33149bf5 -r ed7c50f07c92 heartbeat/VirtualDomain
--- a/heartbeat/VirtualDomain	Wed Aug 05 08:50:14 2009 +0200
+++ b/heartbeat/VirtualDomain	Mon Aug 10 15:45:33 2009 +0200
@@ -150,13 +150,13 @@
 		# whenever virsh can't reliably obtain the domain
 		# state.
 		ocf_log info "Virtual domain $DOMAIN_NAME currently has no state, retrying."
+		sleep 1
 		;;
             *)
 		# any other output is unexpected.
                 ocf_log error "Virtual domain $DOMAIN_NAME has unknown status \"$status\"!"
                 ;;
         esac
-	sleep 1
     done
     return $rc
 }
@@ -173,10 +173,11 @@
 	ocf_log error "Failed to start virtual domain ${DOMAIN_NAME}."
 	return $OCF_ERR_GENERIC
     fi
-    
-    while sleep 1; do
-	VirtualDomain_Monitor && return $OCF_SUCCESS
+
+    while ! VirtualDomain_Monitor; do
+	sleep 1
     done
+    return $OCF_SUCCESS
 }
 
 VirtualDomain_Stop() {
@@ -190,12 +191,10 @@
 		;;
 	esac
 	virsh $VIRSH_OPTIONS $op ${DOMAIN_NAME}
-	while sleep 1; do
-	    VirtualDomain_Status
-	    if [ $? -eq $OCF_NOT_RUNNING ]; then
-		return $OCF_SUCCESS
-	    fi
+	while VirtualDomain_Status; do
+	    sleep 1
 	done
+	return $OCF_SUCCESS
     else
 	ocf_log info "Domain $DOMAIN_NAME already stopped."
 	return $OCF_SUCCESS
@@ -237,8 +236,8 @@
 }
 
 VirtualDomain_Migrate_From() {
-    while sleep 1; do
-	VirtualDomain_Monitor && break
+    while ! VirtualDomain_Monitor; do
+	sleep 1
     done
     ocf_log info "$DOMAIN_NAME: live migration from ${OCF_RESKEY_CRM_meta_migrate_source} succeeded."
     return $OCF_SUCCESS
_______________________________________________________
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic