Skip to content

Commit

Permalink
free conns in both direct an normal cases
Browse files Browse the repository at this point in the history
  • Loading branch information
amitnagl committed Apr 16, 2024
1 parent 9ad4bd0 commit e8462aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3631,7 +3631,6 @@ int rdbSaveToSlavesSockets(int req, rdbSaveInfo *rsi) {
}
if (direct) {
rioFreeConnset(&rdb);
zfree(conns);
} else {
rioFreeFd(&rdb);
}
Expand Down Expand Up @@ -3678,6 +3677,7 @@ int rdbSaveToSlavesSockets(int req, rdbSaveInfo *rsi) {
if (aeCreateFileEvent(server.el, server.rdb_pipe_read, AE_READABLE, rdbPipeReadHandler,NULL) == AE_ERR) {
serverPanic("Unrecoverable error creating server.rdb_pipe_read file event.");
}
if (direct) zfree(conns);
}
close(safe_to_exit_pipe);
return (childpid == -1) ? C_ERR : C_OK;
Expand Down
14 changes: 7 additions & 7 deletions src/replication.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ void addSlaveToPsyncWaitingRax(client* slave) {
tail->refcount++;
}
}
serverLog(LL_DEBUG, "Add slave %s to waiting psync rax, with cid %lu, %s ", replicationGetSlaveName(slave), slave->id,
serverLog(LL_DEBUG, "Add slave %s to waiting psync rax, with cid %llu, %s ", replicationGetSlaveName(slave), (long long unsigned int)slave->id,
tail? "with repl-backlog tail": "repl-backlog is empty");
slave->ref_repl_buf_node = tail? ln: NULL;
/* Prevent rdb client from being freed before psync is established. */
Expand All @@ -250,7 +250,7 @@ void addSlaveToPsyncWaitingRaxRetrospect(void) {
if (slave->ref_repl_buf_node) continue;
slave->ref_repl_buf_node = ln;
head->refcount++;
serverLog(LL_DEBUG, "Retrospect attach slave %lu to repl buf block", slave->id);
serverLog(LL_DEBUG, "Retrospect attach slave %llu to repl buf block", (long long unsigned int)slave->id);
}
raxStop(&iter);
}
Expand All @@ -268,8 +268,8 @@ void removeSlaveFromPsyncWaitingRax(client* slave) {
}
peer_slave->ref_repl_buf_node = NULL;
peer_slave->flags &= ~CLIENT_PROTECTED_RDB_CHANNEL;
serverLog(LL_DEBUG, "Remove psync waiting slave %s with cid %lu, repl buffer block %s",
replicationGetSlaveName(slave), slave->associated_rdb_client_id, o? "ref count decreased": "doesn't exist");
serverLog(LL_DEBUG, "Remove psync waiting slave %s with cid %llu, repl buffer block %s",
replicationGetSlaveName(slave), (long long unsigned int)slave->associated_rdb_client_id, o? "ref count decreased": "doesn't exist");
uint64_t id = htonu64(peer_slave->id);
raxRemove(server.slaves_waiting_psync,(unsigned char*)&id,sizeof(id),NULL);
}
Expand Down Expand Up @@ -2620,9 +2620,9 @@ void abortRdbConnectionSync(void) {
int sendCurrentOffsetToReplica(client* replica) {
char buf[128];
int buflen;
buflen = snprintf(buf, sizeof(buf), "$ENDOFF:%lld %s %d %lu\r\n", server.master_repl_offset, server.replid, server.db->id, replica->id);
serverLog(LL_NOTICE, "Sending to replica %s RDB end offset %lld and client-id %lu",
replicationGetSlaveName(replica), server.master_repl_offset, replica->id);
buflen = snprintf(buf, sizeof(buf), "$ENDOFF:%lld %s %d %llu\r\n", server.master_repl_offset, server.replid, server.db->id, (long long unsigned int)replica->id);
serverLog(LL_NOTICE, "Sending to replica %s RDB end offset %lld and client-id %llu",
replicationGetSlaveName(replica), server.master_repl_offset, (long long unsigned int)replica->id);
if (connSyncWrite(replica->conn, buf, buflen, server.repl_syncio_timeout*1000) != buflen) {
freeClientAsync(replica);
return C_ERR;
Expand Down

0 comments on commit e8462aa

Please sign in to comment.