From f48cd4b90cc298a74ded3f7adc45740a4dd1a9c1 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 21 Dec 2011 12:22:13 +0100 Subject: [PATCH] some RDB server struct fields renamed. --- src/aof.c | 4 ++-- src/config.c | 12 ++++++------ src/db.c | 10 +++++----- src/debug.c | 4 ++-- src/rdb.c | 18 +++++++++--------- src/redis.c | 32 ++++++++++++++++---------------- src/redis.h | 6 +++--- src/replication.c | 12 ++++++------ 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/aof.c b/src/aof.c index c50611b9..b1f3c693 100644 --- a/src/aof.c +++ b/src/aof.c @@ -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. */ @@ -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) { diff --git a/src/config.c b/src/config.c index 007d4913..f74f3f97 100644 --- a/src/config.c +++ b/src/config.c @@ -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) { @@ -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) { @@ -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; @@ -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)) { diff --git a/src/db.c b/src/db.c index 0b6ce045..f7d93e08 100644 --- a/src/db.c +++ b/src/db.c @@ -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; @@ -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++; diff --git a/src/debug.c b/src/debug.c index bc496fb3..d218f0f9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -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; } diff --git a/src/rdb.c b/src/rdb.c index a401fe89..77e2a048 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -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; @@ -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; @@ -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; } @@ -1062,20 +1062,20 @@ 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); @@ -1083,11 +1083,11 @@ void saveCommand(redisClient *c) { } 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); diff --git a/src/redis.c b/src/redis.c index 6236f603..da975636 100644 --- a/src/redis.c +++ b/src/redis.c @@ -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(); @@ -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(); } @@ -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; @@ -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); @@ -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) @@ -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; @@ -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(); @@ -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 @@ -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 @@ -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); @@ -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) { diff --git a/src/redis.h b/src/redis.h index 2010f19b..86fd47c6 100644 --- a/src/redis.h +++ b/src/redis.h @@ -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? */ diff --git a/src/replication.c b/src/replication.c index d671acc2..3424ff36 100644 --- a/src/replication.c +++ b/src/replication.c @@ -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 */ @@ -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; @@ -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)); @@ -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); @@ -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; @@ -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; -- 2.45.2