[Groonga-commit] groonga/groonga at d952a32 [master] io: use portable futimes()

Back to archive index

Kouhei Sutou null+****@clear*****
Sat Mar 31 00:58:44 JST 2018


Kouhei Sutou	2018-03-31 00:58:44 +0900 (Sat, 31 Mar 2018)

  New Revision: d952a320626281b7b8a7be1504d1a1d07bde84a7
  https://github.com/groonga/groonga/commit/d952a320626281b7b8a7be1504d1a1d07bde84a7

  Message:
    io: use portable futimes()

  Modified files:
    lib/io.c

  Modified: lib/io.c (+6 -8)
===================================================================
--- lib/io.c    2018-03-31 00:39:43 +0900 (d3f40f199)
+++ lib/io.c    2018-03-31 00:58:44 +0900 (eaa70bc55)
@@ -23,6 +23,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <sys/stat.h>
+#include <sys/time.h>
 
 #include "grn_ctx.h"
 #include "grn_io.h"
@@ -2137,18 +2138,15 @@ grn_msync(grn_ctx *ctx, fileinfo *fi, void *start, size_t length)
     return r;
   }
 
-/* TODO: We should check futimens() availability. */
-#ifdef __linux__
   if (fi->fd > 0) {
-    struct timespec times[2];
-    times[0].tv_nsec = UTIME_NOW;
-    times[1].tv_nsec = UTIME_NOW;
-    r = futimens(fi->fd, times);
+    struct timeval times[2];
+    gettimeofday(&(times[0]), NULL);
+    times[1] = times[0];
+    r = futimes(fi->fd, times);
     if (r == -1) {
-      SERR("futimens failed: <%d>", fi->fd);
+      SERR("futimen failed: <%d>", fi->fd);
     }
   }
-#endif
 
   return r;
 }
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180331/a0fa9116/attachment-0001.htm 



More information about the Groonga-commit mailing list
Back to archive index