Currently coroipcc detects EINTR returns from poll() etc and simply
retries the operation without informing the clients.

I think the clients need to know a signal has been detected. Many
daemons trap SIGINT to help them shutdown cleanly, and this used to
work. Now they get the signal delivered but calls like quorum_dispatch()
do not return so they can't tidy up and close down.

This patch changes the behaviour so that if EINTR is detected it is
passed back to the clients as CS_ERR_INTERRUPT. The clients can then
retry the operation or exit as they see fit.

-- 

Chrissie
Index: coroipcc.c
===================================================================
--- coroipcc.c	(revision 2285)
+++ coroipcc.c	(working copy)
@@ -140,8 +140,8 @@
 	if (result == -1) {
 		switch (errno) {
 		case EINTR:
-			goto retry_send;
-			break;
+			res = CS_ERR_INTERRUPT;
+			goto res_exit;
 		case EAGAIN:
 			goto retry_send;
 			break;
@@ -197,8 +197,8 @@
 	if (result == -1) {
 		switch (errno) {
 		case EINTR:
-			goto retry_recv;
-			break;
+			res = CS_ERR_INTERRUPT;
+			goto res_exit;
 		case EAGAIN:
 			goto retry_recv;
 			break;
@@ -413,7 +413,7 @@
 retry_semop:
 	res = semop (ipc_instance->semid, &sop, 1);
 	if (res == -1 && errno == EINTR) {
-		goto retry_semop;
+		return (CS_ERR_INTERRUPT);
 	} else
 	if (res == -1 && errno == EACCES) {
 		priv_change_send (ipc_instance);
@@ -446,7 +446,7 @@
 retry_semop:
 	res = semop (ipc_instance->semid, &sop, 1);
 	if (res == -1 && errno == EINTR) {
-		goto retry_semop;
+		return (CS_ERR_INTERRUPT);
 	} else
 	if (res == -1 && errno == EACCES) {
 		priv_change_send (ipc_instance);
@@ -484,7 +484,7 @@
 retry_semop:
 	res = semop (ipc_instance->semid, &sop, 1);
 	if (res == -1 && errno == EINTR) {
-		goto retry_semop;
+		return (CS_ERR_INTERRUPT);
 	} else
 	if (res == -1 && errno == EACCES) {
 		priv_change_send (ipc_instance);
@@ -756,10 +756,10 @@
 	ufds.events = POLLIN;
 	ufds.revents = 0;
 
-retry_poll:
 	poll_events = poll (&ufds, 1, timeout);
 	if (poll_events == -1 && errno == EINTR) {
-		goto retry_poll;
+		error = CS_ERR_INTERRUPT;
+		goto error_put;
 	} else
 	if (poll_events == -1) {
 		goto error_put;
@@ -771,10 +771,11 @@
 		error = CS_ERR_LIBRARY;
 		goto error_put;
 	}
-retry_recv:
+
 	res = recv (ipc_instance->fd, &buf, 1, 0);
 	if (res == -1 && errno == EINTR) {
-		goto retry_recv;
+		res = CS_ERR_INTERRUPT;
+		goto error_put;
 	} else
 	if (res == -1) {
 		goto error_put;
@@ -837,7 +838,7 @@
 retry_semop:
 	res = semop (ipc_instance->semid, &sop, 1);
 	if (res == -1 && errno == EINTR) {
-		goto retry_semop;
+		return (CS_ERR_INTERRUPT);
 	} else
 	if (res == -1 && errno == EACCES) {
 		priv_change_send (ipc_instance);
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to