Kouhei Sutou
null+****@clear*****
Fri Jul 20 16:13:25 JST 2018
Kouhei Sutou 2018-07-20 16:13:25 +0900 (Fri, 20 Jul 2018) New Revision: 74f94a9e9fa8ec8b30171efc370b094e70896e19 https://github.com/groonga/groonga/commit/74f94a9e9fa8ec8b30171efc370b094e70896e19 Message: Defer plugin close on database Because a table may refer plugin. For example, normalizer with options call normalizer's close options function. groonga-normalizer-mysql provides it as a plugin. If plugin is closed before the table that has normalizer with options, Groonga crashes. Modified files: lib/db.c Modified: lib/db.c (+23 -4) =================================================================== --- lib/db.c 2018-07-20 16:13:20 +0900 (acdece660) +++ lib/db.c 2018-07-20 16:13:25 +0900 (3ac942f0f) @@ -473,10 +473,6 @@ grn_db_close(grn_ctx *ctx, grn_obj *db) } } - GRN_TINY_ARRAY_EACH(&s->values, 1, grn_db_curr_id(ctx, db), id, vp, { - if (vp->ptr) { grn_obj_close(ctx, vp->ptr); } - }); - if (ctx_used_db) { if (ctx->impl->values) { grn_db_obj *o; @@ -487,6 +483,29 @@ grn_db_close(grn_ctx *ctx, grn_obj *db) } } + { + grn_obj plugins; + GRN_PTR_INIT(&plugins, GRN_OBJ_VECTOR, GRN_ID_NIL); + GRN_TINY_ARRAY_EACH(&s->values, 1, grn_db_curr_id(ctx, db), id, vp, { + if (vp->ptr) { + if (grn_obj_is_proc(ctx, vp->ptr)) { + GRN_PTR_PUT(ctx, &plugins, vp->ptr); + } else { + grn_obj_close(ctx, vp->ptr); + } + } + }); + { + size_t i, n_plugins; + n_plugins = GRN_BULK_VSIZE(&plugins) / sizeof(grn_obj *); + for (i = 0; i < n_plugins; i++) { + grn_obj *plugin = GRN_PTR_VALUE_AT(&plugins, i); + grn_obj_close(ctx, plugin); + } + } + GRN_OBJ_FIN(ctx, &plugins); + } + /* grn_tiny_array_fin should be refined.. */ #ifdef WIN32 { -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180720/e12dece3/attachment-0001.htm