X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer%2Fconsumer-metadata-cache.c;h=82221717491c4e215e401d81fc0eebd8e66fe310;hp=ac83443a9500856f17230563511bba6270dd00c7;hb=e2d1190b9ea09c54e5d7373643d62e2034bc1531;hpb=5b8eb761b650749a164de120f014b0cb6c218cf2 diff --git a/src/common/consumer/consumer-metadata-cache.c b/src/common/consumer/consumer-metadata-cache.c index ac83443a9..822217174 100644 --- a/src/common/consumer/consumer-metadata-cache.c +++ b/src/common/consumer/consumer-metadata-cache.c @@ -1,19 +1,9 @@ /* - * Copyright (C) 2013 - Julien Desfossez - * David Goulet + * Copyright (C) 2013 Julien Desfossez + * Copyright (C) 2013 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: GPL-2.0-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _LGPL_SOURCE @@ -89,7 +79,7 @@ void metadata_cache_reset(struct consumer_metadata_cache *cache) */ static int metadata_cache_check_version(struct consumer_metadata_cache *cache, - struct lttng_consumer_channel *channel, uint64_t version) + uint64_t version) { int ret = 0; @@ -120,10 +110,20 @@ int consumer_metadata_wakeup_pipe(const struct lttng_consumer_channel *channel) write_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1], &dummy, 1); if (write_ret < 1) { - PERROR("Wake-up UST metadata pipe"); - ret = -1; - goto end; - } + if (errno == EWOULDBLOCK) { + /* + * This is fine, the metadata poll thread + * is having a hard time keeping-up, but + * it will eventually wake-up and consume + * the available data. + */ + ret = 0; + } else { + PERROR("Wake-up UST metadata pipe"); + ret = -1; + goto end; + } + } } end: @@ -150,7 +150,7 @@ int consumer_metadata_cache_write(struct lttng_consumer_channel *channel, cache = channel->metadata_cache; - ret = metadata_cache_check_version(cache, channel, version); + ret = metadata_cache_check_version(cache, version); if (ret < 0) { goto end; } @@ -263,17 +263,20 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, pthread_mutex_lock(&channel->lock); } pthread_mutex_lock(&channel->timer_lock); - pthread_mutex_lock(&channel->metadata_cache->lock); - metadata_stream = channel->metadata_stream; - if (!metadata_stream) { /* * Having no metadata stream means the channel is being destroyed so there * is no cache to flush anymore. */ ret = 0; - } else if (metadata_stream->ust_metadata_pushed >= offset) { + goto end_unlock_channel; + } + + pthread_mutex_lock(&metadata_stream->lock); + pthread_mutex_lock(&channel->metadata_cache->lock); + + if (metadata_stream->ust_metadata_pushed >= offset) { ret = 0; } else if (channel->metadata_stream->endpoint_status != CONSUMER_ENDPOINT_ACTIVE) { @@ -285,6 +288,8 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, } pthread_mutex_unlock(&channel->metadata_cache->lock); + pthread_mutex_unlock(&metadata_stream->lock); +end_unlock_channel: pthread_mutex_unlock(&channel->timer_lock); if (!timer) { pthread_mutex_unlock(&channel->lock);