Skip to content

Commit dde65f3

Browse files
committed
added config.h for #ifdef business isolation, added fstat64 for Mac OS X
1 parent ec93bba commit dde65f3

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

TODO

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
BEFORE REDIS 1.0.0-rc1
22

33
* Add number of keys for every DB in INFO
4-
* maxmemory support
54
* Resize the expires and Sets hash tables if needed as well? For Sets the right moment to check for this is probably in SREM
65
* What happens if the saving child gets killed or segfaults instead of ending normally? Handle this.
76
* check 'server.dirty' everywere. Make it proprotional to the number of objects modified.
87
* 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.
9-
* Objects sharing configuration, add the directive `objectsharingpool <size>`
108
* Make sure to convert all the fstat() calls to 64bit versions.
119
* Cover most of the source code with test-redis.tcl
1210

config.h

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef __CONFIG_H
2+
#define __CONFIG_H
3+
4+
/* malloc_size() */
5+
#ifdef __APPLE__
6+
#include <malloc/malloc.h>
7+
#define HAVE_MALLOC_SIZE
8+
#define redis_malloc_size(p) malloc_size(p)
9+
#endif
10+
11+
/* define redis_fstat to fstat or fstat64() */
12+
#ifdef __APPLE__
13+
#define redis_fstat fstat64
14+
#define redis_stat stat64
15+
#else
16+
#define redis_fstat fstat
17+
#define redis_stat stat
18+
#endif
19+
20+
#endif

redis.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@
6060
#include "lzf.h" /* LZF compression library */
6161
#include "pqsort.h" /* Partial qsort for SORT+LIMIT */
6262

63+
#include "config.h"
64+
6365
/* Error codes */
6466
#define REDIS_OK 0
6567
#define REDIS_ERR -1
@@ -3866,15 +3868,15 @@ static void updateSalvesWaitingBgsave(int bgsaveerr) {
38663868
startbgsave = 1;
38673869
slave->replstate = REDIS_REPL_WAIT_BGSAVE_END;
38683870
} else if (slave->replstate == REDIS_REPL_WAIT_BGSAVE_END) {
3869-
struct stat buf;
3871+
struct redis_stat buf;
38703872

38713873
if (bgsaveerr != REDIS_OK) {
38723874
freeClient(slave);
38733875
redisLog(REDIS_WARNING,"SYNC failed. BGSAVE child returned an error");
38743876
continue;
38753877
}
38763878
if ((slave->repldbfd = open(server.dbfilename,O_RDONLY)) == -1 ||
3877-
fstat(slave->repldbfd,&buf) == -1) {
3879+
redis_fstat(slave->repldbfd,&buf) == -1) {
38783880
freeClient(slave);
38793881
redisLog(REDIS_WARNING,"SYNC failed. Can't open/stat DB after BGSAVE: %s", strerror(errno));
38803882
continue;

zmalloc.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@
3030

3131
#include <stdlib.h>
3232
#include <string.h>
33-
34-
#ifdef __APPLE__
35-
#include <malloc/malloc.h>
36-
#define HAVE_MALLOC_SIZE
37-
#define redis_malloc_size(p) malloc_size(p)
38-
#endif
33+
#include "config.h"
3934

4035
static size_t used_memory = 0;
4136

0 commit comments

Comments
 (0)