summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6abb7d2)
raw | patch | inline | side by side (parent: 6abb7d2)
author | Sebastian Harl <sh@tokkee.org> | |
Mon, 21 Apr 2014 16:18:56 +0000 (18:18 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Mon, 21 Apr 2014 16:26:58 +0000 (18:26 +0200) |
For callbacks not registered from a plugin, we don't have a context. For
example, the frontend's connection logger callback does not have a context.
example, the frontend's connection logger callback does not have a context.
src/core/plugin.c | patch | blob | history |
diff --git a/src/core/plugin.c b/src/core/plugin.c
index fe8844a505d061e1df09ec9a720d95c2f30fb9c9..687ed36e39aa4c18b59fdca83ecd92a26ec4448b 100644 (file)
--- a/src/core/plugin.c
+++ b/src/core/plugin.c
const sdb_plugin_cb_t *cb = SDB_CONST_PLUGIN_CB(obj);
const char *name = id;
- assert(cb && id && cb->cb_ctx);
+ assert(cb && id);
+
+ /* when a plugin was registered from outside a plugin (e.g. the core),
+ * we don't have a plugin context */
+ if (! cb->cb_ctx)
+ return 1;
+
if (!strcasecmp(cb->cb_ctx->info.plugin_name, name))
return 0;
return 1;
if (! cb)
break;
+ assert(cb->cb_ctx);
+
sdb_log(SDB_LOG_INFO, "core: Unregistering "
"%s callback '%s' (module %s)", type, cb->super.name,
cb->cb_ctx->info.plugin_name);
return -1;
}
+ /* cb_ctx may be NULL if the plugin was not registered by a plugin */
+
SDB_PLUGIN_CB(obj)->cb_callback = callback;
SDB_PLUGIN_CB(obj)->cb_ctx = ctx_get();
sdb_object_ref(SDB_OBJ(SDB_PLUGIN_CB(obj)->cb_ctx));