[Groonga-commit] groonga/groonga at 08f8cbd [master] windows: always use _close() on Windows

Back to archive index

Kouhei Sutou null+****@clear*****
Thu Apr 16 21:44:22 JST 2015


Kouhei Sutou	2015-04-16 21:44:22 +0900 (Thu, 16 Apr 2015)

  New Revision: 08f8cbda2c7225e86a3b4d51432440a054a0fc19
  https://github.com/groonga/groonga/commit/08f8cbda2c7225e86a3b4d51432440a054a0fc19

  Message:
    windows: always use _close() on Windows

  Modified files:
    build/ac_macros/check_functions.m4
    config.h.cmake
    include/groonga/portability.h
    lib/grn.h
    lib/ii.c
    lib/io.c
    lib/proc.c

  Modified: build/ac_macros/check_functions.m4 (+0 -1)
===================================================================
--- build/ac_macros/check_functions.m4    2015-04-16 21:39:39 +0900 (746917f)
+++ build/ac_macros/check_functions.m4    2015-04-16 21:44:22 +0900 (388f746)
@@ -5,7 +5,6 @@ AC_CHECK_FUNCS(_localtime64_s)
 AC_CHECK_FUNCS(_stricmp)
 AC_CHECK_FUNCS(_strnicmp)
 AC_CHECK_FUNCS(_strtoui64)
-AC_CHECK_FUNCS(close)
 AC_CHECK_FUNCS(gmtime_r)
 AC_CHECK_FUNCS(localtime_r)
 AC_CHECK_FUNCS(mkostemp)

  Modified: config.h.cmake (+0 -1)
===================================================================
--- config.h.cmake    2015-04-16 21:39:39 +0900 (750e5b8)
+++ config.h.cmake    2015-04-16 21:44:22 +0900 (940ebc4)
@@ -144,7 +144,6 @@
 #cmakedefine HAVE_BACKTRACE
 #cmakedefine HAVE_CLOCK
 #cmakedefine HAVE_CLOCK_GETTIME
-#cmakedefine HAVE_CLOSE
 #cmakedefine HAVE_FPCLASSIFY
 #cmakedefine HAVE_GMTIME_R
 #cmakedefine HAVE_LOCALTIME_R

  Modified: include/groonga/portability.h (+6 -0)
===================================================================
--- include/groonga/portability.h    2015-04-16 21:39:39 +0900 (3dba1fe)
+++ include/groonga/portability.h    2015-04-16 21:44:22 +0900 (742d961)
@@ -121,4 +121,10 @@
 # define grn_read(fd, buf, count) read((fd), (buf), (count))
 #endif /* WIN32 */
 
+#ifdef WIN32
+# define grn_close(fd) _close((fd))
+#else /* WIN32 */
+# define grn_close(fd) close((fd))
+#endif /* WIN32 */
+
 #endif /* GROONGA_PORTABILITY_H */

  Modified: lib/grn.h (+0 -6)
===================================================================
--- lib/grn.h    2015-04-16 21:39:39 +0900 (4de7324)
+++ lib/grn.h    2015-04-16 21:44:22 +0900 (4482e16)
@@ -73,12 +73,6 @@
 # define GRN_OPEN(pathname, ...) _open(pathname, __VA_ARGS__)
 #endif /* HAVE_OPEN */
 
-#ifdef HAVE_CLOSE
-# define GRN_CLOSE(fd) close(fd)
-#else
-# define GRN_CLOSE(fd) _close(fd)
-#endif /* HAVE_CLOSE */
-
 #ifdef WIN32
 
 # if defined(__GNUC__) && !defined(WINVER)

  Modified: lib/ii.c (+3 -3)
