[Groonga-commit] groonga/groonga at 069ca48 [master] ctx: don't leave an incomplete grn_ctx in a linked list

Back to archive index

Susumu Yata null+****@clear*****
Fri Mar 25 13:14:20 JST 2016


Susumu Yata	2016-03-25 13:14:20 +0900 (Fri, 25 Mar 2016)

  New Revision: 069ca48d1ed884bc5434d23f0ec5976c41c10eb3
  https://github.com/groonga/groonga/commit/069ca48d1ed884bc5434d23f0ec5976c41c10eb3

  Message:
    ctx: don't leave an incomplete grn_ctx in a linked list
    
    GitHub: fix #505

  Modified files:
    lib/ctx.c

  Modified: lib/ctx.c (+9 -1)
===================================================================
--- lib/ctx.c    2016-03-25 12:54:31 +0900 (6c75ab0)
+++ lib/ctx.c    2016-03-25 13:14:20 +0900 (e9c5c55)
@@ -750,6 +750,15 @@ grn_ctx_init(grn_ctx *ctx, int flags)
   if (rc == GRN_SUCCESS) {
     grn_ctx_impl_init(ctx);
     rc = ctx->rc;
+    if (rc != GRN_SUCCESS) {
+      grn_ctx_fin(ctx);
+      if (flags & GRN_CTX_ALLOCATED) {
+        CRITICAL_SECTION_ENTER(grn_glock);
+        ctx->next->prev = ctx->prev;
+        ctx->prev->next = ctx->next;
+        CRITICAL_SECTION_LEAVE(grn_glock);
+      }
+    }
   }
 
   return rc;
@@ -762,7 +771,6 @@ grn_ctx_open(int flags)
   if (ctx) {
     grn_ctx_init(ctx, flags|GRN_CTX_ALLOCATED);
     if (ERRP(ctx, GRN_ERROR)) {
-      grn_ctx_fin(ctx);
       GRN_GFREE(ctx);
       ctx = NULL;
     }
-------------- next part --------------
HTML����������������������������...
下载 



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