Skip to content

Commit

Permalink
tmp fix
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin <[email protected]>
  • Loading branch information
enjoy-binbin committed Oct 27, 2024
1 parent 01e544f commit 8cbc7d3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ void moduleReleaseTempClient(client *c) {
c->bufpos = 0;
c->raw_flag = 0;
c->flag.module = 1;
c->flag.fake = 1;
c->user = NULL; /* Root user */
c->cmd = c->lastcmd = c->realcmd = c->io_parsed_cmd = NULL;
if (c->bstate.async_rm_call_handle) {
Expand Down
9 changes: 7 additions & 2 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,10 @@ int prepareClientToWrite(client *c) {
* is set. */
if (c->flag.primary && !c->flag.primary_force_reply) return C_ERR;

/* Skip the fake client, such as the fake client for AOF loading. */
if (c->flag.fake) return C_ERR;
/* Skip the fake client, such as the fake client for AOF loading.
* But CLIENT_ID_CACHED_RESPONSE is allowed since it is a fake client
* but has a connection to cache the response. */
if (c->flag.fake && c->id != CLIENT_ID_CACHED_RESPONSE) return C_ERR;
serverAssert(c->conn);

/* Schedule the client to write the output buffers to the socket, unless
Expand Down Expand Up @@ -350,6 +352,9 @@ sds aggregateClientOutputBuffer(client *c) {
* It needs be paired with `deleteCachedResponseClient` function to stop caching. */
client *createCachedResponseClient(int resp) {
struct client *recording_client = createClient(NULL);
/* It is a fake client but with a connection, setting a special client id,
* so we can identify it's a fake cached response client. */
recording_client->id = CLIENT_ID_CACHED_RESPONSE;
recording_client->resp = resp;
/* Allocating the `conn` allows to prepare the caching client before adding
* data to the clients output buffer by `prepareClientToWrite`. */
Expand Down
7 changes: 4 additions & 3 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -1084,9 +1084,10 @@ typedef struct {
/* With multiplexing we need to take per-client state.
* Clients are taken in a linked list. */

#define CLIENT_ID_AOF (UINT64_MAX) /* Reserved ID for the AOF client. If you \
need more reserved IDs use UINT64_MAX-1, \
-2, ... and so forth. */
#define CLIENT_ID_AOF (UINT64_MAX) /* Reserved ID for the AOF client. If you \
need more reserved IDs use UINT64_MAX-1, \
-2, ... and so forth. */
#define CLIENT_ID_CACHED_RESPONSE (UINT64_MAX - 1) /* Client for cached response, see createCachedResponseClient. */

/* Replication backlog is not a separate memory, it just is one consumer of
* the global replication buffer. This structure records the reference of
Expand Down

0 comments on commit 8cbc7d3

Please sign in to comment.