Skip to content

Commit

Permalink
Using the already computed c->net_input_bytes_curr_cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
lschmidtcavalcante-sc committed Feb 7, 2025
1 parent 37101df commit acd833a
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -4335,18 +4335,11 @@ int processCommand(client *c) {
* disconnection.
*/
if (server.write_throttling && is_write_command && server.primary_host == NULL) {
/* Size of the command to be stored in the output buffer. */
unsigned long long command_size = 3 + digits10(c->argc); /* 3: *[argc]\r\n */
for (int iarg = 0; iarg < c->argc; ++iarg) {
size_t arg_length = sdslen(c->argv[iarg]->ptr);
command_size += 5 + digits10(arg_length) + arg_length; /* 5: $[arglen]\r\n[arg]\r\n */
}

listIter li;
listNode *ln;
listRewind(server.replicas, &li);
while ((ln = listNext(&li))) {
if (willClientOutputBufferExceedLimits((client *)listNodeValue(ln), command_size)) {
if (willClientOutputBufferExceedLimits((client *)listNodeValue(ln), c->net_input_bytes_curr_cmd)) {
rejectCommand(c, shared.throttlederr);
return C_OK;
}
Expand Down

0 comments on commit acd833a

Please sign in to comment.