Browse Source

libraster: +comment to justify fsync before closing data files

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@74458 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 6 years ago
parent
commit
d5a441a35c
1 changed files with 13 additions and 3 deletions
  1. 13 3
      lib/raster/close.c

+ 13 - 3
lib/raster/close.c

@@ -41,12 +41,22 @@ static int close_new(int, int);
 
 static void sync_and_close(int fd, char *element, char *name)
 {
+    /* from man 2 write:
+     * A successful return from write() does not make any guarantee 
+     * that data has been committed to disk.  On some filesystems, 
+     * including NFS, it does not even guarantee that space has 
+     * successfully been reserved for the data.  In this case, some 
+     * errors might be delayed until a future write(2), fsync(2), or 
+     * even close(2).  The only way to be sure is to call fsync(2) 
+     * after you are done writing all your data.
+     */
+
     if (fsync(fd)) {
-	G_warning(_("Unable to flush %s file for raster map %s: %s"),
+	G_warning(_("Unable to flush file %s for raster map %s: %s"),
 	            element, name, strerror(errno));
-		}
+    }
     if (close(fd)) {
-	G_warning(_("Unable to close %s file for raster map %s: %s"),
+	G_warning(_("Unable to close file %s for raster map %s: %s"),
 	            element, name, strerror(errno));
     }
 }