null+****@clear*****
null+****@clear*****
2010年 10月 6日 (水) 11:30:29 JST
Kouhei Sutou 2010-10-06 02:30:29 +0000 (Wed, 06 Oct 2010) New Revision: b0c7de538645b52a381f5ecb9e23f2c6c078ae43 Log: call init function only once for each module. #567 Modified files: lib/module.c Modified: lib/module.c (+9 -6) =================================================================== --- lib/module.c 2010-10-14 15:16:48 +0000 (fa15962) +++ lib/module.c 2010-10-06 02:30:29 +0000 (7704d20) @@ -62,7 +62,7 @@ grn_module_path(grn_ctx *ctx, grn_id id) static grn_rc grn_module_initialize(grn_ctx *ctx, grn_module *module, - grn_dl dl, const char *path) + grn_dl dl, grn_id id, const char *path) { const char *base_name, *extension; char init_func_name[PATH_MAX]; @@ -109,6 +109,12 @@ grn_module_initialize(grn_ctx *ctx, grn_module *module, fin_func_name, module->fin_func ? "" : "not "); } + if (!ctx->rc) { + ctx->impl->module_path = path; + grn_module_init(ctx, id); + ctx->impl->module_path = NULL; + } + return ctx->rc; } @@ -128,7 +134,7 @@ grn_module_open(grn_ctx *ctx, const char *filename) (void **)&module, NULL))) { *module = GRN_GMALLOCN(grn_module, 1); if (*module) { - if (grn_module_initialize(ctx, *module, dl, filename)) { + if (grn_module_initialize(ctx, *module, dl, id, filename)) { GRN_GFREE(*module); *module = NULL; } @@ -300,10 +306,7 @@ grn_db_register(grn_ctx *ctx, const char *path) if (id) { ctx->impl->module_path = path; - ctx->rc = grn_module_init(ctx, id); - if (!ctx->rc) { - ctx->rc = grn_module_register(ctx, id); - } + ctx->rc = grn_module_register(ctx, id); ctx->impl->module_path = NULL; if (ctx->rc) { grn_module_close(ctx, id);