Skip to content

Commit

Permalink
Fix client flag indexing
Browse files Browse the repository at this point in the history
Signed-off-by: naglera <[email protected]>
  • Loading branch information
naglera committed May 26, 2024
1 parent 3179baf commit 43a476a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -1707,9 +1707,6 @@ void freeClient(client *c) {
moduleFireServerEvent(VALKEYMODULE_EVENT_REPLICA_CHANGE,
VALKEYMODULE_SUBEVENT_REPLICA_CHANGE_OFFLINE,
NULL);
if (c->flags & CLIENT_REPL_RDB_CHANNEL) {
uint64_t id = htonu64(c->id);
raxRemove(server.slaves_waiting_psync,(unsigned char*)&id,sizeof(id),NULL); }
}

/* Master/slave cleanup Case 2:
Expand Down Expand Up @@ -2740,7 +2737,7 @@ void readQueryFromClient(connection *conn) {
sds info = catClientInfoString(sdsempty(), c);
serverLog(LL_VERBOSE, "Client closed connection %s", info);
if (c->flags & CLIENT_PROTECTED_RDB_CHANNEL) {
serverLog(LL_VERBOSE, "Postpone RDB client (%llu) free for %d seconds", (unsigned long long)c->id, server.wait_before_rdb_client_free);
serverLog(LL_VERBOSE, "Postpone RDB client id=%llu (%s) free for %d seconds", (unsigned long long)c->id, replicationGetSlaveName(c), server.wait_before_rdb_client_free);
}
sdsfree(info);
}
Expand Down
7 changes: 7 additions & 0 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <fcntl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <ctype.h>

void replicationDiscardCachedMaster(void);
void replicationResurrectCachedMaster(connection *conn);
Expand Down Expand Up @@ -389,6 +390,12 @@ void incrementalTrimReplicationBacklog(size_t max_blocks) {

/* Free replication buffer blocks that are referenced by this client. */
void freeReplicaReferencedReplBuffer(client *replica) {
if (replica->flags & CLIENT_REPL_RDB_CHANNEL) {
serverLog(LL_DEBUG, "Remove psync waiting slave %s with cid %llu from replicas rax.",
replicationGetSlaveName(replica), (long long unsigned int)replica->associated_rdb_client_id);
uint64_t id = htonu64(replica->id);
raxRemove(server.slaves_waiting_psync,(unsigned char*)&id,sizeof(id),NULL);
}
if (replica->ref_repl_buf_node != NULL) {
/* Decrease the start buffer node reference count. */
replBufBlock *o = listNodeValue(replica->ref_repl_buf_node);
Expand Down
6 changes: 3 additions & 3 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ extern int configOOMScoreAdjValuesDefaults[CONFIG_OOM_COUNT];
#define CLIENT_REPROCESSING_COMMAND (1ULL<<50) /* The client is re-processing the command. */
#define CLIENT_PREREPL_DONE (1ULL<<51) /* Indicate that pre-replication has been done on the client */

#define CLIENT_REPL_MAIN_CHANNEL (1ULL<<50) /* RDB Channel: track a connection
#define CLIENT_REPL_MAIN_CHANNEL (1ULL<<52) /* RDB Channel: track a connection
which is used for online replication data */
#define CLIENT_REPL_RDB_CHANNEL (1ULL<<51) /* RDB Channel: track a connection
#define CLIENT_REPL_RDB_CHANNEL (1ULL<<53) /* RDB Channel: track a connection
which is used for rdb snapshot */
#define CLIENT_PROTECTED_RDB_CHANNEL (1ULL<<52) /* Client should kept until PSYNC establishment. */
#define CLIENT_PROTECTED_RDB_CHANNEL (1ULL<<54) /* Client should kept until PSYNC establishment. */

/* Client block type (btype field in client structure)
* if CLIENT_BLOCKED flag is set. */
Expand Down

0 comments on commit 43a476a

Please sign in to comment.