Bound maximum data read to RECV_DATA_BUFFER_SIZE per iteration
[lttng-tools.git] / src / bin / lttng-relayd / main.c
index 19b1342ac5deeffa9ac2fc8c886779c2fa5fbd1d..1da63148758079f55a2986ae2861744eb58cb667 100644 (file)
@@ -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
This page took 0.025062 seconds and 5 git commands to generate.