[Groonga-commit] groonga/groonga at 4978fff [master] grn_proc_create: stop to re-initialize existing proc object

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jan 5 23:06:34 JST 2015


Kouhei Sutou	2015-01-05 23:06:34 +0900 (Mon, 05 Jan 2015)

  New Revision: 4978fff95e6c5121a304786d965fc6801c8cfadc
  https://github.com/groonga/groonga/commit/4978fff95e6c5121a304786d965fc6801c8cfadc

  Message:
    grn_proc_create: stop to re-initialize existing proc object
    
    It's not thread safe because proc object is shared in N threads.
    
    It may cause memory leaks because re-initialize code doesn't free
    existing values.

  Modified files:
    lib/db.c

  Modified: lib/db.c (+2 -0)
===================================================================
--- lib/db.c    2015-01-05 23:06:04 +0900 (7e356d0)
+++ lib/db.c    2015-01-05 23:06:34 +0900 (d051b4d)
@@ -590,12 +590,14 @@ grn_proc_create(grn_ctx *ctx, const char *name, int name_size, grn_proc_type typ
     if (!added) {
       db_value *vp;
       if ((vp = grn_tiny_array_at(&s->values, id)) && (res = (grn_proc *)vp->ptr)) {
+        /* TODO: Do more robust check. */
         if (res->funcs[PROC_INIT] ||
             res->funcs[PROC_NEXT] ||
             res->funcs[PROC_FIN]) {
           ERR(GRN_INVALID_ARGUMENT, "already used name");
           GRN_API_RETURN(NULL);
         }
+        GRN_API_RETURN((grn_obj *)res);
       } else {
         added = 1;
       }
-------------- next part --------------
HTML����������������������������...
Download 



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