Skip to content

Commit

Permalink
Clang format for feature related c files
Browse files Browse the repository at this point in the history
Signed-off-by: naglera <[email protected]>
  • Loading branch information
naglera committed Jul 2, 2024
1 parent 19297b7 commit a97cb64
Show file tree
Hide file tree
Showing 9 changed files with 306 additions and 305 deletions.
6 changes: 4 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2276,8 +2276,10 @@ static void numericConfigRewrite(standardConfig *config, const char *name, struc
}

#define createSpecialConfig(name, alias, modifiable, setfn, getfn, rewritefn, applyfn) \
{.type = SPECIAL_CONFIG, \
embedCommonConfig(name, alias, modifiable) embedConfigInterface(NULL, setfn, getfn, rewritefn, applyfn)}
{ \
.type = SPECIAL_CONFIG, \
embedCommonConfig(name, alias, modifiable) embedConfigInterface(NULL, setfn, getfn, rewritefn, applyfn) \
}

static int isValidActiveDefrag(int val, const char **err) {
#ifndef HAVE_DEFRAG
Expand Down
10 changes: 4 additions & 6 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -994,19 +994,17 @@ void debugCommand(client *c) {
return;
}
addReply(c, shared.ok);
} else if(!strcasecmp(c->argv[1]->ptr,"sleep-after-fork-seconds") &&
c->argc == 3) {
} else if (!strcasecmp(c->argv[1]->ptr, "sleep-after-fork-seconds") && c->argc == 3) {
double sleep_after_fork_seconds;
if (getDoubleFromObjectOrReply(c, c->argv[2], &sleep_after_fork_seconds, NULL) != C_OK) {
addReply(c, shared.err);
return;
}
server.debug_sleep_after_fork_ms = (int)(sleep_after_fork_seconds * 1e6);
addReply(c,shared.ok);
} else if(!strcasecmp(c->argv[1]->ptr,"WAIT-BEFORE-RDB-CLIENT-FREE") &&
c->argc == 3) {
addReply(c, shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr, "WAIT-BEFORE-RDB-CLIENT-FREE") && c->argc == 3) {
server.wait_before_rdb_client_free = atoi(c->argv[2]->ptr);
addReply(c,shared.ok);
addReply(c, shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr, "dict-resizing") && c->argc == 3) {
server.dict_resizing = atoi(c->argv[2]->ptr);
addReply(c, shared.ok);
Expand Down
34 changes: 20 additions & 14 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ void putClientInPendingWriteQueue(client *c) {
* writes at this stage. */
if (!(c->flags & CLIENT_PENDING_WRITE) &&
(c->repl_state == REPL_STATE_NONE ||
((c->repl_state == REPLICA_STATE_ONLINE || c->repl_state == REPLICA_STATE_BG_RDB_LOAD) && !c->repl_start_cmd_stream_on_ack))) {
((c->repl_state == REPLICA_STATE_ONLINE || c->repl_state == REPLICA_STATE_BG_RDB_LOAD) &&
!c->repl_start_cmd_stream_on_ack))) {
/* Here instead of installing the write handler, we just flag the
* client and put it into a list of clients that have something
* to write to the socket. This way before re-entering the event
Expand Down Expand Up @@ -1622,10 +1623,10 @@ void freeClient(client *c) {

/* Log link disconnection with replica */
if (getClientType(c) == CLIENT_TYPE_REPLICA) {
serverLog(LL_NOTICE, c->flags & CLIENT_REPL_RDB_CONN ?
"Replica %s rdb connection disconnected.":
"Connection with replica %s lost.",
replicationGetReplicaName(c));
serverLog(LL_NOTICE,
c->flags & CLIENT_REPL_RDB_CONN ? "Replica %s rdb connection disconnected."
: "Connection with replica %s lost.",
replicationGetReplicaName(c));
}

/* Free the query buffer */
Expand Down Expand Up @@ -1812,16 +1813,19 @@ int freeClientsInAsyncFreeQueue(void) {
if (c->flags & CLIENT_PROTECTED_RDB_CONN) {
/* Check if it's safe to remove RDB connection protection during synchronization
* The primary gives a grace period before freeing this client because
* it serves as a reference to the first required replication data block for
* it serves as a reference to the first required replication data block for
* this replica */
if (!c->rdb_client_disconnect_time) {
c->rdb_client_disconnect_time = server.unixtime;
serverLog(LL_VERBOSE, "Postpone RDB client id=%llu (%s) free for %d seconds",
(unsigned long long)c->id, replicationGetReplicaName(c), server.wait_before_rdb_client_free);
serverLog(LL_VERBOSE, "Postpone RDB client id=%llu (%s) free for %d seconds", (unsigned long long)c->id,
replicationGetReplicaName(c), server.wait_before_rdb_client_free);
continue;
}
if (server.unixtime - c->rdb_client_disconnect_time > server.wait_before_rdb_client_free) {
serverLog(LL_NOTICE, "Replica main connection failed to establish PSYNC within the grace period (%ld seconds). Freeing RDB client %llu.", (long int)(server.unixtime - c->rdb_client_disconnect_time), (unsigned long long)c->id);
serverLog(LL_NOTICE,
"Replica main connection failed to establish PSYNC within the grace period (%ld seconds). "
"Freeing RDB client %llu.",
(long int)(server.unixtime - c->rdb_client_disconnect_time), (unsigned long long)c->id);
c->flags &= ~CLIENT_PROTECTED_RDB_CONN;
}
}
Expand Down Expand Up @@ -1851,7 +1855,7 @@ client *lookupClientByID(uint64_t id) {
client *lookupRdbClientByID(uint64_t id) {
id = htonu64(id);
void *c = NULL;
raxFind(server.replicas_waiting_psync,(unsigned char*)&id,sizeof(id),&c);
raxFind(server.replicas_waiting_psync, (unsigned char *)&id, sizeof(id), &c);
return c;
}

Expand Down Expand Up @@ -4024,7 +4028,9 @@ int closeClientOnOutputBufferLimitReached(client *c, int async) {
serverAssert(c->reply_bytes < SIZE_MAX - (1024 * 64));
/* Note that c->reply_bytes is irrelevant for replica clients
* (they use the global repl buffers). */
if ((c->reply_bytes == 0 && getClientType(c) != CLIENT_TYPE_REPLICA) || (c->flags & CLIENT_CLOSE_ASAP && !(c->flags & CLIENT_PROTECTED_RDB_CONN))) return 0;
if ((c->reply_bytes == 0 && getClientType(c) != CLIENT_TYPE_REPLICA) ||
(c->flags & CLIENT_CLOSE_ASAP && !(c->flags & CLIENT_PROTECTED_RDB_CONN)))
return 0;
if (checkClientOutputBufferLimits(c)) {
sds client = catClientInfoString(sdsempty(), c);
/* Remove RDB connection protection on COB overrun */
Expand Down Expand Up @@ -4072,9 +4078,9 @@ void flushReplicasOutputBuffers(void) {
*
* 3. Obviously if the replica is not ONLINE.
*/
if ((replica->repl_state == REPLICA_STATE_ONLINE || replica->repl_state == REPLICA_STATE_BG_RDB_LOAD)
&& !(replica->flags & CLIENT_CLOSE_ASAP) &&
can_receive_writes && !replica->repl_start_cmd_stream_on_ack && clientHasPendingReplies(replica)) {
if ((replica->repl_state == REPLICA_STATE_ONLINE || replica->repl_state == REPLICA_STATE_BG_RDB_LOAD) &&
!(replica->flags & CLIENT_CLOSE_ASAP) && can_receive_writes && !replica->repl_start_cmd_stream_on_ack &&
clientHasPendingReplies(replica)) {
writeToClient(replica, 0);
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/rdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3542,7 +3542,7 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) {
}
/* Filter replica connections pending full sync (ie. in WAIT_BGSAVE_START state). */
listRewind(server.replicas, &li);
while((ln = listNext(&li))) {
while ((ln = listNext(&li))) {
client *replica = ln->value;
if (replica->repl_state == REPLICA_STATE_WAIT_BGSAVE_START) {
/* Check replica has the exact requirements */
Expand All @@ -3556,7 +3556,7 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) {
/* This replica uses diskless dual connection sync, hence we need
* to inform it with the save end offset.*/
sendCurrentOffsetToReplica(replica);
/* Make sure repl traffic is appended to the replication backlog */
/* Make sure repl traffic is appended to the replication backlog */
addReplicaToPsyncWait(replica);
} else {
server.rdb_pipe_numconns++;
Expand Down Expand Up @@ -3633,8 +3633,8 @@ int rdbSaveToReplicasSockets(int req, rdbSaveInfo *rsi) {
server.rdb_pipe_numconns_writing = 0;
}
} else {
serverLog(LL_NOTICE, "Background RDB transfer started by pid %ld to %s",
(long) childpid, dual_conn? "replica socket" : "pipe");
serverLog(LL_NOTICE, "Background RDB transfer started by pid %ld to %s", (long)childpid,
dual_conn ? "replica socket" : "pipe");
server.rdb_save_time_start = time(NULL);
server.rdb_child_type = RDB_CHILD_TYPE_SOCKET;
close(rdb_pipe_write); /* close write in parent so that it can detect the close on the child. */
Expand Down
Loading

0 comments on commit a97cb64

Please sign in to comment.