@@ -2855,30 +2855,30 @@ void processMultibulkBuffer(client *c) {
2855
2855
*
2856
2856
* Calculation: For multi bulk buffer, we accumulate four factors, namely;
2857
2857
*
2858
- * 1) multibulklen_slen + 1
2858
+ * 1) multibulklen_slen + 3
2859
2859
* Cumulative string length (and not the value of) of multibulklen,
2860
- * including +1 from RESP first byte.
2861
- * 2) bulklen_slen + c->argc
2860
+ * including the first "*" byte and last "\r\n" 2 bytes from RESP .
2861
+ * 2) bulklen_slen + 3
2862
2862
* Cumulative string length (and not the value of) of bulklen,
2863
- * including +1 from RESP first byte per argument count.
2863
+ * including +3 from RESP first "$" byte and last "\r\n" 2 bytes per argument count.
2864
2864
* 3) c->argv_len_sum
2865
2865
* Cumulative string length of all argument vectors.
2866
- * 4) c->argc * 4 + 2
2867
- * Cumulative string length of all white-spaces, for which there exists a total of
2868
- * 4 bytes per argument, plus 2 bytes from the leading ' \r\n' from multibulklen .
2866
+ * 4) c->argc * 2
2867
+ * Cumulative string length of the arguments' white-spaces, for which there exists a total of
2868
+ * " \r\n" 2 bytes per argument .
2869
2869
*
2870
2870
* For example;
2871
2871
* Command) SET key value
2872
2872
* RESP) *3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n
2873
2873
*
2874
- * 1) String length of "*3" is 2 , obtained from (multibulklen_slen + 1 ).
2875
- * 2) String length of "$3" "$3" "$5" is 6 , obtained from (bulklen_slen + c->argc ).
2874
+ * 1) String length of "*3\r\n " is 4 , obtained from (multibulklen_slen + 3 ).
2875
+ * 2) String length of "$3\r\n " "$3\r\n " "$5\r\n " is 12 , obtained from (bulklen_slen + 3 ).
2876
2876
* 3) String length of "SET" "key" "value" is 11, obtained from (c->argv_len_sum).
2877
- * 4) String length of all white-spaces "\r\n" is 14 , obtained from (c->argc * 4 + 2).
2877
+ * 4) String length of the 3 arguments' white-spaces "\r\n" is 6 , obtained from (c->argc * 2).
2878
2878
*
2879
2879
* The 1st component is calculated within the below line.
2880
2880
* */
2881
- c -> net_input_bytes_curr_cmd += (multibulklen_slen + 1 );
2881
+ c -> net_input_bytes_curr_cmd += (multibulklen_slen + 3 );
2882
2882
}
2883
2883
2884
2884
serverAssertWithInfo (c , NULL , c -> multibulklen > 0 );
@@ -2943,9 +2943,8 @@ void processMultibulkBuffer(client *c) {
2943
2943
}
2944
2944
}
2945
2945
c -> bulklen = ll ;
2946
- /* Per-slot network bytes-in calculation, 2nd component.
2947
- * c->argc portion is deferred, as it may not have been fully populated at this point. */
2948
- c -> net_input_bytes_curr_cmd += bulklen_slen ;
2946
+ /* Per-slot network bytes-in calculation, 2nd component. */
2947
+ c -> net_input_bytes_curr_cmd += (bulklen_slen + 3 );
2949
2948
}
2950
2949
2951
2950
/* Read bulk argument */
@@ -2983,9 +2982,8 @@ void processMultibulkBuffer(client *c) {
2983
2982
2984
2983
/* We're done when c->multibulk == 0 */
2985
2984
if (c -> multibulklen == 0 ) {
2986
- /* Per-slot network bytes-in calculation, 3rd and 4th components.
2987
- * Here, the deferred c->argc from 2nd component is added, resulting in c->argc * 5 instead of * 4. */
2988
- c -> net_input_bytes_curr_cmd += (c -> argv_len_sum + (c -> argc * 5 + 2 ));
2985
+ /* Per-slot network bytes-in calculation, 3rd and 4th components. */
2986
+ c -> net_input_bytes_curr_cmd += (c -> argv_len_sum + (c -> argc * 2 ));
2989
2987
c -> read_flags |= READ_FLAGS_PARSING_COMPLETED ;
2990
2988
}
2991
2989
}
0 commit comments