浏览代码

Close null file before attempting to rename() it (issue https://trac.osgeo.org/grass/ticket/2712)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65775 15284696-431f-4ddb-bdfa-cd5b030d7da7
Glynn Clements 9 年之前
父节点
当前提交
5b7953a6db
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      lib/raster/close.c

+ 9 - 5
lib/raster/close.c

@@ -362,6 +362,15 @@ static int close_new(int fd, int ok)
 	    fcb->data = NULL;
 	}
 
+	if (fcb->null_row_ptr) {			/* compressed nulls */
+	    fcb->null_row_ptr[fcb->cellhd.rows] = lseek(fcb->null_fd, 0L, SEEK_CUR);
+	    Rast__write_null_row_ptrs(fd, fcb->null_fd);
+	}
+
+	if (fcb->null_fd >= 0)
+	    close(fcb->null_fd);
+	fcb->null_fd = -1;
+
 	/* create path : full null file name */
 	G__make_mapset_element_misc("cell_misc", fcb->name);
 	G_file_name_misc(path, "cell_misc", NULL_FILE, fcb->name, G_mapset());
@@ -395,11 +404,6 @@ static int close_new(int fd, int ok)
 	    Rast__write_row_ptrs(fd);
 	}
 
-	if (fcb->null_row_ptr) {			/* compressed nulls */
-	    fcb->null_row_ptr[fcb->cellhd.rows] = lseek(fcb->null_fd, 0L, SEEK_CUR);
-	    Rast__write_null_row_ptrs(fd, fcb->null_fd);
-	}
-
 	if (fcb->map_type != CELL_TYPE) {	/* floating point map */
 	    int cell_fd;