Skip to content

Commit

Permalink
some RDB server struct fields renamed.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Dec 21, 2011
1 parent ff2145a commit f48cd4b
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/aof.c
Expand Up @@ -144,7 +144,7 @@ void flushAppendOnlyFile(int force) {
/* Don't fsync if no-appendfsync-on-rewrite is set to yes and there are
* children doing I/O in the background. */
if (server.aof_no_fsync_on_rewrite &&
(server.aof_child_pid != -1 || server.bgsavechildpid != -1))
(server.aof_child_pid != -1 || server.rdb_child_pid != -1))
return;

/* Perform the fsync if needed. */
Expand Down Expand Up @@ -815,7 +815,7 @@ int rewriteAppendOnlyFileBackground(void) {
void bgrewriteaofCommand(redisClient *c) {
if (server.aof_child_pid != -1) {
addReplyError(c,"Background append only file rewriting already in progress");
} else if (server.bgsavechildpid != -1) {
} else if (server.rdb_child_pid != -1) {
server.aof_rewrite_scheduled = 1;
addReplyStatus(c,"Background append only file rewriting scheduled");
} else if (rewriteAppendOnlyFileBackground() == REDIS_OK) {
Expand Down
12 changes: 6 additions & 6 deletions src/config.c
Expand Up @@ -201,7 +201,7 @@ void loadServerConfigFromString(char *config) {
} else if (!strcasecmp(argv[0],"glueoutputbuf")) {
redisLog(REDIS_WARNING, "Deprecated configuration directive: \"%s\"", argv[0]);
} else if (!strcasecmp(argv[0],"rdbcompression") && argc == 2) {
if ((server.rdbcompression = yesnotoi(argv[1])) == -1) {
if ((server.rdb_compression = yesnotoi(argv[1])) == -1) {
err = "argument must be 'yes' or 'no'"; goto loaderr;
}
} else if (!strcasecmp(argv[0],"activerehashing") && argc == 2) {
Expand Down Expand Up @@ -256,8 +256,8 @@ void loadServerConfigFromString(char *config) {
zfree(server.pidfile);
server.pidfile = zstrdup(argv[1]);
} else if (!strcasecmp(argv[0],"dbfilename") && argc == 2) {
zfree(server.dbfilename);
server.dbfilename = zstrdup(argv[1]);
zfree(server.rdb_filename);
server.rdb_filename = zstrdup(argv[1]);
} else if (!strcasecmp(argv[0],"hash-max-zipmap-entries") && argc == 2) {
server.hash_max_zipmap_entries = memtoll(argv[1], NULL);
} else if (!strcasecmp(argv[0],"hash-max-zipmap-value") && argc == 2) {
Expand Down Expand Up @@ -376,8 +376,8 @@ void configSetCommand(redisClient *c) {
o = c->argv[3];

if (!strcasecmp(c->argv[2]->ptr,"dbfilename")) {
zfree(server.dbfilename);
server.dbfilename = zstrdup(o->ptr);
zfree(server.rdb_filename);
server.rdb_filename = zstrdup(o->ptr);
} else if (!strcasecmp(c->argv[2]->ptr,"requirepass")) {
zfree(server.requirepass);
server.requirepass = ((char*)o->ptr)[0] ? zstrdup(o->ptr) : NULL;
Expand Down Expand Up @@ -567,7 +567,7 @@ void configGetCommand(redisClient *c) {
}
if (stringmatch(pattern,"dbfilename",0)) {
addReplyBulkCString(c,"dbfilename");
addReplyBulkCString(c,server.dbfilename);
addReplyBulkCString(c,server.rdb_filename);
matches++;
}
if (stringmatch(pattern,"requirepass",0)) {
Expand Down
10 changes: 5 additions & 5 deletions src/db.c
Expand Up @@ -40,7 +40,7 @@ robj *lookupKey(redisDb *db, robj *key) {
/* Update the access time for the aging algorithm.
* Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */
if (server.bgsavechildpid == -1 && server.aof_child_pid == -1)
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1)
val->lru = server.lruclock;
server.stat_keyspace_hits++;
return val;
Expand Down Expand Up @@ -210,15 +210,15 @@ void flushallCommand(redisClient *c) {
signalFlushedDb(-1);
server.dirty += emptyDb();
addReply(c,shared.ok);
if (server.bgsavechildpid != -1) {
kill(server.bgsavechildpid,SIGKILL);
rdbRemoveTempFile(server.bgsavechildpid);
if (server.rdb_child_pid != -1) {
kill(server.rdb_child_pid,SIGKILL);
rdbRemoveTempFile(server.rdb_child_pid);
}
if (server.saveparamslen > 0) {
/* Normally rdbSave() will reset dirty, but we don't want this here
* as otherwise FLUSHALL will not be replicated nor put into the AOF. */
int saved_dirty = server.dirty;
rdbSave(server.dbfilename);
rdbSave(server.rdb_filename);
server.dirty = saved_dirty;
}
server.dirty++;
Expand Down
4 changes: 2 additions & 2 deletions src/debug.c
Expand Up @@ -216,12 +216,12 @@ void debugCommand(redisClient *c) {
if (c->argc >= 3) c->argv[2] = tryObjectEncoding(c->argv[2]);
redisAssertWithInfo(c,c->argv[0],1 == 2);
} else if (!strcasecmp(c->argv[1]->ptr,"reload")) {
if (rdbSave(server.dbfilename) != REDIS_OK) {
if (rdbSave(server.rdb_filename) != REDIS_OK) {
addReply(c,shared.err);
return;
}
emptyDb();
if (rdbLoad(server.dbfilename) != REDIS_OK) {
if (rdbLoad(server.rdb_filename) != REDIS_OK) {
addReplyError(c,"Error trying to load the RDB dump");
return;
}
Expand Down
18 changes: 9 additions & 9 deletions src/rdb.c
Expand Up @@ -253,7 +253,7 @@ int rdbSaveRawString(rio *rdb, unsigned char *s, size_t len) {

/* Try LZF compression - under 20 bytes it's unable to compress even
* aaaaaaaaaaaaaaaaaa so skip it */
if (server.rdbcompression && len > 20) {
if (server.rdb_compression && len > 20) {
n = rdbSaveLzfStringObject(rdb,s,len);
if (n == -1) return -1;
if (n > 0) return n;
Expand Down Expand Up @@ -670,7 +670,7 @@ int rdbSaveBackground(char *filename) {
pid_t childpid;
long long start;

if (server.bgsavechildpid != -1) return REDIS_ERR;
if (server.rdb_child_pid != -1) return REDIS_ERR;

server.dirty_before_bgsave = server.dirty;

Expand All @@ -692,7 +692,7 @@ int rdbSaveBackground(char *filename) {
return REDIS_ERR;
}
redisLog(REDIS_NOTICE,"Background saving started by pid %d",childpid);
server.bgsavechildpid = childpid;
server.rdb_child_pid = childpid;
updateDictResizePolicy();
return REDIS_OK;
}
Expand Down Expand Up @@ -1062,32 +1062,32 @@ void backgroundSaveDoneHandler(int exitcode, int bysignal) {
} else {
redisLog(REDIS_WARNING,
"Background saving terminated by signal %d", bysignal);
rdbRemoveTempFile(server.bgsavechildpid);
rdbRemoveTempFile(server.rdb_child_pid);
}
server.bgsavechildpid = -1;
server.rdb_child_pid = -1;
/* Possibly there are slaves waiting for a BGSAVE in order to be served
* (the first stage of SYNC is a bulk transfer of dump.rdb) */
updateSlavesWaitingBgsave(exitcode == 0 ? REDIS_OK : REDIS_ERR);
}

void saveCommand(redisClient *c) {
if (server.bgsavechildpid != -1) {
if (server.rdb_child_pid != -1) {
addReplyError(c,"Background save already in progress");
return;
}
if (rdbSave(server.dbfilename) == REDIS_OK) {
if (rdbSave(server.rdb_filename) == REDIS_OK) {
addReply(c,shared.ok);
} else {
addReply(c,shared.err);
}
}

void bgsaveCommand(redisClient *c) {
if (server.bgsavechildpid != -1) {
if (server.rdb_child_pid != -1) {
addReplyError(c,"Background save already in progress");
} else if (server.aof_child_pid != -1) {
addReplyError(c,"Can't BGSAVE while AOF log rewriting is in progress");
} else if (rdbSaveBackground(server.dbfilename) == REDIS_OK) {
} else if (rdbSaveBackground(server.rdb_filename) == REDIS_OK) {
addReplyStatus(c,"Background saving started");
} else {
addReply(c,shared.err);
Expand Down
32 changes: 16 additions & 16 deletions src/redis.c
Expand Up @@ -563,7 +563,7 @@ void incrementallyRehash(void) {
* for dict.c to resize the hash tables accordingly to the fact we have o not
* running childs. */
void updateDictResizePolicy(void) {
if (server.bgsavechildpid == -1 && server.aof_child_pid == -1)
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1)
dictEnableResize();
else
dictDisableResize();
Expand Down Expand Up @@ -673,7 +673,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
* if we resize the HT while there is the saving child at work actually
* a lot of memory movements in the parent will cause a lot of pages
* copied. */
if (server.bgsavechildpid == -1 && server.aof_child_pid == -1) {
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1) {
if (!(loops % 10)) tryResizeHashTables();
if (server.activerehashing) incrementallyRehash();
}
Expand All @@ -692,14 +692,14 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {

/* Start a scheduled AOF rewrite if this was requested by the user while
* a BGSAVE was in progress. */
if (server.bgsavechildpid == -1 && server.aof_child_pid == -1 &&
if (server.rdb_child_pid == -1 && server.aof_child_pid == -1 &&
server.aof_rewrite_scheduled)
{
rewriteAppendOnlyFileBackground();
}

/* Check if a background saving or AOF rewrite in progress terminated. */
if (server.bgsavechildpid != -1 || server.aof_child_pid != -1) {
if (server.rdb_child_pid != -1 || server.aof_child_pid != -1) {
int statloc;
pid_t pid;

Expand All @@ -709,7 +709,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {

if (WIFSIGNALED(statloc)) bysignal = WTERMSIG(statloc);

if (pid == server.bgsavechildpid) {
if (pid == server.rdb_child_pid) {
backgroundSaveDoneHandler(exitcode,bysignal);
} else {
backgroundRewriteDoneHandler(exitcode,bysignal);
Expand All @@ -728,13 +728,13 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
now-server.lastsave > sp->seconds) {
redisLog(REDIS_NOTICE,"%d changes in %d seconds. Saving...",
sp->changes, sp->seconds);
rdbSaveBackground(server.dbfilename);
rdbSaveBackground(server.rdb_filename);
break;
}
}

/* Trigger an AOF rewrite if needed */
if (server.bgsavechildpid == -1 &&
if (server.rdb_child_pid == -1 &&
server.aof_child_pid == -1 &&
server.aof_rewrite_perc &&
server.aof_current_size > server.aof_rewrite_min_size)
Expand Down Expand Up @@ -885,10 +885,10 @@ void initServerConfig() {
server.aof_selected_db = -1; /* Make sure the first time will not match */
server.aof_flush_postponed_start = 0;
server.pidfile = zstrdup("/var/run/redis.pid");
server.dbfilename = zstrdup("dump.rdb");
server.rdb_filename = zstrdup("dump.rdb");
server.aof_filename = zstrdup("appendonly.aof");
server.requirepass = NULL;
server.rdbcompression = 1;
server.rdb_compression = 1;
server.activerehashing = 1;
server.maxclients = REDIS_MAX_CLIENTS;
server.bpop_blocked_clients = 0;
Expand Down Expand Up @@ -1044,7 +1044,7 @@ void initServer() {
listSetFreeMethod(server.pubsub_patterns,freePubsubPattern);
listSetMatchMethod(server.pubsub_patterns,listMatchPubsubPattern);
server.cronloops = 0;
server.bgsavechildpid = -1;
server.rdb_child_pid = -1;
server.aof_child_pid = -1;
server.aof_rewrite_buf = sdsempty();
server.aof_buf = sdsempty();
Expand Down Expand Up @@ -1305,10 +1305,10 @@ int prepareForShutdown(int flags) {
/* Kill the saving child if there is a background saving in progress.
We want to avoid race conditions, for instance our saving child may
overwrite the synchronous saving did by SHUTDOWN. */
if (server.bgsavechildpid != -1) {
if (server.rdb_child_pid != -1) {
redisLog(REDIS_WARNING,"There is a child saving an .rdb. Killing it!");
kill(server.bgsavechildpid,SIGKILL);
rdbRemoveTempFile(server.bgsavechildpid);
kill(server.rdb_child_pid,SIGKILL);
rdbRemoveTempFile(server.rdb_child_pid);
}
if (server.aof_state != REDIS_AOF_OFF) {
/* Kill the AOF saving child as the AOF we already have may be longer
Expand All @@ -1325,7 +1325,7 @@ int prepareForShutdown(int flags) {
if ((server.saveparamslen > 0 && !nosave) || save) {
redisLog(REDIS_NOTICE,"Saving the final RDB snapshot before exiting.");
/* Snapshotting. Perform a SYNC SAVE and exit */
if (rdbSave(server.dbfilename) != REDIS_OK) {
if (rdbSave(server.rdb_filename) != REDIS_OK) {
/* Ooops.. error saving! The best we can do is to continue
* operating. Note that if there was a background saving process,
* in the next cron() Redis will be notified that the background
Expand Down Expand Up @@ -1499,7 +1499,7 @@ sds genRedisInfoString(char *section) {
server.loading,
server.aof_state != REDIS_AOF_OFF,
server.dirty,
server.bgsavechildpid != -1,
server.rdb_child_pid != -1,
server.lastsave,
server.aof_child_pid != -1);

Expand Down Expand Up @@ -2102,7 +2102,7 @@ int main(int argc, char **argv) {
if (loadAppendOnlyFile(server.aof_filename) == REDIS_OK)
redisLog(REDIS_NOTICE,"DB loaded from append only file: %.3f seconds",(float)(ustime()-start)/1000000);
} else {
if (rdbLoad(server.dbfilename) == REDIS_OK) {
if (rdbLoad(server.rdb_filename) == REDIS_OK) {
redisLog(REDIS_NOTICE,"DB loaded from disk: %.3f seconds",
(float)(ustime()-start)/1000000);
} else if (errno != ENOENT) {
Expand Down
6 changes: 3 additions & 3 deletions src/redis.h
Expand Up @@ -570,11 +570,11 @@ struct redisServer {
/* RDB persistence */
long long dirty; /* Changes to DB from the last save */
long long dirty_before_bgsave; /* Used to restore dirty on failed BGSAVE */
pid_t bgsavechildpid; /* PID of RDB saving child */
pid_t rdb_child_pid; /* PID of RDB saving child */
struct saveparam *saveparams; /* Save points array for RDB */
int saveparamslen; /* Number of saving points */
char *dbfilename; /* Name of RDB file */
int rdbcompression; /* Use compression in RDB? */
char *rdb_filename; /* Name of RDB file */
int rdb_compression; /* Use compression in RDB? */
/* Logging */
char *logfile; /* Path of log file */
int syslog_enabled; /* Is syslog enabled? */
Expand Down
12 changes: 6 additions & 6 deletions src/replication.c
Expand Up @@ -106,7 +106,7 @@ void syncCommand(redisClient *c) {
redisLog(REDIS_NOTICE,"Slave ask for synchronization");
/* Here we need to check if there is a background saving operation
* in progress, or if it is required to start one */
if (server.bgsavechildpid != -1) {
if (server.rdb_child_pid != -1) {
/* Ok a background save is in progress. Let's check if it is a good
* one for replication, i.e. if there is another slave that is
* registering differences since the server forked to save */
Expand Down Expand Up @@ -135,7 +135,7 @@ void syncCommand(redisClient *c) {
} else {
/* Ok we don't have a BGSAVE in progress, let's start one */
redisLog(REDIS_NOTICE,"Starting BGSAVE for SYNC");
if (rdbSaveBackground(server.dbfilename) != REDIS_OK) {
if (rdbSaveBackground(server.rdb_filename) != REDIS_OK) {
redisLog(REDIS_NOTICE,"Replication failed, can't BGSAVE");
addReplyError(c,"Unable to perform background save");
return;
Expand Down Expand Up @@ -229,7 +229,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr) {
redisLog(REDIS_WARNING,"SYNC failed. BGSAVE child returned an error");
continue;
}
if ((slave->repldbfd = open(server.dbfilename,O_RDONLY)) == -1 ||
if ((slave->repldbfd = open(server.rdb_filename,O_RDONLY)) == -1 ||
redis_fstat(slave->repldbfd,&buf) == -1) {
freeClient(slave);
redisLog(REDIS_WARNING,"SYNC failed. Can't open/stat DB after BGSAVE: %s", strerror(errno));
Expand All @@ -246,7 +246,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr) {
}
}
if (startbgsave) {
if (rdbSaveBackground(server.dbfilename) != REDIS_OK) {
if (rdbSaveBackground(server.rdb_filename) != REDIS_OK) {
listIter li;

listRewind(server.slaves,&li);
Expand Down Expand Up @@ -333,7 +333,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
server.repl_transfer_left -= nread;
/* Check if the transfer is now complete */
if (server.repl_transfer_left == 0) {
if (rename(server.repl_transfer_tmpfile,server.dbfilename) == -1) {
if (rename(server.repl_transfer_tmpfile,server.rdb_filename) == -1) {
redisLog(REDIS_WARNING,"Failed trying to rename the temp DB into dump.rdb in MASTER <-> SLAVE synchronization: %s", strerror(errno));
replicationAbortSyncTransfer();
return;
Expand All @@ -345,7 +345,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
* rdbLoad() will call the event loop to process events from time to
* time for non blocking loading. */
aeDeleteFileEvent(server.el,server.repl_transfer_s,AE_READABLE);
if (rdbLoad(server.dbfilename) != REDIS_OK) {
if (rdbLoad(server.rdb_filename) != REDIS_OK) {
redisLog(REDIS_WARNING,"Failed trying to load the MASTER synchronization DB from disk");
replicationAbortSyncTransfer();
return;
Expand Down

0 comments on commit f48cd4b

Please sign in to comment.