[Linux-ha-dev] heartbeat should detect and recover from corrupt CIB

Aníbal Monsalve Salazar anibal at sgi.com
Sun Mar 4 23:14:59 MST 2007


On Fri, Mar 02, 2007 at 09:03:19AM +0100, Andrew Beekhof wrote:
>coincidentally i already applied something equivalent to the first
>part of this patch a couple of days ago - but the second half looks
>like a good addition too.

There is a missing crm_free(buffer). Updated patch follows.

--- lib/crm/common/xml.c~	2007-01-12 13:57:08.000000000 +1100
+++ lib/crm/common/xml.c	2007-03-05 11:31:17.630665050 +1100
@@ -634,6 +634,11 @@
 
 	/* establish the file with correct permissions */
 	file_output_strm = fopen(filename, "w");
+	if(file_output_strm == NULL) {
+		crm_free(buffer);
+		cl_perror("Cannot open %s", filename);
+		return -1;
+	}
 	fclose(file_output_strm);
 	chmod(filename, cib_mode);
 
@@ -684,7 +689,12 @@
 		if(res < 0) {
 			cl_perror("Cannot write output to %s",filename);
 		}
-		fflush(file_output_strm);
+		if(fflush(file_output_strm) == EOF || fsync(fileno(file_output_strm)) < 0) {
+			crm_free(buffer);
+			cl_perror("fflush or fsync error on %s", filename);
+			fclose(file_output_strm);
+			return -1;
+		}
 	}
 	fclose(file_output_strm);
 	crm_free(buffer);

Aníbal


More information about the Linux-HA-Dev mailing list