[Groonga-commit] groonga/groonga at ffce14c [master] windows io: fix wrong handle

Back to archive index

Kouhei Sutou null+****@clear*****
Mon May 9 15:15:00 JST 2016


Kouhei Sutou	2016-05-09 15:15:00 +0900 (Mon, 09 May 2016)

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

  Message:
    windows io: fix wrong handle
    
    It should be file handle not file mapping object handle.

  Modified files:
    lib/io.c

  Modified: lib/io.c (+11 -15)
===================================================================
--- lib/io.c    2016-05-08 23:42:07 +0900 (e7988af)
+++ lib/io.c    2016-05-09 15:15:00 +0900 (9fae5a4)
@@ -76,14 +76,14 @@ inline static void * grn_mmap(grn_ctx *ctx, grn_ctx *owner_ctx,
 inline static int grn_munmap(grn_ctx *ctx, grn_ctx *owner_ctx,
                              grn_io *io, HANDLE *fmo, fileinfo *fi,
                              void *start, size_t length);
-inline static int grn_msync(grn_ctx *ctx, HANDLE *fmo,
+inline static int grn_msync(grn_ctx *ctx, HANDLE fh,
                             void *start, size_t length);
 # define GRN_MMAP(ctx,owner_ctx,io,fmo,fi,offset,length)\
   (grn_mmap((ctx), (owner_ctx), (io), (fmo), (fi), (offset), (length)))
 # define GRN_MUNMAP(ctx,owner_ctx,io,fmo,fi,start,length)\
   (grn_munmap((ctx), (owner_ctx), (io), (fmo), (fi), (start), (length)))
-# define GRN_MSYNC(ctx,fmo,start,length) \
-  (grn_msync((ctx), (fmo), (start), (length)))
+# define GRN_MSYNC(ctx,fh,start,length) \
+  (grn_msync((ctx), (fh), (start), (length)))
 #else /* WIN32 */
 inline static void * grn_mmap(grn_ctx *ctx, grn_ctx *owner_ctx,
                               grn_io *io, fileinfo *fi,
@@ -94,7 +94,7 @@ inline static int grn_munmap(grn_ctx *ctx, grn_ctx *owner_ctx,
 inline static int grn_msync(grn_ctx *ctx, void *start, size_t length);
 # define GRN_MUNMAP(ctx,owner_ctx,io,fmo,fi,start,length) \
   (grn_munmap((ctx), (owner_ctx), (io), (fi), (start), (length)))
-# define GRN_MSYNC(ctx,fmo,start,length) \
+# define GRN_MSYNC(ctx,fh,start,length) \
   (grn_msync((ctx), (start), (length)))
 # ifdef USE_FAIL_MALLOC
 inline static void * grn_fail_mmap(grn_ctx *ctx, grn_ctx *owner_ctx,
@@ -316,7 +316,7 @@ grn_io_create(grn_ctx *ctx, const char *path, uint32_t header_size,
         header->flags = flags;
         header->lock = 0;
         grn_memcpy(header->idstr, GRN_IO_IDSTR, 16);
-        GRN_MSYNC(ctx, &(fis->fmo), header, b);
+        GRN_MSYNC(ctx, fis[0].fh, header, b);
         if ((io = GRN_MALLOCN(grn_io, 1))) {
           grn_io_mapinfo *maps = NULL;
           if ((maps = GRN_CALLOC(sizeof(grn_io_mapinfo) * max_segment))) {
@@ -1395,7 +1395,7 @@ grn_io_flush(grn_ctx *ctx, grn_io *io)
   header = io->header;
   aligned_header_size = grn_io_compute_base(header->header_size);
 
-  if (GRN_MSYNC(ctx, &(io->fis->fmo), header, aligned_header_size) != 0) {
+  if (GRN_MSYNC(ctx, io->fis[0].fh, header, aligned_header_size) != 0) {
     return ctx->rc;
   }
 
@@ -1414,7 +1414,7 @@ grn_io_flush(grn_ctx *ctx, grn_io *io)
       if (!info->map) {
         continue;
       }
-      if (GRN_MSYNC(ctx, &(info->fmo), info->map, segment_size) != 0) {
+      if (GRN_MSYNC(ctx, io->fis[i].fh, info->map, segment_size) != 0) {
         rc = ctx->rc;
         break;
       }
@@ -1781,7 +1781,7 @@ grn_fileinfo_opened(fileinfo *fi)
 }
 
 inline static int
-grn_msync(grn_ctx *ctx, HANDLE *handle, void *start, size_t length)
+grn_msync(grn_ctx *ctx, HANDLE handle, void *start, size_t length)
 {
   BOOL succeeded;
   SYSTEMTIME system_time;
@@ -1794,11 +1794,7 @@ grn_msync(grn_ctx *ctx, HANDLE *handle, void *start, size_t length)
     return -1;
   }
 
-  if (!handle) {
-    return 0;
-  }
-
-  if (*handle == INVALID_HANDLE_VALUE) {
+  if (handle == INVALID_HANDLE_VALUE) {
     return 0;
   }
 
@@ -1816,10 +1812,10 @@ grn_msync(grn_ctx *ctx, HANDLE *handle, void *start, size_t length)
     return -1;
   }
 
-  succeeded = SetFileTime(*handle, NULL, NULL, &file_time);
+  succeeded = SetFileTime(handle, NULL, NULL, &file_time);
   if (!succeeded) {
     SERR("SetFileTime(<%p>, <%p>, <%" GRN_FMT_SIZE ">) failed",
-         *handle, start, length);
+         handle, start, length);
     return -1;
   }
 
-------------- next part --------------
HTML����������������������������...
下載 



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