[PATCH 6/8] Ensure exit handler is really signaled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/main.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/exec/main.c b/exec/main.c
index cc2bd4c..605393c 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -182,12 +182,26 @@ static void unlink_all_completed (void)
 void corosync_shutdown_request (void)
 {
 	char buf = 0;
+	ssize_t res;
 
 	if (corosync_exit_pipe[1] == 0) {
 		corosync_exit_error (AIS_DONE_EXIT);
 	}
 
-	write(corosync_exit_pipe[1], &buf, sizeof(buf));
+retry_write:
+	res = write(corosync_exit_pipe[1], &buf, sizeof(buf));
+	if (res == -1) {
+		if (errno == EINTR || errno == EAGAIN) {
+			goto retry_write;
+		} else {
+			/*
+			 * Other error. This shouldn't happen. We cannot
+			 * signalize exit_pipe but user reqested exit,
+			 * so we will shutdown uncleanly
+			 */
+			assert(res == 1);
+		}
+	}
 }
 
 static int corosync_exit_dispatch_fn (
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux