[Openais] [PATCH 1/1] whitetank: Return error if there is no space for semaphore

Jan Friesse jfriesse at redhat.com
Thu Mar 17 09:56:46 PDT 2011


open_ais_service_connect creates SYS V semaphores and shms.
If system limit for semaphores/shms is exceeded code looped
in endless cycle.

Now ENOSPC is correctly handled and SA_AIS_ERR_NO_SPACE is
returned to lib user.
---
 branches/whitetank/lib/util.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/branches/whitetank/lib/util.c b/branches/whitetank/lib/util.c
index f285eb5..d5c26c2 100644
--- a/branches/whitetank/lib/util.c
+++ b/branches/whitetank/lib/util.c
@@ -339,6 +339,11 @@ openais_service_connect (
 		shmkey = random();
 		ipc_segment->shmid = shmget (shmkey, sizeof (struct shared_memory),
 			IPC_CREAT|IPC_EXCL|0600);
+
+		if (ipc_segment->shmid == -1 && errno == ENOSPC) {
+			res_setup.error = SA_AIS_ERR_NO_SPACE;
+			goto error_exit;
+		}
 	} while (ipc_segment->shmid == -1);
 
 	/*
@@ -348,6 +353,11 @@ openais_service_connect (
 		semkey = random();
 		ipc_segment->semid = semget (semkey, 3, IPC_CREAT|IPC_EXCL|0600);
 		ipc_segment->euid = geteuid ();
+
+		if (ipc_segment->semid == -1 && errno == ENOSPC) {
+			res_setup.error = SA_AIS_ERR_NO_SPACE;
+			goto error_exit;
+		}
 	} while (ipc_segment->semid == -1);
 
 	/*
-- 
1.5.5.6



More information about the Openais mailing list