X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdaemon%2Fmeta_data.c;h=29236e2f18563760279d9f3868b2a748e1e1a8a4;hb=7bfda8d327240ac73297e4449663814dd0594be5;hp=6ee8446b37639dc38e479db4f6dcd48807cde725;hpb=dab48f284f9d4bb6ae98244310c5cdb6c5d91bf3;p=collectd.git diff --git a/src/daemon/meta_data.c b/src/daemon/meta_data.c index 6ee8446b..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);