Commit 32f80e2f authored by antirez's avatar antirez
Browse files

RDMF: More consistent define names.

parent 40eb548a
This diff is collapsed.
...@@ -116,7 +116,7 @@ void bioInit(void) { ...@@ -116,7 +116,7 @@ void bioInit(void) {
for (j = 0; j < REDIS_BIO_NUM_OPS; j++) { for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
void *arg = (void*)(unsigned long) j; void *arg = (void*)(unsigned long) j;
if (pthread_create(&thread,&attr,bioProcessBackgroundJobs,arg) != 0) { if (pthread_create(&thread,&attr,bioProcessBackgroundJobs,arg) != 0) {
serverLog(REDIS_WARNING,"Fatal: Can't initialize Background Jobs."); serverLog(LL_WARNING,"Fatal: Can't initialize Background Jobs.");
exit(1); exit(1);
} }
bio_threads[j] = thread; bio_threads[j] = thread;
...@@ -144,7 +144,7 @@ void *bioProcessBackgroundJobs(void *arg) { ...@@ -144,7 +144,7 @@ void *bioProcessBackgroundJobs(void *arg) {
/* Check that the type is within the right interval. */ /* Check that the type is within the right interval. */
if (type >= REDIS_BIO_NUM_OPS) { if (type >= REDIS_BIO_NUM_OPS) {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"Warning: bio thread started with wrong type %lu",type); "Warning: bio thread started with wrong type %lu",type);
return NULL; return NULL;
} }
...@@ -160,7 +160,7 @@ void *bioProcessBackgroundJobs(void *arg) { ...@@ -160,7 +160,7 @@ void *bioProcessBackgroundJobs(void *arg) {
sigemptyset(&sigset); sigemptyset(&sigset);
sigaddset(&sigset, SIGALRM); sigaddset(&sigset, SIGALRM);
if (pthread_sigmask(SIG_BLOCK, &sigset, NULL)) if (pthread_sigmask(SIG_BLOCK, &sigset, NULL))
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"Warning: can't mask SIGALRM in bio.c thread: %s", strerror(errno)); "Warning: can't mask SIGALRM in bio.c thread: %s", strerror(errno));
while(1) { while(1) {
...@@ -184,7 +184,7 @@ void *bioProcessBackgroundJobs(void *arg) { ...@@ -184,7 +184,7 @@ void *bioProcessBackgroundJobs(void *arg) {
} else if (type == REDIS_BIO_AOF_FSYNC) { } else if (type == REDIS_BIO_AOF_FSYNC) {
aof_fsync((long)job->arg1); aof_fsync((long)job->arg1);
} else { } else {
redisPanic("Wrong job type in bioProcessBackgroundJobs()."); serverPanic("Wrong job type in bioProcessBackgroundJobs().");
} }
zfree(job); zfree(job);
...@@ -215,11 +215,11 @@ void bioKillThreads(void) { ...@@ -215,11 +215,11 @@ void bioKillThreads(void) {
for (j = 0; j < REDIS_BIO_NUM_OPS; j++) { for (j = 0; j < REDIS_BIO_NUM_OPS; j++) {
if (pthread_cancel(bio_threads[j]) == 0) { if (pthread_cancel(bio_threads[j]) == 0) {
if ((err = pthread_join(bio_threads[j],NULL)) != 0) { if ((err = pthread_join(bio_threads[j],NULL)) != 0) {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"Bio thread for job type #%d can be joined: %s", "Bio thread for job type #%d can be joined: %s",
j, strerror(err)); j, strerror(err));
} else { } else {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"Bio thread for job type #%d terminated",j); "Bio thread for job type #%d terminated",j);
} }
} }
......
...@@ -195,7 +195,7 @@ long redisBitpos(void *s, unsigned long count, int bit) { ...@@ -195,7 +195,7 @@ long redisBitpos(void *s, unsigned long count, int bit) {
/* If we reached this point, there is a bug in the algorithm, since /* If we reached this point, there is a bug in the algorithm, since
* the case of no match is handled as a special case before. */ * the case of no match is handled as a special case before. */
redisPanic("End of redisBitpos() reached."); serverPanic("End of redisBitpos() reached.");
return 0; /* Just to avoid warnings. */ return 0; /* Just to avoid warnings. */
} }
...@@ -250,7 +250,7 @@ void setbitCommand(client *c) { ...@@ -250,7 +250,7 @@ void setbitCommand(client *c) {
byteval |= ((on & 0x1) << bit); byteval |= ((on & 0x1) << bit);
((uint8_t*)o->ptr)[byte] = byteval; ((uint8_t*)o->ptr)[byte] = byteval;
signalModifiedKey(c->db,c->argv[1]); signalModifiedKey(c->db,c->argv[1]);
notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"setbit",c->argv[1],c->db->id); notifyKeyspaceEvent(NOTIFY_STRING,"setbit",c->argv[1],c->db->id);
server.dirty++; server.dirty++;
addReply(c, bitval ? shared.cone : shared.czero); addReply(c, bitval ? shared.cone : shared.czero);
} }
...@@ -446,11 +446,11 @@ void bitopCommand(client *c) { ...@@ -446,11 +446,11 @@ void bitopCommand(client *c) {
if (maxlen) { if (maxlen) {
o = createObject(OBJ_STRING,res); o = createObject(OBJ_STRING,res);
setKey(c->db,targetkey,o); setKey(c->db,targetkey,o);
notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"set",targetkey,c->db->id); notifyKeyspaceEvent(NOTIFY_STRING,"set",targetkey,c->db->id);
decrRefCount(o); decrRefCount(o);
} else if (dbDelete(c->db,targetkey)) { } else if (dbDelete(c->db,targetkey)) {
signalModifiedKey(c->db,targetkey); signalModifiedKey(c->db,targetkey);
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",targetkey,c->db->id); notifyKeyspaceEvent(NOTIFY_GENERIC,"del",targetkey,c->db->id);
} }
server.dirty++; server.dirty++;
addReplyLongLong(c,maxlen); /* Return the output string length in bytes. */ addReplyLongLong(c,maxlen); /* Return the output string length in bytes. */
......
...@@ -34,17 +34,17 @@ ...@@ -34,17 +34,17 @@
* getTimeoutFromObjectOrReply() is just an utility function to parse a * getTimeoutFromObjectOrReply() is just an utility function to parse a
* timeout argument since blocking operations usually require a timeout. * timeout argument since blocking operations usually require a timeout.
* *
* blockClient() set the REDIS_BLOCKED flag in the client, and set the * blockClient() set the CLIENT_BLOCKED flag in the client, and set the
* specified block type 'btype' filed to one of REDIS_BLOCKED_* macros. * specified block type 'btype' filed to one of BLOCKED_* macros.
* *
* unblockClient() unblocks the client doing the following: * unblockClient() unblocks the client doing the following:
* 1) It calls the btype-specific function to cleanup the state. * 1) It calls the btype-specific function to cleanup the state.
* 2) It unblocks the client by unsetting the REDIS_BLOCKED flag. * 2) It unblocks the client by unsetting the CLIENT_BLOCKED flag.
* 3) It puts the client into a list of just unblocked clients that are * 3) It puts the client into a list of just unblocked clients that are
* processed ASAP in the beforeSleep() event loop callback, so that * processed ASAP in the beforeSleep() event loop callback, so that
* if there is some query buffer to process, we do it. This is also * if there is some query buffer to process, we do it. This is also
* required because otherwise there is no 'readable' event fired, we * required because otherwise there is no 'readable' event fired, we
* already read the pending commands. We also set the REDIS_UNBLOCKED * already read the pending commands. We also set the CLIENT_UNBLOCKED
* flag to remember the client is in the unblocked_clients list. * flag to remember the client is in the unblocked_clients list.
* *
* processUnblockedClients() is called inside the beforeSleep() function * processUnblockedClients() is called inside the beforeSleep() function
...@@ -94,11 +94,11 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int ...@@ -94,11 +94,11 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int
return C_OK; return C_OK;
} }
/* Block a client for the specific operation type. Once the REDIS_BLOCKED /* Block a client for the specific operation type. Once the CLIENT_BLOCKED
* flag is set client query buffer is not longer processed, but accumulated, * flag is set client query buffer is not longer processed, but accumulated,
* and will be processed when the client is unblocked. */ * and will be processed when the client is unblocked. */
void blockClient(client *c, int btype) { void blockClient(client *c, int btype) {
c->flags |= REDIS_BLOCKED; c->flags |= CLIENT_BLOCKED;
c->btype = btype; c->btype = btype;
server.bpop_blocked_clients++; server.bpop_blocked_clients++;
} }
...@@ -115,13 +115,13 @@ void processUnblockedClients(void) { ...@@ -115,13 +115,13 @@ void processUnblockedClients(void) {
serverAssert(ln != NULL); serverAssert(ln != NULL);
c = ln->value; c = ln->value;
listDelNode(server.unblocked_clients,ln); listDelNode(server.unblocked_clients,ln);
c->flags &= ~REDIS_UNBLOCKED; c->flags &= ~CLIENT_UNBLOCKED;
/* Process remaining data in the input buffer, unless the client /* Process remaining data in the input buffer, unless the client
* is blocked again. Actually processInputBuffer() checks that the * is blocked again. Actually processInputBuffer() checks that the
* client is not blocked before to proceed, but things may change and * client is not blocked before to proceed, but things may change and
* the code is conceptually more correct this way. */ * the code is conceptually more correct this way. */
if (!(c->flags & REDIS_BLOCKED)) { if (!(c->flags & CLIENT_BLOCKED)) {
if (c->querybuf && sdslen(c->querybuf) > 0) { if (c->querybuf && sdslen(c->querybuf) > 0) {
processInputBuffer(c); processInputBuffer(c);
} }
...@@ -132,22 +132,22 @@ void processUnblockedClients(void) { ...@@ -132,22 +132,22 @@ void processUnblockedClients(void) {
/* Unblock a client calling the right function depending on the kind /* Unblock a client calling the right function depending on the kind
* of operation the client is blocking for. */ * of operation the client is blocking for. */
void unblockClient(client *c) { void unblockClient(client *c) {
if (c->btype == REDIS_BLOCKED_LIST) { if (c->btype == BLOCKED_LIST) {
unblockClientWaitingData(c); unblockClientWaitingData(c);
} else if (c->btype == REDIS_BLOCKED_WAIT) { } else if (c->btype == BLOCKED_WAIT) {
unblockClientWaitingReplicas(c); unblockClientWaitingReplicas(c);
} else { } else {
redisPanic("Unknown btype in unblockClient()."); serverPanic("Unknown btype in unblockClient().");
} }
/* Clear the flags, and put the client in the unblocked list so that /* Clear the flags, and put the client in the unblocked list so that
* we'll process new commands in its query buffer ASAP. */ * we'll process new commands in its query buffer ASAP. */
c->flags &= ~REDIS_BLOCKED; c->flags &= ~CLIENT_BLOCKED;
c->btype = REDIS_BLOCKED_NONE; c->btype = BLOCKED_NONE;
server.bpop_blocked_clients--; server.bpop_blocked_clients--;
/* The client may already be into the unblocked list because of a previous /* The client may already be into the unblocked list because of a previous
* blocking operation, don't add back it into the list multiple times. */ * blocking operation, don't add back it into the list multiple times. */
if (!(c->flags & REDIS_UNBLOCKED)) { if (!(c->flags & CLIENT_UNBLOCKED)) {
c->flags |= REDIS_UNBLOCKED; c->flags |= CLIENT_UNBLOCKED;
listAddNodeTail(server.unblocked_clients,c); listAddNodeTail(server.unblocked_clients,c);
} }
} }
...@@ -155,12 +155,12 @@ void unblockClient(client *c) { ...@@ -155,12 +155,12 @@ void unblockClient(client *c) {
/* This function gets called when a blocked client timed out in order to /* This function gets called when a blocked client timed out in order to
* send it a reply of some kind. */ * send it a reply of some kind. */
void replyToBlockedClientTimedOut(client *c) { void replyToBlockedClientTimedOut(client *c) {
if (c->btype == REDIS_BLOCKED_LIST) { if (c->btype == BLOCKED_LIST) {
addReply(c,shared.nullmultibulk); addReply(c,shared.nullmultibulk);
} else if (c->btype == REDIS_BLOCKED_WAIT) { } else if (c->btype == BLOCKED_WAIT) {
addReplyLongLong(c,replicationCountAcksByOffset(c->bpop.reploffset)); addReplyLongLong(c,replicationCountAcksByOffset(c->bpop.reploffset));
} else { } else {
redisPanic("Unknown btype in replyToBlockedClientTimedOut()."); serverPanic("Unknown btype in replyToBlockedClientTimedOut().");
} }
} }
...@@ -179,12 +179,12 @@ void disconnectAllBlockedClients(void) { ...@@ -179,12 +179,12 @@ void disconnectAllBlockedClients(void) {
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
client *c = listNodeValue(ln); client *c = listNodeValue(ln);
if (c->flags & REDIS_BLOCKED) { if (c->flags & CLIENT_BLOCKED) {
addReplySds(c,sdsnew( addReplySds(c,sdsnew(
"-UNBLOCKED force unblock from blocking operation, " "-UNBLOCKED force unblock from blocking operation, "
"instance state changed (master -> slave?)\r\n")); "instance state changed (master -> slave?)\r\n"));
unblockClient(c); unblockClient(c);
c->flags |= REDIS_CLOSE_AFTER_REPLY; c->flags |= CLIENT_CLOSE_AFTER_REPLY;
} }
} }
} }
This diff is collapsed.
...@@ -94,7 +94,7 @@ typedef struct clusterNode { ...@@ -94,7 +94,7 @@ typedef struct clusterNode {
mstime_t voted_time; /* Last time we voted for a slave of this master */ mstime_t voted_time; /* Last time we voted for a slave of this master */
mstime_t repl_offset_time; /* Unix time we received offset for this node */ mstime_t repl_offset_time; /* Unix time we received offset for this node */
long long repl_offset; /* Last known repl offset for this node. */ long long repl_offset; /* Last known repl offset for this node. */
char ip[REDIS_IP_STR_LEN]; /* Latest known IP address of this node */ char ip[NET_IP_STR_LEN]; /* Latest known IP address of this node */
int port; /* Latest known port of this node */ int port; /* Latest known port of this node */
clusterLink *link; /* TCP/IP link with this node */ clusterLink *link; /* TCP/IP link with this node */
list *fail_reports; /* List of nodes signaling this as failing */ list *fail_reports; /* List of nodes signaling this as failing */
...@@ -165,7 +165,7 @@ typedef struct { ...@@ -165,7 +165,7 @@ typedef struct {
char nodename[REDIS_CLUSTER_NAMELEN]; char nodename[REDIS_CLUSTER_NAMELEN];
uint32_t ping_sent; uint32_t ping_sent;
uint32_t pong_received; uint32_t pong_received;
char ip[REDIS_IP_STR_LEN]; /* IP address last time it was seen */ char ip[NET_IP_STR_LEN]; /* IP address last time it was seen */
uint16_t port; /* port last time it was seen */ uint16_t port; /* port last time it was seen */
uint16_t flags; /* node->flags copy */ uint16_t flags; /* node->flags copy */
uint16_t notused1; /* Some room for future improvements. */ uint16_t notused1; /* Some room for future improvements. */
......
...@@ -44,12 +44,12 @@ typedef struct configEnum { ...@@ -44,12 +44,12 @@ typedef struct configEnum {
} configEnum; } configEnum;
configEnum maxmemory_policy_enum[] = { configEnum maxmemory_policy_enum[] = {
{"volatile-lru", REDIS_MAXMEMORY_VOLATILE_LRU}, {"volatile-lru", MAXMEMORY_VOLATILE_LRU},
{"volatile-random",REDIS_MAXMEMORY_VOLATILE_RANDOM}, {"volatile-random",MAXMEMORY_VOLATILE_RANDOM},
{"volatile-ttl",REDIS_MAXMEMORY_VOLATILE_TTL}, {"volatile-ttl",MAXMEMORY_VOLATILE_TTL},
{"allkeys-lru",REDIS_MAXMEMORY_ALLKEYS_LRU}, {"allkeys-lru",MAXMEMORY_ALLKEYS_LRU},
{"allkeys-random",REDIS_MAXMEMORY_ALLKEYS_RANDOM}, {"allkeys-random",MAXMEMORY_ALLKEYS_RANDOM},
{"noeviction",REDIS_MAXMEMORY_NO_EVICTION}, {"noeviction",MAXMEMORY_NO_EVICTION},
{NULL, 0} {NULL, 0}
}; };
...@@ -67,18 +67,18 @@ configEnum syslog_facility_enum[] = { ...@@ -67,18 +67,18 @@ configEnum syslog_facility_enum[] = {
}; };
configEnum loglevel_enum[] = { configEnum loglevel_enum[] = {
{"debug", REDIS_DEBUG}, {"debug", LL_DEBUG},
{"verbose", REDIS_VERBOSE}, {"verbose", LL_VERBOSE},
{"notice", REDIS_NOTICE}, {"notice", LL_NOTICE},
{"warning", REDIS_WARNING}, {"warning", LL_WARNING},
{NULL,0} {NULL,0}
}; };
configEnum supervised_mode_enum[] = { configEnum supervised_mode_enum[] = {
{"upstart", REDIS_SUPERVISED_UPSTART}, {"upstart", SUPERVISED_UPSTART},
{"systemd", REDIS_SUPERVISED_SYSTEMD}, {"systemd", SUPERVISED_SYSTEMD},
{"auto", REDIS_SUPERVISED_AUTODETECT}, {"auto", SUPERVISED_AUTODETECT},
{"no", REDIS_SUPERVISED_NONE}, {"no", SUPERVISED_NONE},
{NULL, 0} {NULL, 0}
}; };
...@@ -90,7 +90,7 @@ configEnum aof_fsync_enum[] = { ...@@ -90,7 +90,7 @@ configEnum aof_fsync_enum[] = {
}; };
/* Output buffer limits presets. */ /* Output buffer limits presets. */
clientBufferLimitsConfig clientBufferLimitsDefaults[REDIS_CLIENT_TYPE_COUNT] = { clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_COUNT] = {
{0, 0, 0}, /* normal */ {0, 0, 0}, /* normal */
{1024*1024*256, 1024*1024*64, 60}, /* slave */ {1024*1024*256, 1024*1024*64, 60}, /* slave */
{1024*1024*32, 1024*1024*8, 60} /* pubsub */ {1024*1024*32, 1024*1024*8, 60} /* pubsub */
...@@ -209,7 +209,7 @@ void loadServerConfigFromString(char *config) { ...@@ -209,7 +209,7 @@ void loadServerConfigFromString(char *config) {
} else if (!strcasecmp(argv[0],"bind") && argc >= 2) { } else if (!strcasecmp(argv[0],"bind") && argc >= 2) {
int j, addresses = argc-1; int j, addresses = argc-1;
if (addresses > REDIS_BINDADDR_MAX) { if (addresses > CONFIG_BINDADDR_MAX) {
err = "Too many bind addresses specified"; goto loaderr; err = "Too many bind addresses specified"; goto loaderr;
} }
for (j = 0; j < addresses; j++) for (j = 0; j < addresses; j++)
...@@ -236,7 +236,7 @@ void loadServerConfigFromString(char *config) { ...@@ -236,7 +236,7 @@ void loadServerConfigFromString(char *config) {
} }
} else if (!strcasecmp(argv[0],"dir") && argc == 2) { } else if (!strcasecmp(argv[0],"dir") && argc == 2) {
if (chdir(argv[1]) == -1) { if (chdir(argv[1]) == -1) {
serverLog(REDIS_WARNING,"Can't chdir to '%s': %s", serverLog(LL_WARNING,"Can't chdir to '%s': %s",
argv[1], strerror(errno)); argv[1], strerror(errno));
exit(1); exit(1);
} }
...@@ -308,7 +308,7 @@ void loadServerConfigFromString(char *config) { ...@@ -308,7 +308,7 @@ void loadServerConfigFromString(char *config) {
slaveof_linenum = linenum; slaveof_linenum = linenum;
server.masterhost = sdsnew(argv[1]); server.masterhost = sdsnew(argv[1]);
server.masterport = atoi(argv[2]); server.masterport = atoi(argv[2]);
server.repl_state = REDIS_REPL_CONNECT; server.repl_state = REPL_STATE_CONNECT;
} else if (!strcasecmp(argv[0],"repl-ping-slave-period") && argc == 2) { } else if (!strcasecmp(argv[0],"repl-ping-slave-period") && argc == 2) {
server.repl_ping_slave_period = atoi(argv[1]); server.repl_ping_slave_period = atoi(argv[1]);
if (server.repl_ping_slave_period <= 0) { if (server.repl_ping_slave_period <= 0) {
...@@ -376,15 +376,15 @@ void loadServerConfigFromString(char *config) { ...@@ -376,15 +376,15 @@ void loadServerConfigFromString(char *config) {
} }
} else if (!strcasecmp(argv[0],"hz") && argc == 2) { } else if (!strcasecmp(argv[0],"hz") && argc == 2) {
server.hz = atoi(argv[1]); server.hz = atoi(argv[1]);
if (server.hz < REDIS_MIN_HZ) server.hz = REDIS_MIN_HZ; if (server.hz < CONFIG_MIN_HZ) server.hz = CONFIG_MIN_HZ;
if (server.hz > REDIS_MAX_HZ) server.hz = REDIS_MAX_HZ; if (server.hz > CONFIG_MAX_HZ) server.hz = CONFIG_MAX_HZ;
} else if (!strcasecmp(argv[0],"appendonly") && argc == 2) { } else if (!strcasecmp(argv[0],"appendonly") && argc == 2) {
int yes; int yes;
if ((yes = yesnotoi(argv[1])) == -1) { if ((yes = yesnotoi(argv[1])) == -1) {
err = "argument must be 'yes' or 'no'"; goto loaderr; err = "argument must be 'yes' or 'no'"; goto loaderr;
} }
server.aof_state = yes ? REDIS_AOF_ON : REDIS_AOF_OFF; server.aof_state = yes ? AOF_ON : AOF_OFF;
} else if (!strcasecmp(argv[0],"appendfilename") && argc == 2) { } else if (!strcasecmp(argv[0],"appendfilename") && argc == 2) {
if (!pathIsBaseName(argv[1])) { if (!pathIsBaseName(argv[1])) {
err = "appendfilename can't be a path, just a filename"; err = "appendfilename can't be a path, just a filename";
...@@ -427,8 +427,8 @@ void loadServerConfigFromString(char *config) { ...@@ -427,8 +427,8 @@ void loadServerConfigFromString(char *config) {
err = "argument must be 'yes' or 'no'"; goto loaderr; err = "argument must be 'yes' or 'no'"; goto loaderr;
} }
} else if (!strcasecmp(argv[0],"requirepass") && argc == 2) { } else if (!strcasecmp(argv[0],"requirepass") && argc == 2) {
if (strlen(argv[1]) > REDIS_AUTHPASS_MAX_LEN) { if (strlen(argv[1]) > CONFIG_AUTHPASS_MAX_LEN) {
err = "Password is longer than REDIS_AUTHPASS_MAX_LEN"; err = "Password is longer than CONFIG_AUTHPASS_MAX_LEN";
goto loaderr; goto loaderr;
} }
server.requirepass = zstrdup(argv[1]); server.requirepass = zstrdup(argv[1]);
...@@ -637,7 +637,7 @@ loaderr: ...@@ -637,7 +637,7 @@ loaderr:
* just load a string. */ * just load a string. */
void loadServerConfig(char *filename, char *options) { void loadServerConfig(char *filename, char *options) {
sds config = sdsempty(); sds config = sdsempty();
char buf[REDIS_CONFIGLINE_MAX+1]; char buf[CONFIG_MAX_LINE+1];
/* Load the file content */ /* Load the file content */
if (filename) { if (filename) {
...@@ -647,12 +647,12 @@ void loadServerConfig(char *filename, char *options) { ...@@ -647,12 +647,12 @@ void loadServerConfig(char *filename, char *options) {
fp = stdin; fp = stdin;
} else { } else {
if ((fp = fopen(filename,"r")) == NULL) { if ((fp = fopen(filename,"r")) == NULL) {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"Fatal error, can't open config file '%s'", filename); "Fatal error, can't open config file '%s'", filename);
exit(1); exit(1);
} }
} }
while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL) while(fgets(buf,CONFIG_MAX_LINE+1,fp) != NULL)
config = sdscat(config,buf); config = sdscat(config,buf);
if (fp != stdin) fclose(fp); if (fp != stdin) fclose(fp);
} }
...@@ -718,7 +718,7 @@ void configSetCommand(client *c) { ...@@ -718,7 +718,7 @@ void configSetCommand(client *c) {
zfree(server.rdb_filename); zfree(server.rdb_filename);
server.rdb_filename = zstrdup(o->ptr); server.rdb_filename = zstrdup(o->ptr);
} config_set_special_field("requirepass") { } config_set_special_field("requirepass") {
if (sdslen(o->ptr) > REDIS_AUTHPASS_MAX_LEN) goto badfmt; if (sdslen(o->ptr) > CONFIG_AUTHPASS_MAX_LEN) goto badfmt;
zfree(server.requirepass); zfree(server.requirepass);
server.requirepass = ((char*)o->ptr)[0] ? zstrdup(o->ptr) : NULL; server.requirepass = ((char*)o->ptr)[0] ? zstrdup(o->ptr) : NULL;
} config_set_special_field("masterauth") { } config_set_special_field("masterauth") {
...@@ -739,10 +739,10 @@ void configSetCommand(client *c) { ...@@ -739,10 +739,10 @@ void configSetCommand(client *c) {
return; return;
} }
if ((unsigned int) aeGetSetSize(server.el) < if ((unsigned int) aeGetSetSize(server.el) <
server.maxclients + REDIS_EVENTLOOP_FDSET_INCR) server.maxclients + CONFIG_FDSET_INCR)
{ {
if (aeResizeSetSize(server.el, if (aeResizeSetSize(server.el,
server.maxclients + REDIS_EVENTLOOP_FDSET_INCR) == AE_ERR) server.maxclients + CONFIG_FDSET_INCR) == AE_ERR)
{ {
addReplyError(c,"The event loop API used by Redis is not able to handle the specified number of clients"); addReplyError(c,"The event loop API used by Redis is not able to handle the specified number of clients");
server.maxclients = orig_value; server.maxclients = orig_value;
...@@ -754,9 +754,9 @@ void configSetCommand(client *c) { ...@@ -754,9 +754,9 @@ void configSetCommand(client *c) {
int enable = yesnotoi(o->ptr); int enable = yesnotoi(o->ptr);
if (enable == -1) goto badfmt; if (enable == -1) goto badfmt;
if (enable == 0 && server.aof_state != REDIS_AOF_OFF) { if (enable == 0 && server.aof_state != AOF_OFF) {
stopAppendOnly(); stopAppendOnly();
} else if (enable && server.aof_state == REDIS_AOF_OFF) { } else if (enable && server.aof_state == AOF_OFF) {
if (startAppendOnly() == C_ERR) { if (startAppendOnly() == C_ERR) {
addReplyError(c, addReplyError(c,
"Unable to turn on AOF. Check server logs."); "Unable to turn on AOF. Check server logs.");
...@@ -940,8 +940,8 @@ void configSetCommand(client *c) { ...@@ -940,8 +940,8 @@ void configSetCommand(client *c) {
"hz",server.hz,0,LLONG_MAX) { "hz",server.hz,0,LLONG_MAX) {
/* Hz is more an hint from the user, so we accept values out of range /* Hz is more an hint from the user, so we accept values out of range
* but cap them to reasonable values. */ * but cap them to reasonable values. */
if (server.hz < REDIS_MIN_HZ) server.hz = REDIS_MIN_HZ; if (server.hz < CONFIG_MIN_HZ) server.hz = CONFIG_MIN_HZ;
if (server.hz > REDIS_MAX_HZ) server.hz = REDIS_MAX_HZ; if (server.hz > CONFIG_MAX_HZ) server.hz = CONFIG_MAX_HZ;
} config_set_numerical_field( } config_set_numerical_field(
"watchdog-period",ll,0,LLONG_MAX) { "watchdog-period",ll,0,LLONG_MAX) {
if (ll) if (ll)
...@@ -954,7 +954,7 @@ void configSetCommand(client *c) { ...@@ -954,7 +954,7 @@ void configSetCommand(client *c) {
} config_set_memory_field("maxmemory",server.maxmemory) { } config_set_memory_field("maxmemory",server.maxmemory) {
if (server.maxmemory) { if (server.maxmemory) {
if (server.maxmemory < zmalloc_used_memory()) { if (server.maxmemory < zmalloc_used_memory()) {
serverLog(REDIS_WARNING,"WARNING: the new maxmemory value set via CONFIG SET is smaller than the current memory usage. This will result in keys eviction and/or inability to accept new write commands depending on the maxmemory-policy."); serverLog(LL_WARNING,"WARNING: the new maxmemory value set via CONFIG SET is smaller than the current memory usage. This will result in keys eviction and/or inability to accept new write commands depending on the maxmemory-policy.");
} }
freeMemoryIfNeeded(); freeMemoryIfNeeded();
} }
...@@ -1130,7 +1130,7 @@ void configGetCommand(client *c) { ...@@ -1130,7 +1130,7 @@ void configGetCommand(client *c) {
if (stringmatch(pattern,"appendonly",0)) { if (stringmatch(pattern,"appendonly",0)) {
addReplyBulkCString(c,"appendonly"); addReplyBulkCString(c,"appendonly");
addReplyBulkCString(c,server.aof_state == REDIS_AOF_OFF ? "no" : "yes"); addReplyBulkCString(c,server.aof_state == AOF_OFF ? "no" : "yes");
matches++; matches++;
} }
if (stringmatch(pattern,"dir",0)) { if (stringmatch(pattern,"dir",0)) {
...@@ -1163,13 +1163,13 @@ void configGetCommand(client *c) { ...@@ -1163,13 +1163,13 @@ void configGetCommand(client *c) {
sds buf = sdsempty(); sds buf = sdsempty();
int j; int j;
for (j = 0; j < REDIS_CLIENT_TYPE_COUNT; j++) { for (j = 0; j < CLIENT_TYPE_COUNT; j++) {
buf = sdscatprintf(buf,"%s %llu %llu %ld", buf = sdscatprintf(buf,"%s %llu %llu %ld",
getClientTypeName(j), getClientTypeName(j),
server.client_obuf_limits[j].hard_limit_bytes, server.client_obuf_limits[j].hard_limit_bytes,
server.client_obuf_limits[j].soft_limit_bytes, server.client_obuf_limits[j].soft_limit_bytes,
(long) server.client_obuf_limits[j].soft_limit_seconds); (long) server.client_obuf_limits[j].soft_limit_seconds);
if (j != REDIS_CLIENT_TYPE_COUNT-1) if (j != CLIENT_TYPE_COUNT-1)
buf = sdscatlen(buf," ",1); buf = sdscatlen(buf," ",1);
} }
addReplyBulkCString(c,"client-output-buffer-limit"); addReplyBulkCString(c,"client-output-buffer-limit");
...@@ -1297,7 +1297,7 @@ void rewriteConfigMarkAsProcessed(struct rewriteConfigState *state, const char * ...@@ -1297,7 +1297,7 @@ void rewriteConfigMarkAsProcessed(struct rewriteConfigState *state, const char *
struct rewriteConfigState *rewriteConfigReadOldFile(char *path) { struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
FILE *fp = fopen(path,"r"); FILE *fp = fopen(path,"r");
struct rewriteConfigState *state = zmalloc(sizeof(*state)); struct rewriteConfigState *state = zmalloc(sizeof(*state));
char buf[REDIS_CONFIGLINE_MAX+1]; char buf[CONFIG_MAX_LINE+1];
int linenum = -1; int linenum = -1;
if (fp == NULL && errno != ENOENT) return NULL; if (fp == NULL && errno != ENOENT) return NULL;
...@@ -1310,7 +1310,7 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) { ...@@ -1310,7 +1310,7 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) {
if (fp == NULL) return state; if (fp == NULL) return state;
/* Read the old file line by line, populate the state. */ /* Read the old file line by line, populate the state. */
while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL) { while(fgets(buf,CONFIG_MAX_LINE+1,fp) != NULL) {
int argc; int argc;
sds *argv; sds *argv;
sds line = sdstrim(sdsnew(buf),"\r\n\t "); sds line = sdstrim(sdsnew(buf),"\r\n\t ");
...@@ -1566,7 +1566,7 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state ...@@ -1566,7 +1566,7 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state
int j; int j;
char *option = "client-output-buffer-limit"; char *option = "client-output-buffer-limit";
for (j = 0; j < REDIS_CLIENT_TYPE_COUNT; j++) { for (j = 0; j < CLIENT_TYPE_COUNT; j++) {
int force = (server.client_obuf_limits[j].hard_limit_bytes != int force = (server.client_obuf_limits[j].hard_limit_bytes !=
clientBufferLimitsDefaults[j].hard_limit_bytes) || clientBufferLimitsDefaults[j].hard_limit_bytes) ||
(server.client_obuf_limits[j].soft_limit_bytes != (server.client_obuf_limits[j].soft_limit_bytes !=
...@@ -1657,7 +1657,7 @@ void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) { ...@@ -1657,7 +1657,7 @@ void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) {
/* Don't blank lines about options the rewrite process /* Don't blank lines about options the rewrite process
* don't understand. */ * don't understand. */
if (dictFind(state->rewritten,option) == NULL) { if (dictFind(state->rewritten,option) == NULL) {
serverLog(REDIS_DEBUG,"Not rewritten option: %s", option); serverLog(LL_DEBUG,"Not rewritten option: %s", option);
continue; continue;
} }
...@@ -1751,12 +1751,12 @@ int rewriteConfig(char *path) { ...@@ -1751,12 +1751,12 @@ int rewriteConfig(char *path) {
rewriteConfigYesNoOption(state,"daemonize",server.daemonize,0); rewriteConfigYesNoOption(state,"daemonize",server.daemonize,0);
rewriteConfigStringOption(state,"pidfile",server.pidfile,CONFIG_DEFAULT_PID_FILE); rewriteConfigStringOption(state,"pidfile",server.pidfile,CONFIG_DEFAULT_PID_FILE);
rewriteConfigNumericalOption(state,"port",server.port,REDIS_SERVERPORT); rewriteConfigNumericalOption(state,"port",server.port,CONFIG_DEFAULT_SERVER_PORT);
rewriteConfigNumericalOption(state,"tcp-backlog",server.tcp_backlog,REDIS_TCP_BACKLOG); rewriteConfigNumericalOption(state,"tcp-backlog",server.tcp_backlog,CONFIG_DEFAULT_TCP_BACKLOG);
rewriteConfigBindOption(state); rewriteConfigBindOption(state);
rewriteConfigStringOption(state,"unixsocket",server.unixsocket,NULL); rewriteConfigStringOption(state,"unixsocket",server.unixsocket,NULL);
rewriteConfigOctalOption(state,"unixsocketperm",server.unixsocketperm,CONFIG_DEFAULT_UNIX_SOCKET_PERM); rewriteConfigOctalOption(state,"unixsocketperm",server.unixsocketperm,CONFIG_DEFAULT_UNIX_SOCKET_PERM);
rewriteConfigNumericalOption(state,"timeout",server.maxidletime,REDIS_MAXIDLETIME); rewriteConfigNumericalOption(state,"timeout",server.maxidletime,CONFIG_DEFAULT_CLIENT_TIMEOUT);
rewriteConfigNumericalOption(state,"tcp-keepalive",server.tcpkeepalive,CONFIG_DEFAULT_TCP_KEEPALIVE); rewriteConfigNumericalOption(state,"tcp-keepalive",server.tcpkeepalive,CONFIG_DEFAULT_TCP_KEEPALIVE);
rewriteConfigEnumOption(state,"loglevel",server.verbosity,loglevel_enum,CONFIG_DEFAULT_VERBOSITY); rewriteConfigEnumOption(state,"loglevel",server.verbosity,loglevel_enum,CONFIG_DEFAULT_VERBOSITY);
rewriteConfigStringOption(state,"logfile",server.logfile,CONFIG_DEFAULT_LOGFILE); rewriteConfigStringOption(state,"logfile",server.logfile,CONFIG_DEFAULT_LOGFILE);
...@@ -1774,8 +1774,8 @@ int rewriteConfig(char *path) { ...@@ -1774,8 +1774,8 @@ int rewriteConfig(char *path) {
rewriteConfigStringOption(state,"masterauth",server.masterauth,NULL); rewriteConfigStringOption(state,"masterauth",server.masterauth,NULL);
rewriteConfigYesNoOption(state,"slave-serve-stale-data",server.repl_serve_stale_data,CONFIG_DEFAULT_SLAVE_SERVE_STALE_DATA); rewriteConfigYesNoOption(state,"slave-serve-stale-data",server.repl_serve_stale_data,CONFIG_DEFAULT_SLAVE_SERVE_STALE_DATA);
rewriteConfigYesNoOption(state,"slave-read-only",server.repl_slave_ro,CONFIG_DEFAULT_SLAVE_READ_ONLY); rewriteConfigYesNoOption(state,"slave-read-only",server.repl_slave_ro,CONFIG_DEFAULT_SLAVE_READ_ONLY);
rewriteConfigNumericalOption(state,"repl-ping-slave-period",server.repl_ping_slave_period,REDIS_REPL_PING_SLAVE_PERIOD); rewriteConfigNumericalOption(state,"repl-ping-slave-period",server.repl_ping_slave_period,CONFIG_DEFAULT_REPL_PING_SLAVE_PERIOD);
rewriteConfigNumericalOption(state,"repl-timeout",server.repl_timeout,REDIS_REPL_TIMEOUT); rewriteConfigNumericalOption(state,"repl-timeout",server.repl_timeout,CONFIG_DEFAULT_REPL_TIMEOUT);
rewriteConfigBytesOption(state,"repl-backlog-size",server.repl_backlog_size,CONFIG_DEFAULT_REPL_BACKLOG_SIZE); rewriteConfigBytesOption(state,"repl-backlog-size",server.repl_backlog_size,CONFIG_DEFAULT_REPL_BACKLOG_SIZE);
rewriteConfigBytesOption(state,"repl-backlog-ttl",server.repl_backlog_time_limit,CONFIG_DEFAULT_REPL_BACKLOG_TIME_LIMIT); rewriteConfigBytesOption(state,"repl-backlog-ttl",server.repl_backlog_time_limit,CONFIG_DEFAULT_REPL_BACKLOG_TIME_LIMIT);
rewriteConfigYesNoOption(state,"repl-disable-tcp-nodelay",server.repl_disable_tcp_nodelay,CONFIG_DEFAULT_REPL_DISABLE_TCP_NODELAY); rewriteConfigYesNoOption(state,"repl-disable-tcp-nodelay",server.repl_disable_tcp_nodelay,CONFIG_DEFAULT_REPL_DISABLE_TCP_NODELAY);
...@@ -1789,22 +1789,22 @@ int rewriteConfig(char *path) { ...@@ -1789,22 +1789,22 @@ int rewriteConfig(char *path) {
rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,CONFIG_DEFAULT_MAXMEMORY); rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,CONFIG_DEFAULT_MAXMEMORY);
rewriteConfigEnumOption(state,"maxmemory-policy",server.maxmemory_policy,maxmemory_policy_enum,CONFIG_DEFAULT_MAXMEMORY_POLICY); rewriteConfigEnumOption(state,"maxmemory-policy",server.maxmemory_policy,maxmemory_policy_enum,CONFIG_DEFAULT_MAXMEMORY_POLICY);
rewriteConfigNumericalOption(state,"maxmemory-samples",server.maxmemory_samples,CONFIG_DEFAULT_MAXMEMORY_SAMPLES); rewriteConfigNumericalOption(state,"maxmemory-samples",server.maxmemory_samples,CONFIG_DEFAULT_MAXMEMORY_SAMPLES);
rewriteConfigYesNoOption(state,"appendonly",server.aof_state != REDIS_AOF_OFF,0); rewriteConfigYesNoOption(state,"appendonly",server.aof_state != AOF_OFF,0);
rewriteConfigStringOption(state,"appendfilename",server.aof_filename,CONFIG_DEFAULT_AOF_FILENAME); rewriteConfigStringOption(state,"appendfilename",server.aof_filename,CONFIG_DEFAULT_AOF_FILENAME);
rewriteConfigEnumOption(state,"appendfsync",server.aof_fsync,aof_fsync_enum,CONFIG_DEFAULT_AOF_FSYNC); rewriteConfigEnumOption(state,"appendfsync",server.aof_fsync,aof_fsync_enum,CONFIG_DEFAULT_AOF_FSYNC);
rewriteConfigYesNoOption(state,"no-appendfsync-on-rewrite",server.aof_no_fsync_on_rewrite,CONFIG_DEFAULT_AOF_NO_FSYNC_ON_REWRITE); rewriteConfigYesNoOption(state,"no-appendfsync-on-rewrite",server.aof_no_fsync_on_rewrite,CONFIG_DEFAULT_AOF_NO_FSYNC_ON_REWRITE);
rewriteConfigNumericalOption(state,"auto-aof-rewrite-percentage",server.aof_rewrite_perc,REDIS_AOF_REWRITE_PERC); rewriteConfigNumericalOption(state,"auto-aof-rewrite-percentage",server.aof_rewrite_perc,AOF_REWRITE_PERC);
rewriteConfigBytesOption(state,"auto-aof-rewrite-min-size",server.aof_rewrite_min_size,REDIS_AOF_REWRITE_MIN_SIZE); rewriteConfigBytesOption(state,"auto-aof-rewrite-min-size",server.aof_rewrite_min_size,AOF_REWRITE_MIN_SIZE);
rewriteConfigNumericalOption(state,"lua-time-limit",server.lua_time_limit,REDIS_LUA_TIME_LIMIT); rewriteConfigNumericalOption(state,"lua-time-limit",server.lua_time_limit,LUA_SCRIPT_TIME_LIMIT);
rewriteConfigYesNoOption(state,"cluster-enabled",server.cluster_enabled,0); rewriteConfigYesNoOption(state,"cluster-enabled",server.cluster_enabled,0);
rewriteConfigStringOption(state,"cluster-config-file",server.cluster_configfile,CONFIG_DEFAULT_CLUSTER_CONFIG_FILE); rewriteConfigStringOption(state,"cluster-config-file",server.cluster_configfile,CONFIG_DEFAULT_CLUSTER_CONFIG_FILE);
rewriteConfigYesNoOption(state,"cluster-require-full-coverage",server.cluster_require_full_coverage,REDIS_CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE); rewriteConfigYesNoOption(state,"cluster-require-full-coverage",server.cluster_require_full_coverage,REDIS_CLUSTER_DEFAULT_REQUIRE_FULL_COVERAGE);
rewriteConfigNumericalOption(state,"cluster-node-timeout",server.cluster_node_timeout,REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT); rewriteConfigNumericalOption(state,"cluster-node-timeout",server.cluster_node_timeout,REDIS_CLUSTER_DEFAULT_NODE_TIMEOUT);
rewriteConfigNumericalOption(state,"cluster-migration-barrier",server.cluster_migration_barrier,REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER); rewriteConfigNumericalOption(state,"cluster-migration-barrier",server.cluster_migration_barrier,REDIS_CLUSTER_DEFAULT_MIGRATION_BARRIER);
rewriteConfigNumericalOption(state,"cluster-slave-validity-factor",server.cluster_slave_validity_factor,REDIS_CLUSTER_DEFAULT_SLAVE_VALIDITY); rewriteConfigNumericalOption(state,"cluster-slave-validity-factor",server.cluster_slave_validity_factor,REDIS_CLUSTER_DEFAULT_SLAVE_VALIDITY);
rewriteConfigNumericalOption(state,"slowlog-log-slower-than",server.slowlog_log_slower_than,REDIS_SLOWLOG_LOG_SLOWER_THAN); rewriteConfigNumericalOption(state,"slowlog-log-slower-than",server.slowlog_log_slower_than,CONFIG_DEFAULT_SLOWLOG_LOG_SLOWER_THAN);
rewriteConfigNumericalOption(state,"latency-monitor-threshold",server.latency_monitor_threshold,CONFIG_DEFAULT_LATENCY_MONITOR_THRESHOLD); rewriteConfigNumericalOption(state,"latency-monitor-threshold",server.latency_monitor_threshold,CONFIG_DEFAULT_LATENCY_MONITOR_THRESHOLD);
rewriteConfigNumericalOption(state,"slowlog-max-len",server.slowlog_max_len,REDIS_SLOWLOG_MAX_LEN); rewriteConfigNumericalOption(state,"slowlog-max-len",server.slowlog_max_len,CONFIG_DEFAULT_SLOWLOG_MAX_LEN);
rewriteConfigNotifykeyspaceeventsOption(state); rewriteConfigNotifykeyspaceeventsOption(state);
rewriteConfigNumericalOption(state,"hash-max-ziplist-entries",server.hash_max_ziplist_entries,OBJ_HASH_MAX_ZIPLIST_ENTRIES); rewriteConfigNumericalOption(state,"hash-max-ziplist-entries",server.hash_max_ziplist_entries,OBJ_HASH_MAX_ZIPLIST_ENTRIES);
rewriteConfigNumericalOption(state,"hash-max-ziplist-value",server.hash_max_ziplist_value,OBJ_HASH_MAX_ZIPLIST_VALUE); rewriteConfigNumericalOption(state,"hash-max-ziplist-value",server.hash_max_ziplist_value,OBJ_HASH_MAX_ZIPLIST_VALUE);
...@@ -1819,7 +1819,7 @@ int rewriteConfig(char *path) { ...@@ -1819,7 +1819,7 @@ int rewriteConfig(char *path) {
rewriteConfigNumericalOption(state,"hz",server.hz,CONFIG_DEFAULT_HZ); rewriteConfigNumericalOption(state,"hz",server.hz,CONFIG_DEFAULT_HZ);
rewriteConfigYesNoOption(state,"aof-rewrite-incremental-fsync",server.aof_rewrite_incremental_fsync,CONFIG_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC); rewriteConfigYesNoOption(state,"aof-rewrite-incremental-fsync",server.aof_rewrite_incremental_fsync,CONFIG_DEFAULT_AOF_REWRITE_INCREMENTAL_FSYNC);
rewriteConfigYesNoOption(state,"aof-load-truncated",server.aof_load_truncated,CONFIG_DEFAULT_AOF_LOAD_TRUNCATED); rewriteConfigYesNoOption(state,"aof-load-truncated",server.aof_load_truncated,CONFIG_DEFAULT_AOF_LOAD_TRUNCATED);
rewriteConfigEnumOption(state,"supervised",server.supervised_mode,supervised_mode_enum,REDIS_SUPERVISED_NONE); rewriteConfigEnumOption(state,"supervised",server.supervised_mode,supervised_mode_enum,SUPERVISED_NONE);
/* Rewrite Sentinel config if in Sentinel mode. */ /* Rewrite Sentinel config if in Sentinel mode. */
if (server.sentinel_mode) rewriteConfigSentinelOption(state); if (server.sentinel_mode) rewriteConfigSentinelOption(state);
...@@ -1862,10 +1862,10 @@ void configCommand(client *c) { ...@@ -1862,10 +1862,10 @@ void configCommand(client *c) {
return; return;
} }
if (rewriteConfig(server.configfile) == -1) { if (rewriteConfig(server.configfile) == -1) {
serverLog(REDIS_WARNING,"CONFIG REWRITE failed: %s", strerror(errno)); serverLog(LL_WARNING,"CONFIG REWRITE failed: %s", strerror(errno));
addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno)); addReplyErrorFormat(c,"Rewriting config file: %s", strerror(errno));
} else { } else {
serverLog(REDIS_WARNING,"CONFIG REWRITE executed with success."); serverLog(LL_WARNING,"CONFIG REWRITE executed with success.");
addReply(c,shared.ok); addReply(c,shared.ok);
} }
} else { } else {
......
...@@ -81,7 +81,7 @@ robj *lookupKeyRead(redisDb *db, robj *key) { ...@@ -81,7 +81,7 @@ robj *lookupKeyRead(redisDb *db, robj *key) {
if (server.current_client && if (server.current_client &&
server.current_client != server.master && server.current_client != server.master &&
server.current_client->cmd && server.current_client->cmd &&
server.current_client->cmd->flags & REDIS_CMD_READONLY) server.current_client->cmd->flags & CMD_READONLY)
{ {
return NULL; return NULL;
} }
...@@ -309,7 +309,7 @@ void delCommand(client *c) { ...@@ -309,7 +309,7 @@ void delCommand(client *c) {
expireIfNeeded(c->db,c->argv[j]); expireIfNeeded(c->db,c->argv[j]);
if (dbDelete(c->db,c->argv[j])) { if (dbDelete(c->db,c->argv[j])) {
signalModifiedKey(c->db,c->argv[j]); signalModifiedKey(c->db,c->argv[j]);
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC, notifyKeyspaceEvent(NOTIFY_GENERIC,
"del",c->argv[j],c->db->id); "del",c->argv[j],c->db->id);
server.dirty++; server.dirty++;
deleted++; deleted++;
...@@ -412,7 +412,7 @@ void scanCallback(void *privdata, const dictEntry *de) { ...@@ -412,7 +412,7 @@ void scanCallback(void *privdata, const dictEntry *de) {
incrRefCount(key); incrRefCount(key);
val = createStringObjectFromLongDouble(*(double*)dictGetVal(de),0); val = createStringObjectFromLongDouble(*(double*)dictGetVal(de),0);
} else { } else {
redisPanic("Type not handled in SCAN callback."); serverPanic("Type not handled in SCAN callback.");
} }
listAddNodeTail(keys, key); listAddNodeTail(keys, key);
...@@ -560,7 +560,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) { ...@@ -560,7 +560,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
} }
cursor = 0; cursor = 0;
} else { } else {
redisPanic("Not handled encoding in SCAN."); serverPanic("Not handled encoding in SCAN.");
} }
/* Step 3: Filter elements. */ /* Step 3: Filter elements. */
...@@ -576,7 +576,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) { ...@@ -576,7 +576,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
if (!stringmatchlen(pat, patlen, kobj->ptr, sdslen(kobj->ptr), 0)) if (!stringmatchlen(pat, patlen, kobj->ptr, sdslen(kobj->ptr), 0))
filter = 1; filter = 1;
} else { } else {
char buf[REDIS_LONGSTR_SIZE]; char buf[LONG_STR_SIZE];
int len; int len;
serverAssert(kobj->encoding == OBJ_ENCODING_INT); serverAssert(kobj->encoding == OBJ_ENCODING_INT);
...@@ -669,9 +669,9 @@ void shutdownCommand(client *c) { ...@@ -669,9 +669,9 @@ void shutdownCommand(client *c) {
return; return;
} else if (c->argc == 2) { } else if (c->argc == 2) {
if (!strcasecmp(c->argv[1]->ptr,"nosave")) { if (!strcasecmp(c->argv[1]->ptr,"nosave")) {
flags |= REDIS_SHUTDOWN_NOSAVE; flags |= SHUTDOWN_NOSAVE;
} else if (!strcasecmp(c->argv[1]->ptr,"save")) { } else if (!strcasecmp(c->argv[1]->ptr,"save")) {
flags |= REDIS_SHUTDOWN_SAVE; flags |= SHUTDOWN_SAVE;
} else { } else {
addReply(c,shared.syntaxerr); addReply(c,shared.syntaxerr);
return; return;
...@@ -684,7 +684,7 @@ void shutdownCommand(client *c) { ...@@ -684,7 +684,7 @@ void shutdownCommand(client *c) {
* *
* Also when in Sentinel mode clear the SAVE flag and force NOSAVE. */ * Also when in Sentinel mode clear the SAVE flag and force NOSAVE. */
if (server.loading || server.sentinel_mode) if (server.loading || server.sentinel_mode)
flags = (flags & ~REDIS_SHUTDOWN_SAVE) | REDIS_SHUTDOWN_NOSAVE; flags = (flags & ~SHUTDOWN_SAVE) | SHUTDOWN_NOSAVE;
if (prepareForShutdown(flags) == C_OK) exit(0); if (prepareForShutdown(flags) == C_OK) exit(0);
addReplyError(c,"Errors trying to SHUTDOWN. Check logs."); addReplyError(c,"Errors trying to SHUTDOWN. Check logs.");
} }
...@@ -723,9 +723,9 @@ void renameGenericCommand(client *c, int nx) { ...@@ -723,9 +723,9 @@ void renameGenericCommand(client *c, int nx) {
dbDelete(c->db,c->argv[1]); dbDelete(c->db,c->argv[1]);
signalModifiedKey(c->db,c->argv[1]); signalModifiedKey(c->db,c->argv[1]);
signalModifiedKey(c->db,c->argv[2]); signalModifiedKey(c->db,c->argv[2]);
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"rename_from", notifyKeyspaceEvent(NOTIFY_GENERIC,"rename_from",
c->argv[1],c->db->id); c->argv[1],c->db->id);
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"rename_to", notifyKeyspaceEvent(NOTIFY_GENERIC,"rename_to",
c->argv[2],c->db->id); c->argv[2],c->db->id);
server.dirty++; server.dirty++;
addReply(c,nx ? shared.cone : shared.ok); addReply(c,nx ? shared.cone : shared.ok);
...@@ -844,7 +844,7 @@ void propagateExpire(redisDb *db, robj *key) { ...@@ -844,7 +844,7 @@ void propagateExpire(redisDb *db, robj *key) {
incrRefCount(argv[0]); incrRefCount(argv[0]);
incrRefCount(argv[1]); incrRefCount(argv[1]);
if (server.aof_state != REDIS_AOF_OFF) if (server.aof_state != AOF_OFF)
feedAppendOnlyFile(server.delCommand,db->id,argv,2); feedAppendOnlyFile(server.delCommand,db->id,argv,2);
replicationFeedSlaves(server.slaves,db->id,argv,2); replicationFeedSlaves(server.slaves,db->id,argv,2);
...@@ -883,7 +883,7 @@ int expireIfNeeded(redisDb *db, robj *key) { ...@@ -883,7 +883,7 @@ int expireIfNeeded(redisDb *db, robj *key) {
/* Delete the key */ /* Delete the key */
server.stat_expiredkeys++; server.stat_expiredkeys++;
propagateExpire(db,key); propagateExpire(db,key);
notifyKeyspaceEvent(REDIS_NOTIFY_EXPIRED, notifyKeyspaceEvent(NOTIFY_EXPIRED,
"expired",key,db->id); "expired",key,db->id);
return dbDelete(db,key); return dbDelete(db,key);
} }
...@@ -932,14 +932,14 @@ void expireGenericCommand(client *c, long long basetime, int unit) { ...@@ -932,14 +932,14 @@ void expireGenericCommand(client *c, long long basetime, int unit) {
rewriteClientCommandVector(c,2,aux,key); rewriteClientCommandVector(c,2,aux,key);
decrRefCount(aux); decrRefCount(aux);
signalModifiedKey(c->db,key); signalModifiedKey(c->db,key);
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"del",key,c->db->id); notifyKeyspaceEvent(NOTIFY_GENERIC,"del",key,c->db->id);
addReply(c, shared.cone); addReply(c, shared.cone);
return; return;
} else { } else {
setExpire(c->db,key,when); setExpire(c->db,key,when);
addReply(c,shared.cone); addReply(c,shared.cone);
signalModifiedKey(c->db,key); signalModifiedKey(c->db,key);
notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"expire",key,c->db->id); notifyKeyspaceEvent(NOTIFY_GENERIC,"expire",key,c->db->id);
server.dirty++; server.dirty++;
return; return;
} }
...@@ -1015,7 +1015,7 @@ void persistCommand(client *c) { ...@@ -1015,7 +1015,7 @@ void persistCommand(client *c) {
* (firstkey, lastkey, step). */ * (firstkey, lastkey, step). */
int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, int *numkeys) { int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, int *numkeys) {
int j, i = 0, last, *keys; int j, i = 0, last, *keys;
REDIS_NOTUSED(argv); UNUSED(argv);
if (cmd->firstkey == 0) { if (cmd->firstkey == 0) {
*numkeys = 0; *numkeys = 0;
...@@ -1061,7 +1061,7 @@ void getKeysFreeResult(int *result) { ...@@ -1061,7 +1061,7 @@ void getKeysFreeResult(int *result) {
* ZINTERSTORE <destkey> <num-keys> <key> <key> ... <key> <options> */ * ZINTERSTORE <destkey> <num-keys> <key> <key> ... <key> <options> */
int *zunionInterGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) { int *zunionInterGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) {
int i, num, *keys; int i, num, *keys;
REDIS_NOTUSED(cmd); UNUSED(cmd);
num = atoi(argv[2]->ptr); num = atoi(argv[2]->ptr);
/* Sanity check. Don't return any key if the command is going to /* Sanity check. Don't return any key if the command is going to
...@@ -1090,7 +1090,7 @@ int *zunionInterGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *nu ...@@ -1090,7 +1090,7 @@ int *zunionInterGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *nu
* EVALSHA <script> <num-keys> <key> <key> ... <key> [more stuff] */ * EVALSHA <script> <num-keys> <key> <key> ... <key> [more stuff] */
int *evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) { int *evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) {
int i, num, *keys; int i, num, *keys;
REDIS_NOTUSED(cmd); UNUSED(cmd);
num = atoi(argv[2]->ptr); num = atoi(argv[2]->ptr);
/* Sanity check. Don't return any key if the command is going to /* Sanity check. Don't return any key if the command is going to
...@@ -1118,7 +1118,7 @@ int *evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) ...@@ -1118,7 +1118,7 @@ int *evalGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys)
* correctly identify keys in the "STORE" option. */ * correctly identify keys in the "STORE" option. */
int *sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) { int *sortGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) {
int i, j, num, *keys, found_store = 0; int i, j, num, *keys, found_store = 0;
REDIS_NOTUSED(cmd); UNUSED(cmd);
num = 0; num = 0;
keys = zmalloc(sizeof(int)*2); /* Alloc 2 places for the worst case. */ keys = zmalloc(sizeof(int)*2); /* Alloc 2 places for the worst case. */
......
...@@ -153,7 +153,7 @@ void computeDatasetDigest(unsigned char *final) { ...@@ -153,7 +153,7 @@ void computeDatasetDigest(unsigned char *final) {
if (o->type == OBJ_STRING) { if (o->type == OBJ_STRING) {
mixObjectDigest(digest,o); mixObjectDigest(digest,o);
} else if (o->type == OBJ_LIST) { } else if (o->type == OBJ_LIST) {
listTypeIterator *li = listTypeInitIterator(o,0,REDIS_TAIL); listTypeIterator *li = listTypeInitIterator(o,0,LIST_TAIL);
listTypeEntry entry; listTypeEntry entry;
while(listTypeNext(li,&entry)) { while(listTypeNext(li,&entry)) {
robj *eleobj = listTypeGet(&entry); robj *eleobj = listTypeGet(&entry);
...@@ -219,7 +219,7 @@ void computeDatasetDigest(unsigned char *final) { ...@@ -219,7 +219,7 @@ void computeDatasetDigest(unsigned char *final) {
} }
dictReleaseIterator(di); dictReleaseIterator(di);
} else { } else {
redisPanic("Unknown sorted set encoding"); serverPanic("Unknown sorted set encoding");
} }
} else if (o->type == OBJ_HASH) { } else if (o->type == OBJ_HASH) {
hashTypeIterator *hi; hashTypeIterator *hi;
...@@ -240,7 +240,7 @@ void computeDatasetDigest(unsigned char *final) { ...@@ -240,7 +240,7 @@ void computeDatasetDigest(unsigned char *final) {
} }
hashTypeReleaseIterator(hi); hashTypeReleaseIterator(hi);
} else { } else {
redisPanic("Unknown object type"); serverPanic("Unknown object type");
} }
/* If the key has an expire, add it to the mix */ /* If the key has an expire, add it to the mix */
if (expiretime != -1) xorDigest(digest,"!!expire!!",10); if (expiretime != -1) xorDigest(digest,"!!expire!!",10);
...@@ -278,7 +278,7 @@ void debugCommand(client *c) { ...@@ -278,7 +278,7 @@ void debugCommand(client *c) {
addReplyError(c,"Error trying to load the RDB dump"); addReplyError(c,"Error trying to load the RDB dump");
return; return;
} }
serverLog(REDIS_WARNING,"DB reloaded by DEBUG RELOAD"); serverLog(LL_WARNING,"DB reloaded by DEBUG RELOAD");
addReply(c,shared.ok); addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"loadaof")) { } else if (!strcasecmp(c->argv[1]->ptr,"loadaof")) {
emptyDb(NULL); emptyDb(NULL);
...@@ -287,7 +287,7 @@ void debugCommand(client *c) { ...@@ -287,7 +287,7 @@ void debugCommand(client *c) {
return; return;
} }
server.dirty = 0; /* Prevent AOF / replication */ server.dirty = 0; /* Prevent AOF / replication */
serverLog(REDIS_WARNING,"Append Only File loaded by DEBUG LOADAOF"); serverLog(LL_WARNING,"Append Only File loaded by DEBUG LOADAOF");
addReply(c,shared.ok); addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) { } else if (!strcasecmp(c->argv[1]->ptr,"object") && c->argc == 3) {
dictEntry *de; dictEntry *de;
...@@ -472,13 +472,13 @@ void debugCommand(client *c) { ...@@ -472,13 +472,13 @@ void debugCommand(client *c) {
void _serverAssert(char *estr, char *file, int line) { void _serverAssert(char *estr, char *file, int line) {
bugReportStart(); bugReportStart();
serverLog(REDIS_WARNING,"=== ASSERTION FAILED ==="); serverLog(LL_WARNING,"=== ASSERTION FAILED ===");
serverLog(REDIS_WARNING,"==> %s:%d '%s' is not true",file,line,estr); serverLog(LL_WARNING,"==> %s:%d '%s' is not true",file,line,estr);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
server.assert_failed = estr; server.assert_failed = estr;
server.assert_file = file; server.assert_file = file;
server.assert_line = line; server.assert_line = line;
serverLog(REDIS_WARNING,"(forcing SIGSEGV to print the bug report.)"); serverLog(LL_WARNING,"(forcing SIGSEGV to print the bug report.)");
#endif #endif
*((char*)-1) = 'x'; *((char*)-1) = 'x';
} }
...@@ -487,10 +487,10 @@ void _serverAssertPrintClientInfo(client *c) { ...@@ -487,10 +487,10 @@ void _serverAssertPrintClientInfo(client *c) {
int j; int j;
bugReportStart(); bugReportStart();
serverLog(REDIS_WARNING,"=== ASSERTION FAILED CLIENT CONTEXT ==="); serverLog(LL_WARNING,"=== ASSERTION FAILED CLIENT CONTEXT ===");
serverLog(REDIS_WARNING,"client->flags = %d", c->flags); serverLog(LL_WARNING,"client->flags = %d", c->flags);
serverLog(REDIS_WARNING,"client->fd = %d", c->fd); serverLog(LL_WARNING,"client->fd = %d", c->fd);
serverLog(REDIS_WARNING,"client->argc = %d", c->argc); serverLog(LL_WARNING,"client->argc = %d", c->argc);
for (j=0; j < c->argc; j++) { for (j=0; j < c->argc; j++) {
char buf[128]; char buf[128];
char *arg; char *arg;
...@@ -502,38 +502,38 @@ void _serverAssertPrintClientInfo(client *c) { ...@@ -502,38 +502,38 @@ void _serverAssertPrintClientInfo(client *c) {
c->argv[j]->type, c->argv[j]->encoding); c->argv[j]->type, c->argv[j]->encoding);
arg = buf; arg = buf;
} }
serverLog(REDIS_WARNING,"client->argv[%d] = \"%s\" (refcount: %d)", serverLog(LL_WARNING,"client->argv[%d] = \"%s\" (refcount: %d)",
j, arg, c->argv[j]->refcount); j, arg, c->argv[j]->refcount);
} }
} }
void serverLogObjectDebugInfo(robj *o) { void serverLogObjectDebugInfo(robj *o) {
serverLog(REDIS_WARNING,"Object type: %d", o->type); serverLog(LL_WARNING,"Object type: %d", o->type);
serverLog(REDIS_WARNING,"Object encoding: %d", o->encoding); serverLog(LL_WARNING,"Object encoding: %d", o->encoding);
serverLog(REDIS_WARNING,"Object refcount: %d", o->refcount); serverLog(LL_WARNING,"Object refcount: %d", o->refcount);
if (o->type == OBJ_STRING && sdsEncodedObject(o)) { if (o->type == OBJ_STRING && sdsEncodedObject(o)) {
serverLog(REDIS_WARNING,"Object raw string len: %zu", sdslen(o->ptr)); serverLog(LL_WARNING,"Object raw string len: %zu", sdslen(o->ptr));
if (sdslen(o->ptr) < 4096) { if (sdslen(o->ptr) < 4096) {
sds repr = sdscatrepr(sdsempty(),o->ptr,sdslen(o->ptr)); sds repr = sdscatrepr(sdsempty(),o->ptr,sdslen(o->ptr));
serverLog(REDIS_WARNING,"Object raw string content: %s", repr); serverLog(LL_WARNING,"Object raw string content: %s", repr);
sdsfree(repr); sdsfree(repr);
} }
} else if (o->type == OBJ_LIST) { } else if (o->type == OBJ_LIST) {
serverLog(REDIS_WARNING,"List length: %d", (int) listTypeLength(o)); serverLog(LL_WARNING,"List length: %d", (int) listTypeLength(o));
} else if (o->type == OBJ_SET) { } else if (o->type == OBJ_SET) {
serverLog(REDIS_WARNING,"Set size: %d", (int) setTypeSize(o)); serverLog(LL_WARNING,"Set size: %d", (int) setTypeSize(o));
} else if (o->type == OBJ_HASH) { } else if (o->type == OBJ_HASH) {
serverLog(REDIS_WARNING,"Hash size: %d", (int) hashTypeLength(o)); serverLog(LL_WARNING,"Hash size: %d", (int) hashTypeLength(o));
} else if (o->type == OBJ_ZSET) { } else if (o->type == OBJ_ZSET) {
serverLog(REDIS_WARNING,"Sorted set size: %d", (int) zsetLength(o)); serverLog(LL_WARNING,"Sorted set size: %d", (int) zsetLength(o));
if (o->encoding == OBJ_ENCODING_SKIPLIST) if (o->encoding == OBJ_ENCODING_SKIPLIST)
serverLog(REDIS_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level); serverLog(LL_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level);
} }
} }
void _serverAssertPrintObject(robj *o) { void _serverAssertPrintObject(robj *o) {
bugReportStart(); bugReportStart();
serverLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ==="); serverLog(LL_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ===");
serverLogObjectDebugInfo(o); serverLogObjectDebugInfo(o);
} }
...@@ -543,21 +543,21 @@ void _serverAssertWithInfo(client *c, robj *o, char *estr, char *file, int line) ...@@ -543,21 +543,21 @@ void _serverAssertWithInfo(client *c, robj *o, char *estr, char *file, int line)
_serverAssert(estr,file,line); _serverAssert(estr,file,line);
} }
void _redisPanic(char *msg, char *file, int line) { void _serverPanic(char *msg, char *file, int line) {
bugReportStart(); bugReportStart();
serverLog(REDIS_WARNING,"------------------------------------------------"); serverLog(LL_WARNING,"------------------------------------------------");
serverLog(REDIS_WARNING,"!!! Software Failure. Press left mouse button to continue"); serverLog(LL_WARNING,"!!! Software Failure. Press left mouse button to continue");
serverLog(REDIS_WARNING,"Guru Meditation: %s #%s:%d",msg,file,line); serverLog(LL_WARNING,"Guru Meditation: %s #%s:%d",msg,file,line);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
serverLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)"); serverLog(LL_WARNING,"(forcing SIGSEGV in order to print the stack trace)");
#endif #endif
serverLog(REDIS_WARNING,"------------------------------------------------"); serverLog(LL_WARNING,"------------------------------------------------");
*((char*)-1) = 'x'; *((char*)-1) = 'x';
} }
void bugReportStart(void) { void bugReportStart(void) {
if (server.bug_report_start == 0) { if (server.bug_report_start == 0) {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"\n\n=== REDIS BUG REPORT START: Cut & paste starting from here ==="); "\n\n=== REDIS BUG REPORT START: Cut & paste starting from here ===");
server.bug_report_start = 1; server.bug_report_start = 1;
} }
...@@ -602,20 +602,20 @@ void logStackContent(void **sp) { ...@@ -602,20 +602,20 @@ void logStackContent(void **sp) {
unsigned long val = (unsigned long) sp[i]; unsigned long val = (unsigned long) sp[i];
if (sizeof(long) == 4) if (sizeof(long) == 4)
serverLog(REDIS_WARNING, "(%08lx) -> %08lx", addr, val); serverLog(LL_WARNING, "(%08lx) -> %08lx", addr, val);
else else
serverLog(REDIS_WARNING, "(%016lx) -> %016lx", addr, val); serverLog(LL_WARNING, "(%016lx) -> %016lx", addr, val);
} }
} }
void logRegisters(ucontext_t *uc) { void logRegisters(ucontext_t *uc) {
serverLog(REDIS_WARNING, "--- REGISTERS"); serverLog(LL_WARNING, "--- REGISTERS");
/* OSX */ /* OSX */
#if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6) #if defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6)
/* OSX AMD64 */ /* OSX AMD64 */
#if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__) #if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__)
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"\n" "\n"
"RAX:%016lx RBX:%016lx\nRCX:%016lx RDX:%016lx\n" "RAX:%016lx RBX:%016lx\nRCX:%016lx RDX:%016lx\n"
"RDI:%016lx RSI:%016lx\nRBP:%016lx RSP:%016lx\n" "RDI:%016lx RSI:%016lx\nRBP:%016lx RSP:%016lx\n"
...@@ -647,7 +647,7 @@ void logRegisters(ucontext_t *uc) { ...@@ -647,7 +647,7 @@ void logRegisters(ucontext_t *uc) {
logStackContent((void**)uc->uc_mcontext->__ss.__rsp); logStackContent((void**)uc->uc_mcontext->__ss.__rsp);
#else #else
/* OSX x86 */ /* OSX x86 */
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"\n" "\n"
"EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n" "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n"
"EDI:%08lx ESI:%08lx EBP:%08lx ESP:%08lx\n" "EDI:%08lx ESI:%08lx EBP:%08lx ESP:%08lx\n"
...@@ -676,7 +676,7 @@ void logRegisters(ucontext_t *uc) { ...@@ -676,7 +676,7 @@ void logRegisters(ucontext_t *uc) {
#elif defined(__linux__) #elif defined(__linux__)
/* Linux x86 */ /* Linux x86 */
#if defined(__i386__) #if defined(__i386__)
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"\n" "\n"
"EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n" "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n"
"EDI:%08lx ESI:%08lx EBP:%08lx ESP:%08lx\n" "EDI:%08lx ESI:%08lx EBP:%08lx ESP:%08lx\n"
...@@ -702,7 +702,7 @@ void logRegisters(ucontext_t *uc) { ...@@ -702,7 +702,7 @@ void logRegisters(ucontext_t *uc) {
logStackContent((void**)uc->uc_mcontext.gregs[7]); logStackContent((void**)uc->uc_mcontext.gregs[7]);
#elif defined(__X86_64__) || defined(__x86_64__) #elif defined(__X86_64__) || defined(__x86_64__)
/* Linux AMD64 */ /* Linux AMD64 */
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"\n" "\n"
"RAX:%016lx RBX:%016lx\nRCX:%016lx RDX:%016lx\n" "RAX:%016lx RBX:%016lx\nRCX:%016lx RDX:%016lx\n"
"RDI:%016lx RSI:%016lx\nRBP:%016lx RSP:%016lx\n" "RDI:%016lx RSI:%016lx\nRBP:%016lx RSP:%016lx\n"
...@@ -732,7 +732,7 @@ void logRegisters(ucontext_t *uc) { ...@@ -732,7 +732,7 @@ void logRegisters(ucontext_t *uc) {
logStackContent((void**)uc->uc_mcontext.gregs[15]); logStackContent((void**)uc->uc_mcontext.gregs[15]);
#endif #endif
#else #else
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
" Dumping of registers not supported for this OS/arch"); " Dumping of registers not supported for this OS/arch");
#endif #endif
} }
...@@ -774,15 +774,15 @@ void logCurrentClient(void) { ...@@ -774,15 +774,15 @@ void logCurrentClient(void) {
sds client; sds client;
int j; int j;
serverLog(REDIS_WARNING, "--- CURRENT CLIENT INFO"); serverLog(LL_WARNING, "--- CURRENT CLIENT INFO");
client = catClientInfoString(sdsempty(),cc); client = catClientInfoString(sdsempty(),cc);
serverLog(REDIS_WARNING,"client: %s", client); serverLog(LL_WARNING,"client: %s", client);
sdsfree(client); sdsfree(client);
for (j = 0; j < cc->argc; j++) { for (j = 0; j < cc->argc; j++) {
robj *decoded; robj *decoded;
decoded = getDecodedObject(cc->argv[j]); decoded = getDecodedObject(cc->argv[j]);
serverLog(REDIS_WARNING,"argv[%d]: '%s'", j, (char*)decoded->ptr); serverLog(LL_WARNING,"argv[%d]: '%s'", j, (char*)decoded->ptr);
decrRefCount(decoded); decrRefCount(decoded);
} }
/* Check if the first argument, usually a key, is found inside the /* Check if the first argument, usually a key, is found inside the
...@@ -795,7 +795,7 @@ void logCurrentClient(void) { ...@@ -795,7 +795,7 @@ void logCurrentClient(void) {
de = dictFind(cc->db->dict, key->ptr); de = dictFind(cc->db->dict, key->ptr);
if (de) { if (de) {
val = dictGetVal(de); val = dictGetVal(de);
serverLog(REDIS_WARNING,"key '%s' found in DB containing the following object:", (char*)key->ptr); serverLog(LL_WARNING,"key '%s' found in DB containing the following object:", (char*)key->ptr);
serverLogObjectDebugInfo(val); serverLogObjectDebugInfo(val);
} }
decrRefCount(key); decrRefCount(key);
...@@ -889,28 +889,28 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) { ...@@ -889,28 +889,28 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
ucontext_t *uc = (ucontext_t*) secret; ucontext_t *uc = (ucontext_t*) secret;
sds infostring, clients; sds infostring, clients;
struct sigaction act; struct sigaction act;
REDIS_NOTUSED(info); UNUSED(info);
bugReportStart(); bugReportStart();
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
" Redis %s crashed by signal: %d", REDIS_VERSION, sig); " Redis %s crashed by signal: %d", REDIS_VERSION, sig);
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
" Failed assertion: %s (%s:%d)", server.assert_failed, " Failed assertion: %s (%s:%d)", server.assert_failed,
server.assert_file, server.assert_line); server.assert_file, server.assert_line);
/* Log the stack trace */ /* Log the stack trace */
serverLog(REDIS_WARNING, "--- STACK TRACE"); serverLog(LL_WARNING, "--- STACK TRACE");
logStackTrace(uc); logStackTrace(uc);
/* Log INFO and CLIENT LIST */ /* Log INFO and CLIENT LIST */
serverLog(REDIS_WARNING, "--- INFO OUTPUT"); serverLog(LL_WARNING, "--- INFO OUTPUT");
infostring = genRedisInfoString("all"); infostring = genRedisInfoString("all");
infostring = sdscatprintf(infostring, "hash_init_value: %u\n", infostring = sdscatprintf(infostring, "hash_init_value: %u\n",
dictGetHashFunctionSeed()); dictGetHashFunctionSeed());
serverLogRaw(REDIS_WARNING, infostring); serverLogRaw(LL_WARNING, infostring);
serverLog(REDIS_WARNING, "--- CLIENT LIST OUTPUT"); serverLog(LL_WARNING, "--- CLIENT LIST OUTPUT");
clients = getAllClientsInfoString(); clients = getAllClientsInfoString();
serverLogRaw(REDIS_WARNING, clients); serverLogRaw(LL_WARNING, clients);
sdsfree(infostring); sdsfree(infostring);
sdsfree(clients); sdsfree(clients);
...@@ -922,18 +922,18 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) { ...@@ -922,18 +922,18 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
#if defined(HAVE_PROC_MAPS) #if defined(HAVE_PROC_MAPS)
/* Test memory */ /* Test memory */
serverLog(REDIS_WARNING, "--- FAST MEMORY TEST"); serverLog(LL_WARNING, "--- FAST MEMORY TEST");
bioKillThreads(); bioKillThreads();
if (memtest_test_linux_anonymous_maps()) { if (memtest_test_linux_anonymous_maps()) {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"!!! MEMORY ERROR DETECTED! Check your memory ASAP !!!"); "!!! MEMORY ERROR DETECTED! Check your memory ASAP !!!");
} else { } else {
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible."); "Fast memory test PASSED, however your memory can still be broken. Please run a memory test for several hours if possible.");
} }
#endif #endif
serverLog(REDIS_WARNING, serverLog(LL_WARNING,
"\n=== REDIS BUG REPORT END. Make sure to include from START to END. ===\n\n" "\n=== REDIS BUG REPORT END. Make sure to include from START to END. ===\n\n"
" Please report the crash by opening an issue on github:\n\n" " Please report the crash by opening an issue on github:\n\n"
" http://github.com/antirez/redis/issues\n\n" " http://github.com/antirez/redis/issues\n\n"
...@@ -969,11 +969,11 @@ void serverLogHexDump(int level, char *descr, void *value, size_t len) { ...@@ -969,11 +969,11 @@ void serverLogHexDump(int level, char *descr, void *value, size_t len) {
len--; len--;
v++; v++;
if (b-buf == 64 || len == 0) { if (b-buf == 64 || len == 0) {
serverLogRaw(level|REDIS_LOG_RAW,buf); serverLogRaw(level|LL_RAW,buf);
b = buf; b = buf;
} }
} }
serverLogRaw(level|REDIS_LOG_RAW,"\n"); serverLogRaw(level|LL_RAW,"\n");
} }
/* =========================== Software Watchdog ============================ */ /* =========================== Software Watchdog ============================ */
...@@ -983,16 +983,16 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) { ...@@ -983,16 +983,16 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) {
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
ucontext_t *uc = (ucontext_t*) secret; ucontext_t *uc = (ucontext_t*) secret;
#endif #endif
REDIS_NOTUSED(info); UNUSED(info);
REDIS_NOTUSED(sig); UNUSED(sig);
serverLogFromHandler(REDIS_WARNING,"\n--- WATCHDOG TIMER EXPIRED ---"); serverLogFromHandler(LL_WARNING,"\n--- WATCHDOG TIMER EXPIRED ---");
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
logStackTrace(uc); logStackTrace(uc);
#else #else
serverLogFromHandler(REDIS_WARNING,"Sorry: no support for backtrace()."); serverLogFromHandler(LL_WARNING,"Sorry: no support for backtrace().");
#endif #endif
serverLogFromHandler(REDIS_WARNING,"--------\n"); serverLogFromHandler(LL_WARNING,"--------\n");
} }
/* Schedule a SIGALRM delivery after the specified period in milliseconds. /* Schedule a SIGALRM delivery after the specified period in milliseconds.
......
...@@ -991,7 +991,7 @@ uint64_t hllCount(struct hllhdr *hdr, int *invalid) { ...@@ -991,7 +991,7 @@ uint64_t hllCount(struct hllhdr *hdr, int *invalid) {
} else if (hdr->encoding == HLL_RAW) { } else if (hdr->encoding == HLL_RAW) {
E = hllRawSum(hdr->registers,PE,&ez); E = hllRawSum(hdr->registers,PE,&ez);
} else { } else {
redisPanic("Unknown HyperLogLog encoding in hllCount()"); serverPanic("Unknown HyperLogLog encoding in hllCount()");
} }
/* Muliply the inverse of E for alpha_m * m^2 to have the raw estimate. */ /* Muliply the inverse of E for alpha_m * m^2 to have the raw estimate. */
...@@ -1184,7 +1184,7 @@ void pfaddCommand(client *c) { ...@@ -1184,7 +1184,7 @@ void pfaddCommand(client *c) {
hdr = o->ptr; hdr = o->ptr;
if (updated) { if (updated) {
signalModifiedKey(c->db,c->argv[1]); signalModifiedKey(c->db,c->argv[1]);
notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"pfadd",c->argv[1],c->db->id); notifyKeyspaceEvent(NOTIFY_STRING,"pfadd",c->argv[1],c->db->id);
server.dirty++; server.dirty++;
HLL_INVALIDATE_CACHE(hdr); HLL_INVALIDATE_CACHE(hdr);
} }
...@@ -1337,7 +1337,7 @@ void pfmergeCommand(client *c) { ...@@ -1337,7 +1337,7 @@ void pfmergeCommand(client *c) {
signalModifiedKey(c->db,c->argv[1]); signalModifiedKey(c->db,c->argv[1]);
/* We generate an PFADD event for PFMERGE for semantical simplicity /* We generate an PFADD event for PFMERGE for semantical simplicity
* since in theory this is a mass-add of elements. */ * since in theory this is a mass-add of elements. */
notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"pfadd",c->argv[1],c->db->id); notifyKeyspaceEvent(NOTIFY_STRING,"pfadd",c->argv[1],c->db->id);
server.dirty++; server.dirty++;
addReply(c,shared.ok); addReply(c,shared.ok);
} }
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
/* Dictionary type for latency events. */ /* Dictionary type for latency events. */
int dictStringKeyCompare(void *privdata, const void *key1, const void *key2) { int dictStringKeyCompare(void *privdata, const void *key1, const void *key2) {
REDIS_NOTUSED(privdata); UNUSED(privdata);
return strcmp(key1,key2) == 0; return strcmp(key1,key2) == 0;
} }
......
...@@ -72,28 +72,28 @@ void queueMultiCommand(client *c) { ...@@ -72,28 +72,28 @@ void queueMultiCommand(client *c) {
void discardTransaction(client *c) { void discardTransaction(client *c) {
freeClientMultiState(c); freeClientMultiState(c);
initClientMultiState(c); initClientMultiState(c);
c->flags &= ~(REDIS_MULTI|REDIS_DIRTY_CAS|REDIS_DIRTY_EXEC); c->flags &= ~(CLIENT_MULTI|CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC);
unwatchAllKeys(c); unwatchAllKeys(c);
} }
/* Flag the transacation as DIRTY_EXEC so that EXEC will fail. /* Flag the transacation as DIRTY_EXEC so that EXEC will fail.
* Should be called every time there is an error while queueing a command. */ * Should be called every time there is an error while queueing a command. */
void flagTransaction(client *c) { void flagTransaction(client *c) {
if (c->flags & REDIS_MULTI) if (c->flags & CLIENT_MULTI)
c->flags |= REDIS_DIRTY_EXEC; c->flags |= CLIENT_DIRTY_EXEC;
} }
void multiCommand(client *c) { void multiCommand(client *c) {
if (c->flags & REDIS_MULTI) { if (c->flags & CLIENT_MULTI) {
addReplyError(c,"MULTI calls can not be nested"); addReplyError(c,"MULTI calls can not be nested");
return; return;
} }
c->flags |= REDIS_MULTI; c->flags |= CLIENT_MULTI;
addReply(c,shared.ok); addReply(c,shared.ok);
} }
void discardCommand(client *c) { void discardCommand(client *c) {
if (!(c->flags & REDIS_MULTI)) { if (!(c->flags & CLIENT_MULTI)) {
addReplyError(c,"DISCARD without MULTI"); addReplyError(c,"DISCARD without MULTI");
return; return;
} }
...@@ -107,7 +107,7 @@ void execCommandPropagateMulti(client *c) { ...@@ -107,7 +107,7 @@ void execCommandPropagateMulti(client *c) {
robj *multistring = createStringObject("MULTI",5); robj *multistring = createStringObject("MULTI",5);
propagate(server.multiCommand,c->db->id,&multistring,1, propagate(server.multiCommand,c->db->id,&multistring,1,
REDIS_PROPAGATE_AOF|REDIS_PROPAGATE_REPL); PROPAGATE_AOF|PROPAGATE_REPL);
decrRefCount(multistring); decrRefCount(multistring);
} }
...@@ -118,7 +118,7 @@ void execCommand(client *c) { ...@@ -118,7 +118,7 @@ void execCommand(client *c) {
struct redisCommand *orig_cmd; struct redisCommand *orig_cmd;
int must_propagate = 0; /* Need to propagate MULTI/EXEC to AOF / slaves? */ int must_propagate = 0; /* Need to propagate MULTI/EXEC to AOF / slaves? */
if (!(c->flags & REDIS_MULTI)) { if (!(c->flags & CLIENT_MULTI)) {
addReplyError(c,"EXEC without MULTI"); addReplyError(c,"EXEC without MULTI");
return; return;
} }
...@@ -129,8 +129,8 @@ void execCommand(client *c) { ...@@ -129,8 +129,8 @@ void execCommand(client *c) {
* A failed EXEC in the first case returns a multi bulk nil object * A failed EXEC in the first case returns a multi bulk nil object
* (technically it is not an error but a special behavior), while * (technically it is not an error but a special behavior), while
* in the second an EXECABORT error is returned. */ * in the second an EXECABORT error is returned. */
if (c->flags & (REDIS_DIRTY_CAS|REDIS_DIRTY_EXEC)) { if (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC)) {
addReply(c, c->flags & REDIS_DIRTY_EXEC ? shared.execaborterr : addReply(c, c->flags & CLIENT_DIRTY_EXEC ? shared.execaborterr :
shared.nullmultibulk); shared.nullmultibulk);
discardTransaction(c); discardTransaction(c);
goto handle_monitor; goto handle_monitor;
...@@ -151,12 +151,12 @@ void execCommand(client *c) { ...@@ -151,12 +151,12 @@ void execCommand(client *c) {
* This way we'll deliver the MULTI/..../EXEC block as a whole and * This way we'll deliver the MULTI/..../EXEC block as a whole and
* both the AOF and the replication link will have the same consistency * both the AOF and the replication link will have the same consistency
* and atomicity guarantees. */ * and atomicity guarantees. */
if (!must_propagate && !(c->cmd->flags & REDIS_CMD_READONLY)) { if (!must_propagate && !(c->cmd->flags & CMD_READONLY)) {
execCommandPropagateMulti(c); execCommandPropagateMulti(c);
must_propagate = 1; must_propagate = 1;
} }
call(c,REDIS_CALL_FULL); call(c,CMD_CALL_FULL);
/* Commands may alter argc/argv, restore mstate. */ /* Commands may alter argc/argv, restore mstate. */
c->mstate.commands[j].argc = c->argc; c->mstate.commands[j].argc = c->argc;
...@@ -175,7 +175,7 @@ handle_monitor: ...@@ -175,7 +175,7 @@ handle_monitor:
/* Send EXEC to clients waiting data from MONITOR. We do it here /* Send EXEC to clients waiting data from MONITOR. We do it here
* since the natural order of commands execution is actually: * since the natural order of commands execution is actually:
* MUTLI, EXEC, ... commands inside transaction ... * MUTLI, EXEC, ... commands inside transaction ...
* Instead EXEC is flagged as REDIS_CMD_SKIP_MONITOR in the command * Instead EXEC is flagged as CMD_SKIP_MONITOR in the command
* table, and we do it here with correct ordering. */ * table, and we do it here with correct ordering. */
if (listLength(server.monitors) && !server.loading) if (listLength(server.monitors) && !server.loading)
replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc); replicationFeedMonitors(c,server.monitors,c->db->id,c->argv,c->argc);
...@@ -267,13 +267,13 @@ void touchWatchedKey(redisDb *db, robj *key) { ...@@ -267,13 +267,13 @@ void touchWatchedKey(redisDb *db, robj *key) {
clients = dictFetchValue(db->watched_keys, key); clients = dictFetchValue(db->watched_keys, key);
if (!clients) return; if (!clients) return;
/* Mark all the clients watching this key as REDIS_DIRTY_CAS */ /* Mark all the clients watching this key as CLIENT_DIRTY_CAS */
/* Check if we are already watching for this key */ /* Check if we are already watching for this key */
listRewind(clients,&li); listRewind(clients,&li);
while((ln = listNext(&li))) { while((ln = listNext(&li))) {
client *c = listNodeValue(ln); client *c = listNodeValue(ln);
c->flags |= REDIS_DIRTY_CAS; c->flags |= CLIENT_DIRTY_CAS;
} }
} }
...@@ -298,7 +298,7 @@ void touchWatchedKeysOnFlush(int dbid) { ...@@ -298,7 +298,7 @@ void touchWatchedKeysOnFlush(int dbid) {
* removed. */ * removed. */
if (dbid == -1 || wk->db->id == dbid) { if (dbid == -1 || wk->db->id == dbid) {
if (dictFind(wk->db->dict, wk->key->ptr) != NULL) if (dictFind(wk->db->dict, wk->key->ptr) != NULL)
c->flags |= REDIS_DIRTY_CAS; c->flags |= CLIENT_DIRTY_CAS;
} }
} }
} }
...@@ -307,7 +307,7 @@ void touchWatchedKeysOnFlush(int dbid) { ...@@ -307,7 +307,7 @@ void touchWatchedKeysOnFlush(int dbid) {
void watchCommand(client *c) { void watchCommand(client *c) {
int j; int j;
if (c->flags & REDIS_MULTI) { if (c->flags & CLIENT_MULTI) {
addReplyError(c,"WATCH inside MULTI is not allowed"); addReplyError(c,"WATCH inside MULTI is not allowed");
return; return;
} }
...@@ -318,6 +318,6 @@ void watchCommand(client *c) { ...@@ -318,6 +318,6 @@ void watchCommand(client *c) {
void unwatchCommand(client *c) { void unwatchCommand(client *c) {
unwatchAllKeys(c); unwatchAllKeys(c);
c->flags &= (~REDIS_DIRTY_CAS); c->flags &= (~CLIENT_DIRTY_CAS);
addReply(c,shared.ok); addReply(c,shared.ok);
} }
This diff is collapsed.
...@@ -43,17 +43,17 @@ int keyspaceEventsStringToFlags(char *classes) { ...@@ -43,17 +43,17 @@ int keyspaceEventsStringToFlags(char *classes) {
while((c = *p++) != '\0') { while((c = *p++) != '\0') {
switch(c) { switch(c) {
case 'A': flags |= REDIS_NOTIFY_ALL; break; case 'A': flags |= NOTIFY_ALL; break;
case 'g': flags |= REDIS_NOTIFY_GENERIC; break; case 'g': flags |= NOTIFY_GENERIC; break;
case '$': flags |= REDIS_NOTIFY_STRING; break; case '$': flags |= NOTIFY_STRING; break;
case 'l': flags |= REDIS_NOTIFY_LIST; break; case 'l': flags |= NOTIFY_LIST; break;
case 's': flags |= REDIS_NOTIFY_SET; break; case 's': flags |= NOTIFY_SET; break;
case 'h': flags |= REDIS_NOTIFY_HASH; break; case 'h': flags |= NOTIFY_HASH; break;
case 'z': flags |= REDIS_NOTIFY_ZSET; break; case 'z': flags |= NOTIFY_ZSET; break;
case 'x': flags |= REDIS_NOTIFY_EXPIRED; break; case 'x': flags |= NOTIFY_EXPIRED; break;
case 'e': flags |= REDIS_NOTIFY_EVICTED; break; case 'e': flags |= NOTIFY_EVICTED; break;
case 'K': flags |= REDIS_NOTIFY_KEYSPACE; break; case 'K': flags |= NOTIFY_KEYSPACE; break;
case 'E': flags |= REDIS_NOTIFY_KEYEVENT; break; case 'E': flags |= NOTIFY_KEYEVENT; break;
default: return -1; default: return -1;
} }
} }
...@@ -68,20 +68,20 @@ sds keyspaceEventsFlagsToString(int flags) { ...@@ -68,20 +68,20 @@ sds keyspaceEventsFlagsToString(int flags) {
sds res; sds res;
res = sdsempty(); res = sdsempty();
if ((flags & REDIS_NOTIFY_ALL) == REDIS_NOTIFY_ALL) { if ((flags & NOTIFY_ALL) == NOTIFY_ALL) {
res = sdscatlen(res,"A",1); res = sdscatlen(res,"A",1);
} else { } else {
if (flags & REDIS_NOTIFY_GENERIC) res = sdscatlen(res,"g",1); if (flags & NOTIFY_GENERIC) res = sdscatlen(res,"g",1);
if (flags & REDIS_NOTIFY_STRING) res = sdscatlen(res,"$",1); if (flags & NOTIFY_STRING) res = sdscatlen(res,"$",1);
if (flags & REDIS_NOTIFY_LIST) res = sdscatlen(res,"l",1); if (flags & NOTIFY_LIST) res = sdscatlen(res,"l",1);
if (flags & REDIS_NOTIFY_SET) res = sdscatlen(res,"s",1); if (flags & NOTIFY_SET) res = sdscatlen(res,"s",1);
if (flags & REDIS_NOTIFY_HASH) res = sdscatlen(res,"h",1); if (flags & NOTIFY_HASH) res = sdscatlen(res,"h",1);
if (flags & REDIS_NOTIFY_ZSET) res = sdscatlen(res,"z",1); if (flags & NOTIFY_ZSET) res = sdscatlen(res,"z",1);
if (flags & REDIS_NOTIFY_EXPIRED) res = sdscatlen(res,"x",1); if (flags & NOTIFY_EXPIRED) res = sdscatlen(res,"x",1);
if (flags & REDIS_NOTIFY_EVICTED) res = sdscatlen(res,"e",1); if (flags & NOTIFY_EVICTED) res = sdscatlen(res,"e",1);
} }
if (flags & REDIS_NOTIFY_KEYSPACE) res = sdscatlen(res,"K",1); if (flags & NOTIFY_KEYSPACE) res = sdscatlen(res,"K",1);
if (flags & REDIS_NOTIFY_KEYEVENT) res = sdscatlen(res,"E",1); if (flags & NOTIFY_KEYEVENT) res = sdscatlen(res,"E",1);
return res; return res;
} }
...@@ -104,7 +104,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) { ...@@ -104,7 +104,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
eventobj = createStringObject(event,strlen(event)); eventobj = createStringObject(event,strlen(event));
/* __keyspace@<db>__:<key> <event> notifications. */ /* __keyspace@<db>__:<key> <event> notifications. */
if (server.notify_keyspace_events & REDIS_NOTIFY_KEYSPACE) { if (server.notify_keyspace_events & NOTIFY_KEYSPACE) {
chan = sdsnewlen("__keyspace@",11); chan = sdsnewlen("__keyspace@",11);
len = ll2string(buf,sizeof(buf),dbid); len = ll2string(buf,sizeof(buf),dbid);
chan = sdscatlen(chan, buf, len); chan = sdscatlen(chan, buf, len);
...@@ -116,7 +116,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) { ...@@ -116,7 +116,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
} }
/* __keyevente@<db>__:<event> <key> notifications. */ /* __keyevente@<db>__:<event> <key> notifications. */
if (server.notify_keyspace_events & REDIS_NOTIFY_KEYEVENT) { if (server.notify_keyspace_events & NOTIFY_KEYEVENT) {
chan = sdsnewlen("__keyevent@",11); chan = sdsnewlen("__keyevent@",11);
if (len == -1) len = ll2string(buf,sizeof(buf),dbid); if (len == -1) len = ll2string(buf,sizeof(buf),dbid);
chan = sdscatlen(chan, buf, len); chan = sdscatlen(chan, buf, len);
......
...@@ -95,7 +95,7 @@ robj *createStringObject(const char *ptr, size_t len) { ...@@ -95,7 +95,7 @@ robj *createStringObject(const char *ptr, size_t len) {
robj *createStringObjectFromLongLong(long long value) { robj *createStringObjectFromLongLong(long long value) {
robj *o; robj *o;
if (value >= 0 && value < REDIS_SHARED_INTEGERS) { if (value >= 0 && value < OBJ_SHARED_INTEGERS) {
incrRefCount(shared.integers[value]); incrRefCount(shared.integers[value]);
o = shared.integers[value]; o = shared.integers[value];
} else { } else {
...@@ -176,7 +176,7 @@ robj *dupStringObject(robj *o) { ...@@ -176,7 +176,7 @@ robj *dupStringObject(robj *o) {
d->ptr = o->ptr; d->ptr = o->ptr;
return d; return d;
default: default:
redisPanic("Wrong encoding."); serverPanic("Wrong encoding.");
break; break;
} }
} }
...@@ -246,7 +246,7 @@ void freeListObject(robj *o) { ...@@ -246,7 +246,7 @@ void freeListObject(robj *o) {
quicklistRelease(o->ptr); quicklistRelease(o->ptr);
break; break;
default: default:
redisPanic("Unknown list encoding type"); serverPanic("Unknown list encoding type");
} }
} }
...@@ -259,7 +259,7 @@ void freeSetObject(robj *o) { ...@@ -259,7 +259,7 @@ void freeSetObject(robj *o) {
zfree(o->ptr); zfree(o->ptr);
break; break;
default: default:
redisPanic("Unknown set encoding type"); serverPanic("Unknown set encoding type");
} }
} }
...@@ -276,7 +276,7 @@ void freeZsetObject(robj *o) { ...@@ -276,7 +276,7 @@ void freeZsetObject(robj *o) {
zfree(o->ptr); zfree(o->ptr);
break; break;
default: default:
redisPanic("Unknown sorted set encoding"); serverPanic("Unknown sorted set encoding");
} }
} }
...@@ -289,7 +289,7 @@ void freeHashObject(robj *o) { ...@@ -289,7 +289,7 @@ void freeHashObject(robj *o) {
zfree(o->ptr); zfree(o->ptr);
break; break;
default: default:
redisPanic("Unknown hash encoding type"); serverPanic("Unknown hash encoding type");
break; break;
} }
} }
...@@ -299,7 +299,7 @@ void incrRefCount(robj *o) { ...@@ -299,7 +299,7 @@ void incrRefCount(robj *o) {
} }
void decrRefCount(robj *o) { void decrRefCount(robj *o) {
if (o->refcount <= 0) redisPanic("decrRefCount against refcount <= 0"); if (o->refcount <= 0) serverPanic("decrRefCount against refcount <= 0");
if (o->refcount == 1) { if (o->refcount == 1) {
switch(o->type) { switch(o->type) {
case OBJ_STRING: freeStringObject(o); break; case OBJ_STRING: freeStringObject(o); break;
...@@ -307,7 +307,7 @@ void decrRefCount(robj *o) { ...@@ -307,7 +307,7 @@ void decrRefCount(robj *o) {
case OBJ_SET: freeSetObject(o); break; case OBJ_SET: freeSetObject(o); break;
case OBJ_ZSET: freeZsetObject(o); break; case OBJ_ZSET: freeZsetObject(o); break;
case OBJ_HASH: freeHashObject(o); break; case OBJ_HASH: freeHashObject(o); break;
default: redisPanic("Unknown object type"); break; default: serverPanic("Unknown object type"); break;
} }
zfree(o); zfree(o);
} else { } else {
...@@ -389,10 +389,10 @@ robj *tryObjectEncoding(robj *o) { ...@@ -389,10 +389,10 @@ robj *tryObjectEncoding(robj *o) {
* because every object needs to have a private LRU field for the LRU * because every object needs to have a private LRU field for the LRU
* algorithm to work well. */ * algorithm to work well. */
if ((server.maxmemory == 0 || if ((server.maxmemory == 0 ||
(server.maxmemory_policy != REDIS_MAXMEMORY_VOLATILE_LRU && (server.maxmemory_policy != MAXMEMORY_VOLATILE_LRU &&
server.maxmemory_policy != REDIS_MAXMEMORY_ALLKEYS_LRU)) && server.maxmemory_policy != MAXMEMORY_ALLKEYS_LRU)) &&
value >= 0 && value >= 0 &&
value < REDIS_SHARED_INTEGERS) value < OBJ_SHARED_INTEGERS)
{ {
decrRefCount(o); decrRefCount(o);
incrRefCount(shared.integers[value]); incrRefCount(shared.integers[value]);
...@@ -453,7 +453,7 @@ robj *getDecodedObject(robj *o) { ...@@ -453,7 +453,7 @@ robj *getDecodedObject(robj *o) {
dec = createStringObject(buf,strlen(buf)); dec = createStringObject(buf,strlen(buf));
return dec; return dec;
} else { } else {
redisPanic("Unknown encoding type"); serverPanic("Unknown encoding type");
} }
} }
...@@ -555,7 +555,7 @@ int getDoubleFromObject(robj *o, double *target) { ...@@ -555,7 +555,7 @@ int getDoubleFromObject(robj *o, double *target) {
} else if (o->encoding == OBJ_ENCODING_INT) { } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr; value = (long)o->ptr;
} else { } else {
redisPanic("Unknown string encoding"); serverPanic("Unknown string encoding");
} }
} }
*target = value; *target = value;
...@@ -593,7 +593,7 @@ int getLongDoubleFromObject(robj *o, long double *target) { ...@@ -593,7 +593,7 @@ int getLongDoubleFromObject(robj *o, long double *target) {
} else if (o->encoding == OBJ_ENCODING_INT) { } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr; value = (long)o->ptr;
} else { } else {
redisPanic("Unknown string encoding"); serverPanic("Unknown string encoding");
} }
} }
*target = value; *target = value;
...@@ -631,7 +631,7 @@ int getLongLongFromObject(robj *o, long long *target) { ...@@ -631,7 +631,7 @@ int getLongLongFromObject(robj *o, long long *target) {
} else if (o->encoding == OBJ_ENCODING_INT) { } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)o->ptr; value = (long)o->ptr;
} else { } else {
redisPanic("Unknown string encoding"); serverPanic("Unknown string encoding");
} }
} }
if (target) *target = value; if (target) *target = value;
...@@ -687,10 +687,10 @@ char *strEncoding(int encoding) { ...@@ -687,10 +687,10 @@ char *strEncoding(int encoding) {
unsigned long long estimateObjectIdleTime(robj *o) { unsigned long long estimateObjectIdleTime(robj *o) {
unsigned long long lruclock = LRU_CLOCK(); unsigned long long lruclock = LRU_CLOCK();
if (lruclock >= o->lru) { if (lruclock >= o->lru) {
return (lruclock - o->lru) * REDIS_LRU_CLOCK_RESOLUTION; return (lruclock - o->lru) * LRU_CLOCK_RESOLUTION;
} else { } else {
return (lruclock + (REDIS_LRU_CLOCK_MAX - o->lru)) * return (lruclock + (LRU_CLOCK_MAX - o->lru)) *
REDIS_LRU_CLOCK_RESOLUTION; LRU_CLOCK_RESOLUTION;
} }
} }
......
...@@ -279,7 +279,7 @@ void subscribeCommand(client *c) { ...@@ -279,7 +279,7 @@ void subscribeCommand(client *c) {
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
pubsubSubscribeChannel(c,c->argv[j]); pubsubSubscribeChannel(c,c->argv[j]);
c->flags |= REDIS_PUBSUB; c->flags |= CLIENT_PUBSUB;
} }
void unsubscribeCommand(client *c) { void unsubscribeCommand(client *c) {
...@@ -291,7 +291,7 @@ void unsubscribeCommand(client *c) { ...@@ -291,7 +291,7 @@ void unsubscribeCommand(client *c) {
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
pubsubUnsubscribeChannel(c,c->argv[j],1); pubsubUnsubscribeChannel(c,c->argv[j],1);
} }
if (clientSubscriptionsCount(c) == 0) c->flags &= ~REDIS_PUBSUB; if (clientSubscriptionsCount(c) == 0) c->flags &= ~CLIENT_PUBSUB;
} }
void psubscribeCommand(client *c) { void psubscribeCommand(client *c) {
...@@ -299,7 +299,7 @@ void psubscribeCommand(client *c) { ...@@ -299,7 +299,7 @@ void psubscribeCommand(client *c) {
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
pubsubSubscribePattern(c,c->argv[j]); pubsubSubscribePattern(c,c->argv[j]);
c->flags |= REDIS_PUBSUB; c->flags |= CLIENT_PUBSUB;
} }
void punsubscribeCommand(client *c) { void punsubscribeCommand(client *c) {
...@@ -311,7 +311,7 @@ void punsubscribeCommand(client *c) { ...@@ -311,7 +311,7 @@ void punsubscribeCommand(client *c) {
for (j = 1; j < c->argc; j++) for (j = 1; j < c->argc; j++)
pubsubUnsubscribePattern(c,c->argv[j],1); pubsubUnsubscribePattern(c,c->argv[j],1);
} }
if (clientSubscriptionsCount(c) == 0) c->flags &= ~REDIS_PUBSUB; if (clientSubscriptionsCount(c) == 0) c->flags &= ~CLIENT_PUBSUB;
} }
void publishCommand(client *c) { void publishCommand(client *c) {
...@@ -319,7 +319,7 @@ void publishCommand(client *c) { ...@@ -319,7 +319,7 @@ void publishCommand(client *c) {
if (server.cluster_enabled) if (server.cluster_enabled)
clusterPropagatePublish(c->argv[1],c->argv[2]); clusterPropagatePublish(c->argv[1],c->argv[2]);
else else
forceCommandPropagation(c,REDIS_PROPAGATE_REPL); forceCommandPropagation(c,PROPAGATE_REPL);
addReplyLongLong(c,receivers); addReplyLongLong(c,receivers);
} }
......
This diff is collapsed.
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __REDIS_RDB_H #ifndef __RDB_H
#define __REDIS_RDB_H #define __RDB_H
#include <stdio.h> #include <stdio.h>
#include "rio.h" #include "rio.h"
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
/* The current RDB version. When the format changes in a way that is no longer /* The current RDB version. When the format changes in a way that is no longer
* backward compatible this number gets incremented. */ * backward compatible this number gets incremented. */
#define REDIS_RDB_VERSION 7 #define RDB_VERSION 7
/* Defines related to the dump file format. To store 32 bits lengths for short /* Defines related to the dump file format. To store 32 bits lengths for short
* keys requires a lot of space, so we check the most significant 2 bits of * keys requires a lot of space, so we check the most significant 2 bits of
...@@ -49,52 +49,52 @@ ...@@ -49,52 +49,52 @@
* 10|000000 [32 bit integer] => if it's 01, a full 32 bit len will follow * 10|000000 [32 bit integer] => if it's 01, a full 32 bit len will follow
* 11|000000 this means: specially encoded object will follow. The six bits * 11|000000 this means: specially encoded object will follow. The six bits
* number specify the kind of object that follows. * number specify the kind of object that follows.
* See the REDIS_RDB_ENC_* defines. * See the RDB_ENC_* defines.
* *
* Lengths up to 63 are stored using a single byte, most DB keys, and may * Lengths up to 63 are stored using a single byte, most DB keys, and may
* values, will fit inside. */ * values, will fit inside. */
#define REDIS_RDB_6BITLEN 0 #define RDB_6BITLEN 0
#define REDIS_RDB_14BITLEN 1 #define RDB_14BITLEN 1
#define REDIS_RDB_32BITLEN 2 #define RDB_32BITLEN 2
#define REDIS_RDB_ENCVAL 3 #define RDB_ENCVAL 3
#define REDIS_RDB_LENERR UINT_MAX #define RDB_LENERR UINT_MAX
/* When a length of a string object stored on disk has the first two bits /* When a length of a string object stored on disk has the first two bits
* set, the remaining two bits specify a special encoding for the object * set, the remaining two bits specify a special encoding for the object
* accordingly to the following defines: */ * accordingly to the following defines: */
#define REDIS_RDB_ENC_INT8 0 /* 8 bit signed integer */ #define RDB_ENC_INT8 0 /* 8 bit signed integer */
#define REDIS_RDB_ENC_INT16 1 /* 16 bit signed integer */ #define RDB_ENC_INT16 1 /* 16 bit signed integer */
#define REDIS_RDB_ENC_INT32 2 /* 32 bit signed integer */ #define RDB_ENC_INT32 2 /* 32 bit signed integer */
#define REDIS_RDB_ENC_LZF 3 /* string compressed with FASTLZ */ #define RDB_ENC_LZF 3 /* string compressed with FASTLZ */
/* Dup object types to RDB object types. Only reason is readability (are we /* Dup object types to RDB object types. Only reason is readability (are we
* dealing with RDB types or with in-memory object types?). */ * dealing with RDB types or with in-memory object types?). */
#define REDIS_RDB_TYPE_STRING 0 #define RDB_TYPE_STRING 0
#define REDIS_RDB_TYPE_LIST 1 #define RDB_TYPE_LIST 1
#define REDIS_RDB_TYPE_SET 2 #define RDB_TYPE_SET 2
#define REDIS_RDB_TYPE_ZSET 3 #define RDB_TYPE_ZSET 3
#define REDIS_RDB_TYPE_HASH 4 #define RDB_TYPE_HASH 4
/* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType() BELOW */ /* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType() BELOW */
/* Object types for encoded objects. */ /* Object types for encoded objects. */
#define REDIS_RDB_TYPE_HASH_ZIPMAP 9 #define RDB_TYPE_HASH_ZIPMAP 9
#define REDIS_RDB_TYPE_LIST_ZIPLIST 10 #define RDB_TYPE_LIST_ZIPLIST 10
#define REDIS_RDB_TYPE_SET_INTSET 11 #define RDB_TYPE_SET_INTSET 11
#define REDIS_RDB_TYPE_ZSET_ZIPLIST 12 #define RDB_TYPE_ZSET_ZIPLIST 12
#define REDIS_RDB_TYPE_HASH_ZIPLIST 13 #define RDB_TYPE_HASH_ZIPLIST 13
#define REDIS_RDB_TYPE_LIST_QUICKLIST 14 #define RDB_TYPE_LIST_QUICKLIST 14
/* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType() BELOW */ /* NOTE: WHEN ADDING NEW RDB TYPE, UPDATE rdbIsObjectType() BELOW */
/* Test if a type is an object type. */ /* Test if a type is an object type. */
#define rdbIsObjectType(t) ((t >= 0 && t <= 4) || (t >= 9 && t <= 14)) #define rdbIsObjectType(t) ((t >= 0 && t <= 4) || (t >= 9 && t <= 14))
/* Special RDB opcodes (saved/loaded with rdbSaveType/rdbLoadType). */ /* Special RDB opcodes (saved/loaded with rdbSaveType/rdbLoadType). */
#define REDIS_RDB_OPCODE_AUX 250 #define RDB_OPCODE_AUX 250
#define REDIS_RDB_OPCODE_RESIZEDB 251 #define RDB_OPCODE_RESIZEDB 251
#define REDIS_RDB_OPCODE_EXPIRETIME_MS 252 #define RDB_OPCODE_EXPIRETIME_MS 252
#define REDIS_RDB_OPCODE_EXPIRETIME 253 #define RDB_OPCODE_EXPIRETIME 253
#define REDIS_RDB_OPCODE_SELECTDB 254 #define RDB_OPCODE_SELECTDB 254
#define REDIS_RDB_OPCODE_EOF 255 #define RDB_OPCODE_EOF 255
int rdbSaveType(rio *rdb, unsigned char type); int rdbSaveType(rio *rdb, unsigned char type);
int rdbLoadType(rio *rdb); int rdbLoadType(rio *rdb);
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
#include "adlist.h" #include "adlist.h"
#include "zmalloc.h" #include "zmalloc.h"
#define REDIS_NOTUSED(V) ((void) V) #define UNUSED(V) ((void) V)
#define RANDPTR_INITIAL_SIZE 8 #define RANDPTR_INITIAL_SIZE 8
static struct config { static struct config {
...@@ -188,9 +188,9 @@ static void clientDone(client c) { ...@@ -188,9 +188,9 @@ static void clientDone(client c) {
static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) { static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
client c = privdata; client c = privdata;
void *reply = NULL; void *reply = NULL;
REDIS_NOTUSED(el); UNUSED(el);
REDIS_NOTUSED(fd); UNUSED(fd);
REDIS_NOTUSED(mask); UNUSED(mask);
/* Calculate latency only for the first read event. This means that the /* Calculate latency only for the first read event. This means that the
* server already sent the reply and we need to parse it. Parsing overhead * server already sent the reply and we need to parse it. Parsing overhead
...@@ -246,9 +246,9 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -246,9 +246,9 @@ static void readHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) { static void writeHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
client c = privdata; client c = privdata;
REDIS_NOTUSED(el); UNUSED(el);
REDIS_NOTUSED(fd); UNUSED(fd);
REDIS_NOTUSED(mask); UNUSED(mask);
/* Initialize request when nothing was written. */ /* Initialize request when nothing was written. */
if (c->written == 0) { if (c->written == 0) {
...@@ -595,9 +595,9 @@ usage: ...@@ -595,9 +595,9 @@ usage:
} }
int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData) { int showThroughput(struct aeEventLoop *eventLoop, long long id, void *clientData) {
REDIS_NOTUSED(eventLoop); UNUSED(eventLoop);
REDIS_NOTUSED(id); UNUSED(id);
REDIS_NOTUSED(clientData); UNUSED(clientData);
if (config.liveclients == 0) { if (config.liveclients == 0) {
fprintf(stderr,"All clients disconnected... aborting.\n"); fprintf(stderr,"All clients disconnected... aborting.\n");
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "crc64.h" #include "crc64.h"
#define ERROR(...) { \ #define ERROR(...) { \
serverLog(REDIS_WARNING, __VA_ARGS__); \ serverLog(LL_WARNING, __VA_ARGS__); \
exit(1); \ exit(1); \
} }
...@@ -88,9 +88,9 @@ static int rdbCheckType(unsigned char t) { ...@@ -88,9 +88,9 @@ static int rdbCheckType(unsigned char t) {
/* In case a new object type is added, update the following /* In case a new object type is added, update the following
* condition as necessary. */ * condition as necessary. */
return return
(t >= REDIS_RDB_TYPE_HASH_ZIPMAP && t <= REDIS_RDB_TYPE_HASH_ZIPLIST) || (t >= RDB_TYPE_HASH_ZIPMAP && t <= RDB_TYPE_HASH_ZIPLIST) ||
t <= REDIS_RDB_TYPE_HASH || t <= RDB_TYPE_HASH ||
t >= REDIS_RDB_OPCODE_EXPIRETIME_MS; t >= RDB_OPCODE_EXPIRETIME_MS;
} }
/* when number of bytes to read is negative, do a peek */ /* when number of bytes to read is negative, do a peek */
...@@ -159,7 +159,7 @@ static int peekType() { ...@@ -159,7 +159,7 @@ static int peekType() {
static int processTime(int type) { static int processTime(int type) {
uint32_t offset = CURR_OFFSET; uint32_t offset = CURR_OFFSET;
unsigned char t[8]; unsigned char t[8];
int timelen = (type == REDIS_RDB_OPCODE_EXPIRETIME_MS) ? 8 : 4; int timelen = (type == RDB_OPCODE_EXPIRETIME_MS) ? 8 : 4;
if (readBytes(t,timelen)) { if (readBytes(t,timelen)) {
return 1; return 1;
...@@ -177,22 +177,22 @@ static uint32_t loadLength(int *isencoded) { ...@@ -177,22 +177,22 @@ static uint32_t loadLength(int *isencoded) {
int type; int type;
if (isencoded) *isencoded = 0; if (isencoded) *isencoded = 0;
if (!readBytes(buf, 1)) return REDIS_RDB_LENERR; if (!readBytes(buf, 1)) return RDB_LENERR;
type = (buf[0] & 0xC0) >> 6; type = (buf[0] & 0xC0) >> 6;
if (type == REDIS_RDB_6BITLEN) { if (type == RDB_6BITLEN) {
/* Read a 6 bit len */ /* Read a 6 bit len */
return buf[0] & 0x3F; return buf[0] & 0x3F;
} else if (type == REDIS_RDB_ENCVAL) { } else if (type == RDB_ENCVAL) {
/* Read a 6 bit len encoding type */ /* Read a 6 bit len encoding type */
if (isencoded) *isencoded = 1; if (isencoded) *isencoded = 1;
return buf[0] & 0x3F; return buf[0] & 0x3F;
} else if (type == REDIS_RDB_14BITLEN) { } else if (type == RDB_14BITLEN) {
/* Read a 14 bit len */ /* Read a 14 bit len */
if (!readBytes(buf+1,1)) return REDIS_RDB_LENERR; if (!readBytes(buf+1,1)) return RDB_LENERR;
return ((buf[0] & 0x3F) << 8) | buf[1]; return ((buf[0] & 0x3F) << 8) | buf[1];
} else { } else {
/* Read a 32 bit len */ /* Read a 32 bit len */
if (!readBytes(&len, 4)) return REDIS_RDB_LENERR; if (!readBytes(&len, 4)) return RDB_LENERR;
return (unsigned int)ntohl(len); return (unsigned int)ntohl(len);
} }
} }
...@@ -202,17 +202,17 @@ static char *loadIntegerObject(int enctype) { ...@@ -202,17 +202,17 @@ static char *loadIntegerObject(int enctype) {
unsigned char enc[4]; unsigned char enc[4];
long long val; long long val;
if (enctype == REDIS_RDB_ENC_INT8) { if (enctype == RDB_ENC_INT8) {
uint8_t v; uint8_t v;
if (!readBytes(enc, 1)) return NULL; if (!readBytes(enc, 1)) return NULL;
v = enc[0]; v = enc[0];
val = (int8_t)v; val = (int8_t)v;
} else if (enctype == REDIS_RDB_ENC_INT16) { } else if (enctype == RDB_ENC_INT16) {
uint16_t v; uint16_t v;
if (!readBytes(enc, 2)) return NULL; if (!readBytes(enc, 2)) return NULL;
v = enc[0]|(enc[1]<<8); v = enc[0]|(enc[1]<<8);
val = (int16_t)v; val = (int16_t)v;
} else if (enctype == REDIS_RDB_ENC_INT32) { } else if (enctype == RDB_ENC_INT32) {
uint32_t v; uint32_t v;
if (!readBytes(enc, 4)) return NULL; if (!readBytes(enc, 4)) return NULL;
v = enc[0]|(enc[1]<<8)|(enc[2]<<16)|(enc[3]<<24); v = enc[0]|(enc[1]<<8)|(enc[2]<<16)|(enc[3]<<24);
...@@ -233,8 +233,8 @@ static char* loadLzfStringObject() { ...@@ -233,8 +233,8 @@ static char* loadLzfStringObject() {
unsigned int slen, clen; unsigned int slen, clen;
char *c, *s; char *c, *s;
if ((clen = loadLength(NULL)) == REDIS_RDB_LENERR) return NULL; if ((clen = loadLength(NULL)) == RDB_LENERR) return NULL;
if ((slen = loadLength(NULL)) == REDIS_RDB_LENERR) return NULL; if ((slen = loadLength(NULL)) == RDB_LENERR) return NULL;
c = zmalloc(clen); c = zmalloc(clen);
if (!readBytes(c, clen)) { if (!readBytes(c, clen)) {
...@@ -261,11 +261,11 @@ static char* loadStringObject() { ...@@ -261,11 +261,11 @@ static char* loadStringObject() {
len = loadLength(&isencoded); len = loadLength(&isencoded);
if (isencoded) { if (isencoded) {
switch(len) { switch(len) {
case REDIS_RDB_ENC_INT8: case RDB_ENC_INT8:
case REDIS_RDB_ENC_INT16: case RDB_ENC_INT16:
case REDIS_RDB_ENC_INT32: case RDB_ENC_INT32:
return loadIntegerObject(len); return loadIntegerObject(len);
case REDIS_RDB_ENC_LZF: case RDB_ENC_LZF:
return loadLzfStringObject(); return loadLzfStringObject();
default: default:
/* unknown encoding */ /* unknown encoding */
...@@ -274,7 +274,7 @@ static char* loadStringObject() { ...@@ -274,7 +274,7 @@ static char* loadStringObject() {
} }
} }
if (len == REDIS_RDB_LENERR) return NULL; if (len == RDB_LENERR) return NULL;
char *buf = zmalloc(sizeof(char) * (len+1)); char *buf = zmalloc(sizeof(char) * (len+1));
if (buf == NULL) return NULL; if (buf == NULL) return NULL;
...@@ -357,30 +357,30 @@ static int loadPair(entry *e) { ...@@ -357,30 +357,30 @@ static int loadPair(entry *e) {
} }
uint32_t length = 0; uint32_t length = 0;
if (e->type == REDIS_RDB_TYPE_LIST || if (e->type == RDB_TYPE_LIST ||
e->type == REDIS_RDB_TYPE_SET || e->type == RDB_TYPE_SET ||
e->type == REDIS_RDB_TYPE_ZSET || e->type == RDB_TYPE_ZSET ||
e->type == REDIS_RDB_TYPE_HASH) { e->type == RDB_TYPE_HASH) {
if ((length = loadLength(NULL)) == REDIS_RDB_LENERR) { if ((length = loadLength(NULL)) == RDB_LENERR) {
SHIFT_ERROR(offset, "Error reading %s length", types[e->type]); SHIFT_ERROR(offset, "Error reading %s length", types[e->type]);
return 0; return 0;
} }
} }
switch(e->type) { switch(e->type) {
case REDIS_RDB_TYPE_STRING: case RDB_TYPE_STRING:
case REDIS_RDB_TYPE_HASH_ZIPMAP: case RDB_TYPE_HASH_ZIPMAP:
case REDIS_RDB_TYPE_LIST_ZIPLIST: case RDB_TYPE_LIST_ZIPLIST:
case REDIS_RDB_TYPE_SET_INTSET: case RDB_TYPE_SET_INTSET:
case REDIS_RDB_TYPE_ZSET_ZIPLIST: case RDB_TYPE_ZSET_ZIPLIST:
case REDIS_RDB_TYPE_HASH_ZIPLIST: case RDB_TYPE_HASH_ZIPLIST:
if (!processStringObject(NULL)) { if (!processStringObject(NULL)) {
SHIFT_ERROR(offset, "Error reading entry value"); SHIFT_ERROR(offset, "Error reading entry value");
return 0; return 0;
} }
break; break;
case REDIS_RDB_TYPE_LIST: case RDB_TYPE_LIST:
case REDIS_RDB_TYPE_SET: case RDB_TYPE_SET:
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
offset = CURR_OFFSET; offset = CURR_OFFSET;
if (!processStringObject(NULL)) { if (!processStringObject(NULL)) {
...@@ -389,7 +389,7 @@ static int loadPair(entry *e) { ...@@ -389,7 +389,7 @@ static int loadPair(entry *e) {
} }
} }
break; break;
case REDIS_RDB_TYPE_ZSET: case RDB_TYPE_ZSET:
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
offset = CURR_OFFSET; offset = CURR_OFFSET;
if (!processStringObject(NULL)) { if (!processStringObject(NULL)) {
...@@ -403,7 +403,7 @@ static int loadPair(entry *e) { ...@@ -403,7 +403,7 @@ static int loadPair(entry *e) {
} }
} }
break; break;
case REDIS_RDB_TYPE_HASH: case RDB_TYPE_HASH:
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
offset = CURR_OFFSET; offset = CURR_OFFSET;
if (!processStringObject(NULL)) { if (!processStringObject(NULL)) {
...@@ -439,8 +439,8 @@ static entry loadEntry() { ...@@ -439,8 +439,8 @@ static entry loadEntry() {
} }
offset[1] = CURR_OFFSET; offset[1] = CURR_OFFSET;
if (e.type == REDIS_RDB_OPCODE_SELECTDB) { if (e.type == RDB_OPCODE_SELECTDB) {
if ((length = loadLength(NULL)) == REDIS_RDB_LENERR) { if ((length = loadLength(NULL)) == RDB_LENERR) {
SHIFT_ERROR(offset[1], "Error reading database number"); SHIFT_ERROR(offset[1], "Error reading database number");
return e; return e;
} }
...@@ -448,7 +448,7 @@ static entry loadEntry() { ...@@ -448,7 +448,7 @@ static entry loadEntry() {
SHIFT_ERROR(offset[1], "Database number out of range (%d)", length); SHIFT_ERROR(offset[1], "Database number out of range (%d)", length);
return e; return e;
} }
} else if (e.type == REDIS_RDB_OPCODE_EOF) { } else if (e.type == RDB_OPCODE_EOF) {
if (positions[level].offset < positions[level].size) { if (positions[level].offset < positions[level].size) {
SHIFT_ERROR(offset[0], "Unexpected EOF"); SHIFT_ERROR(offset[0], "Unexpected EOF");
} else { } else {
...@@ -457,8 +457,8 @@ static entry loadEntry() { ...@@ -457,8 +457,8 @@ static entry loadEntry() {
return e; return e;
} else { } else {
/* optionally consume expire */ /* optionally consume expire */
if (e.type == REDIS_RDB_OPCODE_EXPIRETIME || if (e.type == RDB_OPCODE_EXPIRETIME ||
e.type == REDIS_RDB_OPCODE_EXPIRETIME_MS) { e.type == RDB_OPCODE_EXPIRETIME_MS) {
if (!processTime(e.type)) return e; if (!processTime(e.type)) return e;
if (!loadType(&e)) return e; if (!loadType(&e)) return e;
} }
...@@ -491,7 +491,7 @@ static void printCentered(int indent, int width, char* body) { ...@@ -491,7 +491,7 @@ static void printCentered(int indent, int width, char* body) {
memset(head, '=', indent); memset(head, '=', indent);
memset(tail, '=', width - 2 - indent - strlen(body)); memset(tail, '=', width - 2 - indent - strlen(body));
serverLog(REDIS_WARNING, "%s %s %s", head, body, tail); serverLog(LL_WARNING, "%s %s %s", head, body, tail);
} }
static void printValid(uint64_t ops, uint64_t bytes) { static void printValid(uint64_t ops, uint64_t bytes) {
...@@ -538,7 +538,7 @@ static void printErrorStack(entry *e) { ...@@ -538,7 +538,7 @@ static void printErrorStack(entry *e) {
/* display error stack */ /* display error stack */
for (i = 0; i < errors.level; i++) { for (i = 0; i < errors.level; i++) {
serverLog(REDIS_WARNING, "0x%08lx - %s", serverLog(LL_WARNING, "0x%08lx - %s",
(unsigned long) errors.offset[i], errors.error[i]); (unsigned long) errors.offset[i], errors.error[i]);
} }
} }
...@@ -551,7 +551,7 @@ void process(void) { ...@@ -551,7 +551,7 @@ void process(void) {
/* Exclude the final checksum for RDB >= 5. Will be checked at the end. */ /* Exclude the final checksum for RDB >= 5. Will be checked at the end. */
if (dump_version >= 5) { if (dump_version >= 5) {
if (positions[0].size < 8) { if (positions[0].size < 8) {
serverLog(REDIS_WARNING, "RDB version >= 5 but no room for checksum."); serverLog(LL_WARNING, "RDB version >= 5 but no room for checksum.");
exit(1); exit(1);
} }
positions[0].size -= 8; positions[0].size -= 8;
...@@ -608,7 +608,7 @@ void process(void) { ...@@ -608,7 +608,7 @@ void process(void) {
printValid(num_valid_ops, num_valid_bytes); printValid(num_valid_ops, num_valid_bytes);
/* expect an eof */ /* expect an eof */
if (entry.type != REDIS_RDB_OPCODE_EOF) { if (entry.type != RDB_OPCODE_EOF) {
/* last byte should be EOF, add error */ /* last byte should be EOF, add error */
errors.level = 0; errors.level = 0;
SHIFT_ERROR(positions[0].offset, "Expected EOF, got %s", types[entry.type]); SHIFT_ERROR(positions[0].offset, "Expected EOF, got %s", types[entry.type]);
...@@ -636,13 +636,13 @@ void process(void) { ...@@ -636,13 +636,13 @@ void process(void) {
if (crc != crc2) { if (crc != crc2) {
SHIFT_ERROR(positions[0].offset, "RDB CRC64 does not match."); SHIFT_ERROR(positions[0].offset, "RDB CRC64 does not match.");
} else { } else {
serverLog(REDIS_WARNING, "CRC64 checksum is OK"); serverLog(LL_WARNING, "CRC64 checksum is OK");
} }
} }
/* print summary on errors */ /* print summary on errors */
if (num_errors) { if (num_errors) {
serverLog(REDIS_WARNING, "Total unprocessable opcodes: %llu", serverLog(LL_WARNING, "Total unprocessable opcodes: %llu",
(unsigned long long) num_errors); (unsigned long long) num_errors);
} }
} }
...@@ -679,16 +679,16 @@ int redis_check_rdb(char *rdbfilename) { ...@@ -679,16 +679,16 @@ int redis_check_rdb(char *rdbfilename) {
errors.level = 0; errors.level = 0;
/* Object types */ /* Object types */
sprintf(types[REDIS_RDB_TYPE_STRING], "STRING"); sprintf(types[RDB_TYPE_STRING], "STRING");
sprintf(types[REDIS_RDB_TYPE_LIST], "LIST"); sprintf(types[RDB_TYPE_LIST], "LIST");
sprintf(types[REDIS_RDB_TYPE_SET], "SET"); sprintf(types[RDB_TYPE_SET], "SET");
sprintf(types[REDIS_RDB_TYPE_ZSET], "ZSET"); sprintf(types[RDB_TYPE_ZSET], "ZSET");
sprintf(types[REDIS_RDB_TYPE_HASH], "HASH"); sprintf(types[RDB_TYPE_HASH], "HASH");
/* Object types only used for dumping to disk */ /* Object types only used for dumping to disk */
sprintf(types[REDIS_RDB_OPCODE_EXPIRETIME], "EXPIRETIME"); sprintf(types[RDB_OPCODE_EXPIRETIME], "EXPIRETIME");
sprintf(types[REDIS_RDB_OPCODE_SELECTDB], "SELECTDB"); sprintf(types[RDB_OPCODE_SELECTDB], "SELECTDB");
sprintf(types[REDIS_RDB_OPCODE_EOF], "EOF"); sprintf(types[RDB_OPCODE_EOF], "EOF");
process(); process();
...@@ -704,7 +704,7 @@ int redis_check_rdb_main(char **argv, int argc) { ...@@ -704,7 +704,7 @@ int redis_check_rdb_main(char **argv, int argc) {
fprintf(stderr, "Usage: %s <rdb-file-name>\n", argv[0]); fprintf(stderr, "Usage: %s <rdb-file-name>\n", argv[0]);
exit(1); exit(1);
} }
serverLog(REDIS_WARNING, "Checking RDB file %s", argv[1]); serverLog(LL_WARNING, "Checking RDB file %s", argv[1]);
exit(redis_check_rdb(argv[1])); exit(redis_check_rdb(argv[1]));
return 0; return 0;
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment