Explorar el Código

Fix section iteration size comparison

git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1367 fd59a12c-fef9-0310-b244-a6a79926bd2f
Steven Dake hace 19 años
padre
commit
f3cd7588d4
Se han modificado 4 ficheros con 34 adiciones y 13 borrados
  1. 7 0
      exec/ckpt.c
  2. 2 2
      test/Makefile
  3. 15 6
      test/ckptbench.c
  4. 10 5
      test/ckptbenchth.c

+ 7 - 0
exec/ckpt.c

@@ -1789,6 +1789,13 @@ static void message_handler_req_exec_ckpt_sectioncreate (
 		error = SA_AIS_ERR_INVALID_PARAM;
 		goto error_exit;
 	}
+	
+	if (checkpoint->checkpoint_creation_attributes.max_section_id_size <
+		req_exec_ckpt_sectioncreate->id_len) {
+		
+		error = SA_AIS_ERR_INVALID_PARAM;
+		goto error_exit;
+	}	
 
 	/*
 	 * Determine if user-specified checkpoint section already exists

+ 2 - 2
test/Makefile

@@ -104,10 +104,10 @@ testckpt: testckpt.o sa_error.o $(LIBRARIES)
 	$(CC) $(LDFLAGS) -o testckpt testckpt.o sa_error.o $(LIBS)
 
 ckptbench: ckptbench.o $(LIBRARIES)
-	$(CC) $(LDFLAGS) -o ckptbench ckptbench.o $(LIBS)
+	$(CC) $(LDFLAGS) -o ckptbench ckptbench.o sa_error.o $(LIBS)
 
 ckptbenchth: ckptbenchth.o $(LIBRARIES)
-	$(CC) $(LDFLAGS) -o ckptbenchth ckptbenchth.o $(LIBS)
+	$(CC) $(LDFLAGS) -o ckptbenchth ckptbenchth.o sa_error.o $(LIBS)
 
 ckptstress: ckptstress.o $(LIBRARIES)
 	$(CC) $(LDFLAGS) -o ckptstress ckptstress.o $(LIBS)

+ 15 - 6
test/ckptbench.c

@@ -53,6 +53,7 @@
 
 #include "saAis.h"
 #include "saCkpt.h"
+#include "sa_error.h"
 
 #ifdef OPENAIS_SOLARIS
 #define timersub(a, b, result)						\
@@ -68,6 +69,13 @@
 
 int alarm_notice;
 
+void fail_on_error(SaAisErrorT error, char* opName) {
+	if (error != SA_AIS_OK) {
+        printf ("%s: result %s\n", opName, get_sa_error_b(error));
+        exit (1);
+	}
+}
+
 void printSaNameT (SaNameT *name)
 {
 	int i;
@@ -92,7 +100,7 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
         .retentionDuration =    0,
         .maxSections =          5,
         .maxSectionSize =       250000,
-        .maxSectionIdSize =     10
+        .maxSectionIdSize =     15
 };
 
 SaCkptSectionIdT sectionId1 = {
@@ -195,10 +203,7 @@ retry:
 		if (error == SA_AIS_ERR_TRY_AGAIN) {
 			goto retry;
 		}
-		if (error != SA_AIS_OK) {
-			printf ("saCkptCheckpointWrite result %d (should be 1)\n", error);
-			exit (1);
-		}
+		fail_on_error(error, "saCkptCheckpointWrite");
 		write_count += 1;
 	} while (alarm_notice == 0);
 	gettimeofday (&tv2, NULL);
@@ -229,21 +234,25 @@ int main (void) {
 	signal (SIGALRM, sigalrm_handler);
 
     error = saCkptInitialize (&ckptHandle, &callbacks, &version);
-
+	fail_on_error(error, "saCkptInitialize");
+	
 	error = saCkptCheckpointOpen (ckptHandle,
 		&checkpointName,
 		&checkpointCreationAttributes,
 		SA_CKPT_CHECKPOINT_CREATE|SA_CKPT_CHECKPOINT_READ|SA_CKPT_CHECKPOINT_WRITE,
 		0,
 		&checkpointHandle);
+	fail_on_error(error, "saCkptCheckpointOpen");
 	error = saCkptSectionCreate (checkpointHandle,
 		&sectionCreationAttributes1,
 		"Initial Data #0",
 		strlen ("Initial Data #0") + 1);
+	fail_on_error(error, "saCkptCheckpointSectionCreate");
 	error = saCkptSectionCreate (checkpointHandle,
 		&sectionCreationAttributes2,
 		"Initial Data #0",
 		strlen ("Initial Data #0") + 1);
+	fail_on_error(error, "saCkptCheckpointSectionCreate");
 
 	size = 1;
 

+ 10 - 5
test/ckptbenchth.c

@@ -51,6 +51,7 @@
 
 #include "saAis.h"
 #include "saCkpt.h"
+#include "sa_error.h"
 
 #ifdef OPENAIS_SOLARIS
 #define timersub(a, b, result)						\
@@ -66,6 +67,13 @@
 
 int alarm_notice = 0;
 
+void fail_on_error(SaAisErrorT error, char* opName) {
+	if (error != SA_AIS_OK) {
+        printf ("%s: result %s\n", opName, get_sa_error_b(error));
+        exit (1);
+	}
+}
+
 void printSaNameT (SaNameT *name)
 {
 	int i;
@@ -88,7 +96,7 @@ SaCkptCheckpointCreationAttributesT checkpointCreationAttributes = {
 	.retentionDuration =	0,
 	.maxSections =		5,
 	.maxSectionSize =	150000,
-	.maxSectionIdSize =	10
+	.maxSectionIdSize =	15
 };
 
 SaCkptSectionIdT sectionId1 = {
@@ -206,10 +214,7 @@ void *benchmark_thread (void *arg)
 			1,
 			&erroroneousVectorIndex);
 		} while (error == SA_AIS_ERR_TRY_AGAIN);
-		if (error != SA_AIS_OK) {
-			printf ("saCkptCheckpointWrite result %d handle (should be 1)\n", error);
-			exit (1);
-		}
+		fail_on_error(error, "saCkptCheckpointWrite");
 		td->written += 1;
 	} while (alarm_notice == 0);
 	pthread_exit (0);