]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: prevent kill race condition 1960/head
authorLoic Dachary <loic@dachary.org>
Fri, 13 Jun 2014 12:41:39 +0000 (14:41 +0200)
committerLoic Dachary <loic@dachary.org>
Fri, 13 Jun 2014 12:46:42 +0000 (14:46 +0200)
When trying to kill a daemon, keep its pid in a variable instead of
retrieving it from the pidfile multiple times. It prevents the following
race condition:

  * try to kill ceph-mon
  * ceph-mon is in the process of dying and removed its pidfile
  * try to kill ceph-mon fails because the pidfile is not found
  * another ceph-mon is spawned and fails to bind the port
    because the previous ceph-mon is still holding it

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/ceph-disk.sh
src/test/mon/mkfs.sh
src/test/mon/mon-test-helpers.sh

index 35e2702669681ee9e52cb127fefae872b33e0a96..3e95bf911a5a3e0c5389a0e3e15aa58f3c2b5eef 100755 (executable)
@@ -72,8 +72,9 @@ function run_mon() {
 
 function kill_daemons() {
     for pidfile in $(find $DIR | grep pidfile) ; do
+        pid=$(cat $pidfile)
         for try in 0 1 1 1 2 3 ; do
-            kill $(cat $pidfile) || break
+            kill $pid || break
             sleep $try
         done
     done
index 33e3fbafefb036a3f9bf26b79d4d0ce8bd106dd3..d24068bdfdd3d0780bee2f8b1508a6a4bff7fbb9 100755 (executable)
@@ -64,8 +64,9 @@ function mon_run() {
 
 function kill_daemons() {
     for pidfile in $(find $DIR -name pidfile) ; do
+        pid=$(cat $pidfile)
         for try in 0 1 1 1 2 3 ; do
-            kill $(cat $pidfile) || break
+            kill $pid || break
             sleep $try
         done
     done
index d228569edd4d1f14ab82aa1bc9b56b6857b28a01..052b1ca3fbdbc74b2a617c557f2ad06c2d2d4f85 100644 (file)
@@ -59,8 +59,9 @@ function run_mon() {
 function kill_daemons() {
     local dir=$1
     for pidfile in $(find $dir | grep pidfile) ; do
+        pid=$(cat $pidfile)
         for try in 0 1 1 1 2 3 ; do
-            kill -9 $(cat $pidfile 2> /dev/null) 2> /dev/null || break
+            kill -9 $pid 2> /dev/null || break
             sleep $try
         done
     done