lttng-sessiond: do not call ustctl_register_done()
[lttng-tools.git] / liblttng-consumer / lttng-consumer.c
index 293d5f808ea0d2f68d441554563b239911fd02b8..0811e68ca8e8368c7695f92f37a44c906b42b7c0 100644 (file)
@@ -129,7 +129,8 @@ void consumer_del_stream(struct lttng_consumer_stream *stream)
                        }
                }
                break;
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                lttng_ustconsumer_del_stream(stream);
                break;
        default:
@@ -173,12 +174,14 @@ struct lttng_consumer_stream *consumer_allocate_stream(
                enum lttng_consumer_stream_state state,
                uint64_t mmap_len,
                enum lttng_event_output output,
-               const char *path_name)
+               const char *path_name,
+               uid_t uid,
+               gid_t gid)
 {
        struct lttng_consumer_stream *stream;
        int ret;
 
-       stream = malloc(sizeof(*stream));
+       stream = zmalloc(sizeof(*stream));
        if (stream == NULL) {
                perror("malloc struct lttng_consumer_stream");
                goto end;
@@ -198,13 +201,16 @@ struct lttng_consumer_stream *consumer_allocate_stream(
        stream->mmap_len = mmap_len;
        stream->mmap_base = NULL;
        stream->output = output;
+       stream->uid = uid;
+       stream->gid = gid;
        strncpy(stream->path_name, path_name, PATH_MAX - 1);
        stream->path_name[PATH_MAX - 1] = '\0';
 
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                break;
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                stream->cpu = stream->chan->cpucount++;
                ret = lttng_ustconsumer_allocate_stream(stream);
                if (ret) {
@@ -244,7 +250,8 @@ int consumer_add_stream(struct lttng_consumer_stream *stream)
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                break;
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                /* Streams are in CPU number order (we rely on this) */
                stream->cpu = stream->chan->nr_streams++;
                break;
@@ -289,7 +296,8 @@ void consumer_del_channel(struct lttng_consumer_channel *channel)
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                break;
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                lttng_ustconsumer_del_channel(channel);
                break;
        default:
@@ -344,7 +352,8 @@ struct lttng_consumer_channel *consumer_allocate_channel(
                channel->mmap_base = NULL;
                channel->mmap_len = 0;
                break;
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                ret = lttng_ustconsumer_allocate_channel(channel);
                if (ret) {
                        free(channel);
@@ -574,7 +583,7 @@ struct lttng_consumer_local_data *lttng_consumer_create(
                consumer_data.type == type);
        consumer_data.type = type;
 
-       ctx = malloc(sizeof(struct lttng_consumer_local_data));
+       ctx = zmalloc(sizeof(struct lttng_consumer_local_data));
        if (ctx == NULL) {
                perror("allocating context");
                goto error;
@@ -656,7 +665,8 @@ int lttng_consumer_on_read_subbuffer_mmap(
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_on_read_subbuffer_mmap(ctx, stream, len);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return lttng_ustconsumer_on_read_subbuffer_mmap(ctx, stream, len);
        default:
                ERR("Unknown consumer_data type");
@@ -676,7 +686,8 @@ int lttng_consumer_on_read_subbuffer_splice(
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_on_read_subbuffer_splice(ctx, stream, len);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return -ENOSYS;
        default:
                ERR("Unknown consumer_data type");
@@ -697,7 +708,8 @@ int lttng_consumer_take_snapshot(struct lttng_consumer_local_data *ctx,
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_take_snapshot(ctx, stream);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return lttng_ustconsumer_take_snapshot(ctx, stream);
        default:
                ERR("Unknown consumer_data type");
@@ -720,7 +732,8 @@ int lttng_consumer_get_produced_snapshot(
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_get_produced_snapshot(ctx, stream, pos);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return lttng_ustconsumer_get_produced_snapshot(ctx, stream, pos);
        default:
                ERR("Unknown consumer_data type");
@@ -735,7 +748,8 @@ int lttng_consumer_recv_cmd(struct lttng_consumer_local_data *ctx,
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_recv_cmd(ctx, sock, consumer_sockpoll);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return lttng_ustconsumer_recv_cmd(ctx, sock, consumer_sockpoll);
        default:
                ERR("Unknown consumer_data type");
@@ -760,7 +774,7 @@ void *lttng_consumer_thread_poll_fds(void *data)
        int tmp2;
        struct lttng_consumer_local_data *ctx = data;
 
-       local_stream = malloc(sizeof(struct lttng_consumer_stream));
+       local_stream = zmalloc(sizeof(struct lttng_consumer_stream));
 
        while (1) {
                high_prio = 0;
@@ -782,7 +796,7 @@ void *lttng_consumer_thread_poll_fds(void *data)
                        }
 
                        /* allocate for all fds + 1 for the consumer_poll_pipe */
-                       pollfd = malloc((consumer_data.stream_count + 1) * sizeof(struct pollfd));
+                       pollfd = zmalloc((consumer_data.stream_count + 1) * sizeof(struct pollfd));
                        if (pollfd == NULL) {
                                perror("pollfd malloc");
                                pthread_mutex_unlock(&consumer_data.lock);
@@ -790,7 +804,7 @@ void *lttng_consumer_thread_poll_fds(void *data)
                        }
 
                        /* allocate for all fds + 1 for the consumer_poll_pipe */
-                       local_stream = malloc((consumer_data.stream_count + 1) *
+                       local_stream = zmalloc((consumer_data.stream_count + 1) *
                                        sizeof(struct lttng_consumer_stream));
                        if (local_stream == NULL) {
                                perror("local_stream malloc");
@@ -862,17 +876,16 @@ void *lttng_consumer_thread_poll_fds(void *data)
                                num_hup++;
                        } else if ((pollfd[i].revents & POLLHUP) &&
                                        !(pollfd[i].revents & POLLIN)) {
-                               if (consumer_data.type == LTTNG_CONSUMER_UST) {
+                               if (consumer_data.type == LTTNG_CONSUMER32_UST
+                                               || consumer_data.type == LTTNG_CONSUMER64_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;
-                                               }
+                                               /* read after flush */
+                                               do {
+                                                       ret = ctx->on_buffer_ready(local_stream[i], ctx);
+                                               } while (ret == EAGAIN);
                                        }
                                } else {
                                        DBG("Polling fd %d tells it has hung up.", pollfd[i].fd);
@@ -1036,7 +1049,8 @@ int lttng_consumer_read_subbuffer(struct lttng_consumer_stream *stream,
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_read_subbuffer(stream, ctx);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return lttng_ustconsumer_read_subbuffer(stream, ctx);
        default:
                ERR("Unknown consumer_data type");
@@ -1050,7 +1064,8 @@ int lttng_consumer_on_recv_stream(struct lttng_consumer_stream *stream)
        switch (consumer_data.type) {
        case LTTNG_CONSUMER_KERNEL:
                return lttng_kconsumer_on_recv_stream(stream);
-       case LTTNG_CONSUMER_UST:
+       case LTTNG_CONSUMER32_UST:
+       case LTTNG_CONSUMER64_UST:
                return lttng_ustconsumer_on_recv_stream(stream);
        default:
                ERR("Unknown consumer_data type");
This page took 0.025638 seconds and 4 git commands to generate.