Code

plugin: Keep a global reference of a plugin context if it's still in use.
authorSebastian Harl <sh@tokkee.org>
Fri, 18 Apr 2014 12:59:09 +0000 (14:59 +0200)
committerSebastian Harl <sh@tokkee.org>
Fri, 18 Apr 2014 12:59:09 +0000 (14:59 +0200)
D'oh!

src/core/plugin.c

index e67f814ba24510ae47b2640bddfa17dacea3c76f..e6df9e9c2a9da7b1746fba2121492dbce630f0bc 100644 (file)
@@ -239,9 +239,9 @@ plugin_unregister_by_name(const char *plugin_name)
                }
        }
 
-       obj = sdb_llist_remove_by_name(all_plugins, plugin_name);
+       obj = sdb_llist_search_by_name(all_plugins, plugin_name);
        if (obj->ref_cnt <= 1)
-               sdb_log(SDB_LOG_INFO, "core: Unloading module %s", plugin_name);
+               sdb_llist_remove_by_name(all_plugins, plugin_name);
        /* else: other callbacks still reference it */
        sdb_object_deref(obj);
 } /* plugin_unregister_by_name */
@@ -271,10 +271,14 @@ ctx_destroy(sdb_object_t *obj)
 
        if (ctx->handle) {
                const char *err;
+
+               sdb_log(SDB_LOG_INFO, "core: Unloading module %s",
+                               ctx->info.plugin_name);
+
                lt_dlerror();
                lt_dlclose(ctx->handle);
                if ((err = lt_dlerror()))
-                       sdb_log(SDB_LOG_WARNING, "core: Failed to unload plugin %s: %s",
+                       sdb_log(SDB_LOG_WARNING, "core: Failed to unload module %s: %s",
                                        ctx->info.plugin_name, err);
        }