소스 검색

Call fsync to force writing buffers to disk

Matthias Vogelgesang 9 년 전
부모
커밋
8a1d468061
1개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 7 0
      tiffperf/tiffperf.c

+ 7 - 0
tiffperf/tiffperf.c

@@ -3,6 +3,7 @@
 #include <stdint.h>
 #include <string.h>
 #include <tiffio.h>
+#include <unistd.h>
 #include "timer.h"
 
 typedef struct {
@@ -44,6 +45,8 @@ write_multi_tiff (uint16_t *data, ImageSize *size)
         TIFFWriteDirectory (tiff);
     }
 
+    /* Flush to disk to outsmart Linux */
+    fsync (TIFFFileno (tiff));
     TIFFClose (tiff);
 }
 
@@ -58,6 +61,10 @@ write_single_tiffs (uint16_t *data, ImageSize *size)
         snprintf (fname, 256, "single-%05i.tiff", i);
         tiff = TIFFOpen (fname, "w");
         write_tiff_data (tiff, data, size);
+
+        /* Flush to disk to outsmart Linux */
+        fsync (TIFFFileno (tiff));
+
         TIFFClose (tiff);
     }
 }