struct lttng_consumer_channel *channel =
caa_container_of(node, struct lttng_consumer_channel, node);
+ switch (consumer_data.type) {
+ case LTTNG_CONSUMER_KERNEL:
+ break;
+ case LTTNG_CONSUMER32_UST:
+ case LTTNG_CONSUMER64_UST:
+ lttng_ustconsumer_free_channel(channel);
+ break;
+ default:
+ ERR("Unknown consumer_data type");
+ abort();
+ }
free(channel);
}
/*
* Allocate and return a consumer relayd socket.
*/
-struct consumer_relayd_sock_pair *consumer_allocate_relayd_sock_pair(
+static struct consumer_relayd_sock_pair *consumer_allocate_relayd_sock_pair(
uint64_t net_seq_idx)
{
struct consumer_relayd_sock_pair *obj = NULL;
}
if (pollfd == lttng_pipe_get_readfd(ctx->consumer_metadata_pipe)) {
- if (revents & (LPOLLERR | LPOLLHUP )) {
- DBG("Metadata thread pipe hung up");
- /*
- * Remove the pipe from the poll set and continue the loop
- * since their might be data to consume.
- */
- lttng_poll_del(&events,
- lttng_pipe_get_readfd(ctx->consumer_metadata_pipe));
- lttng_pipe_read_close(ctx->consumer_metadata_pipe);
- continue;
- } else if (revents & LPOLLIN) {
+ if (revents & LPOLLIN) {
ssize_t pipe_len;
pipe_len = lttng_pipe_read(ctx->consumer_metadata_pipe,
&stream, sizeof(stream));
if (pipe_len < sizeof(stream)) {
- PERROR("read metadata stream");
+ if (pipe_len < 0) {
+ PERROR("read metadata stream");
+ }
/*
- * Continue here to handle the rest of the streams.
+ * Remove the pipe from the poll set and continue the loop
+ * since their might be data to consume.
*/
+ lttng_poll_del(&events,
+ lttng_pipe_get_readfd(ctx->consumer_metadata_pipe));
+ lttng_pipe_read_close(ctx->consumer_metadata_pipe);
continue;
}
/* Add metadata stream to the global poll events list */
lttng_poll_add(&events, stream->wait_fd,
LPOLLIN | LPOLLPRI | LPOLLHUP);
+ } else if (revents & (LPOLLERR | LPOLLHUP)) {
+ DBG("Metadata thread pipe hung up");
+ /*
+ * Remove the pipe from the poll set and continue the loop
+ * since their might be data to consume.
+ */
+ lttng_poll_del(&events,
+ lttng_pipe_get_readfd(ctx->consumer_metadata_pipe));
+ lttng_pipe_read_close(ctx->consumer_metadata_pipe);
+ continue;
+ } else {
+ ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ goto end;
}
/* Handle other stream */
stream = caa_container_of(node, struct lttng_consumer_stream,
node);
- /* Check for error event */
- if (revents & (LPOLLERR | LPOLLHUP)) {
+ if (revents & (LPOLLIN | LPOLLPRI)) {
+ /* Get the data out of the metadata file descriptor */
+ DBG("Metadata available on fd %d", pollfd);
+ assert(stream->wait_fd == pollfd);
+
+ do {
+ health_code_update();
+
+ len = ctx->on_buffer_ready(stream, ctx);
+ /*
+ * We don't check the return value here since if we get
+ * a negative len, it means an error occured thus we
+ * simply remove it from the poll set and free the
+ * stream.
+ */
+ } while (len > 0);
+
+ /* It's ok to have an unavailable sub-buffer */
+ if (len < 0 && len != -EAGAIN && len != -ENODATA) {
+ /* Clean up stream from consumer and free it. */
+ lttng_poll_del(&events, stream->wait_fd);
+ consumer_del_metadata_stream(stream, metadata_ht);
+ }
+ } else if (revents & (LPOLLERR | LPOLLHUP)) {
DBG("Metadata fd %d is hup|err.", pollfd);
if (!stream->hangup_flush_done
&& (consumer_data.type == LTTNG_CONSUMER32_UST
* and securely free the stream.
*/
consumer_del_metadata_stream(stream, metadata_ht);
- } else if (revents & (LPOLLIN | LPOLLPRI)) {
- /* Get the data out of the metadata file descriptor */
- DBG("Metadata available on fd %d", pollfd);
- assert(stream->wait_fd == pollfd);
-
- do {
- health_code_update();
-
- len = ctx->on_buffer_ready(stream, ctx);
- /*
- * We don't check the return value here since if we get
- * a negative len, it means an error occured thus we
- * simply remove it from the poll set and free the
- * stream.
- */
- } while (len > 0);
-
- /* It's ok to have an unavailable sub-buffer */
- if (len < 0 && len != -EAGAIN && len != -ENODATA) {
- /* Clean up stream from consumer and free it. */
- lttng_poll_del(&events, stream->wait_fd);
- consumer_del_metadata_stream(stream, metadata_ht);
- }
+ } else {
+ ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ rcu_read_unlock();
+ goto end;
}
-
/* Release RCU lock for the stream looked up */
rcu_read_unlock();
}
}
if (pollfd == ctx->consumer_channel_pipe[0]) {
- if (revents & (LPOLLERR | LPOLLHUP)) {
- DBG("Channel thread pipe hung up");
- /*
- * Remove the pipe from the poll set and continue the loop
- * since their might be data to consume.
- */
- lttng_poll_del(&events, ctx->consumer_channel_pipe[0]);
- continue;
- } else if (revents & LPOLLIN) {
+ if (revents & LPOLLIN) {
enum consumer_channel_action action;
uint64_t key;
ret = read_channel_pipe(ctx, &chan, &key, &action);
if (ret <= 0) {
- ERR("Error reading channel pipe");
+ if (ret < 0) {
+ ERR("Error reading channel pipe");
+ }
+ lttng_poll_del(&events, ctx->consumer_channel_pipe[0]);
continue;
}
rcu_read_unlock();
/* Add channel to the global poll events list */
lttng_poll_add(&events, chan->wait_fd,
- LPOLLIN | LPOLLPRI);
+ LPOLLERR | LPOLLHUP);
break;
case CONSUMER_CHANNEL_DEL:
{
ERR("Unknown action");
break;
}
+ } else if (revents & (LPOLLERR | LPOLLHUP)) {
+ DBG("Channel thread pipe hung up");
+ /*
+ * Remove the pipe from the poll set and continue the loop
+ * since their might be data to consume.
+ */
+ lttng_poll_del(&events, ctx->consumer_channel_pipe[0]);
+ continue;
+ } else {
+ ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ goto end;
}
/* Handle other stream */
&& !uatomic_read(&chan->nb_init_stream_left)) {
consumer_del_channel(chan);
}
+ } else {
+ ERR("Unexpected poll events %u for sock %d", revents, pollfd);
+ rcu_read_unlock();
+ goto end;
}
/* Release RCU lock for the channel looked up */