This cleans-up the error handling of the case handling the
LTTNG_CONSUMER_ADD_STREAM command. This is done in order to allow a
follow-up commit to perform some common clean-up operations on error
while introducing as few changes as possible.
No behaviour change is intended beyond additional calls to
health_code_update() in some code paths which should have no impact.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
ret = consumer_send_status_msg(sock, ret_code);
if (ret < 0) {
/* Somehow, the session daemon is not responding anymore. */
ret = consumer_send_status_msg(sock, ret_code);
if (ret < 0) {
/* Somehow, the session daemon is not responding anymore. */
+ goto error_add_stream_fatal;
}
health_code_update();
if (ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
/* Channel was not found. */
}
health_code_update();
if (ret_code != LTTCOMM_CONSUMERD_SUCCESS) {
/* Channel was not found. */
+ goto error_add_stream_nosignal;
ret = lttng_consumer_poll_socket(consumer_sockpoll);
health_poll_exit();
if (ret) {
ret = lttng_consumer_poll_socket(consumer_sockpoll);
health_poll_exit();
if (ret) {
+ goto error_add_stream_fatal;
ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1);
if (ret != sizeof(fd)) {
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD);
ret = lttcomm_recv_fds_unix_sock(sock, &fd, 1);
if (ret != sizeof(fd)) {
lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_ERROR_RECV_FD);
- rcu_read_unlock();
- return ret;
ret = consumer_send_status_msg(sock, ret_code);
if (ret < 0) {
/* Somehow, the session daemon is not responding anymore. */
ret = consumer_send_status_msg(sock, ret_code);
if (ret < 0) {
/* Somehow, the session daemon is not responding anymore. */
+ goto error_add_stream_nosignal;
break;
}
pthread_mutex_unlock(&channel->lock);
break;
}
pthread_mutex_unlock(&channel->lock);
+ goto error_add_stream_nosignal;
}
new_stream->chan = channel;
}
new_stream->chan = channel;
if (ret < 0) {
pthread_mutex_unlock(&channel->lock);
ERR("Failed to get kernel maximal subbuffer size");
if (ret < 0) {
pthread_mutex_unlock(&channel->lock);
ERR("Failed to get kernel maximal subbuffer size");
+ goto error_add_stream_nosignal;
}
consumer_stream_update_channel_attributes(new_stream,
}
consumer_stream_update_channel_attributes(new_stream,
ret = utils_create_pipe(new_stream->splice_pipe);
if (ret < 0) {
pthread_mutex_unlock(&channel->lock);
ret = utils_create_pipe(new_stream->splice_pipe);
if (ret < 0) {
pthread_mutex_unlock(&channel->lock);
+ goto error_add_stream_nosignal;
}
break;
case CONSUMER_CHANNEL_MMAP:
}
break;
case CONSUMER_CHANNEL_MMAP:
default:
ERR("Stream output unknown %d", channel->output);
pthread_mutex_unlock(&channel->lock);
default:
ERR("Stream output unknown %d", channel->output);
pthread_mutex_unlock(&channel->lock);
+ goto error_add_stream_nosignal;
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
consumer_stream_free(new_stream);
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
consumer_stream_free(new_stream);
+ goto error_add_stream_nosignal;
}
}
health_code_update();
}
}
health_code_update();
cds_list_add(&new_stream->send_node, &channel->streams.head);
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
cds_list_add(&new_stream->send_node, &channel->streams.head);
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
}
/* Send stream to relayd if the stream has an ID. */
}
/* Send stream to relayd if the stream has an ID. */
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
consumer_stream_free(new_stream);
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
consumer_stream_free(new_stream);
+ goto error_add_stream_nosignal;
if (ret < 0) {
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
if (ret < 0) {
pthread_mutex_unlock(&new_stream->lock);
pthread_mutex_unlock(&channel->lock);
+ goto error_add_stream_nosignal;
} else {
consumer_del_stream_for_data(new_stream);
}
} else {
consumer_del_stream_for_data(new_stream);
}
+ goto error_add_stream_nosignal;
}
DBG("Kernel consumer ADD_STREAM %s (fd: %d) %s with relayd id %" PRIu64,
new_stream->name, fd, new_stream->chan->pathname, new_stream->relayd_stream_id);
}
DBG("Kernel consumer ADD_STREAM %s (fd: %d) %s with relayd id %" PRIu64,
new_stream->name, fd, new_stream->chan->pathname, new_stream->relayd_stream_id);
+error_add_stream_nosignal:
+ goto end_nosignal;
+error_add_stream_fatal:
+ goto error_fatal;
}
case LTTNG_CONSUMER_STREAMS_SENT:
{
}
case LTTNG_CONSUMER_STREAMS_SENT:
{
/*
* Return 1 to indicate success since the 0 value can be a socket
* shutdown during the recv() or send() call.
*/
/*
* Return 1 to indicate success since the 0 value can be a socket
* shutdown during the recv() or send() call.
*/
- health_code_update();
- return 1;
-
+ ret = 1;
+ goto end;
+error_fatal:
+ /* This will issue a consumer stop. */
+ ret = -1;
+ goto end;
end_msg_sessiond:
/*
* The returned value here is not useful since either way we'll return 1 to
end_msg_sessiond:
/*
* The returned value here is not useful since either way we'll return 1 to
if (ret < 0) {
goto error_fatal;
}
if (ret < 0) {
goto error_fatal;
}
-
- return 1;
-
-error_fatal:
- /* This will issue a consumer stop. */
- return -1;