[Debian-ha-commits] [pacemaker] 05/05: High: cib: Ensure the archived file hits the disk before returning

Christoph Berg myon at debian.org
Mon Jan 4 22:02:55 UTC 2016


This is an automated email from the git hooks/post-receive script.

myon pushed a commit to tag Pacemaker-0.6.1
in repository pacemaker.

commit 9d2383c466b56ca943549023ac556f7aaa4b085c
Author: Andrew Beekhof <andrew at beekhof.net>
Date:   Mon Feb 11 15:22:22 2008 +0100

    High: cib: Ensure the archived file hits the disk before returning
    
    Mercurial revision: 3dc60cb966281a6d42204e943788d5e3d255213d
---
 cib/io.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/cib/io.c b/cib/io.c
index f9f79e0..62b7404 100644
--- a/cib/io.c
+++ b/cib/io.c
@@ -268,7 +268,7 @@ retrieveCib(const char *filename, const char *sigfile, gboolean archive_invalid)
 	
     } else if(validate_cib_digest(root, sigfile) == FALSE) {
 	crm_err("Checksum of %s failed!  Configuration contents ignored!", filename);
-	crm_err("Usually this is caused by manually changes, "
+	crm_err("Usually this is caused by manual changes, "
 		"please refer to http://linux-ha.org/v2/faq/cib_changes_detected");
 	crm_warn("Continuing but %s will NOT used.", filename);
 	free_xml(root);
@@ -522,6 +522,21 @@ initializeCib(crm_data_t *new_cib)
 	return TRUE;
 }
 
+static void
+sync_file(const char *file) 
+{
+    FILE *syncme = fopen(file, "a");
+    if(syncme == NULL) {
+	cl_perror("Cannot open file %s for syncing", file);
+	return;
+    }
+    
+    if(fsync(fileno(syncme)) < 0) {
+	cl_perror("fsync for %s failed:", file);
+    }
+    fclose(syncme);
+}
+
 int
 archive_file(const char *oldname, const char *newname, const char *ext, gboolean preserve)
 {
@@ -590,6 +605,7 @@ archive_file(const char *oldname, const char *newname, const char *ext, gboolean
 		} else {
 			crm_debug("%s archived as %s", oldname, backup_file);
 		}
+		sync_file(backup_file);
 	}
 	crm_free(backup_file);
 	return rc;
@@ -721,6 +737,7 @@ write_cib_contents(gpointer p)
 
 	    CRM_ASSERT(retrieveCib(CIB_FILENAME, CIB_FILENAME".sig", FALSE) != NULL);
 	    CRM_ASSERT(retrieveCib(CIB_FILENAME".last", CIB_FILENAME".sig.last", FALSE) != NULL);
+	    
 	    crm_debug("Verified CIB archive");	    
 	}
 	

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-ha/pacemaker.git



More information about the Debian-HA-Commits mailing list