Преглед изворни кода

defect 998
Sometimes the default section isn't synchronized


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@864 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake пре 20 година
родитељ
комит
6dfa2cb0ed
1 измењених фајлова са 33 додато и 1 уклоњено
  1. 33 1
      exec/ckpt.c

+ 33 - 1
exec/ckpt.c

@@ -2058,7 +2058,35 @@ static int recovery_section_create (SaCkptSectionDescriptorT *sectionDescriptor,
 								 SectionId,
 								(int)sectionDescriptor->sectionId.idLen);
 	if (ckptCheckpointSection) {
-		error = SA_AIS_ERR_EXIST;
+		/*
+		 * This use case is mostly for the default section and is not probable for any other
+		 * sections.
+		 */
+		if (sectionDescriptor->sectionSize
+			> ckptCheckpointSection->sectionDescriptor.sectionSize) {
+			
+			log_printf (LOG_LEVEL_NOTICE, 
+				"CKPT: recovery_section_create reallocating data. Present Size: %d, New Size: %d\n",
+				ckptCheckpointSection->sectionDescriptor.sectionSize,sectionDescriptor->sectionSize);
+
+			ckptCheckpointSection->sectionData =
+				realloc (ckptCheckpointSection->sectionData, sectionDescriptor->sectionSize);
+
+			if (ckptCheckpointSection->sectionData == 0) {
+				log_printf (LOG_LEVEL_ERROR,
+					"CKPT: recovery_section_create sectionData realloc returned 0 Calling error_exit.\n");
+				error = SA_AIS_ERR_NO_MEMORY;
+				checkpoint_section_release(ckptCheckpointSection);
+				goto error_exit;
+			}
+
+			ckptCheckpointSection->sectionDescriptor.sectionSize = sectionDescriptor->sectionSize;
+			error = SA_AIS_OK;
+			
+		}
+		else {
+			error = SA_AIS_ERR_EXIST;
+		}
 		goto error_exit;
 	}
 
@@ -2460,6 +2488,10 @@ static int recovery_section_write(int sectionIdLen,
 	 */
 	sizeRequired = dataOffSet + dataSize;
 	if (sizeRequired > ckptCheckpointSection->sectionDescriptor.sectionSize) {
+		log_printf (LOG_LEVEL_ERROR,
+			"recovery_section_write. write-past-end sizeRequired:(%d), dataOffSet:(%d), dataSize:(%d), sync-section-size:(%d)\n",
+			sizeRequired, dataOffSet, dataSize,
+			(int)ckptCheckpointSection->sectionDescriptor.sectionSize);
 		error = SA_AIS_ERR_ACCESS;
 		goto error_exit;		
 	}