[Groonga-commit] groonga/groonga at 27f5e4b [master] Add missing locks for registering/unregistering I/O

Back to archive index

Kouhei Sutou null+****@clear*****
Wed Jun 5 18:37:26 JST 2013


Kouhei Sutou	2013-06-05 18:37:26 +0900 (Wed, 05 Jun 2013)

  New Revision: 27f5e4b6bfa0d5e8bc869600a86ee439edb951a3
  https://github.com/groonga/groonga/commit/27f5e4b6bfa0d5e8bc869600a86ee439edb951a3

  Message:
    Add missing locks for registering/unregistering I/O

  Modified files:
    lib/io.c

  Modified: lib/io.c (+12 -2)
===================================================================
--- lib/io.c    2013-06-05 17:47:03 +0900 (4200a83)
+++ lib/io.c    2013-06-05 18:37:26 +0900 (7c999f2)
@@ -155,10 +155,15 @@ static void
 grn_io_register(grn_io *io)
 {
   if (io->fis && (io->flags & (GRN_IO_EXPIRE_GTICK|GRN_IO_EXPIRE_SEGMENT))) {
+    grn_bool succeeded = GRN_FALSE;
+    CRITICAL_SECTION_ENTER(grn_glock);
     if (grn_gctx.impl && grn_gctx.impl->ios &&
         grn_hash_add(&grn_gctx, grn_gctx.impl->ios, io->path, strlen(io->path),
                      (void **)&io, NULL)) {
-    } else {
+      succeeded = GRN_TRUE;
+    }
+    CRITICAL_SECTION_LEAVE(grn_glock);
+    if (!succeeded) {
       GRN_LOG(&grn_gctx, GRN_LOG_WARNING,
               "grn_io_register(%s) failed", io->path);
     }
@@ -169,10 +174,15 @@ static void
 grn_io_unregister(grn_io *io)
 {
   if (io->fis && (io->flags & (GRN_IO_EXPIRE_GTICK|GRN_IO_EXPIRE_SEGMENT))) {
+    grn_bool succeeded = GRN_FALSE;
+    CRITICAL_SECTION_ENTER(grn_glock);
     if (grn_gctx.impl && grn_gctx.impl->ios) {
       grn_hash_delete(&grn_gctx, grn_gctx.impl->ios,
                       io->path, strlen(io->path), NULL);
-    } else {
+      succeeded = GRN_TRUE;
+    }
+    CRITICAL_SECTION_LEAVE(grn_glock);
+    if (!succeeded) {
       GRN_LOG(&grn_gctx, GRN_LOG_WARNING,
               "grn_io_unregister(%s) failed", io->path);
     }
-------------- next part --------------
HTML����������������������������...
Download 



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