[Groonga-commit] groonga/groonga at dffb40a [master] Add more delete operation logs

Back to archive index

Kentaro Hayashi null+****@clear*****
Mon Jun 5 14:51:12 JST 2017


Kentaro Hayashi	2017-06-05 14:51:12 +0900 (Mon, 05 Jun 2017)

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

  Merged a51ea44: Merge pull request #700 from kenhys/more-delete-log

  Message:
    Add more delete operation logs

  Modified files:
    lib/dat.cpp
    lib/ii.c
    lib/io.c

  Modified: lib/dat.cpp (+11 -1)
===================================================================
--- lib/dat.cpp    2017-06-04 00:01:21 +0900 (c4cd90a)
+++ lib/dat.cpp    2017-06-05 14:51:12 +0900 (18782e9)
@@ -71,7 +71,17 @@ bool
 grn_dat_remove_file(grn_ctx *ctx, const char *path)
 {
   struct stat stat;
-  return !::stat(path, &stat) && !grn_unlink(path);
+  bool succeeded = GRN_FALSE;
+  if (!::stat(path, &stat)) {
+    if (grn_unlink(path) != 0) {
+      ERRNO_ERR("failed to remove path: <%s>", path);
+    } else {
+      GRN_LOG(ctx, GRN_LOG_INFO,
+              "removed path on grn_dat_remove_file(): <%s>", path);
+      succeeded = GRN_TRUE;
+    }
+  }
+  return succeeded;
 }
 
 grn_rc

  Modified: lib/ii.c (+21 -3)
===================================================================
--- lib/ii.c    2017-06-04 00:01:21 +0900 (2c761d0)
+++ lib/ii.c    2017-06-05 14:51:12 +0900 (3e42996)
@@ -10295,7 +10295,13 @@ grn_ii_buffer_commit(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
           "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_unlink(ii_buffer->tmpfpath);
+  if (grn_unlink(ii_buffer->tmpfpath) != 0) {
+    ERRNO_ERR("failed to remove path on grn_ii_buffer_commit(): <%s>",
+              ii_buffer->tmpfpath);
+  } else {
+    GRN_LOG(ctx, GRN_LOG_INFO,
+            "removed path on grn_ii_buffer_commit(): <%s>", ii_buffer->tmpfpath);
+  }
   ii_buffer->tmpfd = -1;
   return ctx->rc;
 }
@@ -10315,7 +10321,13 @@ grn_ii_buffer_close(grn_ctx *ctx, grn_ii_buffer *ii_buffer)
   }
   if (ii_buffer->tmpfd != -1) {
     grn_close(ii_buffer->tmpfd);
-    grn_unlink(ii_buffer->tmpfpath);
+    if (grn_unlink(ii_buffer->tmpfpath) != 0) {
+      ERRNO_ERR("failed to remove path on grn_ii_buffer_close(): <%s>",
+                ii_buffer->tmpfpath);
+    } else {
+      GRN_LOG(ctx, GRN_LOG_INFO,
+              "removed path on grn_ii_buffer_close(): <%s>", ii_buffer->tmpfpath);
+    }
   }
   if (ii_buffer->block_buf) {
     GRN_FREE(ii_buffer->block_buf);
@@ -11391,7 +11403,13 @@ grn_ii_builder_fin(grn_ctx *ctx, grn_ii_builder *builder)
   }
   if (builder->fd != -1) {
     grn_close(builder->fd);
-    grn_unlink(builder->path);
+    if (grn_unlink(builder->path) != 0) {
+      ERRNO_ERR("failed to remove path on grn_ii_builder_fin(): <%s>",
+                builder->path);
+    } else {
+      GRN_LOG(ctx, GRN_LOG_INFO,
+              "removed path on grn_ii_builder_fin(): <%s>", builder->path);
+    }
   }
   grn_ii_builder_fin_terms(ctx, builder);
   if (builder->lexicon) {

  Modified: lib/io.c (+7 -0)
===================================================================
--- lib/io.c    2017-06-04 00:01:21 +0900 (1bf60ff)
+++ lib/io.c    2017-06-05 14:51:12 +0900 (bbdc41b)
@@ -364,6 +364,8 @@ grn_io_create(grn_ctx *ctx, const char *path, uint32_t header_size,
                 "failed to grn_unlink() path on grn_io_create() error: "
                 "<%s>: <%s>",
                 path, grn_strerror(errno));
+      } else {
+        GRN_LOG(ctx, GRN_LOG_INFO, "removed path on grn_io_create(): <%s>", path);
       }
     }
     GRN_FREE(fis);
@@ -825,6 +827,8 @@ grn_io_remove_raw(grn_ctx *ctx, const char *path)
     ERRNO_ERR("failed to remove path: <%s>",
               path);
     return ctx->rc;
+  } else {
+    GRN_LOG(ctx, GRN_LOG_INFO, "removed path on grn_io_remove_raw(): <%s>", path);
   }
 
   for (fno = 1; ; fno++) {
@@ -837,6 +841,9 @@ grn_io_remove_raw(grn_ctx *ctx, const char *path)
       ERRNO_ERR("failed to remove path: <%s>",
                 buffer);
       rc = ctx->rc;
+    } else {
+      GRN_LOG(ctx, GRN_LOG_INFO,
+              "removed path with fno on grn_io_remove_raw(): <%s>", buffer);
     }
   }
   return rc;
-------------- next part --------------
HTML����������������������������...
Download 



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