===================================================================
--- lib/ii.c    2015-04-16 21:39:39 +0900 (86ed65a)
+++ lib/ii.c    2015-04-16 21:44:22 +0900 (83a5b52)
@@ -7759,7 +7759,7 @@ grn_ii_buffer_commit(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
     grn_ii_buffer_flush(ctx, ii_buffer);
   }
   if (ii_buffer->tmpfd != -1) {
-    GRN_CLOSE(ii_buffer->tmpfd);
+    grn_close(ii_buffer->tmpfd);
   }
   if (ii_buffer->block_buf) {
     GRN_FREE(ii_buffer->block_buf);
@@ -7834,7 +7834,7 @@ grn_ii_buffer_commit(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
   GRN_LOG(ctx, GRN_LOG_NOTICE,
           "tmpfile_size:%" GRN_FMT_INT64D " > total_chunk_size:%" GRN_FMT_SIZE,
           ii_buffer->filepos, ii_buffer->total_chunk_size);
-  GRN_CLOSE(ii_buffer->tmpfd);
+  grn_close(ii_buffer->tmpfd);
   grn_unlink(ii_buffer->tmpfpath);
   ii_buffer->tmpfd = -1;
   return ctx->rc;
@@ -7853,7 +7853,7 @@ grn_ii_buffer_close(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
     grn_obj_close(ctx, ii_buffer->tmp_lexicon);
   }
   if (ii_buffer->tmpfd != -1) {
-    GRN_CLOSE(ii_buffer->tmpfd);
+    grn_close(ii_buffer->tmpfd);
     grn_unlink(ii_buffer->tmpfpath);
   }
   if (ii_buffer->block_buf) {

  Modified: lib/io.c (+10 -10)
===================================================================
--- lib/io.c    2015-04-16 21:39:39 +0900 (3b4412c)
+++ lib/io.c    2015-04-16 21:44:22 +0900 (d9d08be)
@@ -68,7 +68,7 @@ static uint32_t grn_io_version_default = GRN_IO_VERSION_DEFAULT;
 inline static grn_rc grn_open(grn_ctx *ctx, fileinfo *fi, const char *path, int flags);
 inline static void grn_fileinfo_init(fileinfo *fis, int nfis);
 inline static int grn_opened(fileinfo *fi);
-inline static grn_rc grn_close(grn_ctx *ctx, fileinfo *fi);
+inline static grn_rc grn_fileinfo_close(grn_ctx *ctx, fileinfo *fi);
 #ifdef WIN32
 inline static void * grn_mmap(grn_ctx *ctx, grn_io *io,
                               HANDLE *fmo, fileinfo *fi,
@@ -323,7 +323,7 @@ grn_io_create(grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t seg
         }
         GRN_MUNMAP(&grn_gctx, NULL, &fis->fmo, fis, header, b);
       }
-      grn_close(ctx, fis);
+      grn_fileinfo_close(ctx, fis);
       grn_unlink(path);
     }
     GRN_GFREE(fis);
@@ -493,7 +493,7 @@ grn_io_detect_type(grn_ctx *ctx, const char *path)
     } else {
       ERR(GRN_INVALID_FORMAT, "grn_io_detect_type failed");
     }
-    GRN_CLOSE(fd);
+    grn_close(fd);
   } else {
     SERR(path);
   }
@@ -526,7 +526,7 @@ grn_io_open(grn_ctx *ctx, const char *path, grn_io_mode mode)
         }
       }
     }
-    GRN_CLOSE(fd);
+    grn_close(fd);
     if (!segment_size) { return NULL; }
   }
   b = grn_io_compute_base(header_size);
@@ -546,7 +546,7 @@ grn_io_open(grn_ctx *ctx, const char *path, grn_io_mode mode)
       fis = GRN_GMALLOCN(fileinfo, max_nfiles);
       if (!fis) {
         GRN_MUNMAP(&grn_gctx, NULL, &(fi.fmo), &fi, header, b);
-        grn_close(ctx, &fi);
+        grn_fileinfo_close(ctx, &fi);
         return NULL;
       }
       grn_fileinfo_init(fis, max_nfiles);
@@ -581,7 +581,7 @@ grn_io_open(grn_ctx *ctx, const char *path, grn_io_mode mode)
       GRN_GFREE(fis);
       GRN_MUNMAP(&grn_gctx, NULL, &(fi.fmo), &fi, header, b);
     }
-    grn_close(ctx, &fi);
+    grn_fileinfo_close(ctx, &fi);
   }
   return NULL;
 }
@@ -627,7 +627,7 @@ grn_io_close(grn_ctx *ctx, grn_io *io)
     int i;
     for (i = 0; i < max_nfiles; i++) {
       fileinfo *fi = &(io->fis[i]);
-      grn_close(ctx, fi);
+      grn_fileinfo_close(ctx, fi);
     }
     GRN_GFREE(io->fis);
   }
@@ -1603,7 +1603,7 @@ grn_munmap(grn_ctx *ctx, grn_io *io,
 }
 
 inline static grn_rc
-grn_close(grn_ctx *ctx, fileinfo *fi)
+grn_fileinfo_close(grn_ctx *ctx, fileinfo *fi)
 {
   if (fi->fmo != NULL) {
     CloseHandle(fi->fmo);
@@ -1715,10 +1715,10 @@ grn_opened(fileinfo *fi)
 }
 
 inline static grn_rc
-grn_close(grn_ctx *ctx, fileinfo *fi)
+grn_fileinfo_close(grn_ctx *ctx, fileinfo *fi)
 {
   if (fi->fd != -1) {
-    if (GRN_CLOSE(fi->fd) == -1) {
+    if (grn_close(fi->fd) == -1) {
       SERR("close");
       return ctx->rc;
     }

  Modified: lib/proc.c (+1 -1)
===================================================================
--- lib/proc.c    2015-04-16 21:39:39 +0900 (4c37c0e)
+++ lib/proc.c    2015-04-16 21:44:22 +0900 (9651cef)
@@ -100,7 +100,7 @@ grn_bulk_put_from_file(grn_ctx *ctx, grn_obj *bulk, const char *path)
     ERR(GRN_INVALID_ARGUMENT, "cannot stat file: <%s>", path);
   }
 exit :
-  GRN_CLOSE(fd);
+  grn_close(fd);
   return ret;
 }
 
-------------- next part --------------
HTML����������������������������...
다운로드 



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