[Groonga-commit] groonga/groonga [master] fixed a bug ref #894

Back to archive index

null+****@clear***** null+****@clear*****
2011年 3月 30日 (水) 20:05:43 JST


Daijiro MORI	2011-03-30 11:05:43 +0000 (Wed, 30 Mar 2011)

  New Revision: f3cee5f9a281a1095a5e51b500c0cd2337ed9785

  Log:
    fixed a bug ref #894

  Modified files:
    lib/plugin.c
    lib/plugin_in.h

  Modified: lib/plugin.c (+7 -1)
===================================================================
--- lib/plugin.c    2011-03-28 02:50:42 +0000 (adfb72a)
+++ lib/plugin.c    2011-03-30 11:05:43 +0000 (37fc45b)
@@ -147,6 +147,9 @@ grn_plugin_open(grn_ctx *ctx, const char *filename)
 
   if ((id = grn_hash_get(ctx, grn_plugins, filename, PATHLEN(filename),
                          (void **)&plugin))) {
+    if (plugin && *plugin) {
+      (*plugin)->refcount++;
+    }
     return id;
   }
   if ((dl = grn_dl_open(filename))) {
@@ -171,6 +174,8 @@ grn_plugin_open(grn_ctx *ctx, const char *filename)
           SERR(label);
         }
         id = GRN_ID_NIL;
+      } else {
+        (*plugin)->refcount = 1;
       }
     } else {
       if (!grn_dl_close(dl)) {
@@ -192,10 +197,11 @@ grn_plugin_close(grn_ctx *ctx, grn_id id)
 {
   grn_plugin *plugin;
 
-  grn_plugin_call_fin(ctx, id);
   if (!grn_hash_get_value(ctx, grn_plugins, id, &plugin)) {
     return GRN_INVALID_ARGUMENT;
   }
+  if (--plugin->refcount) { return GRN_SUCCESS; }
+  grn_plugin_call_fin(ctx, id);
   if (!grn_dl_close(plugin->dl)) {
     const char *label;
     label = grn_dl_close_error_label;

  Modified: lib/plugin_in.h (+1 -0)
===================================================================
--- lib/plugin_in.h    2011-03-28 02:50:42 +0000 (bc64998)
+++ lib/plugin_in.h    2011-03-30 11:05:43 +0000 (aa6dc6f)
@@ -50,6 +50,7 @@ struct _grn_plugin {
   grn_plugin_func register_func;
   grn_plugin_func unregister_func;
   grn_plugin_func fin_func;
+  int refcount;
 };
 
 grn_rc grn_plugins_init(void);




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