[Groonga-commit] groonga/groonga [master] increase lock section to avoid data break in multi process. fixes #890

Back to archive index

null+****@clear***** null+****@clear*****
2011年 5月 15日 (日) 23:28:41 JST


Kouhei Sutou	2011-05-15 14:28:41 +0000 (Sun, 15 May 2011)

  New Revision: 5bf5301dcf84de53c86052ec9762924c084cac3a

  Log:
    increase lock section to avoid data break in multi process. fixes #890

  Modified files:
    lib/store.c

  Modified: lib/store.c (+5 -2)
===================================================================
--- lib/store.c    2011-05-16 04:18:44 +0000 (5e3828d)
+++ lib/store.c    2011-05-15 14:28:41 +0000 (8c0d290)
@@ -735,16 +735,19 @@ grn_ja_alloc(grn_ctx *ctx, grn_ja *ja, grn_id id,
         vp->pos = 0;
       }
     }
-    grn_io_unlock(ja->io);
     EINFO_ENC(einfo, vp->seg, vp->pos, element_size);
     GRN_IO_SEG_REF(ja->io, vp->seg, addr);
-    if (!addr) { return GRN_NO_MEMORY_AVAILABLE; }
+    if (!addr) {
+      grn_io_unlock(ja->io);
+      return GRN_NO_MEMORY_AVAILABLE;
+    }
     iw->segment = vp->seg;
     iw->addr = addr + vp->pos;
     if ((vp->pos += aligned_size) == JA_SEGMENT_SIZE) {
       vp->seg = 0;
       vp->pos = 0;
     }
+    grn_io_unlock(ja->io);
     return GRN_SUCCESS;
   }
 }




Groonga-commit メーリングリストの案内
Back to archive index