Просмотр исходного кода

tests: Use CS_DISPATCH_BLOCKING instead of cycle

Some tests were using dispatch function in CS_DISPATCH_ALL mode
without poll/select on fd. This leads to busywait cycle, because
CS_DISPATCH_ALL masks CS_ERR_TRY_AGAIN error.

Simpliest solution is to use CS_DISPATCH_BLOCKING instead and remove
while cycle, because CS_DISPATCH_BLOCKING handles CS_ERR_TRY_AGAIN
correctly.

(backported from master fbae8f20d5ff5650daad48dd1f73111378404269)

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 5 лет назад
Родитель
Сommit
8595a8768e
2 измененных файлов с 7 добавлено и 10 удалено
  1. 4 5
      test/testquorum.c
  2. 3 5
      test/testvotequorum1.c

+ 4 - 5
test/testquorum.c

@@ -54,11 +54,10 @@ int main(int argc, char *argv[])
 	printf("Waiting for quorum events, press ^C to finish\n");
 	printf("Waiting for quorum events, press ^C to finish\n");
 	printf("-------------------\n");
 	printf("-------------------\n");
 
 
-	while (1)
-		if (quorum_dispatch(g_handle, CS_DISPATCH_ALL) != CS_OK) {
-			fprintf(stderr, "Error from quorum_dispatch\n");
-			return -1;
-		}
+	if (quorum_dispatch(g_handle, CS_DISPATCH_BLOCKING) != CS_OK) {
+		fprintf(stderr, "Error from quorum_dispatch\n");
+		return -1;
+	}
 
 
 	return 0;
 	return 0;
 }
 }

+ 3 - 5
test/testvotequorum1.c

@@ -191,11 +191,9 @@ int main(int argc, char *argv[])
 	printf("Waiting for votequorum events, press ^C to finish\n");
 	printf("Waiting for votequorum events, press ^C to finish\n");
 	printf("-------------------\n");
 	printf("-------------------\n");
 
 
-	while (1) {
-		if (votequorum_dispatch(g_handle, CS_DISPATCH_ALL) != CS_OK) {
-			fprintf(stderr, "votequorum_dispatch error\n");
-			return -1;
-		}
+	if (votequorum_dispatch(g_handle, CS_DISPATCH_BLOCKING) != CS_OK) {
+		fprintf(stderr, "votequorum_dispatch error\n");
+		return -1;
 	}
 	}
 
 
 	return 0;
 	return 0;