}
chan->chan->ops = &transport->ops;
memcpy(&chan->attr, attr, sizeof(chan->attr));
+ chan->wait_fd = ustctl_channel_get_wait_fd(chan);
+ chan->wakeup_fd = ustctl_channel_get_wakeup_fd(chan);
return chan;
chan_error:
int ustctl_channel_close_wait_fd(struct ustctl_consumer_channel *consumer_chan)
{
struct channel *chan;
+ int ret;
chan = consumer_chan->chan->chan;
- return ring_buffer_channel_close_wait_fd(&chan->backend.config,
+ ret = ring_buffer_channel_close_wait_fd(&chan->backend.config,
chan, chan->handle);
+ if (!ret)
+ consumer_chan->wait_fd = -1;
+ return ret;
}
int ustctl_channel_close_wakeup_fd(struct ustctl_consumer_channel *consumer_chan)
{
struct channel *chan;
+ int ret;
chan = consumer_chan->chan->chan;
- return ring_buffer_channel_close_wakeup_fd(&chan->backend.config,
+ ret = ring_buffer_channel_close_wakeup_fd(&chan->backend.config,
chan, chan->handle);
+ if (!ret)
+ consumer_chan->wakeup_fd = -1;
+ return ret;
}
int ustctl_stream_close_wait_fd(struct ustctl_consumer_stream *stream)
DEFINE_URCU_TLS(unsigned int, lib_ring_buffer_nesting);
+/*
+ * wakeup_fd_mutex protects wakeup fd use by timer from concurrent
+ * close.
+ */
+static pthread_mutex_t wakeup_fd_mutex = PTHREAD_MUTEX_INITIALIZER;
+
static
void lib_ring_buffer_print_errors(struct channel *chan,
struct lttng_ust_lib_ring_buffer *buf, int cpu,
DBG("Timer for channel %p\n", chan);
+ pthread_mutex_lock(&wakeup_fd_mutex);
if (config->alloc == RING_BUFFER_ALLOC_PER_CPU) {
for_each_possible_cpu(cpu) {
struct lttng_ust_lib_ring_buffer *buf =
lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE,
chan->handle);
}
+ pthread_mutex_unlock(&wakeup_fd_mutex);
return;
}
int cpu)
{
struct shm_ref *ref;
+ int ret;
if (config->alloc == RING_BUFFER_ALLOC_GLOBAL) {
cpu = 0;
return -EINVAL;
}
ref = &chan->backend.buf[cpu].shmp._ref;
- return shm_close_wakeup_fd(handle, ref);
+ pthread_mutex_lock(&wakeup_fd_mutex);
+ ret = shm_close_wakeup_fd(handle, ref);
+ pthread_mutex_unlock(&wakeup_fd_mutex);
+ return ret;
}
int lib_ring_buffer_open_read(struct lttng_ust_lib_ring_buffer *buf,