Skip to content

Commit

Permalink
Use fake client flag to replace not conn check
Browse files Browse the repository at this point in the history
The fake client flag was introduced in valkey-io#1063, we want
this to replace all !conn fake client checks.

Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Oct 21, 2024
1 parent a62d1f1 commit bd5fb97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ int prepareClientToWrite(client *c) {
* is set. */
if (c->flag.primary && !c->flag.primary_force_reply) return C_ERR;

if (!c->conn) return C_ERR; /* Fake client for AOF loading. */
/* Skip the fake client, such as the fake client for AOF loading. */
if (c->flag.fake) return C_ERR;
serverAssert(c->conn);

/* Schedule the client to write the output buffers to the socket, unless
* it should already be setup to do so (it has already pending data). */
Expand Down Expand Up @@ -4437,7 +4439,7 @@ int checkClientOutputBufferLimits(client *c) {
*
* Returns 1 if client was (flagged) closed. */
int closeClientOnOutputBufferLimitReached(client *c, int async) {
if (!c->conn) return 0; /* It is unsafe to free fake clients. */
if (c->flag.fake) return 0; /* It is unsafe to free fake clients. */
serverAssert(c->reply_bytes < SIZE_MAX - (1024 * 64));
/* Note that c->reply_bytes is irrelevant for replica clients
* (they use the global repl buffers). */
Expand Down
2 changes: 1 addition & 1 deletion src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ void updateClientMemoryUsage(client *c) {
}

int clientEvictionAllowed(client *c) {
if (server.maxmemory_clients == 0 || c->flag.no_evict || !c->conn) {
if (server.maxmemory_clients == 0 || c->flag.no_evict || c->flag.fake) {
return 0;
}
int type = getClientType(c);
Expand Down

0 comments on commit bd5fb97

Please sign in to comment.