[Groonga-commit] groonga/groonga at dc22a5a [master] io: improve CreateFile() logs

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jun 5 17:02:27 JST 2017


Kouhei Sutou	2017-06-05 17:02:27 +0900 (Mon, 05 Jun 2017)

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

  Message:
    io: improve CreateFile() logs

  Modified files:
    lib/io.c

  Modified: lib/io.c (+22 -8)
===================================================================
--- lib/io.c    2017-06-05 16:52:13 +0900 (d623d04)
+++ lib/io.c    2017-06-05 17:02:27 +0900 (913d24d)
@@ -1690,9 +1690,25 @@ grn_fileinfo_open_common(grn_ctx *ctx, fileinfo *fi, const char *path, int flags
       SERR("CreateFile(<%s>, <%s>) failed",
            path, flags_description);
       goto exit;
-    } else {
+    }
+
+    switch (dwCreationDisposition) {
+    case CREATE_NEW :
       GRN_LOG(ctx, GRN_LOG_INFO,
-              "[io][open] file is created on CreateFile: <%s>", path);
+              "[io][open] create new file: <%s>", path);
+      break;
+    case OPEN_ALWAYS :
+      if (GetLastError() == ERROR_ALREADY_EXISTS) {
+        GRN_LOG(ctx, GRN_LOG_INFO,
+                "[io][open] open existing file because it exists: <%s>", path);
+      } else {
+        GRN_LOG(ctx, GRN_LOG_INFO,
+                "[io][open] create new file because it doesn't exist: <%s>",
+                path);
+      }
+      break;
+    default :
+      break;
     }
 
     if (grn_io_use_sparse) {
@@ -1729,10 +1745,9 @@ grn_fileinfo_open_common(grn_ctx *ctx, fileinfo *fi, const char *path, int flags
       SERR("CreateFile(<%s>, <O_RDWR|O_TRUNC>) failed",
            path);
       goto exit;
-    } else {
-      GRN_LOG(ctx, GRN_LOG_INFO,
-              "[io][open] file is truncated: <%s>", path);
     }
+    GRN_LOG(ctx, GRN_LOG_INFO,
+            "[io][open] truncated: <%s>", path);
     goto exit;
   }
   /* O_RDWR only */
@@ -1744,10 +1759,9 @@ grn_fileinfo_open_common(grn_ctx *ctx, fileinfo *fi, const char *path, int flags
     SERR("CreateFile(<%s>, <O_RDWR>) failed",
          path);
     goto exit;
-  } else {
-    GRN_LOG(ctx, GRN_LOG_INFO,
-            "[io][open] file is created: <%s>", path);
   }
+  GRN_LOG(ctx, GRN_LOG_INFO,
+          "[io][open] open existing file: <%s>", path);
 
 exit :
   return ctx->rc;
-------------- next part --------------
HTML����������������������������...
Download 



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