Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
7b45bfb2
Commit
7b45bfb2
authored
Mar 25, 2009
by
antirez
Browse files
New protocol fix for LREM
parent
4e405577
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis.c
View file @
7b45bfb2
...
@@ -215,7 +215,7 @@ typedef struct _redisSortOperation {
...
@@ -215,7 +215,7 @@ typedef struct _redisSortOperation {
struct sharedObjectsStruct {
struct sharedObjectsStruct {
robj *crlf, *ok, *err, *emptybulk, *czero, *cone, *pong, *space,
robj *crlf, *ok, *err, *emptybulk, *czero, *cone, *pong, *space,
*colon,
*minus1,
*nullbulk, *nullmultibulk,
*colon, *nullbulk, *nullmultibulk,
*emptymultibulk, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr,
*emptymultibulk, *wrongtypeerr, *nokeyerr, *syntaxerr, *sameobjecterr,
*outofrangeerr, *plus,
*outofrangeerr, *plus,
*select0, *select1, *select2, *select3, *select4,
*select0, *select1, *select2, *select3, *select4,
...
@@ -667,7 +667,6 @@ static void createSharedObjects(void) {
...
@@ -667,7 +667,6 @@ static void createSharedObjects(void) {
shared.nullmultibulk = createObject(REDIS_STRING,sdsnew("*-1\r\n"));
shared.nullmultibulk = createObject(REDIS_STRING,sdsnew("*-1\r\n"));
shared.emptymultibulk = createObject(REDIS_STRING,sdsnew("*0\r\n"));
shared.emptymultibulk = createObject(REDIS_STRING,sdsnew("*0\r\n"));
/* no such key */
/* no such key */
shared.minus1 = createObject(REDIS_STRING,sdsnew("-1\r\n"));
shared.pong = createObject(REDIS_STRING,sdsnew("+PONG\r\n"));
shared.pong = createObject(REDIS_STRING,sdsnew("+PONG\r\n"));
shared.wrongtypeerr = createObject(REDIS_STRING,sdsnew(
shared.wrongtypeerr = createObject(REDIS_STRING,sdsnew(
"-ERR Operation against a key holding the wrong kind of value\r\n"));
"-ERR Operation against a key holding the wrong kind of value\r\n"));
...
@@ -1532,13 +1531,19 @@ static int saveDbBackground(char *filename) {
...
@@ -1532,13 +1531,19 @@ static int saveDbBackground(char *filename) {
return REDIS_OK; /* unreached */
return REDIS_OK; /* unreached */
}
}
static int loadType(FILE *fp) {
uint8_t type;
if (fread(&type,1,1,fp) == 0) return -1;
return type;
}
static int loadDb(char *filename) {
static int loadDb(char *filename) {
FILE *fp;
FILE *fp;
char buf[REDIS_LOADBUF_LEN]; /* Try to use this buffer instead of */
char buf[REDIS_LOADBUF_LEN]; /* Try to use this buffer instead of */
char vbuf[REDIS_LOADBUF_LEN]; /* malloc() when the element is small */
char vbuf[REDIS_LOADBUF_LEN]; /* malloc() when the element is small */
char *key = NULL, *val = NULL;
char *key = NULL, *val = NULL;
uint32_t klen,vlen,dbid;
uint32_t klen,vlen,dbid;
u
int
8_t
type;
int type;
int retval;
int retval;
dict *d = server.dict[0];
dict *d = server.dict[0];
...
@@ -1554,7 +1559,7 @@ static int loadDb(char *filename) {
...
@@ -1554,7 +1559,7 @@ static int loadDb(char *filename) {
robj *o;
robj *o;
/* Read type. */
/* Read type. */
if (
fread(&type,1,1,
fp) ==
0
) goto eoferr;
if (
(type = loadType(
fp)
)
==
-1
) goto eoferr;
if (type == REDIS_EOF) break;
if (type == REDIS_EOF) break;
/* Handle SELECT DB opcode as a special case */
/* Handle SELECT DB opcode as a special case */
if (type == REDIS_SELECTDB) {
if (type == REDIS_SELECTDB) {
...
@@ -2280,7 +2285,7 @@ static void lremCommand(redisClient *c) {
...
@@ -2280,7 +2285,7 @@ static void lremCommand(redisClient *c) {
de = dictFind(c->dict,c->argv[1]);
de = dictFind(c->dict,c->argv[1]);
if (de == NULL) {
if (de == NULL) {
addReply(c,shared.
minus1
);
addReply(c,shared.
nokeyerr
);
} else {
} else {
robj *o = dictGetEntryVal(de);
robj *o = dictGetEntryVal(de);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment