Skip to content

Commit

Permalink
added config.h for #ifdef business isolation, added fstat64 for Mac OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jun 5, 2009
1 parent ec93bba commit dde65f3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -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 <size>`
* Make sure to convert all the fstat() calls to 64bit versions.
* Cover most of the source code with test-redis.tcl

Expand Down
20 changes: 20 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#ifndef __CONFIG_H
#define __CONFIG_H

/* malloc_size() */
#ifdef __APPLE__
#include <malloc/malloc.h>
#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
6 changes: 4 additions & 2 deletions redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3866,15 +3868,15 @@ 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);
redisLog(REDIS_WARNING,"SYNC failed. BGSAVE child returned an error");
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;
Expand Down
7 changes: 1 addition & 6 deletions zmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@

#include <stdlib.h>
#include <string.h>

#ifdef __APPLE__
#include <malloc/malloc.h>
#define HAVE_MALLOC_SIZE
#define redis_malloc_size(p) malloc_size(p)
#endif
#include "config.h"

static size_t used_memory = 0;

Expand Down

0 comments on commit dde65f3

Please sign in to comment.