uint64_t metadata_id;
struct consumer_relayd_sock_pair *relayd = NULL;
+ /* RCU lock for the relayd pointer */
+ rcu_read_lock();
+
/* Flag that the current stream if set for network streaming. */
if (stream->net_seq_idx != -1) {
relayd = consumer_find_relayd(stream->net_seq_idx);
goto end;
}
- /* RCU lock for the relayd pointer */
- rcu_read_lock();
-
/* Handle stream on the relayd if the output is on the network */
if (relayd) {
+ unsigned long netlen = len;
+
/*
* Lock the control socket for the complete duration of the function
* since from this point on we will use the socket.
if (stream->metadata_flag) {
/* Metadata requires the control socket. */
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
+ netlen += sizeof(stream->relayd_stream_id);
}
- ret = consumer_handle_stream_before_relayd(stream, len);
+ ret = consumer_handle_stream_before_relayd(stream, netlen);
if (ret >= 0) {
/* Use the returned socket. */
outfd = ret;
uint64_t metadata_id;
struct consumer_relayd_sock_pair *relayd = NULL;
+ /* RCU lock for the relayd pointer */
+ rcu_read_lock();
+
/* Flag that the current stream if set for network streaming. */
if (stream->net_seq_idx != -1) {
relayd = consumer_find_relayd(stream->net_seq_idx);
}
}
- /* RCU lock for the relayd pointer */
- rcu_read_lock();
-
/* Write metadata stream id before payload */
if (stream->metadata_flag && relayd) {
/*
return -ENOENT;
}
+ /* relayd needs RCU read-side protection */
+ rcu_read_lock();
+
switch (msg.cmd_type) {
case LTTNG_CONSUMER_ADD_RELAYD_SOCKET:
{
ret = write(ctx->consumer_poll_pipe[1], "", 1);
} while (ret < 0 && errno == EINTR);
end_nosignal:
+ rcu_read_unlock();
return 0;
}