Skip to content

Commit

Permalink
Refine comments
Browse files Browse the repository at this point in the history
  • Loading branch information
moticless committed Sep 24, 2024
1 parent 2ce22dc commit 40074fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -1634,17 +1634,17 @@ void sflushCommand(client *c) {

/* Verify slotsToFlushRq[] covers ALL slots of myNode. */
clusterNode *myNode = getMyClusterNode();
/* During iteration trace also the slot range pairs and save in SlotsFlush
* Allocated on heap since there is a chance that FLUSH SYNC will be run as
* blocking ASYNC and only later reply with slot ranges */
/* During iteration trace also the slot range pairs and save in SlotsFlush.
* It is allocated on heap since there is a chance that FLUSH SYNC will be
* running as blocking ASYNC and only later reply with slot ranges */
int capacity = 32; /* Initial capacity */
SlotsFlush *sflush = zmalloc(sizeof(SlotsFlush) + sizeof(SlotRange) * capacity);
sflush->numRanges = 0;
int inSlotRange = 0;
for (int i = 0; i < CLUSTER_SLOTS; i++) {
if (myNode == getNodeBySlot(i)) {
if (!slotsToFlushRq[i]) {
addReplySetLen(c, 0); /* Not all slots of my node got covered */
addReplySetLen(c, 0); /* Not all slots of mynode got covered. See sflushCommand() comment. */
zfree(sflush);
return;
}
Expand Down
15 changes: 8 additions & 7 deletions src/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ void flushAllDataAndResetRDB(int flags) {
* Utilized by commands SFLUSH, FLUSHALL and FLUSHDB.
*/
void flushallSyncBgDone(uint64_t client_id, void *sflush) {
SlotsFlush *slotFlush = (SlotsFlush *)sflush;
SlotsFlush *slotsFlush = (SlotsFlush *)sflush;
client *c = lookupClientByID(client_id);

/* Verify that client still exists */
Expand All @@ -746,11 +746,10 @@ void flushallSyncBgDone(uint64_t client_id, void *sflush) {
updateStatsOnUnblock(c, 0 /*blocked_us*/, elapsedUs(c->bstate.lazyfreeStartTime), 0);

/* Only SFLUSH command pass pointer to `SlotsFlush` */
if (slotFlush) {
replySlotsFlush(c, slotFlush);
} else {
if (slotsFlush)
replySlotsFlush(c, slotsFlush);
else
addReply(c, shared.ok);
}

/* mark client as unblocked */
unblockClient(c, 1);
Expand All @@ -770,10 +769,12 @@ void flushallSyncBgDone(uint64_t client_id, void *sflush) {
* Return 1 indicates that flush SYNC is actually running in bg as blocking ASYNC
* Return 0 otherwise
*
* sflush - provided only by SFLUSH command, otherwise NULL
* sflush - provided only by SFLUSH command, otherwise NULL. Will be used on
* completion to reply with the slots flush result. Ownership is passed
* to the completion job in case of `blocking_async`.
*/
int flushCommandCommon(client *c, int type, int flags, SlotsFlush *sflush) {
int blocking_async = 0; /* FLUSHALL\FLUSHDB SYNC opt to run as blocking ASYNC */
int blocking_async = 0; /* Flush SYNC option to run as blocking ASYNC */

/* in case of SYNC, check if we can optimize and run it in bg as blocking ASYNC */
if ((!(flags & EMPTYDB_ASYNC)) && (!(c->flags & CLIENT_AVOID_BLOCKING_ASYNC_FLUSH))) {
Expand Down

0 comments on commit 40074fc

Please sign in to comment.