X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fmeta_data.c;h=29236e2f18563760279d9f3868b2a748e1e1a8a4;hb=f7b05ebf3311b4c6cb5289f1f7cd8ee02918ef92;hp=d3da9bb5800bc776c1b509c31a6f0225300661c4;hpb=8aad55ab7d737a97d5927458b2b00885e27cae4d;p=collectd.git diff --git a/src/daemon/meta_data.c b/src/daemon/meta_data.c index d3da9bb5..29236e2f 100644 --- a/src/daemon/meta_data.c +++ b/src/daemon/meta_data.c @@ -114,6 +114,8 @@ static meta_entry_t *md_entry_clone (const meta_entry_t *orig) /* {{{ */ return (NULL); copy = md_entry_alloc (orig->key); + if (copy == NULL) + return (NULL); copy->type = orig->type; if (copy->type == MD_TYPE_STRING) copy->value.mv_string = strdup (orig->value.mv_string); @@ -212,6 +214,17 @@ static meta_entry_t *md_entry_lookup (meta_data_t *md, /* {{{ */ } /* }}} meta_entry_t *md_entry_lookup */ /* + * Each value_list_t*, as it is going through the system, is handled by exactly + * one thread. Plugins which pass a value_list_t* to another thread, e.g. the + * rrdtool plugin, must create a copy first. The meta data within a + * value_list_t* is not thread safe and doesn't need to be. + * + * The meta data associated with cache entries are a different story. There, we + * need to ensure exclusive locking to prevent leaks and other funky business. + * This is ensured by the uc_meta_data_get_*() functions. + */ + +/* * Public functions */ meta_data_t *meta_data_create (void) /* {{{ */ @@ -255,7 +268,6 @@ void meta_data_destroy (meta_data_t *md) /* {{{ */ if (md == NULL) return; - pthread_mutex_destroy(&md->lock); md_entry_free (md->head); pthread_mutex_destroy (&md->lock); free (md); @@ -494,7 +506,7 @@ int meta_data_get_string (meta_data_t *md, /* {{{ */ if (e->type != MD_TYPE_STRING) { - ERROR ("meta_data_get_signed_int: Type mismatch for key `%s'", e->key); + ERROR ("meta_data_get_string: Type mismatch for key `%s'", e->key); pthread_mutex_unlock (&md->lock); return (-ENOENT); }