X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=be984a49270fefbba0b55bccd8ebf897ceea4ce7;hb=bb63afd9d236f8aa96935ce21f415d76452187e2;hp=16521a8b863788fd957b756d7c4882f6b3c5abbd;hpb=8fa0b55b4931b9b5294120b20259be73b0b87ad5;p=lttng-tools.git diff --git a/src/common/consumer.c b/src/common/consumer.c index 16521a8b8..be984a492 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -1435,7 +1435,13 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( } while (ret < 0 && errno == EINTR); DBG("Consumer mmap write() ret %zd (len %lu)", ret, len); if (ret < 0) { - PERROR("Error in file write"); + /* + * This is possible if the fd is closed on the other side (outfd) + * or any write problem. It can be verbose a bit for a normal + * execution if for instance the relayd is stopped abruptly. This + * can happen so set this to a DBG statement. + */ + DBG("Error in file write mmap"); if (written == 0) { written = ret; } @@ -2101,17 +2107,13 @@ void *consumer_thread_metadata_poll(void *data) DBG("Metadata main loop started"); while (1) { - lttng_poll_reset(&events); - - nb_fd = LTTNG_POLL_GETNB(&events); - /* Only the metadata pipe is set */ - if (nb_fd == 0 && consumer_quit == 1) { + if (LTTNG_POLL_GETNB(&events) == 0 && consumer_quit == 1) { goto end; } restart: - DBG("Metadata poll wait with %d fd(s)", nb_fd); + DBG("Metadata poll wait with %d fd(s)", LTTNG_POLL_GETNB(&events)); ret = lttng_poll_wait(&events, -1); DBG("Metadata event catched in thread"); if (ret < 0) { @@ -2122,6 +2124,8 @@ restart: goto error; } + nb_fd = ret; + /* From here, the event is a metadata wait fd */ for (i = 0; i < nb_fd; i++) { revents = LTTNG_POLL_GETEV(&events, i); @@ -2366,6 +2370,11 @@ void *consumer_thread_data_poll(void *data) pipe_readlen = read(ctx->consumer_data_pipe[0], &new_stream, sizeof(new_stream)); } while (pipe_readlen == -1 && errno == EINTR); + if (pipe_readlen < 0) { + PERROR("read consumer data pipe"); + /* Continue so we can at least handle the current stream(s). */ + continue; + } /* * If the stream is NULL, just ignore it. It's also possible that @@ -3008,7 +3017,8 @@ int consumer_data_pending(uint64_t id) if (relayd) { pthread_mutex_lock(&relayd->ctrl_sock_mutex); if (stream->metadata_flag) { - ret = relayd_quiescent_control(&relayd->control_sock); + ret = relayd_quiescent_control(&relayd->control_sock, + stream->relayd_stream_id); } else { ret = relayd_data_pending(&relayd->control_sock, stream->relayd_stream_id, stream->next_net_seq_num); @@ -3030,10 +3040,12 @@ int consumer_data_pending(uint64_t id) ret = relayd_end_data_pending(&relayd->control_sock, relayd->relayd_session_id, &is_data_inflight); pthread_mutex_unlock(&relayd->ctrl_sock_mutex); - if (ret < 0 || !is_data_inflight) { - /* On error or if NO data inflight, no data is pending. */ + if (ret < 0) { goto data_not_pending; } + if (is_data_inflight) { + goto data_pending; + } } /*