From dde65f3f3c9949570cf19fb56e35ba195b48227d Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 5 Jun 2009 10:50:51 +0200 Subject: [PATCH] added config.h for #ifdef business isolation, added fstat64 for Mac OS X --- TODO | 2 -- config.h | 20 ++++++++++++++++++++ redis.c | 6 ++++-- zmalloc.c | 7 +------ 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 config.h diff --git a/TODO b/TODO index 4fff80a8..0540346f 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,10 @@ BEFORE REDIS 1.0.0-rc1 * Add number of keys for every DB in INFO - * maxmemory support * Resize the expires and Sets hash tables if needed as well? For Sets the right moment to check for this is probably in SREM * What happens if the saving child gets killed or segfaults instead of ending normally? Handle this. * check 'server.dirty' everywere. Make it proprotional to the number of objects modified. * Shutdown must kill other background savings before to start saving. Otherwise the DB can get replaced by the child that rename(2) after the parent for some reason. Child should trap the signal and remove the temp file name. - * Objects sharing configuration, add the directive `objectsharingpool ` * Make sure to convert all the fstat() calls to 64bit versions. * Cover most of the source code with test-redis.tcl diff --git a/config.h b/config.h new file mode 100644 index 00000000..79240b75 --- /dev/null +++ b/config.h @@ -0,0 +1,20 @@ +#ifndef __CONFIG_H +#define __CONFIG_H + +/* malloc_size() */ +#ifdef __APPLE__ +#include +#define HAVE_MALLOC_SIZE +#define redis_malloc_size(p) malloc_size(p) +#endif + +/* define redis_fstat to fstat or fstat64() */ +#ifdef __APPLE__ +#define redis_fstat fstat64 +#define redis_stat stat64 +#else +#define redis_fstat fstat +#define redis_stat stat +#endif + +#endif diff --git a/redis.c b/redis.c index 39d45a2d..28e1c64f 100644 --- a/redis.c +++ b/redis.c @@ -60,6 +60,8 @@ #include "lzf.h" /* LZF compression library */ #include "pqsort.h" /* Partial qsort for SORT+LIMIT */ +#include "config.h" + /* Error codes */ #define REDIS_OK 0 #define REDIS_ERR -1 @@ -3866,7 +3868,7 @@ static void updateSalvesWaitingBgsave(int bgsaveerr) { startbgsave = 1; slave->replstate = REDIS_REPL_WAIT_BGSAVE_END; } else if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_END) { - struct stat buf; + struct redis_stat buf; if (bgsaveerr != REDIS_OK) { freeClient(slave); @@ -3874,7 +3876,7 @@ static void updateSalvesWaitingBgsave(int bgsaveerr) { continue; } if ((slave->repldbfd = open(server.dbfilename,O_RDONLY)) == -1 || - fstat(slave->repldbfd,&buf) == -1) { + redis_fstat(slave->repldbfd,&buf) == -1) { freeClient(slave); redisLog(REDIS_WARNING,"SYNC failed. Can't open/stat DB after BGSAVE: %s", strerror(errno)); continue; diff --git a/zmalloc.c b/zmalloc.c index 4cb2c53c..c813d6b8 100644 --- a/zmalloc.c +++ b/zmalloc.c @@ -30,12 +30,7 @@ #include #include - -#ifdef __APPLE__ -#include -#define HAVE_MALLOC_SIZE -#define redis_malloc_size(p) malloc_size(p) -#endif +#include "config.h" static size_t used_memory = 0; -- 2.45.2