Skip to content

Commit

Permalink
change commandlog type to enum
Browse files Browse the repository at this point in the history
Signed-off-by: zhaozhao.zz <[email protected]>
  • Loading branch information
soloestoy committed Jan 15, 2025
1 parent 0b8f651 commit 5aa87fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/commandlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void commandlogFreeEntry(void *ceptr) {
/* Initialize the command log. This function should be called a single time
* at server startup. */
void commandlogInit(void) {
for (int i = 0; i < COMMANDLOG_TYPE_MAX; i++) {
for (int i = 0; i < COMMANDLOG_TYPE_NUM; i++) {
server.commandlog[i].entries = listCreate();
server.commandlog[i].entry_id = 0;
listSetFreeMethod(server.commandlog[i].entries, commandlogFreeEntry);
Expand Down
13 changes: 8 additions & 5 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,13 @@ typedef enum blocking_type {
buffer configuration. Just the first \
three: normal, replica, pubsub. */

#define COMMANDLOG_TYPE_SLOW 0
#define COMMANDLOG_TYPE_LARGE_REQUEST 1
#define COMMANDLOG_TYPE_LARGE_REPLY 2
#define COMMANDLOG_TYPE_MAX 3
/* Type of commandlog */
typedef enum {
COMMANDLOG_TYPE_SLOW = 0,
COMMANDLOG_TYPE_LARGE_REQUEST,
COMMANDLOG_TYPE_LARGE_REPLY,
COMMANDLOG_TYPE_NUM
} commandlog_type;

/* Configuration and entry list of different types of command logs */
typedef struct commandlog {
Expand Down Expand Up @@ -1702,7 +1705,7 @@ struct valkeyServer {
long long stat_sync_full; /* Number of full resyncs with replicas. */
long long stat_sync_partial_ok; /* Number of accepted PSYNC requests. */
long long stat_sync_partial_err; /* Number of unaccepted PSYNC requests. */
commandlog commandlog[COMMANDLOG_TYPE_MAX]; /* Logs of commands. */
commandlog commandlog[COMMANDLOG_TYPE_NUM]; /* Logs of commands. */
struct malloc_stats cron_malloc_stats; /* sampled in serverCron(). */
long long stat_net_input_bytes; /* Bytes read from network. */
long long stat_net_output_bytes; /* Bytes written to network. */
Expand Down

0 comments on commit 5aa87fd

Please sign in to comment.