diff --git a/src/aof.c b/src/aof.c index 2c143dd67..03b6a3670 100644 --- a/src/aof.c +++ b/src/aof.c @@ -95,10 +95,10 @@ void aofChildWriteDiffData(aeEventLoop *el, int fd, void *privdata, int mask) { listNode *ln; aofrwblock *block; ssize_t nwritten; - REDIS_NOTUSED(el); - REDIS_NOTUSED(fd); - REDIS_NOTUSED(privdata); - REDIS_NOTUSED(mask); + UNUSED(el); + UNUSED(fd); + UNUSED(privdata); + UNUSED(mask); while(1) { ln = listFirst(server.aof_rewrite_buf_blocks); @@ -150,8 +150,8 @@ void aofRewriteBufferAppend(unsigned char *s, unsigned long len) { * as a notice or warning. */ numblocks = listLength(server.aof_rewrite_buf_blocks); if (((numblocks+1) % 10) == 0) { - int level = ((numblocks+1) % 100) == 0 ? REDIS_WARNING : - REDIS_NOTICE; + int level = ((numblocks+1) % 100) == 0 ? LL_WARNING : + LL_NOTICE; serverLog(level,"Background AOF buffer size: %lu MB", aofRewriteBufferSize()/(1024*1024)); } @@ -204,19 +204,19 @@ void aof_background_fsync(int fd) { /* Called when the user switches from "appendonly yes" to "appendonly no" * at runtime using the CONFIG command. */ void stopAppendOnly(void) { - serverAssert(server.aof_state != REDIS_AOF_OFF); + serverAssert(server.aof_state != AOF_OFF); flushAppendOnlyFile(1); aof_fsync(server.aof_fd); close(server.aof_fd); server.aof_fd = -1; server.aof_selected_db = -1; - server.aof_state = REDIS_AOF_OFF; + server.aof_state = AOF_OFF; /* rewrite operation in progress? kill it, wait child exit */ if (server.aof_child_pid != -1) { int statloc; - serverLog(REDIS_NOTICE,"Killing running AOF rewrite child: %ld", + serverLog(LL_NOTICE,"Killing running AOF rewrite child: %ld", (long) server.aof_child_pid); if (kill(server.aof_child_pid,SIGUSR1) != -1) wait3(&statloc,0,NULL); @@ -235,19 +235,19 @@ void stopAppendOnly(void) { int startAppendOnly(void) { server.aof_last_fsync = server.unixtime; server.aof_fd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644); - serverAssert(server.aof_state == REDIS_AOF_OFF); + serverAssert(server.aof_state == AOF_OFF); if (server.aof_fd == -1) { - serverLog(REDIS_WARNING,"Redis needs to enable the AOF but can't open the append only file: %s",strerror(errno)); + serverLog(LL_WARNING,"Redis needs to enable the AOF but can't open the append only file: %s",strerror(errno)); return C_ERR; } if (rewriteAppendOnlyFileBackground() == C_ERR) { close(server.aof_fd); - serverLog(REDIS_WARNING,"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error."); + serverLog(LL_WARNING,"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error."); return C_ERR; } /* We correctly switched on AOF, now wait for the rewrite to be complete * in order to append data on disk. */ - server.aof_state = REDIS_AOF_WAIT_REWRITE; + server.aof_state = AOF_WAIT_REWRITE; return C_OK; } @@ -298,7 +298,7 @@ void flushAppendOnlyFile(int force) { /* Otherwise fall trough, and go write since we can't wait * over two seconds. */ server.aof_delayed_fsync++; - serverLog(REDIS_NOTICE,"Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis."); + serverLog(LL_NOTICE,"Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis."); } } /* We want to perform a single write. This should be guaranteed atomic @@ -340,13 +340,13 @@ void flushAppendOnlyFile(int force) { /* Log the AOF write error and record the error code. */ if (nwritten == -1) { if (can_log) { - serverLog(REDIS_WARNING,"Error writing to the AOF file: %s", + serverLog(LL_WARNING,"Error writing to the AOF file: %s", strerror(errno)); server.aof_last_write_errno = errno; } } else { if (can_log) { - serverLog(REDIS_WARNING,"Short write while writing to " + serverLog(LL_WARNING,"Short write while writing to " "the AOF file: (nwritten=%lld, " "expected=%lld)", (long long)nwritten, @@ -355,7 +355,7 @@ void flushAppendOnlyFile(int force) { if (ftruncate(server.aof_fd, server.aof_current_size) == -1) { if (can_log) { - serverLog(REDIS_WARNING, "Could not remove short write " + serverLog(LL_WARNING, "Could not remove short write " "from the append-only file. Redis may refuse " "to load the AOF the next time it starts. " "ftruncate: %s", strerror(errno)); @@ -374,7 +374,7 @@ void flushAppendOnlyFile(int force) { * reply for the client is already in the output buffers, and we * have the contract with the user that on acknowledged write data * is synced on disk. */ - serverLog(REDIS_WARNING,"Can't recover from AOF write error when the AOF fsync policy is 'always'. Exiting..."); + serverLog(LL_WARNING,"Can't recover from AOF write error when the AOF fsync policy is 'always'. Exiting..."); exit(1); } else { /* Recover from failed write leaving data into the buffer. However @@ -394,7 +394,7 @@ void flushAppendOnlyFile(int force) { /* Successful write(2). If AOF was in error state, restore the * OK state and log the event. */ if (server.aof_last_write_status == C_ERR) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "AOF write error looks solved, Redis can write again."); server.aof_last_write_status = C_OK; } @@ -531,7 +531,7 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a /* Append to the AOF buffer. This will be flushed on disk just before * of re-entering the event loop, so before the client will get a * positive reply about the operation performed. */ - if (server.aof_state == REDIS_AOF_ON) + if (server.aof_state == AOF_ON) server.aof_buf = sdscatlen(server.aof_buf,buf,sdslen(buf)); /* If a background append only file rewriting is in progress we want to @@ -562,10 +562,10 @@ struct client *createFakeClient(void) { c->argv = NULL; c->bufpos = 0; c->flags = 0; - c->btype = REDIS_BLOCKED_NONE; + c->btype = BLOCKED_NONE; /* We set the fake client as a slave waiting for the synchronization * so that Redis will not try to send replies to this client. */ - c->replstate = REDIS_REPL_WAIT_BGSAVE_START; + c->replstate = SLAVE_STATE_WAIT_BGSAVE_START; c->reply = listCreate(); c->reply_bytes = 0; c->obuf_soft_limit_reached_time = 0; @@ -611,13 +611,13 @@ int loadAppendOnlyFile(char *filename) { } if (fp == NULL) { - serverLog(REDIS_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno)); + serverLog(LL_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno)); exit(1); } /* Temporarily disable AOF, to prevent EXEC from feeding a MULTI * to the same file we're about to read. */ - server.aof_state = REDIS_AOF_OFF; + server.aof_state = AOF_OFF; fakeClient = createFakeClient(); startLoading(fp); @@ -677,7 +677,7 @@ int loadAppendOnlyFile(char *filename) { /* Command lookup */ cmd = lookupCommand(argv[0]->ptr); if (!cmd) { - serverLog(REDIS_WARNING,"Unknown command '%s' reading the append only file", (char*)argv[0]->ptr); + serverLog(LL_WARNING,"Unknown command '%s' reading the append only file", (char*)argv[0]->ptr); exit(1); } @@ -687,7 +687,7 @@ int loadAppendOnlyFile(char *filename) { /* The fake client should not have a reply */ serverAssert(fakeClient->bufpos == 0 && listLength(fakeClient->reply) == 0); /* The fake client should never get blocked */ - serverAssert((fakeClient->flags & REDIS_BLOCKED) == 0); + serverAssert((fakeClient->flags & CLIENT_BLOCKED) == 0); /* Clean up. Command code may have changed argv/argc so we use the * argv/argc of the client instead of the local variables. */ @@ -697,7 +697,7 @@ int loadAppendOnlyFile(char *filename) { /* This point can only be reached when EOF is reached without errors. * If the client is in the middle of a MULTI/EXEC, log error and quit. */ - if (fakeClient->flags & REDIS_MULTI) goto uxeof; + if (fakeClient->flags & CLIENT_MULTI) goto uxeof; loaded_ok: /* DB loaded, cleanup and return C_OK to the caller. */ fclose(fp); @@ -710,40 +710,40 @@ loaded_ok: /* DB loaded, cleanup and return C_OK to the caller. */ readerr: /* Read error. If feof(fp) is true, fall through to unexpected EOF. */ if (!feof(fp)) { - serverLog(REDIS_WARNING,"Unrecoverable error reading the append only file: %s", strerror(errno)); + serverLog(LL_WARNING,"Unrecoverable error reading the append only file: %s", strerror(errno)); exit(1); } uxeof: /* Unexpected AOF end of file. */ if (server.aof_load_truncated) { - serverLog(REDIS_WARNING,"!!! Warning: short read while loading the AOF file !!!"); - serverLog(REDIS_WARNING,"!!! Truncating the AOF at offset %llu !!!", + serverLog(LL_WARNING,"!!! Warning: short read while loading the AOF file !!!"); + serverLog(LL_WARNING,"!!! Truncating the AOF at offset %llu !!!", (unsigned long long) valid_up_to); if (valid_up_to == -1 || truncate(filename,valid_up_to) == -1) { if (valid_up_to == -1) { - serverLog(REDIS_WARNING,"Last valid command offset is invalid"); + serverLog(LL_WARNING,"Last valid command offset is invalid"); } else { - serverLog(REDIS_WARNING,"Error truncating the AOF file: %s", + serverLog(LL_WARNING,"Error truncating the AOF file: %s", strerror(errno)); } } else { /* Make sure the AOF file descriptor points to the end of the * file after the truncate call. */ if (server.aof_fd != -1 && lseek(server.aof_fd,0,SEEK_END) == -1) { - serverLog(REDIS_WARNING,"Can't seek the end of the AOF file: %s", + serverLog(LL_WARNING,"Can't seek the end of the AOF file: %s", strerror(errno)); } else { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "AOF loaded anyway because aof-load-truncated is enabled"); goto loaded_ok; } } } - serverLog(REDIS_WARNING,"Unexpected end of file reading the append only file. You can: 1) Make a backup of your AOF file, then use ./redis-check-aof --fix . 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server."); + serverLog(LL_WARNING,"Unexpected end of file reading the append only file. You can: 1) Make a backup of your AOF file, then use ./redis-check-aof --fix . 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server."); exit(1); fmterr: /* Format error. */ - serverLog(REDIS_WARNING,"Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix "); + serverLog(LL_WARNING,"Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix "); exit(1); } @@ -761,7 +761,7 @@ int rioWriteBulkObject(rio *r, robj *obj) { } else if (sdsEncodedObject(obj)) { return rioWriteBulkString(r,obj->ptr,sdslen(obj->ptr)); } else { - redisPanic("Unknown string encoding"); + serverPanic("Unknown string encoding"); } } @@ -777,8 +777,8 @@ int rewriteListObject(rio *r, robj *key, robj *o) { while (quicklistNext(li,&entry)) { if (count == 0) { - int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ? - REDIS_AOF_REWRITE_ITEMS_PER_CMD : items; + int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? + AOF_REWRITE_ITEMS_PER_CMD : items; if (rioWriteBulkCount(r,'*',2+cmd_items) == 0) return 0; if (rioWriteBulkString(r,"RPUSH",5) == 0) return 0; if (rioWriteBulkObject(r,key) == 0) return 0; @@ -789,12 +789,12 @@ int rewriteListObject(rio *r, robj *key, robj *o) { } else { if (rioWriteBulkLongLong(r,entry.longval) == 0) return 0; } - if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0; + if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0; items--; } quicklistReleaseIterator(li); } else { - redisPanic("Unknown list encoding"); + serverPanic("Unknown list encoding"); } return 1; } @@ -810,15 +810,15 @@ int rewriteSetObject(rio *r, robj *key, robj *o) { while(intsetGet(o->ptr,ii++,&llval)) { if (count == 0) { - int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ? - REDIS_AOF_REWRITE_ITEMS_PER_CMD : items; + int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? + AOF_REWRITE_ITEMS_PER_CMD : items; if (rioWriteBulkCount(r,'*',2+cmd_items) == 0) return 0; if (rioWriteBulkString(r,"SADD",4) == 0) return 0; if (rioWriteBulkObject(r,key) == 0) return 0; } if (rioWriteBulkLongLong(r,llval) == 0) return 0; - if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0; + if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0; items--; } } else if (o->encoding == OBJ_ENCODING_HT) { @@ -828,20 +828,20 @@ int rewriteSetObject(rio *r, robj *key, robj *o) { while((de = dictNext(di)) != NULL) { robj *eleobj = dictGetKey(de); if (count == 0) { - int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ? - REDIS_AOF_REWRITE_ITEMS_PER_CMD : items; + int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? + AOF_REWRITE_ITEMS_PER_CMD : items; if (rioWriteBulkCount(r,'*',2+cmd_items) == 0) return 0; if (rioWriteBulkString(r,"SADD",4) == 0) return 0; if (rioWriteBulkObject(r,key) == 0) return 0; } if (rioWriteBulkObject(r,eleobj) == 0) return 0; - if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0; + if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0; items--; } dictReleaseIterator(di); } else { - redisPanic("Unknown set encoding"); + serverPanic("Unknown set encoding"); } return 1; } @@ -869,8 +869,8 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) { score = zzlGetScore(sptr); if (count == 0) { - int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ? - REDIS_AOF_REWRITE_ITEMS_PER_CMD : items; + int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? + AOF_REWRITE_ITEMS_PER_CMD : items; if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0; if (rioWriteBulkString(r,"ZADD",4) == 0) return 0; @@ -883,7 +883,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) { if (rioWriteBulkLongLong(r,vll) == 0) return 0; } zzlNext(zl,&eptr,&sptr); - if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0; + if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0; items--; } } else if (o->encoding == OBJ_ENCODING_SKIPLIST) { @@ -896,8 +896,8 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) { double *score = dictGetVal(de); if (count == 0) { - int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ? - REDIS_AOF_REWRITE_ITEMS_PER_CMD : items; + int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? + AOF_REWRITE_ITEMS_PER_CMD : items; if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0; if (rioWriteBulkString(r,"ZADD",4) == 0) return 0; @@ -905,12 +905,12 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) { } if (rioWriteBulkDouble(r,*score) == 0) return 0; if (rioWriteBulkObject(r,eleobj) == 0) return 0; - if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0; + if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0; items--; } dictReleaseIterator(di); } else { - redisPanic("Unknown sorted zset encoding"); + serverPanic("Unknown sorted zset encoding"); } return 1; } @@ -941,7 +941,7 @@ static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) { return rioWriteBulkObject(r, value); } - redisPanic("Unknown hash encoding"); + serverPanic("Unknown hash encoding"); return 0; } @@ -954,8 +954,8 @@ int rewriteHashObject(rio *r, robj *key, robj *o) { hi = hashTypeInitIterator(o); while (hashTypeNext(hi) != C_ERR) { if (count == 0) { - int cmd_items = (items > REDIS_AOF_REWRITE_ITEMS_PER_CMD) ? - REDIS_AOF_REWRITE_ITEMS_PER_CMD : items; + int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? + AOF_REWRITE_ITEMS_PER_CMD : items; if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0; if (rioWriteBulkString(r,"HMSET",5) == 0) return 0; @@ -964,7 +964,7 @@ int rewriteHashObject(rio *r, robj *key, robj *o) { if (rioWriteHashIteratorCursor(r, hi, OBJ_HASH_KEY) == 0) return 0; if (rioWriteHashIteratorCursor(r, hi, OBJ_HASH_VALUE) == 0) return 0; - if (++count == REDIS_AOF_REWRITE_ITEMS_PER_CMD) count = 0; + if (++count == AOF_REWRITE_ITEMS_PER_CMD) count = 0; items--; } @@ -993,7 +993,7 @@ ssize_t aofReadDiffFromParent(void) { * * In order to minimize the number of commands needed in the rewritten * log Redis uses variadic commands when possible, such as RPUSH, SADD - * and ZADD. However at max REDIS_AOF_REWRITE_ITEMS_PER_CMD items per time + * and ZADD. However at max AOF_REWRITE_ITEMS_PER_CMD items per time * are inserted using a single command. */ int rewriteAppendOnlyFile(char *filename) { dictIterator *di = NULL; @@ -1011,14 +1011,14 @@ int rewriteAppendOnlyFile(char *filename) { snprintf(tmpfile,256,"temp-rewriteaof-%d.aof", (int) getpid()); fp = fopen(tmpfile,"w"); if (!fp) { - serverLog(REDIS_WARNING, "Opening the temp file for AOF rewrite in rewriteAppendOnlyFile(): %s", strerror(errno)); + serverLog(LL_WARNING, "Opening the temp file for AOF rewrite in rewriteAppendOnlyFile(): %s", strerror(errno)); return C_ERR; } server.aof_child_diff = sdsempty(); rioInitWithFile(&aof,fp); if (server.aof_rewrite_incremental_fsync) - rioSetAutoSync(&aof,REDIS_AOF_AUTOSYNC_BYTES); + rioSetAutoSync(&aof,AOF_AUTOSYNC_BYTES); for (j = 0; j < server.dbnum; j++) { char selectcmd[] = "*2\r\n$6\r\nSELECT\r\n"; redisDb *db = server.db+j; @@ -1066,7 +1066,7 @@ int rewriteAppendOnlyFile(char *filename) { } else if (o->type == OBJ_HASH) { if (rewriteHashObject(&aof,&key,o) == 0) goto werr; } else { - redisPanic("Unknown object type"); + serverPanic("Unknown object type"); } /* Save the expire time */ if (expiretime != -1) { @@ -1118,13 +1118,13 @@ int rewriteAppendOnlyFile(char *filename) { * the child will eventually get terminated. */ if (syncRead(server.aof_pipe_read_ack_from_parent,&byte,1,5000) != 1 || byte != '!') goto werr; - serverLog(REDIS_NOTICE,"Parent agreed to stop sending diffs. Finalizing AOF..."); + serverLog(LL_NOTICE,"Parent agreed to stop sending diffs. Finalizing AOF..."); /* Read the final diff if any. */ aofReadDiffFromParent(); /* Write the received diff to the file. */ - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Concatenating %.2f MB of AOF diff received from parent.", (double) sdslen(server.aof_child_diff) / (1024*1024)); if (rioWrite(&aof,server.aof_child_diff,sdslen(server.aof_child_diff)) == 0) @@ -1138,15 +1138,15 @@ int rewriteAppendOnlyFile(char *filename) { /* Use RENAME to make sure the DB file is changed atomically only * if the generate DB file is ok. */ if (rename(tmpfile,filename) == -1) { - serverLog(REDIS_WARNING,"Error moving temp append only file on the final destination: %s", strerror(errno)); + serverLog(LL_WARNING,"Error moving temp append only file on the final destination: %s", strerror(errno)); unlink(tmpfile); return C_ERR; } - serverLog(REDIS_NOTICE,"SYNC append only file rewrite performed"); + serverLog(LL_NOTICE,"SYNC append only file rewrite performed"); return C_OK; werr: - serverLog(REDIS_WARNING,"Write error writing append only file on disk: %s", strerror(errno)); + serverLog(LL_WARNING,"Write error writing append only file on disk: %s", strerror(errno)); fclose(fp); unlink(tmpfile); if (di) dictReleaseIterator(di); @@ -1162,19 +1162,19 @@ werr: * parent sends a '!' as well to acknowledge. */ void aofChildPipeReadable(aeEventLoop *el, int fd, void *privdata, int mask) { char byte; - REDIS_NOTUSED(el); - REDIS_NOTUSED(privdata); - REDIS_NOTUSED(mask); + UNUSED(el); + UNUSED(privdata); + UNUSED(mask); if (read(fd,&byte,1) == 1 && byte == '!') { - serverLog(REDIS_NOTICE,"AOF rewrite child asks to stop sending diffs."); + serverLog(LL_NOTICE,"AOF rewrite child asks to stop sending diffs."); server.aof_stop_sending_diff = 1; if (write(server.aof_pipe_write_ack_to_child,"!",1) != 1) { /* If we can't send the ack, inform the user, but don't try again * since in the other side the children will use a timeout if the * kernel can't buffer our write, or, the children was * terminated. */ - serverLog(REDIS_WARNING,"Can't send ACK to AOF child: %s", + serverLog(LL_WARNING,"Can't send ACK to AOF child: %s", strerror(errno)); } } @@ -1210,7 +1210,7 @@ int aofCreatePipes(void) { return C_OK; error: - serverLog(REDIS_WARNING,"Error opening /setting AOF rewrite IPC pipes: %s", + serverLog(LL_WARNING,"Error opening /setting AOF rewrite IPC pipes: %s", strerror(errno)); for (j = 0; j < 6; j++) if(fds[j] != -1) close(fds[j]); return C_ERR; @@ -1261,7 +1261,7 @@ int rewriteAppendOnlyFileBackground(void) { size_t private_dirty = zmalloc_get_private_dirty(); if (private_dirty) { - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "AOF rewrite: %zu MB of memory used by copy-on-write", private_dirty/(1024*1024)); } @@ -1275,12 +1275,12 @@ int rewriteAppendOnlyFileBackground(void) { server.stat_fork_rate = (double) zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024); /* GB per second. */ latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000); if (childpid == -1) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Can't rewrite append only file in background: fork: %s", strerror(errno)); return C_ERR; } - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Background append only file rewriting started by pid %d",childpid); server.aof_rewrite_scheduled = 0; server.aof_rewrite_time_start = time(NULL); @@ -1327,7 +1327,7 @@ void aofUpdateCurrentSize(void) { latencyStartMonitor(latency); if (redis_fstat(server.aof_fd,&sb) == -1) { - serverLog(REDIS_WARNING,"Unable to obtain the AOF file length. stat: %s", + serverLog(LL_WARNING,"Unable to obtain the AOF file length. stat: %s", strerror(errno)); } else { server.aof_current_size = sb.st_size; @@ -1345,7 +1345,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { long long now = ustime(); mstime_t latency; - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Background AOF rewrite terminated with success"); /* Flush the differences accumulated by the parent to the @@ -1355,13 +1355,13 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { (int)server.aof_child_pid); newfd = open(tmpfile,O_WRONLY|O_APPEND); if (newfd == -1) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Unable to open the temporary AOF produced by the child: %s", strerror(errno)); goto cleanup; } if (aofRewriteBufferWrite(newfd) == -1) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Error trying to flush the parent diff to the rewritten AOF: %s", strerror(errno)); close(newfd); goto cleanup; @@ -1369,7 +1369,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { latencyEndMonitor(latency); latencyAddSampleIfNeeded("aof-rewrite-diff-write",latency); - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Residual parent diff successfully flushed to the rewritten AOF (%.2f MB)", (double) aofRewriteBufferSize() / (1024*1024)); /* The only remaining thing to do is to rename the temporary file to @@ -1415,7 +1415,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { * it exists, because we reference it with "oldfd". */ latencyStartMonitor(latency); if (rename(tmpfile,server.aof_filename) == -1) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Error trying to rename the temporary AOF file: %s", strerror(errno)); close(newfd); if (oldfd != -1) close(oldfd); @@ -1448,25 +1448,25 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { server.aof_lastbgrewrite_status = C_OK; - serverLog(REDIS_NOTICE, "Background AOF rewrite finished successfully"); + serverLog(LL_NOTICE, "Background AOF rewrite finished successfully"); /* Change state from WAIT_REWRITE to ON if needed */ - if (server.aof_state == REDIS_AOF_WAIT_REWRITE) - server.aof_state = REDIS_AOF_ON; + if (server.aof_state == AOF_WAIT_REWRITE) + server.aof_state = AOF_ON; /* Asynchronously close the overwritten AOF. */ if (oldfd != -1) bioCreateBackgroundJob(REDIS_BIO_CLOSE_FILE,(void*)(long)oldfd,NULL,NULL); - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "Background AOF rewrite signal handler took %lldus", ustime()-now); } else if (!bysignal && exitcode != 0) { server.aof_lastbgrewrite_status = C_ERR; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Background AOF rewrite terminated with error"); } else { server.aof_lastbgrewrite_status = C_ERR; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Background AOF rewrite terminated by signal %d", bysignal); } @@ -1478,6 +1478,6 @@ cleanup: server.aof_rewrite_time_last = time(NULL)-server.aof_rewrite_time_start; server.aof_rewrite_time_start = -1; /* Schedule a new rewrite if we are waiting for it to switch the AOF ON. */ - if (server.aof_state == REDIS_AOF_WAIT_REWRITE) + if (server.aof_state == AOF_WAIT_REWRITE) server.aof_rewrite_scheduled = 1; } diff --git a/src/bio.c b/src/bio.c index e76c8f1e6..5eb803212 100644 --- a/src/bio.c +++ b/src/bio.c @@ -116,7 +116,7 @@ void bioInit(void) { for (j = 0; j < REDIS_BIO_NUM_OPS; j++) { void *arg = (void*)(unsigned long) j; 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); } bio_threads[j] = thread; @@ -144,7 +144,7 @@ void *bioProcessBackgroundJobs(void *arg) { /* Check that the type is within the right interval. */ if (type >= REDIS_BIO_NUM_OPS) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Warning: bio thread started with wrong type %lu",type); return NULL; } @@ -160,7 +160,7 @@ void *bioProcessBackgroundJobs(void *arg) { sigemptyset(&sigset); sigaddset(&sigset, SIGALRM); 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)); while(1) { @@ -184,7 +184,7 @@ void *bioProcessBackgroundJobs(void *arg) { } else if (type == REDIS_BIO_AOF_FSYNC) { aof_fsync((long)job->arg1); } else { - redisPanic("Wrong job type in bioProcessBackgroundJobs()."); + serverPanic("Wrong job type in bioProcessBackgroundJobs()."); } zfree(job); @@ -215,11 +215,11 @@ void bioKillThreads(void) { for (j = 0; j < REDIS_BIO_NUM_OPS; j++) { if (pthread_cancel(bio_threads[j]) == 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", j, strerror(err)); } else { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Bio thread for job type #%d terminated",j); } } diff --git a/src/bitops.c b/src/bitops.c index 8603899e4..e4c383612 100644 --- a/src/bitops.c +++ b/src/bitops.c @@ -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 * 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. */ } @@ -250,7 +250,7 @@ void setbitCommand(client *c) { byteval |= ((on & 0x1) << bit); ((uint8_t*)o->ptr)[byte] = byteval; 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++; addReply(c, bitval ? shared.cone : shared.czero); } @@ -446,11 +446,11 @@ void bitopCommand(client *c) { if (maxlen) { o = createObject(OBJ_STRING,res); setKey(c->db,targetkey,o); - notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"set",targetkey,c->db->id); + notifyKeyspaceEvent(NOTIFY_STRING,"set",targetkey,c->db->id); decrRefCount(o); } else if (dbDelete(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++; addReplyLongLong(c,maxlen); /* Return the output string length in bytes. */ diff --git a/src/blocked.c b/src/blocked.c index c6194a0e7..d22872548 100644 --- a/src/blocked.c +++ b/src/blocked.c @@ -34,17 +34,17 @@ * getTimeoutFromObjectOrReply() is just an utility function to parse a * timeout argument since blocking operations usually require a timeout. * - * blockClient() set the REDIS_BLOCKED flag in the client, and set the - * specified block type 'btype' filed to one of REDIS_BLOCKED_* macros. + * blockClient() set the CLIENT_BLOCKED flag in the client, and set the + * specified block type 'btype' filed to one of BLOCKED_* macros. * * unblockClient() unblocks the client doing the following: * 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 * processed ASAP in the beforeSleep() event loop callback, so that * if there is some query buffer to process, we do it. This is also * 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. * * processUnblockedClients() is called inside the beforeSleep() function @@ -94,11 +94,11 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int 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, * and will be processed when the client is unblocked. */ void blockClient(client *c, int btype) { - c->flags |= REDIS_BLOCKED; + c->flags |= CLIENT_BLOCKED; c->btype = btype; server.bpop_blocked_clients++; } @@ -115,13 +115,13 @@ void processUnblockedClients(void) { serverAssert(ln != NULL); c = ln->value; listDelNode(server.unblocked_clients,ln); - c->flags &= ~REDIS_UNBLOCKED; + c->flags &= ~CLIENT_UNBLOCKED; /* Process remaining data in the input buffer, unless the client * is blocked again. Actually processInputBuffer() checks that the * client is not blocked before to proceed, but things may change and * 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) { processInputBuffer(c); } @@ -132,22 +132,22 @@ void processUnblockedClients(void) { /* Unblock a client calling the right function depending on the kind * of operation the client is blocking for. */ void unblockClient(client *c) { - if (c->btype == REDIS_BLOCKED_LIST) { + if (c->btype == BLOCKED_LIST) { unblockClientWaitingData(c); - } else if (c->btype == REDIS_BLOCKED_WAIT) { + } else if (c->btype == BLOCKED_WAIT) { unblockClientWaitingReplicas(c); } else { - redisPanic("Unknown btype in unblockClient()."); + serverPanic("Unknown btype in unblockClient()."); } /* Clear the flags, and put the client in the unblocked list so that * we'll process new commands in its query buffer ASAP. */ - c->flags &= ~REDIS_BLOCKED; - c->btype = REDIS_BLOCKED_NONE; + c->flags &= ~CLIENT_BLOCKED; + c->btype = BLOCKED_NONE; server.bpop_blocked_clients--; /* 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. */ - if (!(c->flags & REDIS_UNBLOCKED)) { - c->flags |= REDIS_UNBLOCKED; + if (!(c->flags & CLIENT_UNBLOCKED)) { + c->flags |= CLIENT_UNBLOCKED; listAddNodeTail(server.unblocked_clients,c); } } @@ -155,12 +155,12 @@ void unblockClient(client *c) { /* This function gets called when a blocked client timed out in order to * send it a reply of some kind. */ void replyToBlockedClientTimedOut(client *c) { - if (c->btype == REDIS_BLOCKED_LIST) { + if (c->btype == BLOCKED_LIST) { addReply(c,shared.nullmultibulk); - } else if (c->btype == REDIS_BLOCKED_WAIT) { + } else if (c->btype == BLOCKED_WAIT) { addReplyLongLong(c,replicationCountAcksByOffset(c->bpop.reploffset)); } else { - redisPanic("Unknown btype in replyToBlockedClientTimedOut()."); + serverPanic("Unknown btype in replyToBlockedClientTimedOut()."); } } @@ -179,12 +179,12 @@ void disconnectAllBlockedClients(void) { while((ln = listNext(&li))) { client *c = listNodeValue(ln); - if (c->flags & REDIS_BLOCKED) { + if (c->flags & CLIENT_BLOCKED) { addReplySds(c,sdsnew( "-UNBLOCKED force unblock from blocking operation, " "instance state changed (master -> slave?)\r\n")); unblockClient(c); - c->flags |= REDIS_CLOSE_AFTER_REPLY; + c->flags |= CLIENT_CLOSE_AFTER_REPLY; } } } diff --git a/src/cluster.c b/src/cluster.c index 04ad6231f..089d85992 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -97,7 +97,7 @@ int clusterLoadConfig(char *filename) { if (errno == ENOENT) { return C_ERR; } else { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Loading the cluster node config from %s: %s", filename, strerror(errno)); exit(1); @@ -146,7 +146,7 @@ int clusterLoadConfig(char *filename) { server.cluster->lastVoteEpoch = strtoull(argv[j+1],NULL,10); } else { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Skipping unknown cluster config variable '%s'", argv[j]); } @@ -195,7 +195,7 @@ int clusterLoadConfig(char *filename) { } else if (!strcasecmp(s,"noflags")) { /* nothing to do */ } else { - redisPanic("Unknown flag in redis cluster config file"); + serverPanic("Unknown flag in redis cluster config file"); } if (p) s = p+1; } @@ -264,7 +264,7 @@ int clusterLoadConfig(char *filename) { zfree(line); fclose(fp); - serverLog(REDIS_NOTICE,"Node configuration loaded, I'm %.40s", myself->name); + serverLog(LL_NOTICE,"Node configuration loaded, I'm %.40s", myself->name); /* Something that should never happen: currentEpoch smaller than * the max epoch found in the nodes configuration. However we handle this @@ -275,7 +275,7 @@ int clusterLoadConfig(char *filename) { return C_OK; fmterr: - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Unrecoverable error: corrupted cluster config file."); zfree(line); if (fp) fclose(fp); @@ -343,7 +343,7 @@ err: void clusterSaveConfigOrDie(int do_fsync) { if (clusterSaveConfig(do_fsync) == -1) { - serverLog(REDIS_WARNING,"Fatal: can't update cluster config file."); + serverLog(LL_WARNING,"Fatal: can't update cluster config file."); exit(1); } } @@ -368,7 +368,7 @@ int clusterLockConfig(char *filename) { * processes. */ int fd = open(filename,O_WRONLY|O_CREAT,0644); if (fd == -1) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Can't open %s in order to acquire a lock: %s", filename, strerror(errno)); return C_ERR; @@ -376,13 +376,13 @@ int clusterLockConfig(char *filename) { if (flock(fd,LOCK_EX|LOCK_NB) == -1) { if (errno == EWOULDBLOCK) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Sorry, the cluster configuration file %s is already used " "by a different Redis Cluster node. Please make sure that " "different nodes use different cluster configuration " "files.", filename); } else { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Impossible to lock %s: %s", filename, strerror(errno)); } close(fd); @@ -429,7 +429,7 @@ void clusterInit(void) { * by the createClusterNode() function. */ myself = server.cluster->myself = createClusterNode(NULL,REDIS_NODE_MYSELF|REDIS_NODE_MASTER); - serverLog(REDIS_NOTICE,"No cluster configuration found, I'm %.40s", + serverLog(LL_NOTICE,"No cluster configuration found, I'm %.40s", myself->name); clusterAddNode(myself); saveconf = 1; @@ -443,7 +443,7 @@ void clusterInit(void) { * The other handshake port check is triggered too late to stop * us from trying to use a too-high cluster port number. */ if (server.port > (65535-REDIS_CLUSTER_PORT_INCR)) { - serverLog(REDIS_WARNING, "Redis port number too high. " + serverLog(LL_WARNING, "Redis port number too high. " "Cluster communication port is 10,000 port " "numbers higher than your Redis port. " "Your Redis port number must be " @@ -461,7 +461,7 @@ void clusterInit(void) { for (j = 0; j < server.cfd_count; j++) { if (aeCreateFileEvent(server.el, server.cfd[j], AE_READABLE, clusterAcceptHandler, NULL) == AE_ERR) - redisPanic("Unrecoverable error creating Redis Cluster " + serverPanic("Unrecoverable error creating Redis Cluster " "file event."); } } @@ -522,7 +522,7 @@ void clusterReset(int hard) { server.cluster->currentEpoch = 0; server.cluster->lastVoteEpoch = 0; myself->configEpoch = 0; - serverLog(REDIS_WARNING, "configEpoch set to 0 via CLUSTER RESET HARD"); + serverLog(LL_WARNING, "configEpoch set to 0 via CLUSTER RESET HARD"); /* To change the Node ID we need to remove the old name from the * nodes table, change the ID, and re-add back with new name. */ @@ -573,11 +573,11 @@ void freeClusterLink(clusterLink *link) { void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) { int cport, cfd; int max = MAX_CLUSTER_ACCEPTS_PER_CALL; - char cip[REDIS_IP_STR_LEN]; + char cip[NET_IP_STR_LEN]; clusterLink *link; - REDIS_NOTUSED(el); - REDIS_NOTUSED(mask); - REDIS_NOTUSED(privdata); + UNUSED(el); + UNUSED(mask); + UNUSED(privdata); /* If the server is starting up, don't accept cluster connections: * UPDATE messages may interact with the database content. */ @@ -587,7 +587,7 @@ void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) { cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); if (cfd == ANET_ERR) { if (errno != EWOULDBLOCK) - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "Error accepting cluster node: %s", server.neterr); return; } @@ -595,7 +595,7 @@ void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) { anetEnableTcpNoDelay(NULL,cfd); /* Use non-blocking I/O for cluster messages. */ - serverLog(REDIS_VERBOSE,"Accepted cluster node %s:%d", cip, cport); + serverLog(LL_VERBOSE,"Accepted cluster node %s:%d", cip, cport); /* Create a link object we use to handle the connection. * It gets passed to the readable handler when data is available. * Initiallly the link->node pointer is set to NULL as we don't know @@ -911,7 +911,7 @@ void clusterRenameNode(clusterNode *node, char *newname) { int retval; sds s = sdsnewlen(node->name, REDIS_CLUSTER_NAMELEN); - serverLog(REDIS_DEBUG,"Renaming node %.40s into %.40s", + serverLog(LL_DEBUG,"Renaming node %.40s into %.40s", node->name, newname); retval = dictDelete(server.cluster->nodes, s); sdsfree(s); @@ -980,7 +980,7 @@ int clusterBumpConfigEpochWithoutConsensus(void) { myself->configEpoch = server.cluster->currentEpoch; clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG| CLUSTER_TODO_FSYNC_CONFIG); - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "New configEpoch set to %llu", (unsigned long long) myself->configEpoch); return C_OK; @@ -1045,7 +1045,7 @@ void clusterHandleConfigEpochCollision(clusterNode *sender) { server.cluster->currentEpoch++; myself->configEpoch = server.cluster->currentEpoch; clusterSaveConfigOrDie(1); - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "WARNING: configEpoch collision with node %.40s." " configEpoch set to %llu", sender->name, @@ -1163,7 +1163,7 @@ void markNodeAsFailingIfNeeded(clusterNode *node) { if (nodeIsMaster(myself)) failures++; if (failures < needed_quorum) return; /* No weak agreement from masters. */ - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Marking node %.40s as failing (quorum reached).", node->name); /* Mark the node as failing. */ @@ -1188,7 +1188,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) { /* For slaves we always clear the FAIL flag if we can contact the * node again. */ if (nodeIsSlave(node) || node->numslots == 0) { - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Clear FAIL state for node %.40s: %s is reachable again.", node->name, nodeIsSlave(node) ? "slave" : "master without slots"); @@ -1204,7 +1204,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) { (now - node->fail_time) > (server.cluster_node_timeout * REDIS_CLUSTER_FAIL_UNDO_TIME_MULT)) { - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Clear FAIL state for node %.40s: is reachable again and nobody is serving its slots after some time.", node->name); node->flags &= ~REDIS_NODE_FAIL; @@ -1239,7 +1239,7 @@ int clusterHandshakeInProgress(char *ip, int port) { * EINVAL - IP or port are not valid. */ int clusterStartHandshake(char *ip, int port) { clusterNode *n; - char norm_ip[REDIS_IP_STR_LEN]; + char norm_ip[NET_IP_STR_LEN]; struct sockaddr_storage sa; /* IP sanity check */ @@ -1264,15 +1264,15 @@ int clusterStartHandshake(char *ip, int port) { /* Set norm_ip as the normalized string representation of the node * IP address. */ - memset(norm_ip,0,REDIS_IP_STR_LEN); + memset(norm_ip,0,NET_IP_STR_LEN); if (sa.ss_family == AF_INET) inet_ntop(AF_INET, (void*)&(((struct sockaddr_in *)&sa)->sin_addr), - norm_ip,REDIS_IP_STR_LEN); + norm_ip,NET_IP_STR_LEN); else inet_ntop(AF_INET6, (void*)&(((struct sockaddr_in6 *)&sa)->sin6_addr), - norm_ip,REDIS_IP_STR_LEN); + norm_ip,NET_IP_STR_LEN); if (clusterHandshakeInProgress(norm_ip,port)) { errno = EAGAIN; @@ -1304,7 +1304,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { sds ci; ci = representRedisNodeFlags(sdsempty(), flags); - serverLog(REDIS_DEBUG,"GOSSIP %.40s %s:%d %s", + serverLog(LL_DEBUG,"GOSSIP %.40s %s:%d %s", g->nodename, g->ip, ntohs(g->port), @@ -1319,14 +1319,14 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { if (sender && nodeIsMaster(sender) && node != myself) { if (flags & (REDIS_NODE_FAIL|REDIS_NODE_PFAIL)) { if (clusterNodeAddFailureReport(node,sender)) { - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "Node %.40s reported node %.40s as not reachable.", sender->name, node->name); } markNodeAsFailingIfNeeded(node); } else { if (clusterNodeDelFailureReport(node,sender)) { - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "Node %.40s reported node %.40s is back online.", sender->name, node->name); } @@ -1365,7 +1365,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) { /* IP -> string conversion. 'buf' is supposed to at least be 46 bytes. */ void nodeIp2String(char *buf, clusterLink *link) { - anetPeerToString(link->fd, buf, REDIS_IP_STR_LEN, NULL); + anetPeerToString(link->fd, buf, NET_IP_STR_LEN, NULL); } /* Update the node address to the IP address that can be extracted @@ -1379,7 +1379,7 @@ void nodeIp2String(char *buf, clusterLink *link) { * The function returns 0 if the node address is still the same, * otherwise 1 is returned. */ int nodeUpdateAddressIfNeeded(clusterNode *node, clusterLink *link, int port) { - char ip[REDIS_IP_STR_LEN] = {0}; + char ip[NET_IP_STR_LEN] = {0}; /* We don't proceed if the link is the same as the sender link, as this * function is designed to see if the node link is consistent with the @@ -1397,7 +1397,7 @@ int nodeUpdateAddressIfNeeded(clusterNode *node, clusterLink *link, int port) { node->port = port; if (node->link) freeClusterLink(node->link); node->flags &= ~REDIS_NODE_NOADDR; - serverLog(REDIS_WARNING,"Address updated for node %.40s, now %s:%d", + serverLog(LL_WARNING,"Address updated for node %.40s, now %s:%d", node->name, node->ip, node->port); /* Check if this is our master and we have to change the @@ -1453,7 +1453,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc curmaster = nodeIsMaster(myself) ? myself : myself->slaveof; if (sender == myself) { - serverLog(REDIS_WARNING,"Discarding UPDATE message about myself."); + serverLog(LL_WARNING,"Discarding UPDATE message about myself."); return; } @@ -1504,7 +1504,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc * 2) We are a slave and our master is left without slots. We need * to replicate to the new slots owner. */ if (newmaster && curmaster->numslots == 0) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Configuration change detected. Reconfiguring myself " "as a replica of %.40s", sender->name); clusterSetMaster(sender); @@ -1542,7 +1542,7 @@ int clusterProcessPacket(clusterLink *link) { clusterNode *sender; server.cluster->stats_bus_messages_received++; - serverLog(REDIS_DEBUG,"--- Processing packet of type %d, %lu bytes", + serverLog(LL_DEBUG,"--- Processing packet of type %d, %lu bytes", type, (unsigned long) totlen); /* Perform sanity checks */ @@ -1612,7 +1612,7 @@ int clusterProcessPacket(clusterLink *link) { server.cluster->mf_master_offset == 0) { server.cluster->mf_master_offset = sender->repl_offset; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Received replication offset for paused " "master manual failover: %lld", server.cluster->mf_master_offset); @@ -1621,7 +1621,7 @@ int clusterProcessPacket(clusterLink *link) { /* Initial processing of PING and MEET requests replying with a PONG. */ if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_MEET) { - serverLog(REDIS_DEBUG,"Ping packet received: %p", (void*)link->node); + serverLog(LL_DEBUG,"Ping packet received: %p", (void*)link->node); /* We use incoming MEET messages in order to set the address * for 'myself', since only other cluster nodes will send us @@ -1635,13 +1635,13 @@ int clusterProcessPacket(clusterLink *link) { * even with a normal PING packet. If it's wrong it will be fixed * by MEET later. */ if (type == CLUSTERMSG_TYPE_MEET || myself->ip[0] == '\0') { - char ip[REDIS_IP_STR_LEN]; + char ip[NET_IP_STR_LEN]; if (anetSockName(link->fd,ip,sizeof(ip),NULL) != -1 && strcmp(ip,myself->ip)) { - memcpy(myself->ip,ip,REDIS_IP_STR_LEN); - serverLog(REDIS_WARNING,"IP address for this node updated to %s", + memcpy(myself->ip,ip,NET_IP_STR_LEN); + serverLog(LL_WARNING,"IP address for this node updated to %s", myself->ip); clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG); } @@ -1675,7 +1675,7 @@ int clusterProcessPacket(clusterLink *link) { if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) { - serverLog(REDIS_DEBUG,"%s packet received: %p", + serverLog(LL_DEBUG,"%s packet received: %p", type == CLUSTERMSG_TYPE_PING ? "ping" : "pong", (void*)link->node); if (link->node) { @@ -1683,7 +1683,7 @@ int clusterProcessPacket(clusterLink *link) { /* If we already have this node, try to change the * IP/port of the node with the new one. */ if (sender) { - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "Handshake: we already know node %.40s, " "updating the address if needed.", sender->name); if (nodeUpdateAddressIfNeeded(sender,link,ntohs(hdr->port))) @@ -1700,7 +1700,7 @@ int clusterProcessPacket(clusterLink *link) { /* First thing to do is replacing the random name with the * right node name if this was a handshake stage. */ clusterRenameNode(link->node, hdr->sender); - serverLog(REDIS_DEBUG,"Handshake with node %.40s completed.", + serverLog(LL_DEBUG,"Handshake with node %.40s completed.", link->node->name); link->node->flags &= ~REDIS_NODE_HANDSHAKE; link->node->flags |= flags&(REDIS_NODE_MASTER|REDIS_NODE_SLAVE); @@ -1711,7 +1711,7 @@ int clusterProcessPacket(clusterLink *link) { /* If the reply has a non matching node ID we * disconnect this node and set it as not having an associated * address. */ - serverLog(REDIS_DEBUG,"PONG contains mismatching sender ID"); + serverLog(LL_DEBUG,"PONG contains mismatching sender ID"); link->node->flags |= REDIS_NODE_NOADDR; link->node->ip[0] = '\0'; link->node->port = 0; @@ -1842,7 +1842,7 @@ int clusterProcessPacket(clusterLink *link) { if (server.cluster->slots[j]->configEpoch > senderConfigEpoch) { - serverLog(REDIS_VERBOSE, + serverLog(LL_VERBOSE, "Node %.40s has old slots configuration, sending " "an UPDATE message about %.40s", sender->name, server.cluster->slots[j]->name); @@ -1877,7 +1877,7 @@ int clusterProcessPacket(clusterLink *link) { if (failing && !(failing->flags & (REDIS_NODE_FAIL|REDIS_NODE_MYSELF))) { - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "FAIL message received from %.40s about %.40s", hdr->sender, hdr->data.fail.about.nodename); failing->flags |= REDIS_NODE_FAIL; @@ -1887,7 +1887,7 @@ int clusterProcessPacket(clusterLink *link) { CLUSTER_TODO_UPDATE_STATE); } } else { - serverLog(REDIS_NOTICE, + serverLog(LL_NOTICE, "Ignoring FAIL message from unknown node %.40s about %.40s", hdr->sender, hdr->data.fail.about.nodename); } @@ -1937,7 +1937,7 @@ int clusterProcessPacket(clusterLink *link) { server.cluster->mf_end = mstime() + REDIS_CLUSTER_MF_TIMEOUT; server.cluster->mf_slave = sender; pauseClients(mstime()+(REDIS_CLUSTER_MF_TIMEOUT*2)); - serverLog(REDIS_WARNING,"Manual failover requested by slave %.40s.", + serverLog(LL_WARNING,"Manual failover requested by slave %.40s.", sender->name); } else if (type == CLUSTERMSG_TYPE_UPDATE) { clusterNode *n; /* The node the update is about. */ @@ -1962,7 +1962,7 @@ int clusterProcessPacket(clusterLink *link) { clusterUpdateSlotsConfigWith(n,reportedConfigEpoch, hdr->data.update.nodecfg.slots); } else { - serverLog(REDIS_WARNING,"Received unknown packet type: %d", type); + serverLog(LL_WARNING,"Received unknown packet type: %d", type); } return 1; } @@ -1983,12 +1983,12 @@ void handleLinkIOError(clusterLink *link) { void clusterWriteHandler(aeEventLoop *el, int fd, void *privdata, int mask) { clusterLink *link = (clusterLink*) privdata; ssize_t nwritten; - REDIS_NOTUSED(el); - REDIS_NOTUSED(mask); + UNUSED(el); + UNUSED(mask); nwritten = write(fd, link->sndbuf, sdslen(link->sndbuf)); if (nwritten <= 0) { - serverLog(REDIS_DEBUG,"I/O error writing to node link: %s", + serverLog(LL_DEBUG,"I/O error writing to node link: %s", strerror(errno)); handleLinkIOError(link); return; @@ -2007,8 +2007,8 @@ void clusterReadHandler(aeEventLoop *el, int fd, void *privdata, int mask) { clusterMsg *hdr; clusterLink *link = (clusterLink*) privdata; unsigned int readlen, rcvbuflen; - REDIS_NOTUSED(el); - REDIS_NOTUSED(mask); + UNUSED(el); + UNUSED(mask); while(1) { /* Read as long as there is data to read. */ rcvbuflen = sdslen(link->rcvbuf); @@ -2025,7 +2025,7 @@ void clusterReadHandler(aeEventLoop *el, int fd, void *privdata, int mask) { if (memcmp(hdr->sig,"RCmb",4) != 0 || ntohl(hdr->totlen) < CLUSTERMSG_MIN_LEN) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Bad message length or signature received " "from Cluster bus."); handleLinkIOError(link); @@ -2041,7 +2041,7 @@ void clusterReadHandler(aeEventLoop *el, int fd, void *privdata, int mask) { if (nread <= 0) { /* I/O error... */ - serverLog(REDIS_DEBUG,"I/O error reading from node link: %s", + serverLog(LL_DEBUG,"I/O error reading from node link: %s", (nread == 0) ? "connection closed" : strerror(errno)); handleLinkIOError(link); return; @@ -2471,7 +2471,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { * our currentEpoch was updated as a side effect of receiving this * request, if the request epoch was greater. */ if (requestCurrentEpoch < server.cluster->currentEpoch) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: reqEpoch (%llu) < curEpoch(%llu)", node->name, (unsigned long long) requestCurrentEpoch, @@ -2481,7 +2481,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { /* I already voted for this epoch? Return ASAP. */ if (server.cluster->lastVoteEpoch == server.cluster->currentEpoch) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: already voted for epoch %llu", node->name, (unsigned long long) server.cluster->currentEpoch); @@ -2495,15 +2495,15 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { (!nodeFailed(master) && !force_ack)) { if (nodeIsMaster(node)) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: it is a master node", node->name); } else if (master == NULL) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: I don't know its master", node->name); } else if (!nodeFailed(master)) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: its master is up", node->name); } @@ -2515,7 +2515,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { * of the algorithm but makes the base case more linear. */ if (mstime() - node->slaveof->voted_time < server.cluster_node_timeout * 2) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: " "can't vote about this master before %lld milliseconds", node->name, @@ -2537,7 +2537,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { /* If we reached this point we found a slot that in our current slots * is served by a master with a greater configEpoch than the one claimed * by the slave requesting our vote. Refuse to vote for this slave. */ - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover auth denied to %.40s: " "slot %d epoch (%llu) > reqEpoch (%llu)", node->name, j, @@ -2550,7 +2550,7 @@ void clusterSendFailoverAuthIfNeeded(clusterNode *node, clusterMsg *request) { clusterSendFailoverAuth(node); server.cluster->lastVoteEpoch = server.cluster->currentEpoch; node->slaveof->voted_time = mstime(); - serverLog(REDIS_WARNING, "Failover auth granted to %.40s for epoch %llu", + serverLog(LL_WARNING, "Failover auth granted to %.40s for epoch %llu", node->name, (unsigned long long) server.cluster->currentEpoch); } @@ -2641,7 +2641,7 @@ void clusterLogCantFailover(int reason) { break; } lastlog_time = time(NULL); - serverLog(REDIS_WARNING,"Currently unable to failover: %s", msg); + serverLog(LL_WARNING,"Currently unable to failover: %s", msg); } /* This function implements the final part of automatic and manual failovers, @@ -2727,7 +2727,7 @@ void clusterHandleSlaveFailover(void) { /* Set data_age to the number of seconds we are disconnected from * the master. */ - if (server.repl_state == REDIS_REPL_CONNECTED) { + if (server.repl_state == REPL_STATE_CONNECTED) { data_age = (mstime_t)(server.unixtime - server.master->lastinteraction) * 1000; } else { @@ -2774,7 +2774,7 @@ void clusterHandleSlaveFailover(void) { server.cluster->failover_auth_time = mstime(); server.cluster->failover_auth_rank = 0; } - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Start of election delayed for %lld milliseconds " "(rank #%d, offset %lld).", server.cluster->failover_auth_time - mstime(), @@ -2801,7 +2801,7 @@ void clusterHandleSlaveFailover(void) { (newrank - server.cluster->failover_auth_rank) * 1000; server.cluster->failover_auth_time += added_delay; server.cluster->failover_auth_rank = newrank; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Slave rank updated to #%d, added %lld milliseconds of delay.", newrank, added_delay); } @@ -2823,7 +2823,7 @@ void clusterHandleSlaveFailover(void) { if (server.cluster->failover_auth_sent == 0) { server.cluster->currentEpoch++; server.cluster->failover_auth_epoch = server.cluster->currentEpoch; - serverLog(REDIS_WARNING,"Starting a failover election for epoch %llu.", + serverLog(LL_WARNING,"Starting a failover election for epoch %llu.", (unsigned long long) server.cluster->currentEpoch); clusterRequestFailoverAuth(); server.cluster->failover_auth_sent = 1; @@ -2837,13 +2837,13 @@ void clusterHandleSlaveFailover(void) { if (server.cluster->failover_auth_count >= needed_quorum) { /* We have the quorum, we can finally failover the master. */ - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Failover election won: I'm the new master."); /* Update my configEpoch to the epoch of the election. */ if (myself->configEpoch < server.cluster->failover_auth_epoch) { myself->configEpoch = server.cluster->failover_auth_epoch; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "configEpoch set to %llu after successful failover", (unsigned long long) myself->configEpoch); } @@ -2941,7 +2941,7 @@ void clusterHandleSlaveMigration(int max_slaves) { /* Step 4: perform the migration if there is a target, and if I'm the * candidate. */ if (target && candidate == myself) { - serverLog(REDIS_WARNING,"Migrating to orphaned master %.40s", + serverLog(LL_WARNING,"Migrating to orphaned master %.40s", target->name); clusterSetMaster(target); } @@ -2995,7 +2995,7 @@ void resetManualFailover(void) { /* If a manual failover timed out, abort it. */ void manualFailoverCheckTimeout(void) { if (server.cluster->mf_end && server.cluster->mf_end < mstime()) { - serverLog(REDIS_WARNING,"Manual failover timed out."); + serverLog(LL_WARNING,"Manual failover timed out."); resetManualFailover(); } } @@ -3016,7 +3016,7 @@ void clusterHandleManualFailover(void) { /* Our replication offset matches the master replication offset * announced after clients were paused. We can start the failover. */ server.cluster->mf_can_start = 1; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "All master replication stream processed, " "manual failover can start."); } @@ -3068,7 +3068,7 @@ void clusterCron(void) { clusterLink *link; fd = anetTcpNonBlockBindConnect(server.neterr, node->ip, - node->port+REDIS_CLUSTER_PORT_INCR, REDIS_BIND_ADDR); + node->port+REDIS_CLUSTER_PORT_INCR, NET_FIRST_BIND_ADDR); if (fd == -1) { /* We got a synchronous error from connect before * clusterSendPing() had a chance to be called. @@ -3076,7 +3076,7 @@ void clusterCron(void) { * so we claim we actually sent a ping now (that will * be really sent as soon as the link is obtained). */ if (node->ping_sent == 0) node->ping_sent = mstime(); - serverLog(REDIS_DEBUG, "Unable to connect to " + serverLog(LL_DEBUG, "Unable to connect to " "Cluster Node [%s]:%d -> %s", node->ip, node->port+REDIS_CLUSTER_PORT_INCR, server.neterr); @@ -3109,7 +3109,7 @@ void clusterCron(void) { * normal PING packets. */ node->flags &= ~REDIS_NODE_MEET; - serverLog(REDIS_DEBUG,"Connecting with Node %.40s at %s:%d", + serverLog(LL_DEBUG,"Connecting with Node %.40s at %s:%d", node->name, node->ip, node->port+REDIS_CLUSTER_PORT_INCR); } } @@ -3136,7 +3136,7 @@ void clusterCron(void) { } } if (min_pong_node) { - serverLog(REDIS_DEBUG,"Pinging node %.40s", min_pong_node->name); + serverLog(LL_DEBUG,"Pinging node %.40s", min_pong_node->name); clusterSendPing(min_pong_node->link, CLUSTERMSG_TYPE_PING); } } @@ -3225,7 +3225,7 @@ void clusterCron(void) { /* Timeout reached. Set the node as possibly failing if it is * not already in this state. */ if (!(node->flags & (REDIS_NODE_PFAIL|REDIS_NODE_FAIL))) { - serverLog(REDIS_DEBUG,"*** NODE %.40s possibly failing", + serverLog(LL_DEBUG,"*** NODE %.40s possibly failing", node->name); node->flags |= REDIS_NODE_PFAIL; update_state = 1; @@ -3488,7 +3488,7 @@ void clusterUpdateState(void) { } /* Change the state and log the event. */ - serverLog(REDIS_WARNING,"Cluster state changed: %s", + serverLog(LL_WARNING,"Cluster state changed: %s", new_state == REDIS_CLUSTER_OK ? "ok" : "fail"); server.cluster->state = new_state; } @@ -3546,11 +3546,11 @@ int verifyClusterConfigWithData(void) { update_config++; /* Case A: slot is unassigned. Take responsibility for it. */ if (server.cluster->slots[j] == NULL) { - serverLog(REDIS_WARNING, "I have keys for unassigned slot %d. " + serverLog(LL_WARNING, "I have keys for unassigned slot %d. " "Taking responsibility for it.",j); clusterAddSlot(myself,j); } else { - serverLog(REDIS_WARNING, "I have keys for slot %d, but the slot is " + serverLog(LL_WARNING, "I have keys for slot %d, but the slot is " "assigned to another node. " "Setting it to importing state.",j); server.cluster->importing_slots_from[j] = server.cluster->slots[j]; @@ -3978,7 +3978,7 @@ void clusterCommand(client *c) { * configEpoch collision resolution will fix it assigning * a different epoch to each node. */ if (clusterBumpConfigEpochWithoutConsensus() == C_OK) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "configEpoch updated after importing slot %d", slot); } server.cluster->importing_slots_from[slot] = NULL; @@ -4220,17 +4220,17 @@ void clusterCommand(client *c) { * generates a new configuration epoch for this node without * consensus, claims the master's slots, and broadcast the new * configuration. */ - serverLog(REDIS_WARNING,"Taking over the master (user request)."); + serverLog(LL_WARNING,"Taking over the master (user request)."); clusterBumpConfigEpochWithoutConsensus(); clusterFailoverReplaceYourMaster(); } else if (force) { /* If this is a forced failover, we don't need to talk with our * master to agree about the offset. We just failover taking over * it without coordination. */ - serverLog(REDIS_WARNING,"Forced failover user request accepted."); + serverLog(LL_WARNING,"Forced failover user request accepted."); server.cluster->mf_can_start = 1; } else { - serverLog(REDIS_WARNING,"Manual failover user request accepted."); + serverLog(LL_WARNING,"Manual failover user request accepted."); clusterSendMFStart(myself->slaveof); } addReply(c,shared.ok); @@ -4257,7 +4257,7 @@ void clusterCommand(client *c) { addReplyError(c,"Node config epoch is already non-zero"); } else { myself->configEpoch = epoch; - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "configEpoch set to %llu via CLUSTER SET-CONFIG-EPOCH", (unsigned long long) myself->configEpoch); @@ -4326,8 +4326,8 @@ void createDumpPayload(rio *payload, robj *o) { */ /* RDB version */ - buf[0] = REDIS_RDB_VERSION & 0xff; - buf[1] = (REDIS_RDB_VERSION >> 8) & 0xff; + buf[0] = RDB_VERSION & 0xff; + buf[1] = (RDB_VERSION >> 8) & 0xff; payload->io.buffer.ptr = sdscatlen(payload->io.buffer.ptr,buf,2); /* CRC64 */ @@ -4352,7 +4352,7 @@ int verifyDumpPayload(unsigned char *p, size_t len) { /* Verify RDB version */ rdbver = (footer[1] << 8) | footer[0]; - if (rdbver != REDIS_RDB_VERSION) return C_ERR; + if (rdbver != RDB_VERSION) return C_ERR; /* Verify CRC64 */ crc = crc64(0,p,len-8); @@ -4728,7 +4728,7 @@ void askingCommand(client *c) { addReplyError(c,"This instance has cluster support disabled"); return; } - c->flags |= REDIS_ASKING; + c->flags |= CLIENT_ASKING; addReply(c,shared.ok); } @@ -4740,13 +4740,13 @@ void readonlyCommand(client *c) { addReplyError(c,"This instance has cluster support disabled"); return; } - c->flags |= REDIS_READONLY; + c->flags |= CLIENT_READONLY; addReply(c,shared.ok); } /* The READWRITE command just clears the READONLY command state. */ void readwriteCommand(client *c) { - c->flags &= ~REDIS_READONLY; + c->flags &= ~CLIENT_READONLY; addReply(c,shared.ok); } @@ -4793,9 +4793,9 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in /* We handle all the cases as if they were EXEC commands, so we have * a common code path for everything */ if (cmd->proc == execCommand) { - /* If REDIS_MULTI flag is not set EXEC is just going to return an + /* If CLIENT_MULTI flag is not set EXEC is just going to return an * error. */ - if (!(c->flags & REDIS_MULTI)) return myself; + if (!(c->flags & CLIENT_MULTI)) return myself; ms = &c->mstate; } else { /* In order to have a single codepath create a fake Multi State @@ -4906,7 +4906,7 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in * involves multiple keys and we don't have them all, the only option is * to send a TRYAGAIN error. */ if (importing_slot && - (c->flags & REDIS_ASKING || cmd->flags & REDIS_CMD_ASKING)) + (c->flags & CLIENT_ASKING || cmd->flags & CMD_ASKING)) { if (multiple_keys && missing_keys) { if (error_code) *error_code = REDIS_CLUSTER_REDIR_UNSTABLE; @@ -4919,8 +4919,8 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in /* Handle the read-only client case reading from a slave: if this * node is a slave and the request is about an hash slot our master * is serving, we can reply without redirection. */ - if (c->flags & REDIS_READONLY && - cmd->flags & REDIS_CMD_READONLY && + if (c->flags & CLIENT_READONLY && + cmd->flags & CMD_READONLY && nodeIsSlave(myself) && myself->slaveof == n) { @@ -4960,7 +4960,7 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co (error_code == REDIS_CLUSTER_REDIR_ASK) ? "ASK" : "MOVED", hashslot,n->ip,n->port)); } else { - redisPanic("getNodeByQuery() unknown error."); + serverPanic("getNodeByQuery() unknown error."); } } @@ -4976,7 +4976,7 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co * longer handles, the client is sent a redirection error, and the function * returns 1. Otherwise 0 is returned and no operation is performed. */ int clusterRedirectBlockedClientIfNeeded(client *c) { - if (c->flags & REDIS_BLOCKED && c->btype == REDIS_BLOCKED_LIST) { + if (c->flags & CLIENT_BLOCKED && c->btype == BLOCKED_LIST) { dictEntry *de; dictIterator *di; diff --git a/src/cluster.h b/src/cluster.h index a6c7e4462..ef0bba805 100644 --- a/src/cluster.h +++ b/src/cluster.h @@ -94,7 +94,7 @@ typedef struct clusterNode { 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 */ 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 */ clusterLink *link; /* TCP/IP link with this node */ list *fail_reports; /* List of nodes signaling this as failing */ @@ -165,7 +165,7 @@ typedef struct { char nodename[REDIS_CLUSTER_NAMELEN]; uint32_t ping_sent; 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 flags; /* node->flags copy */ uint16_t notused1; /* Some room for future improvements. */ diff --git a/src/config.c b/src/config.c index 7f31c4782..06cce489e 100644 --- a/src/config.c +++ b/src/config.c @@ -44,12 +44,12 @@ typedef struct configEnum { } configEnum; configEnum maxmemory_policy_enum[] = { - {"volatile-lru", REDIS_MAXMEMORY_VOLATILE_LRU}, - {"volatile-random",REDIS_MAXMEMORY_VOLATILE_RANDOM}, - {"volatile-ttl",REDIS_MAXMEMORY_VOLATILE_TTL}, - {"allkeys-lru",REDIS_MAXMEMORY_ALLKEYS_LRU}, - {"allkeys-random",REDIS_MAXMEMORY_ALLKEYS_RANDOM}, - {"noeviction",REDIS_MAXMEMORY_NO_EVICTION}, + {"volatile-lru", MAXMEMORY_VOLATILE_LRU}, + {"volatile-random",MAXMEMORY_VOLATILE_RANDOM}, + {"volatile-ttl",MAXMEMORY_VOLATILE_TTL}, + {"allkeys-lru",MAXMEMORY_ALLKEYS_LRU}, + {"allkeys-random",MAXMEMORY_ALLKEYS_RANDOM}, + {"noeviction",MAXMEMORY_NO_EVICTION}, {NULL, 0} }; @@ -67,18 +67,18 @@ configEnum syslog_facility_enum[] = { }; configEnum loglevel_enum[] = { - {"debug", REDIS_DEBUG}, - {"verbose", REDIS_VERBOSE}, - {"notice", REDIS_NOTICE}, - {"warning", REDIS_WARNING}, + {"debug", LL_DEBUG}, + {"verbose", LL_VERBOSE}, + {"notice", LL_NOTICE}, + {"warning", LL_WARNING}, {NULL,0} }; configEnum supervised_mode_enum[] = { - {"upstart", REDIS_SUPERVISED_UPSTART}, - {"systemd", REDIS_SUPERVISED_SYSTEMD}, - {"auto", REDIS_SUPERVISED_AUTODETECT}, - {"no", REDIS_SUPERVISED_NONE}, + {"upstart", SUPERVISED_UPSTART}, + {"systemd", SUPERVISED_SYSTEMD}, + {"auto", SUPERVISED_AUTODETECT}, + {"no", SUPERVISED_NONE}, {NULL, 0} }; @@ -90,7 +90,7 @@ configEnum aof_fsync_enum[] = { }; /* Output buffer limits presets. */ -clientBufferLimitsConfig clientBufferLimitsDefaults[REDIS_CLIENT_TYPE_COUNT] = { +clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_COUNT] = { {0, 0, 0}, /* normal */ {1024*1024*256, 1024*1024*64, 60}, /* slave */ {1024*1024*32, 1024*1024*8, 60} /* pubsub */ @@ -209,7 +209,7 @@ void loadServerConfigFromString(char *config) { } else if (!strcasecmp(argv[0],"bind") && argc >= 2) { int j, addresses = argc-1; - if (addresses > REDIS_BINDADDR_MAX) { + if (addresses > CONFIG_BINDADDR_MAX) { err = "Too many bind addresses specified"; goto loaderr; } for (j = 0; j < addresses; j++) @@ -236,7 +236,7 @@ void loadServerConfigFromString(char *config) { } } else if (!strcasecmp(argv[0],"dir") && argc == 2) { 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)); exit(1); } @@ -308,7 +308,7 @@ void loadServerConfigFromString(char *config) { slaveof_linenum = linenum; server.masterhost = sdsnew(argv[1]); 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) { server.repl_ping_slave_period = atoi(argv[1]); if (server.repl_ping_slave_period <= 0) { @@ -376,15 +376,15 @@ void loadServerConfigFromString(char *config) { } } else if (!strcasecmp(argv[0],"hz") && argc == 2) { server.hz = atoi(argv[1]); - if (server.hz < REDIS_MIN_HZ) server.hz = REDIS_MIN_HZ; - if (server.hz > REDIS_MAX_HZ) server.hz = REDIS_MAX_HZ; + if (server.hz < CONFIG_MIN_HZ) server.hz = CONFIG_MIN_HZ; + if (server.hz > CONFIG_MAX_HZ) server.hz = CONFIG_MAX_HZ; } else if (!strcasecmp(argv[0],"appendonly") && argc == 2) { int yes; if ((yes = yesnotoi(argv[1])) == -1) { 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) { if (!pathIsBaseName(argv[1])) { err = "appendfilename can't be a path, just a filename"; @@ -427,8 +427,8 @@ void loadServerConfigFromString(char *config) { err = "argument must be 'yes' or 'no'"; goto loaderr; } } else if (!strcasecmp(argv[0],"requirepass") && argc == 2) { - if (strlen(argv[1]) > REDIS_AUTHPASS_MAX_LEN) { - err = "Password is longer than REDIS_AUTHPASS_MAX_LEN"; + if (strlen(argv[1]) > CONFIG_AUTHPASS_MAX_LEN) { + err = "Password is longer than CONFIG_AUTHPASS_MAX_LEN"; goto loaderr; } server.requirepass = zstrdup(argv[1]); @@ -637,7 +637,7 @@ loaderr: * just load a string. */ void loadServerConfig(char *filename, char *options) { sds config = sdsempty(); - char buf[REDIS_CONFIGLINE_MAX+1]; + char buf[CONFIG_MAX_LINE+1]; /* Load the file content */ if (filename) { @@ -647,12 +647,12 @@ void loadServerConfig(char *filename, char *options) { fp = stdin; } else { if ((fp = fopen(filename,"r")) == NULL) { - serverLog(REDIS_WARNING, + serverLog(LL_WARNING, "Fatal error, can't open config file '%s'", filename); exit(1); } } - while(fgets(buf,REDIS_CONFIGLINE_MAX+1,fp) != NULL) + while(fgets(buf,CONFIG_MAX_LINE+1,fp) != NULL) config = sdscat(config,buf); if (fp != stdin) fclose(fp); } @@ -718,7 +718,7 @@ void configSetCommand(client *c) { zfree(server.rdb_filename); server.rdb_filename = zstrdup(o->ptr); } 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); server.requirepass = ((char*)o->ptr)[0] ? zstrdup(o->ptr) : NULL; } config_set_special_field("masterauth") { @@ -739,10 +739,10 @@ void configSetCommand(client *c) { return; } if ((unsigned int) aeGetSetSize(server.el) < - server.maxclients + REDIS_EVENTLOOP_FDSET_INCR) + server.maxclients + CONFIG_FDSET_INCR) { 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"); server.maxclients = orig_value; @@ -754,9 +754,9 @@ void configSetCommand(client *c) { int enable = yesnotoi(o->ptr); if (enable == -1) goto badfmt; - if (enable == 0 && server.aof_state != REDIS_AOF_OFF) { + if (enable == 0 && server.aof_state != AOF_OFF) { stopAppendOnly(); - } else if (enable && server.aof_state == REDIS_AOF_OFF) { + } else if (enable && server.aof_state == AOF_OFF) { if (startAppendOnly() == C_ERR) { addReplyError(c, "Unable to turn on AOF. Check server logs."); @@ -940,8 +940,8 @@ void configSetCommand(client *c) { "hz",server.hz,0,LLONG_MAX) { /* Hz is more an hint from the user, so we accept values out of range * but cap them to reasonable values. */ - if (server.hz < REDIS_MIN_HZ) server.hz = REDIS_MIN_HZ; - if (server.hz > REDIS_MAX_HZ) server.hz = REDIS_MAX_HZ; + if (server.hz < CONFIG_MIN_HZ) server.hz = CONFIG_MIN_HZ; + if (server.hz > CONFIG_MAX_HZ) server.hz = CONFIG_MAX_HZ; } config_set_numerical_field( "watchdog-period",ll,0,LLONG_MAX) { if (ll) @@ -954,7 +954,7 @@ void configSetCommand(client *c) { } config_set_memory_field("maxmemory",server.maxmemory) { if (server.maxmemory) { 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(); } @@ -1130,7 +1130,7 @@ void configGetCommand(client *c) { if (stringmatch(pattern,"appendonly",0)) { addReplyBulkCString(c,"appendonly"); - addReplyBulkCString(c,server.aof_state == REDIS_AOF_OFF ? "no" : "yes"); + addReplyBulkCString(c,server.aof_state == AOF_OFF ? "no" : "yes"); matches++; } if (stringmatch(pattern,"dir",0)) { @@ -1163,13 +1163,13 @@ void configGetCommand(client *c) { sds buf = sdsempty(); 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", getClientTypeName(j), server.client_obuf_limits[j].hard_limit_bytes, server.client_obuf_limits[j].soft_limit_bytes, (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); } addReplyBulkCString(c,"client-output-buffer-limit"); @@ -1297,7 +1297,7 @@ void rewriteConfigMarkAsProcessed(struct rewriteConfigState *state, const char * struct rewriteConfigState *rewriteConfigReadOldFile(char *path) { FILE *fp = fopen(path,"r"); struct rewriteConfigState *state = zmalloc(sizeof(*state)); - char buf[REDIS_CONFIGLINE_MAX+1]; + char buf[CONFIG_MAX_LINE+1]; int linenum = -1; if (fp == NULL && errno != ENOENT) return NULL; @@ -1310,7 +1310,7 @@ struct rewriteConfigState *rewriteConfigReadOldFile(char *path) { if (fp == NULL) return 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; sds *argv; sds line = sdstrim(sdsnew(buf),"\r\n\t "); @@ -1566,7 +1566,7 @@ void rewriteConfigClientoutputbufferlimitOption(struct rewriteConfigState *state int j; 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 != clientBufferLimitsDefaults[j].hard_limit_bytes) || (server.client_obuf_limits[j].soft_limit_bytes != @@ -1657,7 +1657,7 @@ void rewriteConfigRemoveOrphaned(struct rewriteConfigState *state) { /* Don't blank lines about options the rewrite process * don't understand. */ if (dictFind(state->rewritten,option) == NULL) { - serverLog(REDIS_DEBUG,"Not rewritten option: %s", option); + serverLog(LL_DEBUG,"Not rewritten option: %s", option); continue; } @@ -1751,12 +1751,12 @@ int rewriteConfig(char *path) { rewriteConfigYesNoOption(state,"daemonize",server.daemonize,0); rewriteConfigStringOption(state,"pidfile",server.pidfile,CONFIG_DEFAULT_PID_FILE); - rewriteConfigNumericalOption(state,"port",server.port,REDIS_SERVERPORT); - rewriteConfigNumericalOption(state,"tcp-backlog",server.tcp_backlog,REDIS_TCP_BACKLOG); + rewriteConfigNumericalOption(state,"port",server.port,CONFIG_DEFAULT_SERVER_PORT); + rewriteConfigNumericalOption(state,"tcp-backlog",server.tcp_backlog,CONFIG_DEFAULT_TCP_BACKLOG); rewriteConfigBindOption(state); rewriteConfigStringOption(state,"unixsocket",server.unixsocket,NULL); 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); rewriteConfigEnumOption(state,"loglevel",server.verbosity,loglevel_enum,CONFIG_DEFAULT_VERBOSITY); rewriteConfigStringOption(state,"logfile",server.logfile,CONFIG_DEFAULT_LOGFILE); @@ -1774,8 +1774,8 @@ int rewriteConfig(char *path) { 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-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-timeout",server.repl_timeout,REDIS_REPL_TIMEOUT); + rewriteConfigNumericalOption(state,"repl-ping-slave-period",server.repl_ping_slave_period,CONFIG_DEFAULT_REPL_PING_SLAVE_PERIOD); + 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-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); @@ -1789,22 +1789,22 @@ int rewriteConfig(char *path) { rewriteConfigBytesOption(state,"maxmemory",server.maxmemory,CONFIG_DEFAULT_MAXMEMORY); 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); - 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); 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); - rewriteConfigNumericalOption(state,"auto-aof-rewrite-percentage",server.aof_rewrite_perc,REDIS_AOF_REWRITE_PERC); - rewriteConfigBytesOption(state,"auto-aof-rewrite-min-size",server.aof_rewrite_min_size,REDIS_AOF_REWRITE_MIN_SIZE); - rewriteConfigNumericalOption(state,"lua-time-limit",server.lua_time_limit,REDIS_LUA_TIME_LIMIT); + 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,AOF_REWRITE_MIN_SIZE); + rewriteConfigNumericalOption(state,"lua-time-limit",server.lua_time_limit,LUA_SCRIPT_TIME_LIMIT); rewriteConfigYesNoOption(state,"cluster-enabled",server.cluster_enabled,0); 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); 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-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,"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); 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); @@ -1819,7 +1819,7 @@ int rewriteConfig(char *path) { 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-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. */ if (server.sentinel_mode) rewriteConfigSentinelOption(state); @@ -1862,10 +1862,10 @@ void configCommand(client *c) { return; } 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)); } else { - serverLog(REDIS_WARNING,"CONFIG REWRITE executed with success."); + serverLog(LL_WARNING,"CONFIG REWRITE executed with success."); addReply(c,shared.ok); } } else { diff --git a/src/db.c b/src/db.c index d1eb1db1c..1100c7ef7 100644 --- a/src/db.c +++ b/src/db.c @@ -81,7 +81,7 @@ robj *lookupKeyRead(redisDb *db, robj *key) { if (server.current_client && server.current_client != server.master && server.current_client->cmd && - server.current_client->cmd->flags & REDIS_CMD_READONLY) + server.current_client->cmd->flags & CMD_READONLY) { return NULL; } @@ -309,7 +309,7 @@ void delCommand(client *c) { expireIfNeeded(c->db,c->argv[j]); if (dbDelete(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); server.dirty++; deleted++; @@ -412,7 +412,7 @@ void scanCallback(void *privdata, const dictEntry *de) { incrRefCount(key); val = createStringObjectFromLongDouble(*(double*)dictGetVal(de),0); } else { - redisPanic("Type not handled in SCAN callback."); + serverPanic("Type not handled in SCAN callback."); } listAddNodeTail(keys, key); @@ -560,7 +560,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) { } cursor = 0; } else { - redisPanic("Not handled encoding in SCAN."); + serverPanic("Not handled encoding in SCAN."); } /* Step 3: Filter elements. */ @@ -576,7 +576,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) { if (!stringmatchlen(pat, patlen, kobj->ptr, sdslen(kobj->ptr), 0)) filter = 1; } else { - char buf[REDIS_LONGSTR_SIZE]; + char buf[LONG_STR_SIZE]; int len; serverAssert(kobj->encoding == OBJ_ENCODING_INT); @@ -669,9 +669,9 @@ void shutdownCommand(client *c) { return; } else if (c->argc == 2) { if (!strcasecmp(c->argv[1]->ptr,"nosave")) { - flags |= REDIS_SHUTDOWN_NOSAVE; + flags |= SHUTDOWN_NOSAVE; } else if (!strcasecmp(c->argv[1]->ptr,"save")) { - flags |= REDIS_SHUTDOWN_SAVE; + flags |= SHUTDOWN_SAVE; } else { addReply(c,shared.syntaxerr); return; @@ -684,7 +684,7 @@ void shutdownCommand(client *c) { * * Also when in Sentinel mode clear the SAVE flag and force NOSAVE. */ 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); addReplyError(c,"Errors trying to SHUTDOWN. Check logs."); } @@ -723,9 +723,9 @@ void renameGenericCommand(client *c, int nx) { dbDelete(c->db,c->argv[1]); signalModifiedKey(c->db,c->argv[1]); signalModifiedKey(c->db,c->argv[2]); - notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"rename_from", + notifyKeyspaceEvent(NOTIFY_GENERIC,"rename_from", c->argv[1],c->db->id); - notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"rename_to", + notifyKeyspaceEvent(NOTIFY_GENERIC,"rename_to", c->argv[2],c->db->id); server.dirty++; addReply(c,nx ? shared.cone : shared.ok); @@ -844,7 +844,7 @@ void propagateExpire(redisDb *db, robj *key) { incrRefCount(argv[0]); incrRefCount(argv[1]); - if (server.aof_state != REDIS_AOF_OFF) + if (server.aof_state != AOF_OFF) feedAppendOnlyFile(server.delCommand,db->id,argv,2); replicationFeedSlaves(server.slaves,db->id,argv,2); @@ -883,7 +883,7 @@ int expireIfNeeded(redisDb *db, robj *key) { /* Delete the key */ server.stat_expiredkeys++; propagateExpire(db,key); - notifyKeyspaceEvent(REDIS_NOTIFY_EXPIRED, + notifyKeyspaceEvent(NOTIFY_EXPIRED, "expired",key,db->id); return dbDelete(db,key); } @@ -932,14 +932,14 @@ void expireGenericCommand(client *c, long long basetime, int unit) { rewriteClientCommandVector(c,2,aux,key); decrRefCount(aux); 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); return; } else { setExpire(c->db,key,when); addReply(c,shared.cone); signalModifiedKey(c->db,key); - notifyKeyspaceEvent(REDIS_NOTIFY_GENERIC,"expire",key,c->db->id); + notifyKeyspaceEvent(NOTIFY_GENERIC,"expire",key,c->db->id); server.dirty++; return; } @@ -1015,7 +1015,7 @@ void persistCommand(client *c) { * (firstkey, lastkey, step). */ int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, int *numkeys) { int j, i = 0, last, *keys; - REDIS_NOTUSED(argv); + UNUSED(argv); if (cmd->firstkey == 0) { *numkeys = 0; @@ -1061,7 +1061,7 @@ void getKeysFreeResult(int *result) { * ZINTERSTORE ... */ int *zunionInterGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *numkeys) { int i, num, *keys; - REDIS_NOTUSED(cmd); + UNUSED(cmd); num = atoi(argv[2]->ptr); /* 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 * EVALSHA