mirror of
https://github.com/valkey-io/valkey.git
synced 2026-05-06 05:26:42 -04:00
Ensure client slot migration pointer is cleared during reset (#3554)
If not cleared, the job may no longer be valid by the time the client goes to cleanup. This dangling reference could cause a crash if you set slot-migration-log-max-len to 0 and are very unlucky. Signed-off-by: Jacob Murphy <jkmurphy@google.com>
This commit is contained in:
@@ -2145,6 +2145,7 @@ void resetSlotMigrationJob(slotMigrationJob *job) {
|
||||
/* Only one of client or conn should be set. */
|
||||
serverAssert(!job->client || !job->conn);
|
||||
if (job->client) {
|
||||
job->client->slot_migration_job = NULL;
|
||||
freeClientAsync(job->client);
|
||||
job->client = NULL;
|
||||
} else if (job->conn) {
|
||||
|
||||
+1
-2
@@ -1978,8 +1978,7 @@ void unlinkClient(client *c) {
|
||||
}
|
||||
/* Check if this is the slot migration client we are writing to in a
|
||||
* child process*/
|
||||
if (c->slot_migration_job && !isImportSlotMigrationJob(c->slot_migration_job) &&
|
||||
server.slot_migration_pipe_conn == c->conn) {
|
||||
if (server.slot_migration_pipe_conn == c->conn) {
|
||||
server.slot_migration_pipe_conn = NULL;
|
||||
serverLog(LL_NOTICE, "Slot migration target dropped, killing fork child.");
|
||||
killSlotMigrationChild();
|
||||
|
||||
Reference in New Issue
Block a user