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

totemknet: Prevent dead-loop in log_flush_messages

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Jan Friesse 8 лет назад
Родитель
Сommit
2c17832fa6
1 измененных файлов с 13 добавлено и 6 удалено
  1. 13 6
      exec/totemknet.c

+ 13 - 6
exec/totemknet.c

@@ -1284,14 +1284,21 @@ static void log_flush_messages (void *knet_context)
 {
 	struct pollfd pfd;
 	struct totemknet_instance *instance = (struct totemknet_instance *)knet_context;
+	int cont;
 
-	pfd.fd = instance->logpipes[0];
-	pfd.events = POLLIN;
-	pfd.revents = 0;
+	cont = 1;
 
-	while (poll(&pfd, 1, 0) > 0) {
-		if (pfd.revents & POLLIN) {
-			(void)log_deliver_fn(instance->logpipes[0], POLLIN, instance);
+	while (cont) {
+		pfd.fd = instance->logpipes[0];
+		pfd.events = POLLIN;
+		pfd.revents = 0;
+
+		if ((poll(&pfd, 1, 0) > 0) &&
+		    (pfd.revents & POLLIN) &&
+		    (log_deliver_fn(instance->logpipes[0], POLLIN, instance) == 0)) {
+			cont = 1;
+		} else {
+			cont = 0;
 		}
 	}
 }