X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fust-consumer%2Fust-consumer.c;h=2b55fd4637ead2b056fcafecc47ef5504d7c5df5;hb=5a4b955ed97bb0802977e50f1aa409f0bb4729ec;hp=04c6157e532d84e9cebe3c341d764a2647f0aeb2;hpb=f5204c9440be52e1b17bbb2c82450277ec02a583;p=lttng-tools.git diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 04c6157e5..2b55fd463 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -2,36 +2,36 @@ * Copyright (C) 2011 - Julien Desfossez * Mathieu Desnoyers * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; only version 2 - * of the License. + * 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. * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * 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 _GNU_SOURCE #include -#include #include #include #include #include #include #include +#include #include #include #include #include #include +#include #include "ust-consumer.h" @@ -58,7 +58,7 @@ ssize_t lttng_ustconsumer_on_read_subbuffer_mmap( stream->buf, &mmap_offset); if (ret != 0) { errno = -ret; - perror("ustctl_get_mmap_read_offset"); + PERROR("ustctl_get_mmap_read_offset"); goto end; } while (len > 0) { @@ -67,11 +67,11 @@ ssize_t lttng_ustconsumer_on_read_subbuffer_mmap( len = 0; } else if (ret < 0) { errno = -ret; - perror("Error in file write"); + PERROR("Error in file write"); goto end; } /* This won't block, but will start writeout asynchronously */ - sync_file_range(outfd, stream->out_fd_offset, ret, + lttng_sync_file_range(outfd, stream->out_fd_offset, ret, SYNC_FILE_RANGE_WRITE); stream->out_fd_offset += ret; } @@ -109,7 +109,7 @@ int lttng_ustconsumer_take_snapshot(struct lttng_consumer_local_data *ctx, ret = ustctl_snapshot(stream->chan->handle, stream->buf); if (ret != 0) { errno = -ret; - perror("Getting sub-buffer snapshot."); + PERROR("Getting sub-buffer snapshot."); } return ret; @@ -131,7 +131,7 @@ int lttng_ustconsumer_get_produced_snapshot( stream->buf, pos); if (ret != 0) { errno = -ret; - perror("kernctl_snapshot_get_produced"); + PERROR("kernctl_snapshot_get_produced"); } return ret; @@ -257,11 +257,20 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, break; } end: - /* signal the poll thread */ - ret = write(ctx->consumer_poll_pipe[1], "4", 1); - if (ret < 0) { - perror("write consumer poll"); - } + /* + * Wake-up the other end by writing a null byte in the pipe + * (non-blocking). Important note: Because writing into the + * pipe is non-blocking (and therefore we allow dropping wakeup + * data, as long as there is wakeup data present in the pipe + * buffer to wake up the other end), the other end should + * perform the following sequence for waiting: + * 1) empty the pipe (reads). + * 2) perform update operation. + * 3) wait on the pipe (poll). + */ + do { + ret = write(ctx->consumer_poll_pipe[1], "", 1); + } while (ret == -1UL && errno == EINTR); end_nosignal: return 0; } @@ -400,7 +409,7 @@ int lttng_ustconsumer_on_recv_stream(struct lttng_consumer_stream *stream) stream->uid, stream->gid); if (ret < 0) { ERR("Opening %s", stream->path_name); - perror("open"); + PERROR("open"); goto error; } stream->out_fd = ret;