X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=liblttng-consumer%2Flttng-consumer.c;h=c7c7b7a7e4db220f8cbb512cb976746213e24dbe;hp=7644eac2cefccb7d223c8310c81f7289864f4461;hb=3a009adbd8bf5305668e7e41e5e9f12813d04959;hpb=d41f73b7cb50d57974bd1fad22342abaf9718566 diff --git a/liblttng-consumer/lttng-consumer.c b/liblttng-consumer/lttng-consumer.c index 7644eac2c..c7c7b7a7e 100644 --- a/liblttng-consumer/lttng-consumer.c +++ b/liblttng-consumer/lttng-consumer.c @@ -305,7 +305,7 @@ struct lttng_consumer_channel *consumer_allocate_channel( struct lttng_consumer_channel *channel; int ret; - channel = malloc(sizeof(*channel)); + channel = zmalloc(sizeof(*channel)); if (channel == NULL) { perror("malloc struct lttng_consumer_channel"); goto end; @@ -845,9 +845,23 @@ void *lttng_consumer_thread_poll_fds(void *data) ERR("Polling fd %d tells fd is not open.", pollfd[i].fd); consumer_del_stream(local_stream[i]); num_hup++; - } else if ((pollfd[i].revents & POLLHUP && - !(pollfd[i].revents & POLLIN))) { - DBG("Polling fd %d tells it has hung up.", pollfd[i].fd); + } else if ((pollfd[i].revents & POLLHUP) && + !(pollfd[i].revents & POLLIN)) { + if (consumer_data.type == LTTNG_CONSUMER_UST) { + DBG("Polling fd %d tells it has hung up. Attempting flush and read.", + pollfd[i].fd); + if (!local_stream[i]->hangup_flush_done) { + lttng_ustconsumer_on_stream_hangup(local_stream[i]); + /* try reading after flush */ + ret = ctx->on_buffer_ready(local_stream[i], ctx); + /* it's ok to have an unavailable sub-buffer */ + if (ret == EAGAIN) { + ret = 0; + } + } + } else { + DBG("Polling fd %d tells it has hung up.", pollfd[i].fd); + } consumer_del_stream(local_stream[i]); num_hup++; }