uid_t uid,
gid_t gid,
int net_index,
- int metadata_flag)
+ int metadata_flag,
+ int *alloc_ret)
{
struct lttng_consumer_stream *stream;
int ret;
stream = zmalloc(sizeof(*stream));
if (stream == NULL) {
perror("malloc struct lttng_consumer_stream");
- goto end;
+ *alloc_ret = -ENOMEM;
+ return NULL;
}
stream->chan = consumer_find_channel(channel_key);
if (!stream->chan) {
- perror("Unable to find channel key");
- goto end;
+ *alloc_ret = -ENOENT;
+ goto error;
}
stream->chan->refcount++;
stream->key = stream_key;
stream->cpu = stream->chan->cpucount++;
ret = lttng_ustconsumer_allocate_stream(stream);
if (ret) {
- free(stream);
- return NULL;
+ *alloc_ret = -EINVAL;
+ goto error;
}
break;
default:
ERR("Unknown consumer_data type");
- assert(0);
- goto end;
+ *alloc_ret = -EINVAL;
+ goto error;
}
/*
stream->shm_fd, stream->wait_fd,
(unsigned long long) stream->mmap_len, stream->out_fd,
stream->net_seq_idx);
-
-end:
return stream;
+
+error:
+ free(stream);
+ return NULL;
}
/*
uid_t uid,
gid_t gid,
int net_index,
- int metadata_flag);
+ int metadata_flag,
+ int *alloc_ret);
extern int consumer_add_stream(struct lttng_consumer_stream *stream);
extern void consumer_del_stream(struct lttng_consumer_stream *stream);
extern void consumer_change_stream_state(int stream_key,
int fd;
struct consumer_relayd_sock_pair *relayd = NULL;
struct lttng_consumer_stream *new_stream;
+ int alloc_ret = 0;
/* block */
if (lttng_consumer_poll_socket(consumer_sockpoll) < 0) {
msg.u.stream.uid,
msg.u.stream.gid,
msg.u.stream.net_index,
- msg.u.stream.metadata_flag);
+ msg.u.stream.metadata_flag,
+ &alloc_ret);
if (new_stream == NULL) {
- lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
+ switch (alloc_ret) {
+ case -ENOMEM:
+ case -EINVAL:
+ default:
+ lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
+ break;
+ case -ENOENT:
+ /*
+ * We could not find the channel. Can happen if cpu hotplug
+ * happens while tearing down.
+ */
+ DBG3("Could not find channel");
+ break;
+ }
goto end_nosignal;
}
int fds[2];
size_t nb_fd = 2;
struct consumer_relayd_sock_pair *relayd = NULL;
+ int alloc_ret = 0;
DBG("UST Consumer adding stream");
msg.u.stream.uid,
msg.u.stream.gid,
msg.u.stream.net_index,
- msg.u.stream.metadata_flag);
+ msg.u.stream.metadata_flag,
+ &alloc_ret);
if (new_stream == NULL) {
- lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
+ switch (alloc_ret) {
+ case -ENOMEM:
+ case -EINVAL:
+ default:
+ lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
+ break;
+ case -ENOENT:
+ /*
+ * We could not find the channel. Can happen if cpu hotplug
+ * happens while tearing down.
+ */
+ DBG3("Could not find channel");
+ break;
+ }
goto end_nosignal;
}