From aa95faca6cb7a9af8ef2edf696a296b0eac6704c Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 31 Jan 2019 16:54:32 -0500 Subject: [PATCH] Bound maximum data read to RECV_DATA_BUFFER_SIZE per iteration Do not consume everything all at once even if there is data left on the socket. This is to provide fairness to the overall data handling of all connections. It also provide a bounded processing execution for a data processing iteration. Signed-off-by: Jonathan Rajotte --- src/bin/lttng-relayd/main.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 19b1342ac..1da631487 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2834,7 +2834,6 @@ static enum relay_connection_status relay_process_data_receive_payload( &conn->protocol.data.state.receive_payload; const size_t chunk_size = RECV_DATA_BUFFER_SIZE; char data_buffer[chunk_size]; - bool partial_recv = false; bool new_stream = false, close_requested = false; uint64_t left_to_receive = state->left_to_receive; struct relay_session *session; @@ -2875,7 +2874,7 @@ static enum relay_connection_status relay_process_data_receive_payload( * - the data immediately available on the socket, * - the on-stack data buffer */ - while (left_to_receive > 0 && !partial_recv) { + if (left_to_receive > 0) { ssize_t write_ret; size_t recv_size = min(left_to_receive, chunk_size); @@ -2892,13 +2891,7 @@ static enum relay_connection_status relay_process_data_receive_payload( DBG3("No more data ready for consumption on data socket of stream id %" PRIu64, state->header.stream_id); status = RELAY_CONNECTION_STATUS_CLOSED; - break; - } else if (ret < (int) recv_size) { - /* - * All the data available on the socket has been - * consumed. - */ - partial_recv = true; + goto data_left_to_process; } recv_size = ret; @@ -2920,6 +2913,8 @@ static enum relay_connection_status relay_process_data_receive_payload( write_ret, stream->stream_handle); } +data_left_to_process: + if (state->left_to_receive > 0) { /* * Did not receive all the data expected, wait for more data to -- 2.34.1