From a9f99c057f72b31de1fa718cd6abe1ea5005ee28 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sun, 20 Apr 2014 12:05:57 +0200 Subject: [PATCH] plugin: Let ctx_create() use ctx_set(). This ensures consistent handling of reference counts. --- src/core/plugin.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/core/plugin.c b/src/core/plugin.c index 929abae..7584aa5 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -292,22 +292,6 @@ static sdb_type_t ctx_type = { ctx_destroy }; -static ctx_t * -ctx_create(const char *name) -{ - ctx_t *ctx; - - ctx = CTX(sdb_object_create(name, ctx_type)); - if (! ctx) - return NULL; - - if (! plugin_ctx_key_initialized) - ctx_key_init(); - sdb_object_ref(SDB_OBJ(ctx)); - pthread_setspecific(plugin_ctx_key, ctx); - return ctx; -} /* ctx_create */ - static ctx_t * ctx_get(void) { @@ -333,6 +317,21 @@ ctx_set(ctx_t *new) return old; } /* ctx_set */ +static ctx_t * +ctx_create(const char *name) +{ + ctx_t *ctx; + + ctx = CTX(sdb_object_create(name, ctx_type)); + if (! ctx) + return NULL; + + if (! plugin_ctx_key_initialized) + ctx_key_init(); + ctx_set(ctx); + return ctx; +} /* ctx_create */ + static int plugin_cb_init(sdb_object_t *obj, va_list ap) { -- 2.30.2