Compare commits
12
Commits
bitoprange
...
v0.9.4-r2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4ad365758 | ||
|
|
3aedcbc0af | ||
|
|
85e62208b3 | ||
|
|
e951386265 | ||
|
|
715de15c3a | ||
|
|
309dcdfd55 | ||
|
|
cac378a1e6 | ||
|
|
d7112df465 | ||
|
|
ed021c88b9 | ||
|
|
5d360ed401 | ||
|
|
8164c93d5a | ||
|
|
82621702cf |
No files matched your search
+2
-2
@@ -270,7 +270,7 @@ $(REDIS_CLI_NAME): $(REDIS_CLI_OBJ)
|
||||
$(REDIS_BENCHMARK_NAME): $(REDIS_BENCHMARK_OBJ)
|
||||
$(REDIS_LD) -o $@ $^ ../deps/hiredis/libhiredis.a $(FINAL_LIBS)
|
||||
|
||||
dict-benchmark: dict.cpp zmalloc.c sds.c siphash.c
|
||||
dict-benchmark: dict.cpp zmalloc.cpp sds.c siphash.c
|
||||
$(REDIS_CC) $(FINAL_CFLAGS) $^ -D DICT_BENCHMARK_MAIN -o $@ $(FINAL_LIBS)
|
||||
|
||||
# Because the jemalloc.h header is generated as a part of the jemalloc build,
|
||||
@@ -312,7 +312,7 @@ lcov:
|
||||
@genhtml --legend -o lcov-html redis.info
|
||||
|
||||
test-sds: sds.c sds.h
|
||||
$(REDIS_CC) sds.c zmalloc.c -DSDS_TEST_MAIN $(FINAL_LIBS) -o /tmp/sds_test
|
||||
$(REDIS_CC) sds.c zmalloc.cpp -DSDS_TEST_MAIN $(FINAL_LIBS) -o /tmp/sds_test
|
||||
/tmp/sds_test
|
||||
|
||||
.PHONY: lcov
|
||||
|
||||
@@ -399,6 +399,8 @@ void loadServerConfigFromString(char *config) {
|
||||
} else if (!strcasecmp(argv[0],"masterauth") && argc == 2) {
|
||||
zfree(server.default_masterauth);
|
||||
server.default_masterauth = argv[1][0] ? zstrdup(argv[1]) : NULL;
|
||||
// Loop through all existing master infos and update them (in case this came after the replicaof config)
|
||||
updateMasterAuth();
|
||||
} else if ((!strcasecmp(argv[0],"slave-serve-stale-data") ||
|
||||
!strcasecmp(argv[0],"replica-serve-stale-data"))
|
||||
&& argc == 2)
|
||||
|
||||
+1
-1
@@ -5077,7 +5077,7 @@ dictType moduleAPIDictType = {
|
||||
NULL /* val destructor */
|
||||
};
|
||||
|
||||
int moduleRegisterApi(const char *funcname, void *funcptr) {
|
||||
extern "C" int moduleRegisterApi(const char *funcname, void *funcptr) {
|
||||
return dictAdd(server.moduleapi, (char*)funcname, funcptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---------------- Defines common between core and modules --------------- */
|
||||
|
||||
/* Error status return values. */
|
||||
@@ -538,4 +542,9 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
|
||||
#define RedisModuleString robj
|
||||
|
||||
#endif /* REDISMODULE_CORE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* REDISMOUDLE_H */
|
||||
@@ -2263,6 +2263,13 @@ struct redisMaster *replicationAddMaster(char *ip, int port) {
|
||||
return mi;
|
||||
}
|
||||
|
||||
void freeMasterInfo(redisMaster *mi)
|
||||
{
|
||||
zfree(mi->masterauth);
|
||||
zfree(mi->masteruser);
|
||||
zfree(mi);
|
||||
}
|
||||
|
||||
/* Cancel replication, setting the instance as a master itself. */
|
||||
void replicationUnsetMaster(redisMaster *mi) {
|
||||
serverAssert(mi->masterhost != NULL);
|
||||
@@ -2305,6 +2312,7 @@ void replicationUnsetMaster(redisMaster *mi) {
|
||||
listNode *ln = listSearchKey(server.masters, mi);
|
||||
serverAssert(ln != nullptr);
|
||||
listDelNode(server.masters, ln);
|
||||
freeMasterInfo(mi);
|
||||
}
|
||||
|
||||
/* This function is called when the slave lose the connection with the
|
||||
@@ -3186,4 +3194,23 @@ void replicaReplayCommand(client *c)
|
||||
// call() will not propogate this for us, so we do so here
|
||||
alsoPropagate(server.rreplayCommand,c->db->id,c->argv,c->argc,PROPAGATE_AOF|PROPAGATE_REPL);
|
||||
return;
|
||||
}
|
||||
|
||||
void updateMasterAuth()
|
||||
{
|
||||
listIter li;
|
||||
listNode *ln;
|
||||
|
||||
listRewind(server.masters, &li);
|
||||
while ((ln = listNext(&li)))
|
||||
{
|
||||
redisMaster *mi = (redisMaster*)listNodeValue(ln);
|
||||
zfree(mi->masterauth); mi->masterauth = nullptr;
|
||||
zfree(mi->masteruser); mi->masteruser = nullptr;
|
||||
|
||||
if (server.default_masterauth)
|
||||
mi->masterauth = zstrdup(server.default_masterauth);
|
||||
if (server.default_masteruser)
|
||||
mi->masteruser = zstrdup(server.default_masteruser);
|
||||
}
|
||||
}
|
||||
@@ -1824,6 +1824,7 @@ void clearReplicationId2(void);
|
||||
void chopReplicationBacklog(void);
|
||||
void replicationCacheMasterUsingMyself(struct redisMaster *mi);
|
||||
void feedReplicationBacklog(const void *ptr, size_t len);
|
||||
void updateMasterAuth();
|
||||
|
||||
/* Generic persistence functions */
|
||||
void startLoading(FILE *fp);
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
#define REDIS_VERSION "0.9.2"
|
||||
#define REDIS_VERSION "0.9.4-r2"
|
||||
@@ -36,7 +36,7 @@
|
||||
* for instance to free results obtained by backtrace_symbols(). We need
|
||||
* to define this function before including zmalloc.h that may shadow the
|
||||
* free implementation if we use jemalloc or another non standard allocator. */
|
||||
void zlibc_free(void *ptr) {
|
||||
extern "C" void zlibc_free(void *ptr) {
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
@@ -49,13 +49,16 @@ void zlibc_free(void *ptr) {
|
||||
#ifdef HAVE_MALLOC_SIZE
|
||||
#define PREFIX_SIZE (0)
|
||||
#else
|
||||
#define PREFIX_SIZE 16
|
||||
#if defined(__sun) || defined(__sparc) || defined(__sparc__)
|
||||
#define PREFIX_SIZE (sizeof(long long))
|
||||
static_assert(PREFIX_SIZE >= (sizeof(long long)), "");
|
||||
#else
|
||||
#define PREFIX_SIZE (sizeof(size_t))
|
||||
static_assert(PREFIX_SIZE >= (sizeof(size_t)), "");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static_assert((PREFIX_SIZE % 16) == 0, "Our prefix must be modulo 16-bytes or our pointers will not be aligned");
|
||||
|
||||
/* Explicitly override malloc/free etc when using tcmalloc. */
|
||||
#if defined(USE_MEMKIND)
|
||||
#define malloc(size, type) salloc(size, type)
|
||||
@@ -104,9 +107,9 @@ static void zmalloc_default_oom(size_t size) {
|
||||
|
||||
static void (*zmalloc_oom_handler)(size_t) = zmalloc_default_oom;
|
||||
|
||||
void *zmalloc(size_t size, enum MALLOC_CLASS class) {
|
||||
(void)class;
|
||||
void *ptr = malloc(size+PREFIX_SIZE, class);
|
||||
void *zmalloc(size_t size, enum MALLOC_CLASS mclass) {
|
||||
(void)mclass;
|
||||
void *ptr = malloc(size+PREFIX_SIZE, mclass);
|
||||
|
||||
if (!ptr) zmalloc_oom_handler(size);
|
||||
#ifdef HAVE_MALLOC_SIZE
|
||||
@@ -137,9 +140,9 @@ void zfree_no_tcache(void *ptr) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void *zcalloc(size_t size, enum MALLOC_CLASS class) {
|
||||
(void)(class);
|
||||
void *ptr = calloc(1, size+PREFIX_SIZE, class);
|
||||
void *zcalloc(size_t size, enum MALLOC_CLASS mclass) {
|
||||
(void)(mclass);
|
||||
void *ptr = calloc(1, size+PREFIX_SIZE, mclass);
|
||||
|
||||
if (!ptr) zmalloc_oom_handler(size);
|
||||
#ifdef HAVE_MALLOC_SIZE
|
||||
@@ -152,7 +155,7 @@ void *zcalloc(size_t size, enum MALLOC_CLASS class) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void *zrealloc(void *ptr, size_t size, enum MALLOC_CLASS class) {
|
||||
void *zrealloc(void *ptr, size_t size, enum MALLOC_CLASS mclass) {
|
||||
#ifndef HAVE_MALLOC_SIZE
|
||||
void *realptr;
|
||||
#endif
|
||||
@@ -163,10 +166,10 @@ void *zrealloc(void *ptr, size_t size, enum MALLOC_CLASS class) {
|
||||
zfree(ptr);
|
||||
return NULL;
|
||||
}
|
||||
if (ptr == NULL) return zmalloc(size, class);
|
||||
if (ptr == NULL) return zmalloc(size, mclass);
|
||||
#ifdef HAVE_MALLOC_SIZE
|
||||
oldsize = zmalloc_size(ptr);
|
||||
newptr = realloc(ptr,size, class);
|
||||
newptr = realloc(ptr,size, mclass);
|
||||
if (!newptr) zmalloc_oom_handler(size);
|
||||
|
||||
update_zmalloc_stat_free(oldsize);
|
||||
@@ -175,7 +178,7 @@ void *zrealloc(void *ptr, size_t size, enum MALLOC_CLASS class) {
|
||||
#else
|
||||
realptr = (char*)ptr-PREFIX_SIZE;
|
||||
oldsize = *((size_t*)realptr);
|
||||
newptr = realloc(realptr,size+PREFIX_SIZE, class);
|
||||
newptr = realloc(realptr,size+PREFIX_SIZE, mclass);
|
||||
if (!newptr) zmalloc_oom_handler(size);
|
||||
|
||||
*((size_t*)newptr) = size;
|
||||
@@ -222,7 +225,7 @@ void zfree(void *ptr) {
|
||||
|
||||
char *zstrdup(const char *s) {
|
||||
size_t l = strlen(s)+1;
|
||||
char *p = zmalloc(l, MALLOC_SHARED);
|
||||
char *p = (char*)zmalloc(l, MALLOC_SHARED);
|
||||
|
||||
memcpy(p,s,l);
|
||||
return p;
|
||||
Reference in new issue
Block a user