X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fcommon%2Fust-consumer%2Fust-consumer.c;h=b2c454deb54302362806dd80180f9b235f29e33a;hb=f3a1fc7b3ab62e498d07546c7ada8e9a381125f5;hp=83b2143d727ca5aab4790d665ba229912a1501d6;hpb=d295668767ac8234e83984e1812d342d03293d88;p=lttng-tools.git diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 83b2143d7..b2c454deb 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -519,7 +519,8 @@ error_open: if (channel->root_shm_path[0]) { (void) run_as_rmdir_recursive(channel->root_shm_path, channel->buffer_credentials.value.uid, - channel->buffer_credentials.value.gid); + channel->buffer_credentials.value.gid, + LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG); } free(stream_fds); error_alloc: @@ -1590,7 +1591,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, if (!channel) { ERR("UST consumer get channel key %" PRIu64 " not found", key); ret_code = LTTCOMM_CONSUMERD_CHAN_NOT_FOUND; - goto end_msg_sessiond; + goto end_get_channel; } health_code_update(); @@ -1606,13 +1607,13 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, * and the consumer can continue its work. The above call * has sent the error status message to the sessiond. */ - goto end_nosignal; + goto end_get_channel_nosignal; } /* * The communicaton was broken hence there is a bad state between * the consumer and sessiond so stop everything. */ - goto error_fatal; + goto error_get_channel_fatal; } health_code_update(); @@ -1622,7 +1623,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, * so don't send them to the data thread. */ if (!channel->monitor) { - goto end_msg_sessiond; + goto end_get_channel; } ret = send_streams_to_thread(channel, ctx); @@ -1631,11 +1632,16 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, * If we are unable to send the stream to the thread, there is * a big problem so just stop everything. */ - goto error_fatal; + goto error_get_channel_fatal; } /* List MUST be empty after or else it could be reused. */ assert(cds_list_empty(&channel->streams.head)); +end_get_channel: goto end_msg_sessiond; +error_get_channel_fatal: + goto error_fatal; +end_get_channel_nosignal: + goto end_nosignal; } case LTTNG_CONSUMER_DESTROY_CHANNEL: { @@ -2008,8 +2014,8 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, case LTTNG_CONSUMER_CREATE_TRACE_CHUNK: { const struct lttng_credentials credentials = { - .uid = msg.u.create_trace_chunk.credentials.uid, - .gid = msg.u.create_trace_chunk.credentials.gid, + .uid = msg.u.create_trace_chunk.credentials.value.uid, + .gid = msg.u.create_trace_chunk.credentials.value.gid, }; const bool is_local_trace = !msg.u.create_trace_chunk.relayd_id.is_set; @@ -2062,9 +2068,12 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, !is_local_trace ? &relayd_id : NULL, msg.u.create_trace_chunk.session_id, msg.u.create_trace_chunk.chunk_id, - (time_t) msg.u.create_trace_chunk.creation_timestamp, + (time_t) msg.u.create_trace_chunk + .creation_timestamp, chunk_override_name, - &credentials, + msg.u.create_trace_chunk.credentials.is_set ? + &credentials : + NULL, chunk_directory_handle.is_set ? &chunk_directory_handle.value : NULL); @@ -2077,15 +2086,21 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } case LTTNG_CONSUMER_CLOSE_TRACE_CHUNK: { + enum lttng_trace_chunk_command_type close_command = + msg.u.close_trace_chunk.close_command.value; const uint64_t relayd_id = msg.u.close_trace_chunk.relayd_id.value; ret_code = lttng_consumer_close_trace_chunk( msg.u.close_trace_chunk.relayd_id.is_set ? - &relayd_id : NULL, + &relayd_id : + NULL, msg.u.close_trace_chunk.session_id, msg.u.close_trace_chunk.chunk_id, - (time_t) msg.u.close_trace_chunk.close_timestamp); + (time_t) msg.u.close_trace_chunk.close_timestamp, + msg.u.close_trace_chunk.close_command.is_set ? + &close_command : + NULL); goto end_msg_sessiond; } case LTTNG_CONSUMER_TRACE_CHUNK_EXISTS: @@ -2105,15 +2120,12 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx, } end_nosignal: - rcu_read_unlock(); - - health_code_update(); - /* * Return 1 to indicate success since the 0 value can be a socket * shutdown during the recv() or send() call. */ - return 1; + ret = 1; + goto end; end_msg_sessiond: /* @@ -2125,11 +2137,9 @@ end_msg_sessiond: if (ret < 0) { goto error_fatal; } - rcu_read_unlock(); - - health_code_update(); + ret = 1; + goto end; - return 1; end_channel_error: if (channel) { pthread_mutex_unlock(&channel->lock); @@ -2145,15 +2155,18 @@ end_channel_error: /* Stop everything if session daemon can not be notified. */ goto error_fatal; } - rcu_read_unlock(); - - health_code_update(); + ret = 1; + goto end; - return 1; error_fatal: - rcu_read_unlock(); /* This will issue a consumer stop. */ - return -1; + ret = -1; + goto end; + +end: + rcu_read_unlock(); + health_code_update(); + return ret; } /* @@ -2340,7 +2353,8 @@ void lttng_ustconsumer_free_channel(struct lttng_consumer_channel *chan) if (chan->root_shm_path[0]) { (void) run_as_rmdir_recursive(chan->root_shm_path, chan->buffer_credentials.value.uid, - chan->buffer_credentials.value.gid); + chan->buffer_credentials.value.gid, + LTTNG_DIRECTORY_HANDLE_SKIP_NON_EMPTY_FLAG); } free(chan->stream_fds); } @@ -2513,6 +2527,13 @@ int commit_one_metadata_packet(struct lttng_consumer_stream *stream) stream->ust_metadata_pushed); ret = write_len; + /* + * Switch packet (but don't open the next one) on every commit of + * a metadata packet. Since the subbuffer is fully filled (with padding, + * if needed), the stream is "quiescent" after this commit. + */ + ustctl_flush_buffer(stream->ustream, 1); + stream->quiescent = true; end: pthread_mutex_unlock(&stream->chan->metadata_cache->lock); return ret; @@ -2557,7 +2578,6 @@ int lttng_ustconsumer_sync_metadata(struct lttng_consumer_local_data *ctx, retry = 1; } - ustctl_flush_buffer(metadata->ustream, 1); ret = ustctl_snapshot(metadata->ustream); if (ret < 0) { if (errno != EAGAIN) { @@ -2761,7 +2781,6 @@ retry: if (ret <= 0) { goto error; } - ustctl_flush_buffer(stream->ustream, 1); goto retry; }