[GRASS-SVN] r74458 - grass/trunk/lib/raster

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 3 01:37:41 PDT 2019


Author: mmetz
Date: 2019-05-03 01:37:41 -0700 (Fri, 03 May 2019)
New Revision: 74458

Modified:
   grass/trunk/lib/raster/close.c
Log:
libraster: +comment to justify fsync before closing data files

Modified: grass/trunk/lib/raster/close.c
===================================================================
--- grass/trunk/lib/raster/close.c	2019-05-03 07:07:46 UTC (rev 74457)
+++ grass/trunk/lib/raster/close.c	2019-05-03 08:37:41 UTC (rev 74458)
@@ -41,12 +41,22 @@
 
 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));
     }
 }



More information about the grass-commit mailing list