diff options
author | antirez <antirez@gmail.com> | 2012-03-20 17:32:48 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2012-03-20 17:32:48 +0100 |
commit | f3fd419fc95e78818f9eeef15eb2d2e5a60bfbbb (patch) | |
tree | 03e75d79523ef181aaf689de2ea4d0e78af73169 /src/multi.c | |
parent | 7a0c72f34550c3811324464661f1b463ccfd362b (diff) | |
download | redis-f3fd419fc95e78818f9eeef15eb2d2e5a60bfbbb.tar.gz |
Support for read-only slaves. Semantical fixes.
This commit introduces support for read only slaves via redis.conf and CONFIG GET/SET commands. Also various semantical fixes are implemented here:
1) MULTI/EXEC with only read commands now work where the server is into a state where writes (or commands increasing memory usage) are not allowed. Before this patch everything inside a transaction would fail in this conditions.
2) Scripts just calling read-only commands will work against read only
slaves, when the server is out of memory, or when persistence is into an
error condition. Before the patch EVAL always failed in this condition.
Diffstat (limited to 'src/multi.c')
-rw-r--r-- | src/multi.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/multi.c b/src/multi.c index 65ec38a8d..eee9748c5 100644 --- a/src/multi.c +++ b/src/multi.c @@ -40,6 +40,13 @@ void queueMultiCommand(redisClient *c) { c->mstate.count++; } +void discardTransaction(redisClient *c) { + freeClientMultiState(c); + initClientMultiState(c); + c->flags &= ~(REDIS_MULTI|REDIS_DIRTY_CAS);; + unwatchAllKeys(c); +} + void multiCommand(redisClient *c) { if (c->flags & REDIS_MULTI) { addReplyError(c,"MULTI calls can not be nested"); @@ -54,11 +61,7 @@ void discardCommand(redisClient *c) { addReplyError(c,"DISCARD without MULTI"); return; } - - freeClientMultiState(c); - initClientMultiState(c); - c->flags &= ~(REDIS_MULTI|REDIS_DIRTY_CAS);; - unwatchAllKeys(c); + discardTransaction(c); addReply(c,shared.ok); } |