Commit 424fe9af authored by antirez's avatar antirez
Browse files

RDMF: redisLog -> serverLog.

parent cef054e8
...@@ -152,7 +152,7 @@ void aofRewriteBufferAppend(unsigned char *s, unsigned long len) { ...@@ -152,7 +152,7 @@ void aofRewriteBufferAppend(unsigned char *s, unsigned long len) {
if (((numblocks+1) % 10) == 0) { if (((numblocks+1) % 10) == 0) {
int level = ((numblocks+1) % 100) == 0 ? REDIS_WARNING : int level = ((numblocks+1) % 100) == 0 ? REDIS_WARNING :
REDIS_NOTICE; REDIS_NOTICE;
redisLog(level,"Background AOF buffer size: %lu MB", serverLog(level,"Background AOF buffer size: %lu MB",
aofRewriteBufferSize()/(1024*1024)); aofRewriteBufferSize()/(1024*1024));
} }
} }
...@@ -216,7 +216,7 @@ void stopAppendOnly(void) { ...@@ -216,7 +216,7 @@ void stopAppendOnly(void) {
if (server.aof_child_pid != -1) { if (server.aof_child_pid != -1) {
int statloc; int statloc;
redisLog(REDIS_NOTICE,"Killing running AOF rewrite child: %ld", serverLog(REDIS_NOTICE,"Killing running AOF rewrite child: %ld",
(long) server.aof_child_pid); (long) server.aof_child_pid);
if (kill(server.aof_child_pid,SIGUSR1) != -1) if (kill(server.aof_child_pid,SIGUSR1) != -1)
wait3(&statloc,0,NULL); wait3(&statloc,0,NULL);
...@@ -237,12 +237,12 @@ int startAppendOnly(void) { ...@@ -237,12 +237,12 @@ int startAppendOnly(void) {
server.aof_fd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644); server.aof_fd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644);
redisAssert(server.aof_state == REDIS_AOF_OFF); redisAssert(server.aof_state == REDIS_AOF_OFF);
if (server.aof_fd == -1) { if (server.aof_fd == -1) {
redisLog(REDIS_WARNING,"Redis needs to enable the AOF but can't open the append only file: %s",strerror(errno)); serverLog(REDIS_WARNING,"Redis needs to enable the AOF but can't open the append only file: %s",strerror(errno));
return REDIS_ERR; return REDIS_ERR;
} }
if (rewriteAppendOnlyFileBackground() == REDIS_ERR) { if (rewriteAppendOnlyFileBackground() == REDIS_ERR) {
close(server.aof_fd); close(server.aof_fd);
redisLog(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(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.");
return REDIS_ERR; return REDIS_ERR;
} }
/* We correctly switched on AOF, now wait for the rewrite to be complete /* We correctly switched on AOF, now wait for the rewrite to be complete
...@@ -298,7 +298,7 @@ void flushAppendOnlyFile(int force) { ...@@ -298,7 +298,7 @@ void flushAppendOnlyFile(int force) {
/* Otherwise fall trough, and go write since we can't wait /* Otherwise fall trough, and go write since we can't wait
* over two seconds. */ * over two seconds. */
server.aof_delayed_fsync++; server.aof_delayed_fsync++;
redisLog(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(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.");
} }
} }
/* We want to perform a single write. This should be guaranteed atomic /* We want to perform a single write. This should be guaranteed atomic
...@@ -340,13 +340,13 @@ void flushAppendOnlyFile(int force) { ...@@ -340,13 +340,13 @@ void flushAppendOnlyFile(int force) {
/* Log the AOF write error and record the error code. */ /* Log the AOF write error and record the error code. */
if (nwritten == -1) { if (nwritten == -1) {
if (can_log) { if (can_log) {
redisLog(REDIS_WARNING,"Error writing to the AOF file: %s", serverLog(REDIS_WARNING,"Error writing to the AOF file: %s",
strerror(errno)); strerror(errno));
server.aof_last_write_errno = errno; server.aof_last_write_errno = errno;
} }
} else { } else {
if (can_log) { if (can_log) {
redisLog(REDIS_WARNING,"Short write while writing to " serverLog(REDIS_WARNING,"Short write while writing to "
"the AOF file: (nwritten=%lld, " "the AOF file: (nwritten=%lld, "
"expected=%lld)", "expected=%lld)",
(long long)nwritten, (long long)nwritten,
...@@ -355,7 +355,7 @@ void flushAppendOnlyFile(int force) { ...@@ -355,7 +355,7 @@ void flushAppendOnlyFile(int force) {
if (ftruncate(server.aof_fd, server.aof_current_size) == -1) { if (ftruncate(server.aof_fd, server.aof_current_size) == -1) {
if (can_log) { if (can_log) {
redisLog(REDIS_WARNING, "Could not remove short write " serverLog(REDIS_WARNING, "Could not remove short write "
"from the append-only file. Redis may refuse " "from the append-only file. Redis may refuse "
"to load the AOF the next time it starts. " "to load the AOF the next time it starts. "
"ftruncate: %s", strerror(errno)); "ftruncate: %s", strerror(errno));
...@@ -374,7 +374,7 @@ void flushAppendOnlyFile(int force) { ...@@ -374,7 +374,7 @@ void flushAppendOnlyFile(int force) {
* reply for the client is already in the output buffers, and we * reply for the client is already in the output buffers, and we
* have the contract with the user that on acknowledged write data * have the contract with the user that on acknowledged write data
* is synced on disk. */ * is synced on disk. */
redisLog(REDIS_WARNING,"Can't recover from AOF write error when the AOF fsync policy is 'always'. Exiting..."); serverLog(REDIS_WARNING,"Can't recover from AOF write error when the AOF fsync policy is 'always'. Exiting...");
exit(1); exit(1);
} else { } else {
/* Recover from failed write leaving data into the buffer. However /* Recover from failed write leaving data into the buffer. However
...@@ -394,7 +394,7 @@ void flushAppendOnlyFile(int force) { ...@@ -394,7 +394,7 @@ void flushAppendOnlyFile(int force) {
/* Successful write(2). If AOF was in error state, restore the /* Successful write(2). If AOF was in error state, restore the
* OK state and log the event. */ * OK state and log the event. */
if (server.aof_last_write_status == REDIS_ERR) { if (server.aof_last_write_status == REDIS_ERR) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"AOF write error looks solved, Redis can write again."); "AOF write error looks solved, Redis can write again.");
server.aof_last_write_status = REDIS_OK; server.aof_last_write_status = REDIS_OK;
} }
...@@ -611,7 +611,7 @@ int loadAppendOnlyFile(char *filename) { ...@@ -611,7 +611,7 @@ int loadAppendOnlyFile(char *filename) {
} }
if (fp == NULL) { if (fp == NULL) {
redisLog(REDIS_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno)); serverLog(REDIS_WARNING,"Fatal error: can't open the append log file for reading: %s",strerror(errno));
exit(1); exit(1);
} }
...@@ -677,7 +677,7 @@ int loadAppendOnlyFile(char *filename) { ...@@ -677,7 +677,7 @@ int loadAppendOnlyFile(char *filename) {
/* Command lookup */ /* Command lookup */
cmd = lookupCommand(argv[0]->ptr); cmd = lookupCommand(argv[0]->ptr);
if (!cmd) { if (!cmd) {
redisLog(REDIS_WARNING,"Unknown command '%s' reading the append only file", (char*)argv[0]->ptr); serverLog(REDIS_WARNING,"Unknown command '%s' reading the append only file", (char*)argv[0]->ptr);
exit(1); exit(1);
} }
...@@ -710,40 +710,40 @@ loaded_ok: /* DB loaded, cleanup and return REDIS_OK to the caller. */ ...@@ -710,40 +710,40 @@ loaded_ok: /* DB loaded, cleanup and return REDIS_OK to the caller. */
readerr: /* Read error. If feof(fp) is true, fall through to unexpected EOF. */ readerr: /* Read error. If feof(fp) is true, fall through to unexpected EOF. */
if (!feof(fp)) { if (!feof(fp)) {
redisLog(REDIS_WARNING,"Unrecoverable error reading the append only file: %s", strerror(errno)); serverLog(REDIS_WARNING,"Unrecoverable error reading the append only file: %s", strerror(errno));
exit(1); exit(1);
} }
uxeof: /* Unexpected AOF end of file. */ uxeof: /* Unexpected AOF end of file. */
if (server.aof_load_truncated) { if (server.aof_load_truncated) {
redisLog(REDIS_WARNING,"!!! Warning: short read while loading the AOF file !!!"); serverLog(REDIS_WARNING,"!!! Warning: short read while loading the AOF file !!!");
redisLog(REDIS_WARNING,"!!! Truncating the AOF at offset %llu !!!", serverLog(REDIS_WARNING,"!!! Truncating the AOF at offset %llu !!!",
(unsigned long long) valid_up_to); (unsigned long long) valid_up_to);
if (valid_up_to == -1 || truncate(filename,valid_up_to) == -1) { if (valid_up_to == -1 || truncate(filename,valid_up_to) == -1) {
if (valid_up_to == -1) { if (valid_up_to == -1) {
redisLog(REDIS_WARNING,"Last valid command offset is invalid"); serverLog(REDIS_WARNING,"Last valid command offset is invalid");
} else { } else {
redisLog(REDIS_WARNING,"Error truncating the AOF file: %s", serverLog(REDIS_WARNING,"Error truncating the AOF file: %s",
strerror(errno)); strerror(errno));
} }
} else { } else {
/* Make sure the AOF file descriptor points to the end of the /* Make sure the AOF file descriptor points to the end of the
* file after the truncate call. */ * file after the truncate call. */
if (server.aof_fd != -1 && lseek(server.aof_fd,0,SEEK_END) == -1) { if (server.aof_fd != -1 && lseek(server.aof_fd,0,SEEK_END) == -1) {
redisLog(REDIS_WARNING,"Can't seek the end of the AOF file: %s", serverLog(REDIS_WARNING,"Can't seek the end of the AOF file: %s",
strerror(errno)); strerror(errno));
} else { } else {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"AOF loaded anyway because aof-load-truncated is enabled"); "AOF loaded anyway because aof-load-truncated is enabled");
goto loaded_ok; goto loaded_ok;
} }
} }
} }
redisLog(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 <filename>. 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server."); 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 <filename>. 2) Alternatively you can set the 'aof-load-truncated' configuration option to yes and restart the server.");
exit(1); exit(1);
fmterr: /* Format error. */ fmterr: /* Format error. */
redisLog(REDIS_WARNING,"Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix <filename>"); serverLog(REDIS_WARNING,"Bad file format reading the append only file: make a backup of your AOF file, then use ./redis-check-aof --fix <filename>");
exit(1); exit(1);
} }
...@@ -1011,7 +1011,7 @@ int rewriteAppendOnlyFile(char *filename) { ...@@ -1011,7 +1011,7 @@ int rewriteAppendOnlyFile(char *filename) {
snprintf(tmpfile,256,"temp-rewriteaof-%d.aof", (int) getpid()); snprintf(tmpfile,256,"temp-rewriteaof-%d.aof", (int) getpid());
fp = fopen(tmpfile,"w"); fp = fopen(tmpfile,"w");
if (!fp) { if (!fp) {
redisLog(REDIS_WARNING, "Opening the temp file for AOF rewrite in rewriteAppendOnlyFile(): %s", strerror(errno)); serverLog(REDIS_WARNING, "Opening the temp file for AOF rewrite in rewriteAppendOnlyFile(): %s", strerror(errno));
return REDIS_ERR; return REDIS_ERR;
} }
...@@ -1118,13 +1118,13 @@ int rewriteAppendOnlyFile(char *filename) { ...@@ -1118,13 +1118,13 @@ int rewriteAppendOnlyFile(char *filename) {
* the child will eventually get terminated. */ * the child will eventually get terminated. */
if (syncRead(server.aof_pipe_read_ack_from_parent,&byte,1,5000) != 1 || if (syncRead(server.aof_pipe_read_ack_from_parent,&byte,1,5000) != 1 ||
byte != '!') goto werr; byte != '!') goto werr;
redisLog(REDIS_NOTICE,"Parent agreed to stop sending diffs. Finalizing AOF..."); serverLog(REDIS_NOTICE,"Parent agreed to stop sending diffs. Finalizing AOF...");
/* Read the final diff if any. */ /* Read the final diff if any. */
aofReadDiffFromParent(); aofReadDiffFromParent();
/* Write the received diff to the file. */ /* Write the received diff to the file. */
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"Concatenating %.2f MB of AOF diff received from parent.", "Concatenating %.2f MB of AOF diff received from parent.",
(double) sdslen(server.aof_child_diff) / (1024*1024)); (double) sdslen(server.aof_child_diff) / (1024*1024));
if (rioWrite(&aof,server.aof_child_diff,sdslen(server.aof_child_diff)) == 0) if (rioWrite(&aof,server.aof_child_diff,sdslen(server.aof_child_diff)) == 0)
...@@ -1138,15 +1138,15 @@ int rewriteAppendOnlyFile(char *filename) { ...@@ -1138,15 +1138,15 @@ int rewriteAppendOnlyFile(char *filename) {
/* Use RENAME to make sure the DB file is changed atomically only /* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */ * if the generate DB file is ok. */
if (rename(tmpfile,filename) == -1) { if (rename(tmpfile,filename) == -1) {
redisLog(REDIS_WARNING,"Error moving temp append only file on the final destination: %s", strerror(errno)); serverLog(REDIS_WARNING,"Error moving temp append only file on the final destination: %s", strerror(errno));
unlink(tmpfile); unlink(tmpfile);
return REDIS_ERR; return REDIS_ERR;
} }
redisLog(REDIS_NOTICE,"SYNC append only file rewrite performed"); serverLog(REDIS_NOTICE,"SYNC append only file rewrite performed");
return REDIS_OK; return REDIS_OK;
werr: werr:
redisLog(REDIS_WARNING,"Write error writing append only file on disk: %s", strerror(errno)); serverLog(REDIS_WARNING,"Write error writing append only file on disk: %s", strerror(errno));
fclose(fp); fclose(fp);
unlink(tmpfile); unlink(tmpfile);
if (di) dictReleaseIterator(di); if (di) dictReleaseIterator(di);
...@@ -1167,14 +1167,14 @@ void aofChildPipeReadable(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -1167,14 +1167,14 @@ void aofChildPipeReadable(aeEventLoop *el, int fd, void *privdata, int mask) {
REDIS_NOTUSED(mask); REDIS_NOTUSED(mask);
if (read(fd,&byte,1) == 1 && byte == '!') { if (read(fd,&byte,1) == 1 && byte == '!') {
redisLog(REDIS_NOTICE,"AOF rewrite child asks to stop sending diffs."); serverLog(REDIS_NOTICE,"AOF rewrite child asks to stop sending diffs.");
server.aof_stop_sending_diff = 1; server.aof_stop_sending_diff = 1;
if (write(server.aof_pipe_write_ack_to_child,"!",1) != 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 /* 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 * since in the other side the children will use a timeout if the
* kernel can't buffer our write, or, the children was * kernel can't buffer our write, or, the children was
* terminated. */ * terminated. */
redisLog(REDIS_WARNING,"Can't send ACK to AOF child: %s", serverLog(REDIS_WARNING,"Can't send ACK to AOF child: %s",
strerror(errno)); strerror(errno));
} }
} }
...@@ -1210,7 +1210,7 @@ int aofCreatePipes(void) { ...@@ -1210,7 +1210,7 @@ int aofCreatePipes(void) {
return REDIS_OK; return REDIS_OK;
error: error:
redisLog(REDIS_WARNING,"Error opening /setting AOF rewrite IPC pipes: %s", serverLog(REDIS_WARNING,"Error opening /setting AOF rewrite IPC pipes: %s",
strerror(errno)); strerror(errno));
for (j = 0; j < 6; j++) if(fds[j] != -1) close(fds[j]); for (j = 0; j < 6; j++) if(fds[j] != -1) close(fds[j]);
return REDIS_ERR; return REDIS_ERR;
...@@ -1261,7 +1261,7 @@ int rewriteAppendOnlyFileBackground(void) { ...@@ -1261,7 +1261,7 @@ int rewriteAppendOnlyFileBackground(void) {
size_t private_dirty = zmalloc_get_private_dirty(); size_t private_dirty = zmalloc_get_private_dirty();
if (private_dirty) { if (private_dirty) {
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"AOF rewrite: %zu MB of memory used by copy-on-write", "AOF rewrite: %zu MB of memory used by copy-on-write",
private_dirty/(1024*1024)); private_dirty/(1024*1024));
} }
...@@ -1275,12 +1275,12 @@ int rewriteAppendOnlyFileBackground(void) { ...@@ -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. */ 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); latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000);
if (childpid == -1) { if (childpid == -1) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Can't rewrite append only file in background: fork: %s", "Can't rewrite append only file in background: fork: %s",
strerror(errno)); strerror(errno));
return REDIS_ERR; return REDIS_ERR;
} }
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"Background append only file rewriting started by pid %d",childpid); "Background append only file rewriting started by pid %d",childpid);
server.aof_rewrite_scheduled = 0; server.aof_rewrite_scheduled = 0;
server.aof_rewrite_time_start = time(NULL); server.aof_rewrite_time_start = time(NULL);
...@@ -1327,7 +1327,7 @@ void aofUpdateCurrentSize(void) { ...@@ -1327,7 +1327,7 @@ void aofUpdateCurrentSize(void) {
latencyStartMonitor(latency); latencyStartMonitor(latency);
if (redis_fstat(server.aof_fd,&sb) == -1) { if (redis_fstat(server.aof_fd,&sb) == -1) {
redisLog(REDIS_WARNING,"Unable to obtain the AOF file length. stat: %s", serverLog(REDIS_WARNING,"Unable to obtain the AOF file length. stat: %s",
strerror(errno)); strerror(errno));
} else { } else {
server.aof_current_size = sb.st_size; server.aof_current_size = sb.st_size;
...@@ -1345,7 +1345,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { ...@@ -1345,7 +1345,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
long long now = ustime(); long long now = ustime();
mstime_t latency; mstime_t latency;
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"Background AOF rewrite terminated with success"); "Background AOF rewrite terminated with success");
/* Flush the differences accumulated by the parent to the /* Flush the differences accumulated by the parent to the
...@@ -1355,13 +1355,13 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { ...@@ -1355,13 +1355,13 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
(int)server.aof_child_pid); (int)server.aof_child_pid);
newfd = open(tmpfile,O_WRONLY|O_APPEND); newfd = open(tmpfile,O_WRONLY|O_APPEND);
if (newfd == -1) { if (newfd == -1) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Unable to open the temporary AOF produced by the child: %s", strerror(errno)); "Unable to open the temporary AOF produced by the child: %s", strerror(errno));
goto cleanup; goto cleanup;
} }
if (aofRewriteBufferWrite(newfd) == -1) { if (aofRewriteBufferWrite(newfd) == -1) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Error trying to flush the parent diff to the rewritten AOF: %s", strerror(errno)); "Error trying to flush the parent diff to the rewritten AOF: %s", strerror(errno));
close(newfd); close(newfd);
goto cleanup; goto cleanup;
...@@ -1369,7 +1369,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { ...@@ -1369,7 +1369,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
latencyEndMonitor(latency); latencyEndMonitor(latency);
latencyAddSampleIfNeeded("aof-rewrite-diff-write",latency); latencyAddSampleIfNeeded("aof-rewrite-diff-write",latency);
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"Residual parent diff successfully flushed to the rewritten AOF (%.2f MB)", (double) aofRewriteBufferSize() / (1024*1024)); "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 /* The only remaining thing to do is to rename the temporary file to
...@@ -1415,7 +1415,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { ...@@ -1415,7 +1415,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
* it exists, because we reference it with "oldfd". */ * it exists, because we reference it with "oldfd". */
latencyStartMonitor(latency); latencyStartMonitor(latency);
if (rename(tmpfile,server.aof_filename) == -1) { if (rename(tmpfile,server.aof_filename) == -1) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Error trying to rename the temporary AOF file: %s", strerror(errno)); "Error trying to rename the temporary AOF file: %s", strerror(errno));
close(newfd); close(newfd);
if (oldfd != -1) close(oldfd); if (oldfd != -1) close(oldfd);
...@@ -1448,7 +1448,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { ...@@ -1448,7 +1448,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
server.aof_lastbgrewrite_status = REDIS_OK; server.aof_lastbgrewrite_status = REDIS_OK;
redisLog(REDIS_NOTICE, "Background AOF rewrite finished successfully"); serverLog(REDIS_NOTICE, "Background AOF rewrite finished successfully");
/* Change state from WAIT_REWRITE to ON if needed */ /* Change state from WAIT_REWRITE to ON if needed */
if (server.aof_state == REDIS_AOF_WAIT_REWRITE) if (server.aof_state == REDIS_AOF_WAIT_REWRITE)
server.aof_state = REDIS_AOF_ON; server.aof_state = REDIS_AOF_ON;
...@@ -1456,17 +1456,17 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { ...@@ -1456,17 +1456,17 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
/* Asynchronously close the overwritten AOF. */ /* Asynchronously close the overwritten AOF. */
if (oldfd != -1) bioCreateBackgroundJob(REDIS_BIO_CLOSE_FILE,(void*)(long)oldfd,NULL,NULL); if (oldfd != -1) bioCreateBackgroundJob(REDIS_BIO_CLOSE_FILE,(void*)(long)oldfd,NULL,NULL);
redisLog(REDIS_VERBOSE, serverLog(REDIS_VERBOSE,
"Background AOF rewrite signal handler took %lldus", ustime()-now); "Background AOF rewrite signal handler took %lldus", ustime()-now);
} else if (!bysignal && exitcode != 0) { } else if (!bysignal && exitcode != 0) {
server.aof_lastbgrewrite_status = REDIS_ERR; server.aof_lastbgrewrite_status = REDIS_ERR;
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Background AOF rewrite terminated with error"); "Background AOF rewrite terminated with error");
} else { } else {
server.aof_lastbgrewrite_status = REDIS_ERR; server.aof_lastbgrewrite_status = REDIS_ERR;
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Background AOF rewrite terminated by signal %d", bysignal); "Background AOF rewrite terminated by signal %d", bysignal);
} }
......
...@@ -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) {
redisLog(REDIS_WARNING,"Fatal: Can't initialize Background Jobs."); serverLog(REDIS_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) {
redisLog(REDIS_WARNING, serverLog(REDIS_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))
redisLog(REDIS_WARNING, serverLog(REDIS_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) {
...@@ -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) {
redisLog(REDIS_WARNING, serverLog(REDIS_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 {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Bio thread for job type #%d terminated",j); "Bio thread for job type #%d terminated",j);
} }
} }
......
This diff is collapsed.
...@@ -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) {
redisLog(REDIS_WARNING,"Can't chdir to '%s': %s", serverLog(REDIS_WARNING,"Can't chdir to '%s': %s",
argv[1], strerror(errno)); argv[1], strerror(errno));
exit(1); exit(1);
} }
...@@ -647,7 +647,7 @@ void loadServerConfig(char *filename, char *options) { ...@@ -647,7 +647,7 @@ void loadServerConfig(char *filename, char *options) {
fp = stdin; fp = stdin;
} else { } else {
if ((fp = fopen(filename,"r")) == NULL) { if ((fp = fopen(filename,"r")) == NULL) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Fatal error, can't open config file '%s'", filename); "Fatal error, can't open config file '%s'", filename);
exit(1); exit(1);
} }
...@@ -954,7 +954,7 @@ void configSetCommand(redisClient *c) { ...@@ -954,7 +954,7 @@ void configSetCommand(redisClient *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()) {
redisLog(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(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.");
} }
freeMemoryIfNeeded(); freeMemoryIfNeeded();
} }
...@@ -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) {
redisLog(REDIS_DEBUG,"Not rewritten option: %s", option); serverLog(REDIS_DEBUG,"Not rewritten option: %s", option);
continue; continue;
} }
...@@ -1862,10 +1862,10 @@ void configCommand(redisClient *c) { ...@@ -1862,10 +1862,10 @@ void configCommand(redisClient *c) {
return; return;
} }
if (rewriteConfig(server.configfile) == -1) { if (rewriteConfig(server.configfile) == -1) {
redisLog(REDIS_WARNING,"CONFIG REWRITE failed: %s", strerror(errno)); serverLog(REDIS_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 {
redisLog(REDIS_WARNING,"CONFIG REWRITE executed with success."); serverLog(REDIS_WARNING,"CONFIG REWRITE executed with success.");
addReply(c,shared.ok); addReply(c,shared.ok);
} }
} else { } else {
......
...@@ -278,7 +278,7 @@ void debugCommand(redisClient *c) { ...@@ -278,7 +278,7 @@ void debugCommand(redisClient *c) {
addReplyError(c,"Error trying to load the RDB dump"); addReplyError(c,"Error trying to load the RDB dump");
return; return;
} }
redisLog(REDIS_WARNING,"DB reloaded by DEBUG RELOAD"); serverLog(REDIS_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(redisClient *c) { ...@@ -287,7 +287,7 @@ void debugCommand(redisClient *c) {
return; return;
} }
server.dirty = 0; /* Prevent AOF / replication */ server.dirty = 0; /* Prevent AOF / replication */
redisLog(REDIS_WARNING,"Append Only File loaded by DEBUG LOADAOF"); serverLog(REDIS_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(redisClient *c) { ...@@ -472,13 +472,13 @@ void debugCommand(redisClient *c) {
void _redisAssert(char *estr, char *file, int line) { void _redisAssert(char *estr, char *file, int line) {
bugReportStart(); bugReportStart();
redisLog(REDIS_WARNING,"=== ASSERTION FAILED ==="); serverLog(REDIS_WARNING,"=== ASSERTION FAILED ===");
redisLog(REDIS_WARNING,"==> %s:%d '%s' is not true",file,line,estr); serverLog(REDIS_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;
redisLog(REDIS_WARNING,"(forcing SIGSEGV to print the bug report.)"); serverLog(REDIS_WARNING,"(forcing SIGSEGV to print the bug report.)");
#endif #endif
*((char*)-1) = 'x'; *((char*)-1) = 'x';
} }
...@@ -487,10 +487,10 @@ void _redisAssertPrintClientInfo(redisClient *c) { ...@@ -487,10 +487,10 @@ void _redisAssertPrintClientInfo(redisClient *c) {
int j; int j;
bugReportStart(); bugReportStart();
redisLog(REDIS_WARNING,"=== ASSERTION FAILED CLIENT CONTEXT ==="); serverLog(REDIS_WARNING,"=== ASSERTION FAILED CLIENT CONTEXT ===");
redisLog(REDIS_WARNING,"client->flags = %d", c->flags); serverLog(REDIS_WARNING,"client->flags = %d", c->flags);
redisLog(REDIS_WARNING,"client->fd = %d", c->fd); serverLog(REDIS_WARNING,"client->fd = %d", c->fd);
redisLog(REDIS_WARNING,"client->argc = %d", c->argc); serverLog(REDIS_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,39 +502,39 @@ void _redisAssertPrintClientInfo(redisClient *c) { ...@@ -502,39 +502,39 @@ void _redisAssertPrintClientInfo(redisClient *c) {
c->argv[j]->type, c->argv[j]->encoding); c->argv[j]->type, c->argv[j]->encoding);
arg = buf; arg = buf;
} }
redisLog(REDIS_WARNING,"client->argv[%d] = \"%s\" (refcount: %d)", serverLog(REDIS_WARNING,"client->argv[%d] = \"%s\" (refcount: %d)",
j, arg, c->argv[j]->refcount); j, arg, c->argv[j]->refcount);
} }
} }
void redisLogObjectDebugInfo(robj *o) { void serverLogObjectDebugInfo(robj *o) {
redisLog(REDIS_WARNING,"Object type: %d", o->type); serverLog(REDIS_WARNING,"Object type: %d", o->type);
redisLog(REDIS_WARNING,"Object encoding: %d", o->encoding); serverLog(REDIS_WARNING,"Object encoding: %d", o->encoding);
redisLog(REDIS_WARNING,"Object refcount: %d", o->refcount); serverLog(REDIS_WARNING,"Object refcount: %d", o->refcount);
if (o->type == REDIS_STRING && sdsEncodedObject(o)) { if (o->type == REDIS_STRING && sdsEncodedObject(o)) {
redisLog(REDIS_WARNING,"Object raw string len: %zu", sdslen(o->ptr)); serverLog(REDIS_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));
redisLog(REDIS_WARNING,"Object raw string content: %s", repr); serverLog(REDIS_WARNING,"Object raw string content: %s", repr);
sdsfree(repr); sdsfree(repr);
} }
} else if (o->type == REDIS_LIST) { } else if (o->type == REDIS_LIST) {
redisLog(REDIS_WARNING,"List length: %d", (int) listTypeLength(o)); serverLog(REDIS_WARNING,"List length: %d", (int) listTypeLength(o));
} else if (o->type == REDIS_SET) { } else if (o->type == REDIS_SET) {
redisLog(REDIS_WARNING,"Set size: %d", (int) setTypeSize(o)); serverLog(REDIS_WARNING,"Set size: %d", (int) setTypeSize(o));
} else if (o->type == REDIS_HASH) { } else if (o->type == REDIS_HASH) {
redisLog(REDIS_WARNING,"Hash size: %d", (int) hashTypeLength(o)); serverLog(REDIS_WARNING,"Hash size: %d", (int) hashTypeLength(o));
} else if (o->type == REDIS_ZSET) { } else if (o->type == REDIS_ZSET) {
redisLog(REDIS_WARNING,"Sorted set size: %d", (int) zsetLength(o)); serverLog(REDIS_WARNING,"Sorted set size: %d", (int) zsetLength(o));
if (o->encoding == REDIS_ENCODING_SKIPLIST) if (o->encoding == REDIS_ENCODING_SKIPLIST)
redisLog(REDIS_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level); serverLog(REDIS_WARNING,"Skiplist level: %d", (int) ((zset*)o->ptr)->zsl->level);
} }
} }
void _redisAssertPrintObject(robj *o) { void _redisAssertPrintObject(robj *o) {
bugReportStart(); bugReportStart();
redisLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ==="); serverLog(REDIS_WARNING,"=== ASSERTION FAILED OBJECT CONTEXT ===");
redisLogObjectDebugInfo(o); serverLogObjectDebugInfo(o);
} }
void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int line) { void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int line) {
...@@ -545,19 +545,19 @@ void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int l ...@@ -545,19 +545,19 @@ void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int l
void _redisPanic(char *msg, char *file, int line) { void _redisPanic(char *msg, char *file, int line) {
bugReportStart(); bugReportStart();
redisLog(REDIS_WARNING,"------------------------------------------------"); serverLog(REDIS_WARNING,"------------------------------------------------");
redisLog(REDIS_WARNING,"!!! Software Failure. Press left mouse button to continue"); serverLog(REDIS_WARNING,"!!! Software Failure. Press left mouse button to continue");
redisLog(REDIS_WARNING,"Guru Meditation: %s #%s:%d",msg,file,line); serverLog(REDIS_WARNING,"Guru Meditation: %s #%s:%d",msg,file,line);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
redisLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)"); serverLog(REDIS_WARNING,"(forcing SIGSEGV in order to print the stack trace)");
#endif #endif
redisLog(REDIS_WARNING,"------------------------------------------------"); serverLog(REDIS_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) {
redisLog(REDIS_WARNING, serverLog(REDIS_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)
redisLog(REDIS_WARNING, "(%08lx) -> %08lx", addr, val); serverLog(REDIS_WARNING, "(%08lx) -> %08lx", addr, val);
else else
redisLog(REDIS_WARNING, "(%016lx) -> %016lx", addr, val); serverLog(REDIS_WARNING, "(%016lx) -> %016lx", addr, val);
} }
} }
void logRegisters(ucontext_t *uc) { void logRegisters(ucontext_t *uc) {
redisLog(REDIS_WARNING, "--- REGISTERS"); serverLog(REDIS_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__)
redisLog(REDIS_WARNING, serverLog(REDIS_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 */
redisLog(REDIS_WARNING, serverLog(REDIS_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__)
redisLog(REDIS_WARNING, serverLog(REDIS_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 */
redisLog(REDIS_WARNING, serverLog(REDIS_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
redisLog(REDIS_WARNING, serverLog(REDIS_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;
redisLog(REDIS_WARNING, "--- CURRENT CLIENT INFO"); serverLog(REDIS_WARNING, "--- CURRENT CLIENT INFO");
client = catClientInfoString(sdsempty(),cc); client = catClientInfoString(sdsempty(),cc);
redisLog(REDIS_WARNING,"client: %s", client); serverLog(REDIS_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]);
redisLog(REDIS_WARNING,"argv[%d]: '%s'", j, (char*)decoded->ptr); serverLog(REDIS_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,8 +795,8 @@ void logCurrentClient(void) { ...@@ -795,8 +795,8 @@ 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);
redisLog(REDIS_WARNING,"key '%s' found in DB containing the following object:", (char*)key->ptr); serverLog(REDIS_WARNING,"key '%s' found in DB containing the following object:", (char*)key->ptr);
redisLogObjectDebugInfo(val); serverLogObjectDebugInfo(val);
} }
decrRefCount(key); decrRefCount(key);
} }
...@@ -892,25 +892,25 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) { ...@@ -892,25 +892,25 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
REDIS_NOTUSED(info); REDIS_NOTUSED(info);
bugReportStart(); bugReportStart();
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
" Redis %s crashed by signal: %d", REDIS_VERSION, sig); " Redis %s crashed by signal: %d", REDIS_VERSION, sig);
redisLog(REDIS_WARNING, serverLog(REDIS_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 */
redisLog(REDIS_WARNING, "--- STACK TRACE"); serverLog(REDIS_WARNING, "--- STACK TRACE");
logStackTrace(uc); logStackTrace(uc);
/* Log INFO and CLIENT LIST */ /* Log INFO and CLIENT LIST */
redisLog(REDIS_WARNING, "--- INFO OUTPUT"); serverLog(REDIS_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());
redisLogRaw(REDIS_WARNING, infostring); serverLogRaw(REDIS_WARNING, infostring);
redisLog(REDIS_WARNING, "--- CLIENT LIST OUTPUT"); serverLog(REDIS_WARNING, "--- CLIENT LIST OUTPUT");
clients = getAllClientsInfoString(); clients = getAllClientsInfoString();
redisLogRaw(REDIS_WARNING, clients); serverLogRaw(REDIS_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 */
redisLog(REDIS_WARNING, "--- FAST MEMORY TEST"); serverLog(REDIS_WARNING, "--- FAST MEMORY TEST");
bioKillThreads(); bioKillThreads();
if (memtest_test_linux_anonymous_maps()) { if (memtest_test_linux_anonymous_maps()) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"!!! MEMORY ERROR DETECTED! Check your memory ASAP !!!"); "!!! MEMORY ERROR DETECTED! Check your memory ASAP !!!");
} else { } else {
redisLog(REDIS_WARNING, serverLog(REDIS_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
redisLog(REDIS_WARNING, serverLog(REDIS_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"
...@@ -954,12 +954,12 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) { ...@@ -954,12 +954,12 @@ void sigsegvHandler(int sig, siginfo_t *info, void *secret) {
/* ==================== Logging functions for debugging ===================== */ /* ==================== Logging functions for debugging ===================== */
void redisLogHexDump(int level, char *descr, void *value, size_t len) { void serverLogHexDump(int level, char *descr, void *value, size_t len) {
char buf[65], *b; char buf[65], *b;
unsigned char *v = value; unsigned char *v = value;
char charset[] = "0123456789abcdef"; char charset[] = "0123456789abcdef";
redisLog(level,"%s (hexdump):", descr); serverLog(level,"%s (hexdump):", descr);
b = buf; b = buf;
while(len) { while(len) {
b[0] = charset[(*v)>>4]; b[0] = charset[(*v)>>4];
...@@ -969,11 +969,11 @@ void redisLogHexDump(int level, char *descr, void *value, size_t len) { ...@@ -969,11 +969,11 @@ void redisLogHexDump(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) {
redisLogRaw(level|REDIS_LOG_RAW,buf); serverLogRaw(level|REDIS_LOG_RAW,buf);
b = buf; b = buf;
} }
} }
redisLogRaw(level|REDIS_LOG_RAW,"\n"); serverLogRaw(level|REDIS_LOG_RAW,"\n");
} }
/* =========================== Software Watchdog ============================ */ /* =========================== Software Watchdog ============================ */
...@@ -986,13 +986,13 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) { ...@@ -986,13 +986,13 @@ void watchdogSignalHandler(int sig, siginfo_t *info, void *secret) {
REDIS_NOTUSED(info); REDIS_NOTUSED(info);
REDIS_NOTUSED(sig); REDIS_NOTUSED(sig);
redisLogFromHandler(REDIS_WARNING,"\n--- WATCHDOG TIMER EXPIRED ---"); serverLogFromHandler(REDIS_WARNING,"\n--- WATCHDOG TIMER EXPIRED ---");
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
logStackTrace(uc); logStackTrace(uc);
#else #else
redisLogFromHandler(REDIS_WARNING,"Sorry: no support for backtrace()."); serverLogFromHandler(REDIS_WARNING,"Sorry: no support for backtrace().");
#endif #endif
redisLogFromHandler(REDIS_WARNING,"--------\n"); serverLogFromHandler(REDIS_WARNING,"--------\n");
} }
/* Schedule a SIGALRM delivery after the specified period in milliseconds. /* Schedule a SIGALRM delivery after the specified period in milliseconds.
......
...@@ -592,7 +592,7 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) { ...@@ -592,7 +592,7 @@ void copyClientOutputBuffer(redisClient *dst, redisClient *src) {
static void acceptCommonHandler(int fd, int flags) { static void acceptCommonHandler(int fd, int flags) {
redisClient *c; redisClient *c;
if ((c = createClient(fd)) == NULL) { if ((c = createClient(fd)) == NULL) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Error registering fd event for the new client: %s (fd=%d)", "Error registering fd event for the new client: %s (fd=%d)",
strerror(errno),fd); strerror(errno),fd);
close(fd); /* May be already closed, just ignore errors */ close(fd); /* May be already closed, just ignore errors */
...@@ -628,11 +628,11 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -628,11 +628,11 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport);
if (cfd == ANET_ERR) { if (cfd == ANET_ERR) {
if (errno != EWOULDBLOCK) if (errno != EWOULDBLOCK)
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Accepting client connection: %s", server.neterr); "Accepting client connection: %s", server.neterr);
return; return;
} }
redisLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport); serverLog(REDIS_VERBOSE,"Accepted %s:%d", cip, cport);
acceptCommonHandler(cfd,0); acceptCommonHandler(cfd,0);
} }
} }
...@@ -647,11 +647,11 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -647,11 +647,11 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) {
cfd = anetUnixAccept(server.neterr, fd); cfd = anetUnixAccept(server.neterr, fd);
if (cfd == ANET_ERR) { if (cfd == ANET_ERR) {
if (errno != EWOULDBLOCK) if (errno != EWOULDBLOCK)
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Accepting client connection: %s", server.neterr); "Accepting client connection: %s", server.neterr);
return; return;
} }
redisLog(REDIS_VERBOSE,"Accepted connection to %s", server.unixsocket); serverLog(REDIS_VERBOSE,"Accepted connection to %s", server.unixsocket);
acceptCommonHandler(cfd,REDIS_UNIX_SOCKET); acceptCommonHandler(cfd,REDIS_UNIX_SOCKET);
} }
} }
...@@ -700,7 +700,7 @@ void freeClient(redisClient *c) { ...@@ -700,7 +700,7 @@ void freeClient(redisClient *c) {
* Note that before doing this we make sure that the client is not in * Note that before doing this we make sure that the client is not in
* some unexpected state, by checking its flags. */ * some unexpected state, by checking its flags. */
if (server.master && c->flags & REDIS_MASTER) { if (server.master && c->flags & REDIS_MASTER) {
redisLog(REDIS_WARNING,"Connection with master lost."); serverLog(REDIS_WARNING,"Connection with master lost.");
if (!(c->flags & (REDIS_CLOSE_AFTER_REPLY| if (!(c->flags & (REDIS_CLOSE_AFTER_REPLY|
REDIS_CLOSE_ASAP| REDIS_CLOSE_ASAP|
REDIS_BLOCKED| REDIS_BLOCKED|
...@@ -713,7 +713,7 @@ void freeClient(redisClient *c) { ...@@ -713,7 +713,7 @@ void freeClient(redisClient *c) {
/* Log link disconnection with slave */ /* Log link disconnection with slave */
if ((c->flags & REDIS_SLAVE) && !(c->flags & REDIS_MONITOR)) { if ((c->flags & REDIS_SLAVE) && !(c->flags & REDIS_MONITOR)) {
redisLog(REDIS_WARNING,"Connection with slave %s lost.", serverLog(REDIS_WARNING,"Connection with slave %s lost.",
replicationGetSlaveName(c)); replicationGetSlaveName(c));
} }
...@@ -883,7 +883,7 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -883,7 +883,7 @@ void sendReplyToClient(aeEventLoop *el, int fd, void *privdata, int mask) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
nwritten = 0; nwritten = 0;
} else { } else {
redisLog(REDIS_VERBOSE, serverLog(REDIS_VERBOSE,
"Error writing to client: %s", strerror(errno)); "Error writing to client: %s", strerror(errno));
freeClient(c); freeClient(c);
return; return;
...@@ -985,7 +985,7 @@ int processInlineBuffer(redisClient *c) { ...@@ -985,7 +985,7 @@ int processInlineBuffer(redisClient *c) {
static void setProtocolError(redisClient *c, int pos) { static void setProtocolError(redisClient *c, int pos) {
if (server.verbosity <= REDIS_VERBOSE) { if (server.verbosity <= REDIS_VERBOSE) {
sds client = catClientInfoString(sdsempty(),c); sds client = catClientInfoString(sdsempty(),c);
redisLog(REDIS_VERBOSE, serverLog(REDIS_VERBOSE,
"Protocol error from client: %s", client); "Protocol error from client: %s", client);
sdsfree(client); sdsfree(client);
} }
...@@ -1205,12 +1205,12 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -1205,12 +1205,12 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
if (errno == EAGAIN) { if (errno == EAGAIN) {
return; return;
} else { } else {
redisLog(REDIS_VERBOSE, "Reading from client: %s",strerror(errno)); serverLog(REDIS_VERBOSE, "Reading from client: %s",strerror(errno));
freeClient(c); freeClient(c);
return; return;
} }
} else if (nread == 0) { } else if (nread == 0) {
redisLog(REDIS_VERBOSE, "Client closed connection"); serverLog(REDIS_VERBOSE, "Client closed connection");
freeClient(c); freeClient(c);
return; return;
} }
...@@ -1223,7 +1223,7 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) { ...@@ -1223,7 +1223,7 @@ void readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
sds ci = catClientInfoString(sdsempty(),c), bytes = sdsempty(); sds ci = catClientInfoString(sdsempty(),c), bytes = sdsempty();
bytes = sdscatrepr(bytes,c->querybuf,64); bytes = sdscatrepr(bytes,c->querybuf,64);
redisLog(REDIS_WARNING,"Closing client that reached max query buffer length: %s (qbuf initial bytes: %s)", ci, bytes); serverLog(REDIS_WARNING,"Closing client that reached max query buffer length: %s (qbuf initial bytes: %s)", ci, bytes);
sdsfree(ci); sdsfree(ci);
sdsfree(bytes); sdsfree(bytes);
freeClient(c); freeClient(c);
...@@ -1660,7 +1660,7 @@ void asyncCloseClientOnOutputBufferLimitReached(redisClient *c) { ...@@ -1660,7 +1660,7 @@ void asyncCloseClientOnOutputBufferLimitReached(redisClient *c) {
sds client = catClientInfoString(sdsempty(),c); sds client = catClientInfoString(sdsempty(),c);
freeClientAsync(c); freeClientAsync(c);
redisLog(REDIS_WARNING,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits.", client); serverLog(REDIS_WARNING,"Client %s scheduled to be closed ASAP for overcoming of output buffer limits.", client);
sdsfree(client); sdsfree(client);
} }
} }
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#define rdbExitReportCorruptRDB(reason) rdbCheckThenExit(reason, __LINE__); #define rdbExitReportCorruptRDB(reason) rdbCheckThenExit(reason, __LINE__);
void rdbCheckThenExit(char *reason, int where) { void rdbCheckThenExit(char *reason, int where) {
redisLog(REDIS_WARNING, "Corrupt RDB detected at rdb.c:%d (%s). " serverLog(REDIS_WARNING, "Corrupt RDB detected at rdb.c:%d (%s). "
"Running 'redis-check-rdb %s'", "Running 'redis-check-rdb %s'",
where, reason, server.rdb_filename); where, reason, server.rdb_filename);
redis_check_rdb(server.rdb_filename); redis_check_rdb(server.rdb_filename);
...@@ -839,7 +839,7 @@ int rdbSave(char *filename) { ...@@ -839,7 +839,7 @@ int rdbSave(char *filename) {
snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid()); snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
fp = fopen(tmpfile,"w"); fp = fopen(tmpfile,"w");
if (!fp) { if (!fp) {
redisLog(REDIS_WARNING, "Failed opening .rdb for saving: %s", serverLog(REDIS_WARNING, "Failed opening .rdb for saving: %s",
strerror(errno)); strerror(errno));
return REDIS_ERR; return REDIS_ERR;
} }
...@@ -858,18 +858,18 @@ int rdbSave(char *filename) { ...@@ -858,18 +858,18 @@ int rdbSave(char *filename) {
/* Use RENAME to make sure the DB file is changed atomically only /* Use RENAME to make sure the DB file is changed atomically only
* if the generate DB file is ok. */ * if the generate DB file is ok. */
if (rename(tmpfile,filename) == -1) { if (rename(tmpfile,filename) == -1) {
redisLog(REDIS_WARNING,"Error moving temp DB file on the final destination: %s", strerror(errno)); serverLog(REDIS_WARNING,"Error moving temp DB file on the final destination: %s", strerror(errno));
unlink(tmpfile); unlink(tmpfile);
return REDIS_ERR; return REDIS_ERR;
} }
redisLog(REDIS_NOTICE,"DB saved on disk"); serverLog(REDIS_NOTICE,"DB saved on disk");
server.dirty = 0; server.dirty = 0;
server.lastsave = time(NULL); server.lastsave = time(NULL);
server.lastbgsave_status = REDIS_OK; server.lastbgsave_status = REDIS_OK;
return REDIS_OK; return REDIS_OK;
werr: werr:
redisLog(REDIS_WARNING,"Write error saving DB on disk: %s", strerror(errno)); serverLog(REDIS_WARNING,"Write error saving DB on disk: %s", strerror(errno));
fclose(fp); fclose(fp);
unlink(tmpfile); unlink(tmpfile);
return REDIS_ERR; return REDIS_ERR;
...@@ -896,7 +896,7 @@ int rdbSaveBackground(char *filename) { ...@@ -896,7 +896,7 @@ int rdbSaveBackground(char *filename) {
size_t private_dirty = zmalloc_get_private_dirty(); size_t private_dirty = zmalloc_get_private_dirty();
if (private_dirty) { if (private_dirty) {
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"RDB: %zu MB of memory used by copy-on-write", "RDB: %zu MB of memory used by copy-on-write",
private_dirty/(1024*1024)); private_dirty/(1024*1024));
} }
...@@ -909,11 +909,11 @@ int rdbSaveBackground(char *filename) { ...@@ -909,11 +909,11 @@ int rdbSaveBackground(char *filename) {
latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000); latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000);
if (childpid == -1) { if (childpid == -1) {
server.lastbgsave_status = REDIS_ERR; server.lastbgsave_status = REDIS_ERR;
redisLog(REDIS_WARNING,"Can't save in background: fork: %s", serverLog(REDIS_WARNING,"Can't save in background: fork: %s",
strerror(errno)); strerror(errno));
return REDIS_ERR; return REDIS_ERR;
} }
redisLog(REDIS_NOTICE,"Background saving started by pid %d",childpid); serverLog(REDIS_NOTICE,"Background saving started by pid %d",childpid);
server.rdb_save_time_start = time(NULL); server.rdb_save_time_start = time(NULL);
server.rdb_child_pid = childpid; server.rdb_child_pid = childpid;
server.rdb_child_type = REDIS_RDB_CHILD_TYPE_DISK; server.rdb_child_type = REDIS_RDB_CHILD_TYPE_DISK;
...@@ -1250,14 +1250,14 @@ int rdbLoad(char *filename) { ...@@ -1250,14 +1250,14 @@ int rdbLoad(char *filename) {
buf[9] = '\0'; buf[9] = '\0';
if (memcmp(buf,"REDIS",5) != 0) { if (memcmp(buf,"REDIS",5) != 0) {
fclose(fp); fclose(fp);
redisLog(REDIS_WARNING,"Wrong signature trying to load DB from file"); serverLog(REDIS_WARNING,"Wrong signature trying to load DB from file");
errno = EINVAL; errno = EINVAL;
return REDIS_ERR; return REDIS_ERR;
} }
rdbver = atoi(buf+5); rdbver = atoi(buf+5);
if (rdbver < 1 || rdbver > REDIS_RDB_VERSION) { if (rdbver < 1 || rdbver > REDIS_RDB_VERSION) {
fclose(fp); fclose(fp);
redisLog(REDIS_WARNING,"Can't handle RDB format version %d",rdbver); serverLog(REDIS_WARNING,"Can't handle RDB format version %d",rdbver);
errno = EINVAL; errno = EINVAL;
return REDIS_ERR; return REDIS_ERR;
} }
...@@ -1295,7 +1295,7 @@ int rdbLoad(char *filename) { ...@@ -1295,7 +1295,7 @@ int rdbLoad(char *filename) {
if ((dbid = rdbLoadLen(&rdb,NULL)) == REDIS_RDB_LENERR) if ((dbid = rdbLoadLen(&rdb,NULL)) == REDIS_RDB_LENERR)
goto eoferr; goto eoferr;
if (dbid >= (unsigned)server.dbnum) { if (dbid >= (unsigned)server.dbnum) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"FATAL: Data file was created with a Redis " "FATAL: Data file was created with a Redis "
"server configured to handle more than %d " "server configured to handle more than %d "
"databases. Exiting\n", server.dbnum); "databases. Exiting\n", server.dbnum);
...@@ -1328,13 +1328,13 @@ int rdbLoad(char *filename) { ...@@ -1328,13 +1328,13 @@ int rdbLoad(char *filename) {
/* All the fields with a name staring with '%' are considered /* All the fields with a name staring with '%' are considered
* information fields and are logged at startup with a log * information fields and are logged at startup with a log
* level of NOTICE. */ * level of NOTICE. */
redisLog(REDIS_NOTICE,"RDB '%s': %s", serverLog(REDIS_NOTICE,"RDB '%s': %s",
(char*)auxkey->ptr, (char*)auxkey->ptr,
(char*)auxval->ptr); (char*)auxval->ptr);
} else { } else {
/* We ignore fields we don't understand, as by AUX field /* We ignore fields we don't understand, as by AUX field
* contract. */ * contract. */
redisLog(REDIS_DEBUG,"Unrecognized RDB AUX field: '%s'", serverLog(REDIS_DEBUG,"Unrecognized RDB AUX field: '%s'",
(char*)auxkey->ptr); (char*)auxkey->ptr);
} }
...@@ -1372,9 +1372,9 @@ int rdbLoad(char *filename) { ...@@ -1372,9 +1372,9 @@ int rdbLoad(char *filename) {
if (rioRead(&rdb,&cksum,8) == 0) goto eoferr; if (rioRead(&rdb,&cksum,8) == 0) goto eoferr;
memrev64ifbe(&cksum); memrev64ifbe(&cksum);
if (cksum == 0) { if (cksum == 0) {
redisLog(REDIS_WARNING,"RDB file was saved with checksum disabled: no check performed."); serverLog(REDIS_WARNING,"RDB file was saved with checksum disabled: no check performed.");
} else if (cksum != expected) { } else if (cksum != expected) {
redisLog(REDIS_WARNING,"Wrong RDB checksum. Aborting now."); serverLog(REDIS_WARNING,"Wrong RDB checksum. Aborting now.");
rdbExitReportCorruptRDB("RDB CRC error"); rdbExitReportCorruptRDB("RDB CRC error");
} }
} }
...@@ -1384,7 +1384,7 @@ int rdbLoad(char *filename) { ...@@ -1384,7 +1384,7 @@ int rdbLoad(char *filename) {
return REDIS_OK; return REDIS_OK;
eoferr: /* unexpected end of file is handled here with a fatal exit */ eoferr: /* unexpected end of file is handled here with a fatal exit */
redisLog(REDIS_WARNING,"Short read or OOM loading DB. Unrecoverable error, aborting now."); serverLog(REDIS_WARNING,"Short read or OOM loading DB. Unrecoverable error, aborting now.");
rdbExitReportCorruptRDB("Unexpected EOF reading RDB file"); rdbExitReportCorruptRDB("Unexpected EOF reading RDB file");
return REDIS_ERR; /* Just to avoid warning */ return REDIS_ERR; /* Just to avoid warning */
} }
...@@ -1393,18 +1393,18 @@ eoferr: /* unexpected end of file is handled here with a fatal exit */ ...@@ -1393,18 +1393,18 @@ eoferr: /* unexpected end of file is handled here with a fatal exit */
* This function covers the case of actual BGSAVEs. */ * This function covers the case of actual BGSAVEs. */
void backgroundSaveDoneHandlerDisk(int exitcode, int bysignal) { void backgroundSaveDoneHandlerDisk(int exitcode, int bysignal) {
if (!bysignal && exitcode == 0) { if (!bysignal && exitcode == 0) {
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"Background saving terminated with success"); "Background saving terminated with success");
server.dirty = server.dirty - server.dirty_before_bgsave; server.dirty = server.dirty - server.dirty_before_bgsave;
server.lastsave = time(NULL); server.lastsave = time(NULL);
server.lastbgsave_status = REDIS_OK; server.lastbgsave_status = REDIS_OK;
} else if (!bysignal && exitcode != 0) { } else if (!bysignal && exitcode != 0) {
redisLog(REDIS_WARNING, "Background saving error"); serverLog(REDIS_WARNING, "Background saving error");
server.lastbgsave_status = REDIS_ERR; server.lastbgsave_status = REDIS_ERR;
} else { } else {
mstime_t latency; mstime_t latency;
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Background saving terminated by signal %d", bysignal); "Background saving terminated by signal %d", bysignal);
latencyStartMonitor(latency); latencyStartMonitor(latency);
rdbRemoveTempFile(server.rdb_child_pid); rdbRemoveTempFile(server.rdb_child_pid);
...@@ -1431,12 +1431,12 @@ void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) { ...@@ -1431,12 +1431,12 @@ void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) {
uint64_t *ok_slaves; uint64_t *ok_slaves;
if (!bysignal && exitcode == 0) { if (!bysignal && exitcode == 0) {
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"Background RDB transfer terminated with success"); "Background RDB transfer terminated with success");
} else if (!bysignal && exitcode != 0) { } else if (!bysignal && exitcode != 0) {
redisLog(REDIS_WARNING, "Background transfer error"); serverLog(REDIS_WARNING, "Background transfer error");
} else { } else {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Background transfer terminated by signal %d", bysignal); "Background transfer terminated by signal %d", bysignal);
} }
server.rdb_child_pid = -1; server.rdb_child_pid = -1;
...@@ -1498,14 +1498,14 @@ void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) { ...@@ -1498,14 +1498,14 @@ void backgroundSaveDoneHandlerSocket(int exitcode, int bysignal) {
} }
} }
if (j == ok_slaves[0] || errorcode != 0) { if (j == ok_slaves[0] || errorcode != 0) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Closing slave %s: child->slave RDB transfer failed: %s", "Closing slave %s: child->slave RDB transfer failed: %s",
replicationGetSlaveName(slave), replicationGetSlaveName(slave),
(errorcode == 0) ? "RDB transfer child aborted" (errorcode == 0) ? "RDB transfer child aborted"
: strerror(errorcode)); : strerror(errorcode));
freeClient(slave); freeClient(slave);
} else { } else {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Slave %s correctly received the streamed RDB file.", "Slave %s correctly received the streamed RDB file.",
replicationGetSlaveName(slave)); replicationGetSlaveName(slave));
/* Restore the socket as non-blocking. */ /* Restore the socket as non-blocking. */
...@@ -1601,7 +1601,7 @@ int rdbSaveToSlavesSockets(void) { ...@@ -1601,7 +1601,7 @@ int rdbSaveToSlavesSockets(void) {
size_t private_dirty = zmalloc_get_private_dirty(); size_t private_dirty = zmalloc_get_private_dirty();
if (private_dirty) { if (private_dirty) {
redisLog(REDIS_NOTICE, serverLog(REDIS_NOTICE,
"RDB: %zu MB of memory used by copy-on-write", "RDB: %zu MB of memory used by copy-on-write",
private_dirty/(1024*1024)); private_dirty/(1024*1024));
} }
...@@ -1654,14 +1654,14 @@ int rdbSaveToSlavesSockets(void) { ...@@ -1654,14 +1654,14 @@ int rdbSaveToSlavesSockets(void) {
server.stat_fork_rate = (double) zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024); /* GB per second. */ 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); latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000);
if (childpid == -1) { if (childpid == -1) {
redisLog(REDIS_WARNING,"Can't save in background: fork: %s", serverLog(REDIS_WARNING,"Can't save in background: fork: %s",
strerror(errno)); strerror(errno));
zfree(fds); zfree(fds);
close(pipefds[0]); close(pipefds[0]);
close(pipefds[1]); close(pipefds[1]);
return REDIS_ERR; return REDIS_ERR;
} }
redisLog(REDIS_NOTICE,"Background RDB transfer started by pid %d",childpid); serverLog(REDIS_NOTICE,"Background RDB transfer started by pid %d",childpid);
server.rdb_save_time_start = time(NULL); server.rdb_save_time_start = time(NULL);
server.rdb_child_pid = childpid; server.rdb_child_pid = childpid;
server.rdb_child_type = REDIS_RDB_CHILD_TYPE_SOCKET; server.rdb_child_type = REDIS_RDB_CHILD_TYPE_SOCKET;
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "crc64.h" #include "crc64.h"
#define ERROR(...) { \ #define ERROR(...) { \
redisLog(REDIS_WARNING, __VA_ARGS__); \ serverLog(REDIS_WARNING, __VA_ARGS__); \
exit(1); \ exit(1); \
} }
...@@ -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));
redisLog(REDIS_WARNING, "%s %s %s", head, body, tail); serverLog(REDIS_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++) {
redisLog(REDIS_WARNING, "0x%08lx - %s", serverLog(REDIS_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) {
redisLog(REDIS_WARNING, "RDB version >= 5 but no room for checksum."); serverLog(REDIS_WARNING, "RDB version >= 5 but no room for checksum.");
exit(1); exit(1);
} }
positions[0].size -= 8; positions[0].size -= 8;
...@@ -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 {
redisLog(REDIS_WARNING, "CRC64 checksum is OK"); serverLog(REDIS_WARNING, "CRC64 checksum is OK");
} }
} }
/* print summary on errors */ /* print summary on errors */
if (num_errors) { if (num_errors) {
redisLog(REDIS_WARNING, "Total unprocessable opcodes: %llu", serverLog(REDIS_WARNING, "Total unprocessable opcodes: %llu",
(unsigned long long) num_errors); (unsigned long long) num_errors);
} }
} }
...@@ -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);
} }
redisLog(REDIS_WARNING, "Checking RDB file %s", argv[1]); serverLog(REDIS_WARNING, "Checking RDB file %s", argv[1]);
exit(redis_check_rdb(argv[1])); exit(redis_check_rdb(argv[1]));
return 0; return 0;
} }
This diff is collapsed.
...@@ -224,7 +224,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) { ...@@ -224,7 +224,7 @@ int luaRedisGenericCommand(lua_State *lua, int raise_error) {
char *recursion_warning = char *recursion_warning =
"luaRedisGenericCommand() recursive call detected. " "luaRedisGenericCommand() recursive call detected. "
"Are you doing funny stuff with Lua debug hooks?"; "Are you doing funny stuff with Lua debug hooks?";
redisLog(REDIS_WARNING,"%s",recursion_warning); serverLog(REDIS_WARNING,"%s",recursion_warning);
luaPushError(lua,recursion_warning); luaPushError(lua,recursion_warning);
return 1; return 1;
} }
...@@ -532,7 +532,7 @@ int luaLogCommand(lua_State *lua) { ...@@ -532,7 +532,7 @@ int luaLogCommand(lua_State *lua) {
log = sdscatlen(log,s,len); log = sdscatlen(log,s,len);
} }
} }
redisLogRaw(level,log); serverLogRaw(level,log);
sdsfree(log); sdsfree(log);
return 0; return 0;
} }
...@@ -544,7 +544,7 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) { ...@@ -544,7 +544,7 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
elapsed = mstime() - server.lua_time_start; elapsed = mstime() - server.lua_time_start;
if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) { if (elapsed >= server.lua_time_limit && server.lua_timedout == 0) {
redisLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed); serverLog(REDIS_WARNING,"Lua slow script detected: still in execution after %lld milliseconds. You can try killing the script using the SCRIPT KILL command.",elapsed);
server.lua_timedout = 1; server.lua_timedout = 1;
/* Once the script timeouts we reenter the event loop to permit others /* Once the script timeouts we reenter the event loop to permit others
* to call SCRIPT KILL or SHUTDOWN NOSAVE if needed. For this reason * to call SCRIPT KILL or SHUTDOWN NOSAVE if needed. For this reason
...@@ -555,7 +555,7 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) { ...@@ -555,7 +555,7 @@ void luaMaskCountHook(lua_State *lua, lua_Debug *ar) {
} }
if (server.lua_timedout) processEventsWhileBlocked(); if (server.lua_timedout) processEventsWhileBlocked();
if (server.lua_kill) { if (server.lua_kill) {
redisLog(REDIS_WARNING,"Lua script killed by user with SCRIPT KILL."); serverLog(REDIS_WARNING,"Lua script killed by user with SCRIPT KILL.");
lua_pushstring(lua,"Script killed by user with SCRIPT KILL..."); lua_pushstring(lua,"Script killed by user with SCRIPT KILL...");
lua_error(lua); lua_error(lua);
} }
......
...@@ -477,11 +477,11 @@ void sentinelIsRunning(void) { ...@@ -477,11 +477,11 @@ void sentinelIsRunning(void) {
int j; int j;
if (server.configfile == NULL) { if (server.configfile == NULL) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Sentinel started without a config file. Exiting..."); "Sentinel started without a config file. Exiting...");
exit(1); exit(1);
} else if (access(server.configfile,W_OK) == -1) { } else if (access(server.configfile,W_OK) == -1) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Sentinel config file %s is not writable: %s. Exiting...", "Sentinel config file %s is not writable: %s. Exiting...",
server.configfile,strerror(errno)); server.configfile,strerror(errno));
exit(1); exit(1);
...@@ -500,7 +500,7 @@ void sentinelIsRunning(void) { ...@@ -500,7 +500,7 @@ void sentinelIsRunning(void) {
} }
/* Log its ID to make debugging of issues simpler. */ /* Log its ID to make debugging of issues simpler. */
redisLog(REDIS_WARNING,"Sentinel ID is %s", sentinel.myid); serverLog(REDIS_WARNING,"Sentinel ID is %s", sentinel.myid);
/* We want to generate a +monitor event for every configured master /* We want to generate a +monitor event for every configured master
* at startup. */ * at startup. */
...@@ -614,7 +614,7 @@ void sentinelEvent(int level, char *type, sentinelRedisInstance *ri, ...@@ -614,7 +614,7 @@ void sentinelEvent(int level, char *type, sentinelRedisInstance *ri,
/* Log the message if the log level allows it to be logged. */ /* Log the message if the log level allows it to be logged. */
if (level >= server.verbosity) if (level >= server.verbosity)
redisLog(level,"%s %s",type,msg); serverLog(level,"%s %s",type,msg);
/* Publish the message via Pub/Sub if it's not a debugging one. */ /* Publish the message via Pub/Sub if it's not a debugging one. */
if (level != REDIS_DEBUG) { if (level != REDIS_DEBUG) {
...@@ -808,7 +808,7 @@ void sentinelCollectTerminatedScripts(void) { ...@@ -808,7 +808,7 @@ void sentinelCollectTerminatedScripts(void) {
ln = sentinelGetScriptListNodeByPid(pid); ln = sentinelGetScriptListNodeByPid(pid);
if (ln == NULL) { if (ln == NULL) {
redisLog(REDIS_WARNING,"wait3() returned a pid (%ld) we can't find in our scripts execution queue!", (long)pid); serverLog(REDIS_WARNING,"wait3() returned a pid (%ld) we can't find in our scripts execution queue!", (long)pid);
continue; continue;
} }
sj = ln->value; sj = ln->value;
...@@ -1852,7 +1852,7 @@ void sentinelFlushConfig(void) { ...@@ -1852,7 +1852,7 @@ void sentinelFlushConfig(void) {
werr: werr:
if (fd != -1) close(fd); if (fd != -1) close(fd);
redisLog(REDIS_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno)); serverLog(REDIS_WARNING,"WARNING: Sentinel was not able to save the new configuration on disk!!!: %s", strerror(errno));
} }
/* ====================== hiredis connection handling ======================= */ /* ====================== hiredis connection handling ======================= */
...@@ -2967,7 +2967,7 @@ void sentinelCommand(redisClient *c) { ...@@ -2967,7 +2967,7 @@ void sentinelCommand(redisClient *c) {
addReplySds(c,sdsnew("-NOGOODSLAVE No suitable slave to promote\r\n")); addReplySds(c,sdsnew("-NOGOODSLAVE No suitable slave to promote\r\n"));
return; return;
} }
redisLog(REDIS_WARNING,"Executing user requested FAILOVER of '%s'", serverLog(REDIS_WARNING,"Executing user requested FAILOVER of '%s'",
ri->name); ri->name);
sentinelStartFailover(ri); sentinelStartFailover(ri);
ri->flags |= SRI_FORCE_FAILOVER; ri->flags |= SRI_FORCE_FAILOVER;
...@@ -3136,13 +3136,13 @@ void sentinelCommand(redisClient *c) { ...@@ -3136,13 +3136,13 @@ void sentinelCommand(redisClient *c) {
if (!strcasecmp(c->argv[j]->ptr,"crash-after-election")) { if (!strcasecmp(c->argv[j]->ptr,"crash-after-election")) {
sentinel.simfailure_flags |= sentinel.simfailure_flags |=
SENTINEL_SIMFAILURE_CRASH_AFTER_ELECTION; SENTINEL_SIMFAILURE_CRASH_AFTER_ELECTION;
redisLog(REDIS_WARNING,"Failure simulation: this Sentinel " serverLog(REDIS_WARNING,"Failure simulation: this Sentinel "
"will crash after being successfully elected as failover " "will crash after being successfully elected as failover "
"leader"); "leader");
} else if (!strcasecmp(c->argv[j]->ptr,"crash-after-promotion")) { } else if (!strcasecmp(c->argv[j]->ptr,"crash-after-promotion")) {
sentinel.simfailure_flags |= sentinel.simfailure_flags |=
SENTINEL_SIMFAILURE_CRASH_AFTER_PROMOTION; SENTINEL_SIMFAILURE_CRASH_AFTER_PROMOTION;
redisLog(REDIS_WARNING,"Failure simulation: this Sentinel " serverLog(REDIS_WARNING,"Failure simulation: this Sentinel "
"will crash after promoting the selected slave to master"); "will crash after promoting the selected slave to master");
} else if (!strcasecmp(c->argv[j]->ptr,"help")) { } else if (!strcasecmp(c->argv[j]->ptr,"help")) {
addReplyMultiBulkLen(c,2); addReplyMultiBulkLen(c,2);
...@@ -3490,7 +3490,7 @@ void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *p ...@@ -3490,7 +3490,7 @@ void sentinelReceiveIsMasterDownReply(redisAsyncContext *c, void *reply, void *p
* replied with a vote. */ * replied with a vote. */
sdsfree(ri->leader); sdsfree(ri->leader);
if ((long long)ri->leader_epoch != r->element[2]->integer) if ((long long)ri->leader_epoch != r->element[2]->integer)
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"%s voted for %s %llu", ri->name, "%s voted for %s %llu", ri->name,
r->element[1]->str, r->element[1]->str,
(unsigned long long) r->element[2]->integer); (unsigned long long) r->element[2]->integer);
...@@ -3552,7 +3552,7 @@ void sentinelAskMasterStateToOtherSentinels(sentinelRedisInstance *master, int f ...@@ -3552,7 +3552,7 @@ void sentinelAskMasterStateToOtherSentinels(sentinelRedisInstance *master, int f
/* Crash because of user request via SENTINEL simulate-failure command. */ /* Crash because of user request via SENTINEL simulate-failure command. */
void sentinelSimFailureCrash(void) { void sentinelSimFailureCrash(void) {
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Sentinel CRASH because of SENTINEL simulate-failure"); "Sentinel CRASH because of SENTINEL simulate-failure");
exit(99); exit(99);
} }
...@@ -3793,7 +3793,7 @@ int sentinelStartFailoverIfNeeded(sentinelRedisInstance *master) { ...@@ -3793,7 +3793,7 @@ int sentinelStartFailoverIfNeeded(sentinelRedisInstance *master) {
ctime_r(&clock,ctimebuf); ctime_r(&clock,ctimebuf);
ctimebuf[24] = '\0'; /* Remove newline. */ ctimebuf[24] = '\0'; /* Remove newline. */
master->failover_delay_logged = master->failover_start_time; master->failover_delay_logged = master->failover_start_time;
redisLog(REDIS_WARNING, serverLog(REDIS_WARNING,
"Next failover delay: I will not start a failover before %s", "Next failover delay: I will not start a failover before %s",
ctimebuf); ctimebuf);
} }
......
This diff is collapsed.
...@@ -1258,13 +1258,13 @@ void forceCommandPropagation(redisClient *c, int flags); ...@@ -1258,13 +1258,13 @@ void forceCommandPropagation(redisClient *c, int flags);
void preventCommandPropagation(redisClient *c); void preventCommandPropagation(redisClient *c);
int prepareForShutdown(); int prepareForShutdown();
#ifdef __GNUC__ #ifdef __GNUC__
void redisLog(int level, const char *fmt, ...) void serverLog(int level, const char *fmt, ...)
__attribute__((format(printf, 2, 3))); __attribute__((format(printf, 2, 3)));
#else #else
void redisLog(int level, const char *fmt, ...); void serverLog(int level, const char *fmt, ...);
#endif #endif
void redisLogRaw(int level, const char *msg); void serverLogRaw(int level, const char *msg);
void redisLogFromHandler(int level, const char *msg); void serverLogFromHandler(int level, const char *msg);
void usage(void); void usage(void);
void updateDictResizePolicy(void); void updateDictResizePolicy(void);
int htNeedsResize(dict *dict); int htNeedsResize(dict *dict);
...@@ -1585,13 +1585,13 @@ void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int l ...@@ -1585,13 +1585,13 @@ void _redisAssertWithInfo(redisClient *c, robj *o, char *estr, char *file, int l
void _redisAssert(char *estr, char *file, int line); void _redisAssert(char *estr, char *file, int line);
void _redisPanic(char *msg, char *file, int line); void _redisPanic(char *msg, char *file, int line);
void bugReportStart(void); void bugReportStart(void);
void redisLogObjectDebugInfo(robj *o); void serverLogObjectDebugInfo(robj *o);
void sigsegvHandler(int sig, siginfo_t *info, void *secret); void sigsegvHandler(int sig, siginfo_t *info, void *secret);
sds genRedisInfoString(char *section); sds genRedisInfoString(char *section);
void enableWatchdog(int period); void enableWatchdog(int period);
void disableWatchdog(void); void disableWatchdog(void);
void watchdogScheduleSignal(int period); void watchdogScheduleSignal(int period);
void redisLogHexDump(int level, char *descr, void *value, size_t len); void serverLogHexDump(int level, char *descr, void *value, size_t len);
#define redisDebug(fmt, ...) \ #define redisDebug(fmt, ...) \
printf("DEBUG %s:%d > " fmt "\n", __FILE__, __LINE__, __VA_ARGS__) printf("DEBUG %s:%d > " fmt "\n", __FILE__, __LINE__, __VA_ARGS__)
......
...@@ -452,7 +452,7 @@ void hashTypeConvertZiplist(robj *o, int enc) { ...@@ -452,7 +452,7 @@ void hashTypeConvertZiplist(robj *o, int enc) {
value = tryObjectEncoding(value); value = tryObjectEncoding(value);
ret = dictAdd(dict, field, value); ret = dictAdd(dict, field, value);
if (ret != DICT_OK) { if (ret != DICT_OK) {
redisLogHexDump(REDIS_WARNING,"ziplist with dup elements dump", serverLogHexDump(REDIS_WARNING,"ziplist with dup elements dump",
o->ptr,ziplistBlobLen(o->ptr)); o->ptr,ziplistBlobLen(o->ptr));
redisAssert(ret == DICT_OK); redisAssert(ret == DICT_OK);
} }
......
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