[GRASS-SVN] r74456 - grass/trunk/lib/raster
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu May 2 12:33:09 PDT 2019
Author: mmetz
Date: 2019-05-02 12:33:09 -0700 (Thu, 02 May 2019)
New Revision: 74456
Modified:
grass/trunk/lib/raster/close.c
Log:
libraster: fsync data files before closing, and capture any errors (see #2764)
Modified: grass/trunk/lib/raster/close.c
===================================================================
--- grass/trunk/lib/raster/close.c 2019-05-02 13:49:47 UTC (rev 74455)
+++ grass/trunk/lib/raster/close.c 2019-05-02 19:33:09 UTC (rev 74456)
@@ -39,6 +39,18 @@
static int close_old(int);
static int close_new(int, int);
+static void sync_and_close(int fd, char *element, char *name)
+{
+ if (0 && fsync(fd)) {
+ G_warning(_("Unable to flush %s file for raster map %s: %s"),
+ element, name, strerror(errno));
+ }
+ if (close(fd)) {
+ G_warning(_("Unable to close %s file for raster map %s: %s"),
+ element, name, strerror(errno));
+ }
+}
+
static void write_fp_format(int fd);
/*!
@@ -436,11 +448,16 @@
} /* ok */
/* NOW CLOSE THE FILE DESCRIPTOR */
- close(fcb->data_fd);
+ sync_and_close(fcb->data_fd,
+ (fcb->map_type == CELL_TYPE ? "cell" : "fcell"),
+ fcb->name);
fcb->open_mode = -1;
- if (fcb->null_fd >= 0)
- close(fcb->null_fd);
+ if (fcb->null_fd >= 0) {
+ sync_and_close(fcb->null_fd,
+ (fcb->null_row_ptr ? NULLC_FILE : NULL_FILE),
+ fcb->name);
+ }
fcb->null_fd = -1;
if (fcb->data != NULL)
More information about the grass-commit
mailing list