Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
eab0e26e
Commit
eab0e26e
authored
Oct 04, 2011
by
antirez
Browse files
replaced redisAssert() with redisAssertWithInfo() in a shitload of places.
parent
bab205f7
Changes
14
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
eab0e26e
...
@@ -1232,7 +1232,7 @@ void clusterCommand(redisClient *c) {
...
@@ -1232,7 +1232,7 @@ void clusterCommand(redisClient *c) {
retval
=
del
?
clusterDelSlot
(
j
)
:
retval
=
del
?
clusterDelSlot
(
j
)
:
clusterAddSlot
(
server
.
cluster
.
myself
,
j
);
clusterAddSlot
(
server
.
cluster
.
myself
,
j
);
redisAssert
(
retval
==
REDIS_OK
);
redisAssert
WithInfo
(
c
,
NULL
,
retval
==
REDIS_OK
);
}
}
}
}
zfree
(
slots
);
zfree
(
slots
);
...
@@ -1462,23 +1462,23 @@ void migrateCommand(redisClient *c) {
...
@@ -1462,23 +1462,23 @@ void migrateCommand(redisClient *c) {
}
}
rioInitWithBuffer
(
&
cmd
,
sdsempty
());
rioInitWithBuffer
(
&
cmd
,
sdsempty
());
redisAssert
(
rioWriteBulkCount
(
&
cmd
,
'*'
,
2
));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
2
));
redisAssert
(
rioWriteBulkString
(
&
cmd
,
"SELECT"
,
6
));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"SELECT"
,
6
));
redisAssert
(
rioWriteBulkLongLong
(
&
cmd
,
dbid
));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkLongLong
(
&
cmd
,
dbid
));
ttl
=
getExpire
(
c
->
db
,
c
->
argv
[
3
]);
ttl
=
getExpire
(
c
->
db
,
c
->
argv
[
3
]);
redisAssert
(
rioWriteBulkCount
(
&
cmd
,
'*'
,
4
));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
4
));
redisAssert
(
rioWriteBulkString
(
&
cmd
,
"RESTORE"
,
7
));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"RESTORE"
,
7
));
redisAssert
(
c
->
argv
[
3
]
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
argv
[
3
]
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
(
rioWriteBulkString
(
&
cmd
,
c
->
argv
[
3
]
->
ptr
,
sdslen
(
c
->
argv
[
3
]
->
ptr
)));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
c
->
argv
[
3
]
->
ptr
,
sdslen
(
c
->
argv
[
3
]
->
ptr
)));
redisAssert
(
rioWriteBulkLongLong
(
&
cmd
,(
ttl
==
-
1
)
?
0
:
ttl
));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkLongLong
(
&
cmd
,(
ttl
==
-
1
)
?
0
:
ttl
));
/* Finally the last argument that is the serailized object payload
/* Finally the last argument that is the serailized object payload
* in the form: <type><rdb-serialized-object>. */
* in the form: <type><rdb-serialized-object>. */
rioInitWithBuffer
(
&
payload
,
sdsempty
());
rioInitWithBuffer
(
&
payload
,
sdsempty
());
redisAssert
(
rdbSaveObjectType
(
&
payload
,
o
));
redisAssert
WithInfo
(
c
,
NULL
,
rdbSaveObjectType
(
&
payload
,
o
));
redisAssert
(
rdbSaveObject
(
&
payload
,
o
)
!=
-
1
);
redisAssert
WithInfo
(
c
,
NULL
,
rdbSaveObject
(
&
payload
,
o
)
!=
-
1
);
redisAssert
(
rioWriteBulkString
(
&
cmd
,
payload
.
io
.
buffer
.
ptr
,
sdslen
(
payload
.
io
.
buffer
.
ptr
)));
redisAssert
WithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
payload
.
io
.
buffer
.
ptr
,
sdslen
(
payload
.
io
.
buffer
.
ptr
)));
sdsfree
(
payload
.
io
.
buffer
.
ptr
);
sdsfree
(
payload
.
io
.
buffer
.
ptr
);
/* Tranfer the query to the other node in 64K chunks. */
/* Tranfer the query to the other node in 64K chunks. */
...
@@ -1561,8 +1561,8 @@ void dumpCommand(redisClient *c) {
...
@@ -1561,8 +1561,8 @@ void dumpCommand(redisClient *c) {
/* Serialize the object in a RDB-like format. It consist of an object type
/* Serialize the object in a RDB-like format. It consist of an object type
* byte followed by the serialized object. This is understood by RESTORE. */
* byte followed by the serialized object. This is understood by RESTORE. */
rioInitWithBuffer
(
&
payload
,
sdsempty
());
rioInitWithBuffer
(
&
payload
,
sdsempty
());
redisAssert
(
rdbSaveObjectType
(
&
payload
,
o
));
redisAssert
WithInfo
(
c
,
NULL
,
rdbSaveObjectType
(
&
payload
,
o
));
redisAssert
(
rdbSaveObject
(
&
payload
,
o
));
redisAssert
WithInfo
(
c
,
NULL
,
rdbSaveObject
(
&
payload
,
o
));
/* Transfer to the client */
/* Transfer to the client */
dumpobj
=
createObject
(
REDIS_STRING
,
payload
.
io
.
buffer
.
ptr
);
dumpobj
=
createObject
(
REDIS_STRING
,
payload
.
io
.
buffer
.
ptr
);
...
@@ -1632,7 +1632,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg
...
@@ -1632,7 +1632,7 @@ clusterNode *getNodeByQuery(redisClient *c, struct redisCommand *cmd, robj **arg
slot
=
keyHashSlot
((
char
*
)
firstkey
->
ptr
,
sdslen
(
firstkey
->
ptr
));
slot
=
keyHashSlot
((
char
*
)
firstkey
->
ptr
,
sdslen
(
firstkey
->
ptr
));
n
=
server
.
cluster
.
slots
[
slot
];
n
=
server
.
cluster
.
slots
[
slot
];
redisAssert
(
n
!=
NULL
);
redisAssert
WithInfo
(
c
,
firstkey
,
n
!=
NULL
);
}
else
{
}
else
{
/* If it is not the first key, make sure it is exactly
/* If it is not the first key, make sure it is exactly
* the same key as the first we saw. */
* the same key as the first we saw. */
...
...
src/config.c
View file @
eab0e26e
...
@@ -330,8 +330,8 @@ loaderr:
...
@@ -330,8 +330,8 @@ loaderr:
void
configSetCommand
(
redisClient
*
c
)
{
void
configSetCommand
(
redisClient
*
c
)
{
robj
*
o
;
robj
*
o
;
long
long
ll
;
long
long
ll
;
redisAssert
(
c
->
argv
[
2
]
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
c
,
c
->
argv
[
2
],
c
->
argv
[
2
]
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
(
c
->
argv
[
3
]
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
c
,
c
->
argv
[
2
],
c
->
argv
[
3
]
->
encoding
==
REDIS_ENCODING_RAW
);
o
=
c
->
argv
[
3
];
o
=
c
->
argv
[
3
];
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"dbfilename"
))
{
if
(
!
strcasecmp
(
c
->
argv
[
2
]
->
ptr
,
"dbfilename"
))
{
...
@@ -503,7 +503,7 @@ void configGetCommand(redisClient *c) {
...
@@ -503,7 +503,7 @@ void configGetCommand(redisClient *c) {
char
*
pattern
=
o
->
ptr
;
char
*
pattern
=
o
->
ptr
;
char
buf
[
128
];
char
buf
[
128
];
int
matches
=
0
;
int
matches
=
0
;
redisAssert
(
o
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
c
,
o
,
o
->
encoding
==
REDIS_ENCODING_RAW
);
if
(
stringmatch
(
pattern
,
"dir"
,
0
))
{
if
(
stringmatch
(
pattern
,
"dir"
,
0
))
{
char
buf
[
1024
];
char
buf
[
1024
];
...
...
src/db.c
View file @
eab0e26e
...
@@ -79,7 +79,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
...
@@ -79,7 +79,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
sds
copy
=
sdsdup
(
key
->
ptr
);
sds
copy
=
sdsdup
(
key
->
ptr
);
int
retval
=
dictAdd
(
db
->
dict
,
copy
,
val
);
int
retval
=
dictAdd
(
db
->
dict
,
copy
,
val
);
redisAssert
(
retval
==
REDIS_OK
);
redisAssert
WithInfo
(
NULL
,
key
,
retval
==
REDIS_OK
);
if
(
server
.
cluster_enabled
)
SlotToKeyAdd
(
key
);
if
(
server
.
cluster_enabled
)
SlotToKeyAdd
(
key
);
}
}
...
@@ -91,7 +91,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
...
@@ -91,7 +91,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
void
dbOverwrite
(
redisDb
*
db
,
robj
*
key
,
robj
*
val
)
{
void
dbOverwrite
(
redisDb
*
db
,
robj
*
key
,
robj
*
val
)
{
struct
dictEntry
*
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
struct
dictEntry
*
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
redisAssert
(
de
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
key
,
de
!=
NULL
);
dictReplace
(
db
->
dict
,
key
->
ptr
,
val
);
dictReplace
(
db
->
dict
,
key
->
ptr
,
val
);
}
}
...
@@ -419,7 +419,7 @@ void moveCommand(redisClient *c) {
...
@@ -419,7 +419,7 @@ void moveCommand(redisClient *c) {
int
removeExpire
(
redisDb
*
db
,
robj
*
key
)
{
int
removeExpire
(
redisDb
*
db
,
robj
*
key
)
{
/* An expire may only be removed if there is a corresponding entry in the
/* An expire may only be removed if there is a corresponding entry in the
* main dict. Otherwise, the key will never be freed. */
* main dict. Otherwise, the key will never be freed. */
redisAssert
(
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
return
dictDelete
(
db
->
expires
,
key
->
ptr
)
==
DICT_OK
;
return
dictDelete
(
db
->
expires
,
key
->
ptr
)
==
DICT_OK
;
}
}
...
@@ -428,7 +428,7 @@ void setExpire(redisDb *db, robj *key, time_t when) {
...
@@ -428,7 +428,7 @@ void setExpire(redisDb *db, robj *key, time_t when) {
/* Reuse the sds from the main dict in the expire dict */
/* Reuse the sds from the main dict in the expire dict */
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
redisAssert
(
de
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
key
,
de
!=
NULL
);
dictReplace
(
db
->
expires
,
dictGetEntryKey
(
de
),(
void
*
)
when
);
dictReplace
(
db
->
expires
,
dictGetEntryKey
(
de
),(
void
*
)
when
);
}
}
...
@@ -443,7 +443,7 @@ time_t getExpire(redisDb *db, robj *key) {
...
@@ -443,7 +443,7 @@ time_t getExpire(redisDb *db, robj *key) {
/* The entry was found in the expire dict, this means it should also
/* The entry was found in the expire dict, this means it should also
* be present in the main dict (safety check). */
* be present in the main dict (safety check). */
redisAssert
(
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
return
(
time_t
)
dictGetEntryVal
(
de
);
return
(
time_t
)
dictGetEntryVal
(
de
);
}
}
...
@@ -525,7 +525,7 @@ void expireGenericCommand(redisClient *c, robj *key, robj *param, long offset) {
...
@@ -525,7 +525,7 @@ void expireGenericCommand(redisClient *c, robj *key, robj *param, long offset) {
if
(
seconds
<=
0
&&
!
server
.
loading
&&
!
server
.
masterhost
)
{
if
(
seconds
<=
0
&&
!
server
.
loading
&&
!
server
.
masterhost
)
{
robj
*
aux
;
robj
*
aux
;
redisAssert
(
dbDelete
(
c
->
db
,
key
));
redisAssert
WithInfo
(
c
,
key
,
dbDelete
(
c
->
db
,
key
));
server
.
dirty
++
;
server
.
dirty
++
;
/* Replicate/AOF this as an explicit DEL. */
/* Replicate/AOF this as an explicit DEL. */
...
...
src/multi.c
View file @
eab0e26e
...
@@ -194,7 +194,7 @@ void unwatchAllKeys(redisClient *c) {
...
@@ -194,7 +194,7 @@ void unwatchAllKeys(redisClient *c) {
* from the list */
* from the list */
wk
=
listNodeValue
(
ln
);
wk
=
listNodeValue
(
ln
);
clients
=
dictFetchValue
(
wk
->
db
->
watched_keys
,
wk
->
key
);
clients
=
dictFetchValue
(
wk
->
db
->
watched_keys
,
wk
->
key
);
redisAssert
(
clients
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
clients
!=
NULL
);
listDelNode
(
clients
,
listSearchKey
(
clients
,
c
));
listDelNode
(
clients
,
listSearchKey
(
clients
,
c
));
/* Kill the entry at all if this was the only client */
/* Kill the entry at all if this was the only client */
if
(
listLength
(
clients
)
==
0
)
if
(
listLength
(
clients
)
==
0
)
...
...
src/networking.c
View file @
eab0e26e
...
@@ -703,7 +703,7 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -703,7 +703,7 @@ int processMultibulkBuffer(redisClient *c) {
if
(
c
->
multibulklen
==
0
)
{
if
(
c
->
multibulklen
==
0
)
{
/* The client should have been reset */
/* The client should have been reset */
redisAssert
(
c
->
argc
==
0
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
argc
==
0
);
/* Multi bulk length cannot be read without a \r\n */
/* Multi bulk length cannot be read without a \r\n */
newline
=
strchr
(
c
->
querybuf
,
'\r'
);
newline
=
strchr
(
c
->
querybuf
,
'\r'
);
...
@@ -716,7 +716,7 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -716,7 +716,7 @@ int processMultibulkBuffer(redisClient *c) {
/* We know for sure there is a whole line since newline != NULL,
/* We know for sure there is a whole line since newline != NULL,
* so go ahead and find out the multi bulk length. */
* so go ahead and find out the multi bulk length. */
redisAssert
(
c
->
querybuf
[
0
]
==
'*'
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
querybuf
[
0
]
==
'*'
);
ok
=
string2ll
(
c
->
querybuf
+
1
,
newline
-
(
c
->
querybuf
+
1
),
&
ll
);
ok
=
string2ll
(
c
->
querybuf
+
1
,
newline
-
(
c
->
querybuf
+
1
),
&
ll
);
if
(
!
ok
||
ll
>
1024
*
1024
)
{
if
(
!
ok
||
ll
>
1024
*
1024
)
{
addReplyError
(
c
,
"Protocol error: invalid multibulk length"
);
addReplyError
(
c
,
"Protocol error: invalid multibulk length"
);
...
@@ -737,7 +737,7 @@ int processMultibulkBuffer(redisClient *c) {
...
@@ -737,7 +737,7 @@ int processMultibulkBuffer(redisClient *c) {
c
->
argv
=
zmalloc
(
sizeof
(
robj
*
)
*
c
->
multibulklen
);
c
->
argv
=
zmalloc
(
sizeof
(
robj
*
)
*
c
->
multibulklen
);
}
}
redisAssert
(
c
->
multibulklen
>
0
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
multibulklen
>
0
);
while
(
c
->
multibulklen
)
{
while
(
c
->
multibulklen
)
{
/* Read bulk length if unknown */
/* Read bulk length if unknown */
if
(
c
->
bulklen
==
-
1
)
{
if
(
c
->
bulklen
==
-
1
)
{
...
@@ -970,7 +970,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
...
@@ -970,7 +970,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
c
->
argv
=
argv
;
c
->
argv
=
argv
;
c
->
argc
=
argc
;
c
->
argc
=
argc
;
c
->
cmd
=
lookupCommand
(
c
->
argv
[
0
]
->
ptr
);
c
->
cmd
=
lookupCommand
(
c
->
argv
[
0
]
->
ptr
);
redisAssert
(
c
->
cmd
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
va_end
(
ap
);
va_end
(
ap
);
}
}
...
@@ -979,7 +979,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
...
@@ -979,7 +979,7 @@ void rewriteClientCommandVector(redisClient *c, int argc, ...) {
void
rewriteClientCommandArgument
(
redisClient
*
c
,
int
i
,
robj
*
newval
)
{
void
rewriteClientCommandArgument
(
redisClient
*
c
,
int
i
,
robj
*
newval
)
{
robj
*
oldval
;
robj
*
oldval
;
redisAssert
(
i
<
c
->
argc
);
redisAssert
WithInfo
(
c
,
NULL
,
i
<
c
->
argc
);
oldval
=
c
->
argv
[
i
];
oldval
=
c
->
argv
[
i
];
c
->
argv
[
i
]
=
newval
;
c
->
argv
[
i
]
=
newval
;
incrRefCount
(
newval
);
incrRefCount
(
newval
);
...
@@ -988,6 +988,6 @@ void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) {
...
@@ -988,6 +988,6 @@ void rewriteClientCommandArgument(redisClient *c, int i, robj *newval) {
/* If this is the command name make sure to fix c->cmd. */
/* If this is the command name make sure to fix c->cmd. */
if
(
i
==
0
)
{
if
(
i
==
0
)
{
c
->
cmd
=
lookupCommand
(
c
->
argv
[
0
]
->
ptr
);
c
->
cmd
=
lookupCommand
(
c
->
argv
[
0
]
->
ptr
);
redisAssert
(
c
->
cmd
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
}
}
}
}
src/object.c
View file @
eab0e26e
...
@@ -45,7 +45,7 @@ robj *createStringObjectFromLongLong(long long value) {
...
@@ -45,7 +45,7 @@ robj *createStringObjectFromLongLong(long long value) {
}
}
robj
*
dupStringObject
(
robj
*
o
)
{
robj
*
dupStringObject
(
robj
*
o
)
{
redisAssert
(
o
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
encoding
==
REDIS_ENCODING_RAW
);
return
createStringObject
(
o
->
ptr
,
sdslen
(
o
->
ptr
));
return
createStringObject
(
o
->
ptr
,
sdslen
(
o
->
ptr
));
}
}
...
@@ -218,7 +218,7 @@ int checkType(redisClient *c, robj *o, int type) {
...
@@ -218,7 +218,7 @@ int checkType(redisClient *c, robj *o, int type) {
}
}
int
isObjectRepresentableAsLongLong
(
robj
*
o
,
long
long
*
llval
)
{
int
isObjectRepresentableAsLongLong
(
robj
*
o
,
long
long
*
llval
)
{
redisAssert
(
o
->
type
==
REDIS_STRING
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
type
==
REDIS_STRING
);
if
(
o
->
encoding
==
REDIS_ENCODING_INT
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_INT
)
{
if
(
llval
)
*
llval
=
(
long
)
o
->
ptr
;
if
(
llval
)
*
llval
=
(
long
)
o
->
ptr
;
return
REDIS_OK
;
return
REDIS_OK
;
...
@@ -241,7 +241,7 @@ robj *tryObjectEncoding(robj *o) {
...
@@ -241,7 +241,7 @@ robj *tryObjectEncoding(robj *o) {
if
(
o
->
refcount
>
1
)
return
o
;
if
(
o
->
refcount
>
1
)
return
o
;
/* Currently we try to encode only strings */
/* Currently we try to encode only strings */
redisAssert
(
o
->
type
==
REDIS_STRING
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
type
==
REDIS_STRING
);
/* Check if we can represent this string as a long integer */
/* Check if we can represent this string as a long integer */
if
(
!
string2l
(
s
,
sdslen
(
s
),
&
value
))
return
o
;
if
(
!
string2l
(
s
,
sdslen
(
s
),
&
value
))
return
o
;
...
@@ -296,7 +296,7 @@ robj *getDecodedObject(robj *o) {
...
@@ -296,7 +296,7 @@ robj *getDecodedObject(robj *o) {
* sdscmp() from sds.c will apply memcmp() so this function ca be considered
* sdscmp() from sds.c will apply memcmp() so this function ca be considered
* binary safe. */
* binary safe. */
int
compareStringObjects
(
robj
*
a
,
robj
*
b
)
{
int
compareStringObjects
(
robj
*
a
,
robj
*
b
)
{
redisAssert
(
a
->
type
==
REDIS_STRING
&&
b
->
type
==
REDIS_STRING
);
redisAssert
WithInfo
(
NULL
,
a
,
a
->
type
==
REDIS_STRING
&&
b
->
type
==
REDIS_STRING
);
char
bufa
[
128
],
bufb
[
128
],
*
astr
,
*
bstr
;
char
bufa
[
128
],
bufb
[
128
],
*
astr
,
*
bstr
;
int
bothsds
=
1
;
int
bothsds
=
1
;
...
@@ -331,7 +331,7 @@ int equalStringObjects(robj *a, robj *b) {
...
@@ -331,7 +331,7 @@ int equalStringObjects(robj *a, robj *b) {
}
}
size_t
stringObjectLen
(
robj
*
o
)
{
size_t
stringObjectLen
(
robj
*
o
)
{
redisAssert
(
o
->
type
==
REDIS_STRING
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
type
==
REDIS_STRING
);
if
(
o
->
encoding
==
REDIS_ENCODING_RAW
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_RAW
)
{
return
sdslen
(
o
->
ptr
);
return
sdslen
(
o
->
ptr
);
}
else
{
}
else
{
...
@@ -348,7 +348,7 @@ int getDoubleFromObject(robj *o, double *target) {
...
@@ -348,7 +348,7 @@ int getDoubleFromObject(robj *o, double *target) {
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
value
=
0
;
value
=
0
;
}
else
{
}
else
{
redisAssert
(
o
->
type
==
REDIS_STRING
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
type
==
REDIS_STRING
);
if
(
o
->
encoding
==
REDIS_ENCODING_RAW
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_RAW
)
{
value
=
strtod
(
o
->
ptr
,
&
eptr
);
value
=
strtod
(
o
->
ptr
,
&
eptr
);
if
(
eptr
[
0
]
!=
'\0'
||
isnan
(
value
))
return
REDIS_ERR
;
if
(
eptr
[
0
]
!=
'\0'
||
isnan
(
value
))
return
REDIS_ERR
;
...
@@ -385,7 +385,7 @@ int getLongLongFromObject(robj *o, long long *target) {
...
@@ -385,7 +385,7 @@ int getLongLongFromObject(robj *o, long long *target) {
if
(
o
==
NULL
)
{
if
(
o
==
NULL
)
{
value
=
0
;
value
=
0
;
}
else
{
}
else
{
redisAssert
(
o
->
type
==
REDIS_STRING
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
type
==
REDIS_STRING
);
if
(
o
->
encoding
==
REDIS_ENCODING_RAW
)
{
if
(
o
->
encoding
==
REDIS_ENCODING_RAW
)
{
value
=
strtoll
(
o
->
ptr
,
&
eptr
,
10
);
value
=
strtoll
(
o
->
ptr
,
&
eptr
,
10
);
if
(
eptr
[
0
]
!=
'\0'
)
return
REDIS_ERR
;
if
(
eptr
[
0
]
!=
'\0'
)
return
REDIS_ERR
;
...
...
src/pubsub.c
View file @
eab0e26e
...
@@ -63,10 +63,10 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
...
@@ -63,10 +63,10 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
retval
=
1
;
retval
=
1
;
/* Remove the client from the channel -> clients list hash table */
/* Remove the client from the channel -> clients list hash table */
de
=
dictFind
(
server
.
pubsub_channels
,
channel
);
de
=
dictFind
(
server
.
pubsub_channels
,
channel
);
redisAssert
(
de
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
de
!=
NULL
);
clients
=
dictGetEntryVal
(
de
);
clients
=
dictGetEntryVal
(
de
);
ln
=
listSearchKey
(
clients
,
c
);
ln
=
listSearchKey
(
clients
,
c
);
redisAssert
(
ln
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
ln
!=
NULL
);
listDelNode
(
clients
,
ln
);
listDelNode
(
clients
,
ln
);
if
(
listLength
(
clients
)
==
0
)
{
if
(
listLength
(
clients
)
==
0
)
{
/* Free the list and associated hash entry at all if this was
/* Free the list and associated hash entry at all if this was
...
...
src/rdb.c
View file @
eab0e26e
...
@@ -284,7 +284,7 @@ int rdbSaveStringObject(rio *rdb, robj *obj) {
...
@@ -284,7 +284,7 @@ int rdbSaveStringObject(rio *rdb, robj *obj) {
if
(
obj
->
encoding
==
REDIS_ENCODING_INT
)
{
if
(
obj
->
encoding
==
REDIS_ENCODING_INT
)
{
return
rdbSaveLongLongAsStringObject
(
rdb
,(
long
)
obj
->
ptr
);
return
rdbSaveLongLongAsStringObject
(
rdb
,(
long
)
obj
->
ptr
);
}
else
{
}
else
{
redisAssert
(
obj
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
NULL
,
obj
,
obj
->
encoding
==
REDIS_ENCODING_RAW
);
return
rdbSaveRawString
(
rdb
,
obj
->
ptr
,
sdslen
(
obj
->
ptr
));
return
rdbSaveRawString
(
rdb
,
obj
->
ptr
,
sdslen
(
obj
->
ptr
));
}
}
}
}
...
@@ -553,7 +553,7 @@ int rdbSaveObject(rio *rdb, robj *o) {
...
@@ -553,7 +553,7 @@ int rdbSaveObject(rio *rdb, robj *o) {
* we could switch to a faster solution. */
* we could switch to a faster solution. */
off_t
rdbSavedObjectLen
(
robj
*
o
)
{
off_t
rdbSavedObjectLen
(
robj
*
o
)
{
int
len
=
rdbSaveObject
(
NULL
,
o
);
int
len
=
rdbSaveObject
(
NULL
,
o
);
redisAssert
(
len
!=
-
1
);
redisAssert
WithInfo
(
NULL
,
o
,
len
!=
-
1
);
return
len
;
return
len
;
}
}
...
...
src/scripting.c
View file @
eab0e26e
...
@@ -531,7 +531,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
...
@@ -531,7 +531,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
{
{
int
retval
=
dictAdd
(
server
.
lua_scripts
,
int
retval
=
dictAdd
(
server
.
lua_scripts
,
sdsnewlen
(
funcname
+
2
,
40
),
c
->
argv
[
1
]);
sdsnewlen
(
funcname
+
2
,
40
),
c
->
argv
[
1
]);
redisAssert
(
retval
==
DICT_OK
);
redisAssert
WithInfo
(
c
,
NULL
,
retval
==
DICT_OK
);
incrRefCount
(
c
->
argv
[
1
]);
incrRefCount
(
c
->
argv
[
1
]);
}
}
}
}
...
@@ -583,7 +583,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
...
@@ -583,7 +583,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
if
(
evalsha
)
{
if
(
evalsha
)
{
robj
*
script
=
dictFetchValue
(
server
.
lua_scripts
,
c
->
argv
[
1
]
->
ptr
);
robj
*
script
=
dictFetchValue
(
server
.
lua_scripts
,
c
->
argv
[
1
]
->
ptr
);
redisAssert
(
script
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
script
!=
NULL
);
rewriteClientCommandArgument
(
c
,
0
,
rewriteClientCommandArgument
(
c
,
0
,
resetRefCount
(
createStringObject
(
"EVAL"
,
4
)));
resetRefCount
(
createStringObject
(
"EVAL"
,
4
)));
rewriteClientCommandArgument
(
c
,
1
,
script
);
rewriteClientCommandArgument
(
c
,
1
,
script
);
...
...
src/sort.c
View file @
eab0e26e
...
@@ -247,7 +247,7 @@ void sortCommand(redisClient *c) {
...
@@ -247,7 +247,7 @@ void sortCommand(redisClient *c) {
}
else
{
}
else
{
redisPanic
(
"Unknown type"
);
redisPanic
(
"Unknown type"
);
}
}
redisAssert
(
j
==
vectorlen
);
redisAssert
WithInfo
(
c
,
sortval
,
j
==
vectorlen
);
/* Now it's time to load the right scores in the sorting vector */
/* Now it's time to load the right scores in the sorting vector */
if
(
dontsort
==
0
)
{
if
(
dontsort
==
0
)
{
...
@@ -273,7 +273,7 @@ void sortCommand(redisClient *c) {
...
@@ -273,7 +273,7 @@ void sortCommand(redisClient *c) {
* far. We can just cast it */
* far. We can just cast it */
vector
[
j
].
u
.
score
=
(
long
)
byval
->
ptr
;
vector
[
j
].
u
.
score
=
(
long
)
byval
->
ptr
;
}
else
{
}
else
{
redisAssert
(
1
!=
1
);
redisAssert
WithInfo
(
c
,
sortval
,
1
!=
1
);
}
}
}
}
...
@@ -330,7 +330,8 @@ void sortCommand(redisClient *c) {
...
@@ -330,7 +330,8 @@ void sortCommand(redisClient *c) {
decrRefCount
(
val
);
decrRefCount
(
val
);
}
}
}
else
{
}
else
{
redisAssert
(
sop
->
type
==
REDIS_SORT_GET
);
/* always fails */
/* Always fails */
redisAssertWithInfo
(
c
,
sortval
,
sop
->
type
==
REDIS_SORT_GET
);
}
}
}
}
}
}
...
@@ -360,8 +361,8 @@ void sortCommand(redisClient *c) {
...
@@ -360,8 +361,8 @@ void sortCommand(redisClient *c) {
listTypePush
(
sobj
,
val
,
REDIS_TAIL
);
listTypePush
(
sobj
,
val
,
REDIS_TAIL
);
decrRefCount
(
val
);
decrRefCount
(
val
);
}
else
{
}
else
{
/*
a
lways fails */
/*
A
lways fails */
redisAssert
(
sop
->
type
==
REDIS_SORT_GET
);
redisAssert
WithInfo
(
c
,
sortval
,
sop
->
type
==
REDIS_SORT_GET
);
}
}
}
}
}
}
...
...
src/t_hash.c
View file @
eab0e26e
...
@@ -160,7 +160,7 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
...
@@ -160,7 +160,7 @@ hashTypeIterator *hashTypeInitIterator(robj *subject) {
}
else
if
(
hi
->
encoding
==
REDIS_ENCODING_HT
)
{
}
else
if
(
hi
->
encoding
==
REDIS_ENCODING_HT
)
{
hi
->
di
=
dictGetIterator
(
subject
->
ptr
);
hi
->
di
=
dictGetIterator
(
subject
->
ptr
);
}
else
{
}
else
{
redisAssert
(
NULL
);
redisAssert
WithInfo
(
NULL
,
subject
,
0
);
}
}
return
hi
;
return
hi
;
}
}
...
@@ -250,7 +250,7 @@ void convertToRealHash(robj *o) {
...
@@ -250,7 +250,7 @@ void convertToRealHash(robj *o) {
unsigned
int
klen
,
vlen
;
unsigned
int
klen
,
vlen
;
dict
*
dict
=
dictCreate
(
&
hashDictType
,
NULL
);
dict
*
dict
=
dictCreate
(
&
hashDictType
,
NULL
);
redisAssert
(
o
->
type
==
REDIS_HASH
&&
o
->
encoding
!=
REDIS_ENCODING_HT
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
type
==
REDIS_HASH
&&
o
->
encoding
!=
REDIS_ENCODING_HT
);
p
=
zipmapRewind
(
zm
);
p
=
zipmapRewind
(
zm
);
while
((
p
=
zipmapNext
(
p
,
&
key
,
&
klen
,
&
val
,
&
vlen
))
!=
NULL
)
{
while
((
p
=
zipmapNext
(
p
,
&
key
,
&
klen
,
&
val
,
&
vlen
))
!=
NULL
)
{
robj
*
keyobj
,
*
valobj
;
robj
*
keyobj
,
*
valobj
;
...
...
src/t_list.c
View file @
eab0e26e
...
@@ -198,7 +198,7 @@ void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
...
@@ -198,7 +198,7 @@ void listTypeInsert(listTypeEntry *entry, robj *value, int where) {
int
listTypeEqual
(
listTypeEntry
*
entry
,
robj
*
o
)
{
int
listTypeEqual
(
listTypeEntry
*
entry
,
robj
*
o
)
{
listTypeIterator
*
li
=
entry
->
li
;
listTypeIterator
*
li
=
entry
->
li
;
if
(
li
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
if
(
li
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
redisAssert
(
o
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
NULL
,
o
,
o
->
encoding
==
REDIS_ENCODING_RAW
);
return
ziplistCompare
(
entry
->
zi
,
o
->
ptr
,
sdslen
(
o
->
ptr
));
return
ziplistCompare
(
entry
->
zi
,
o
->
ptr
,
sdslen
(
o
->
ptr
));
}
else
if
(
li
->
encoding
==
REDIS_ENCODING_LINKEDLIST
)
{
}
else
if
(
li
->
encoding
==
REDIS_ENCODING_LINKEDLIST
)
{
return
equalStringObjects
(
o
,
listNodeValue
(
entry
->
ln
));
return
equalStringObjects
(
o
,
listNodeValue
(
entry
->
ln
));
...
@@ -235,7 +235,7 @@ void listTypeDelete(listTypeEntry *entry) {
...
@@ -235,7 +235,7 @@ void listTypeDelete(listTypeEntry *entry) {
void
listTypeConvert
(
robj
*
subject
,
int
enc
)
{
void
listTypeConvert
(
robj
*
subject
,
int
enc
)
{
listTypeIterator
*
li
;
listTypeIterator
*
li
;
listTypeEntry
entry
;
listTypeEntry
entry
;
redisAssert
(
subject
->
type
==
REDIS_LIST
);
redisAssert
WithInfo
(
NULL
,
subject
,
subject
->
type
==
REDIS_LIST
);
if
(
enc
==
REDIS_ENCODING_LINKEDLIST
)
{
if
(
enc
==
REDIS_ENCODING_LINKEDLIST
)
{
list
*
l
=
listCreate
();
list
*
l
=
listCreate
();
...
@@ -310,7 +310,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
...
@@ -310,7 +310,7 @@ void pushxGenericCommand(redisClient *c, robj *refval, robj *val, int where) {
if
(
refval
!=
NULL
)
{
if
(
refval
!=
NULL
)
{
/* Note: we expect refval to be string-encoded because it is *not* the
/* Note: we expect refval to be string-encoded because it is *not* the
* last argument of the multi-bulk LINSERT. */
* last argument of the multi-bulk LINSERT. */
redisAssert
(
refval
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
c
,
refval
,
refval
->
encoding
==
REDIS_ENCODING_RAW
);
/* We're not sure if this value can be inserted yet, but we cannot
/* We're not sure if this value can be inserted yet, but we cannot
* convert the list inside the iterator. We don't want to loop over
* convert the list inside the iterator. We don't want to loop over
...
@@ -774,7 +774,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, time_t timeout, robj
...
@@ -774,7 +774,7 @@ void blockForKeys(redisClient *c, robj **keys, int numkeys, time_t timeout, robj
l
=
listCreate
();
l
=
listCreate
();
retval
=
dictAdd
(
c
->
db
->
blocking_keys
,
keys
[
j
],
l
);
retval
=
dictAdd
(
c
->
db
->
blocking_keys
,
keys
[
j
],
l
);
incrRefCount
(
keys
[
j
]);
incrRefCount
(
keys
[
j
]);
redisAssert
(
retval
==
DICT_OK
);
redisAssert
WithInfo
(
c
,
keys
[
j
],
retval
==
DICT_OK
);
}
else
{
}
else
{
l
=
dictGetEntryVal
(
de
);
l
=
dictGetEntryVal
(
de
);
}
}
...
@@ -791,12 +791,12 @@ void unblockClientWaitingData(redisClient *c) {
...
@@ -791,12 +791,12 @@ void unblockClientWaitingData(redisClient *c) {
list
*
l
;
list
*
l
;
int
j
;
int
j
;
redisAssert
(
c
->
bpop
.
keys
!=
NULL
);
redisAssert
WithInfo
(
c
,
NULL
,
c
->
bpop
.
keys
!=
NULL
);
/* The client may wait for multiple keys, so unblock it for every key. */
/* The client may wait for multiple keys, so unblock it for every key. */
for
(
j
=
0
;
j
<
c
->
bpop
.
count
;
j
++
)
{
for
(
j
=
0
;
j
<
c
->
bpop
.
count
;
j
++
)
{
/* Remove this client from the list of clients waiting for this key. */
/* Remove this client from the list of clients waiting for this key. */
de
=
dictFind
(
c
->
db
->
blocking_keys
,
c
->
bpop
.
keys
[
j
]);
de
=
dictFind
(
c
->
db
->
blocking_keys
,
c
->
bpop
.
keys
[
j
]);
redisAssert
(
de
!=
NULL
);
redisAssert
WithInfo
(
c
,
c
->
bpop
.
keys
[
j
],
de
!=
NULL
);
l
=
dictGetEntryVal
(
de
);
l
=
dictGetEntryVal
(
de
);
listDelNode
(
l
,
listSearchKey
(
l
,
c
));
listDelNode
(
l
,
listSearchKey
(
l
,
c
));
/* If the list is empty we need to remove it to avoid wasting memory */
/* If the list is empty we need to remove it to avoid wasting memory */
...
@@ -848,7 +848,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
...
@@ -848,7 +848,7 @@ int handleClientsWaitingListPush(redisClient *c, robj *key, robj *ele) {
* this happens, it simply tries the next client waiting for a push. */
* this happens, it simply tries the next client waiting for a push. */
while
(
numclients
--
)
{
while
(
numclients
--
)
{
ln
=
listFirst
(
clients
);
ln
=
listFirst
(
clients
);
redisAssert
(
ln
!=
NULL
);
redisAssert
WithInfo
(
c
,
key
,
ln
!=
NULL
);
receiver
=
ln
->
value
;
receiver
=
ln
->
value
;
dstkey
=
receiver
->
bpop
.
target
;
dstkey
=
receiver
->
bpop
.
target
;
...
@@ -995,7 +995,7 @@ void brpoplpushCommand(redisClient *c) {
...
@@ -995,7 +995,7 @@ void brpoplpushCommand(redisClient *c) {
/* The list exists and has elements, so
/* The list exists and has elements, so
* the regular rpoplpushCommand is executed. */
* the regular rpoplpushCommand is executed. */
redisAssert
(
listTypeLength
(
key
)
>
0
);
redisAssert
WithInfo
(
c
,
key
,
listTypeLength
(
key
)
>
0
);
rpoplpushCommand
(
c
);
rpoplpushCommand
(
c
);
}
}
}
}
...
...
src/t_set.c
View file @
eab0e26e
...
@@ -37,7 +37,7 @@ int setTypeAdd(robj *subject, robj *value) {
...
@@ -37,7 +37,7 @@ int setTypeAdd(robj *subject, robj *value) {
/* The set *was* an intset and this value is not integer
/* The set *was* an intset and this value is not integer
* encodable, so dictAdd should always work. */
* encodable, so dictAdd should always work. */
redisAssert
(
dictAdd
(
subject
->
ptr
,
value
,
NULL
)
==
DICT_OK
);
redisAssert
WithInfo
(
NULL
,
value
,
dictAdd
(
subject
->
ptr
,
value
,
NULL
)
==
DICT_OK
);
incrRefCount
(
value
);
incrRefCount
(
value
);
return
1
;
return
1
;
}
}
...
@@ -189,8 +189,8 @@ unsigned long setTypeSize(robj *subject) {
...
@@ -189,8 +189,8 @@ unsigned long setTypeSize(robj *subject) {
* set. */
* set. */
void
setTypeConvert
(
robj
*
setobj
,
int
enc
)
{
void
setTypeConvert
(
robj
*
setobj
,
int
enc
)
{
setTypeIterator
*
si
;
setTypeIterator
*
si
;
redisAssert
(
setobj
->
type
==
REDIS_SET
&&
redisAssert
WithInfo
(
NULL
,
setobj
,
setobj
->
type
==
REDIS_SET
&&
setobj
->
encoding
==
REDIS_ENCODING_INTSET
);
setobj
->
encoding
==
REDIS_ENCODING_INTSET
);
if
(
enc
==
REDIS_ENCODING_HT
)
{
if
(
enc
==
REDIS_ENCODING_HT
)
{
int64_t
intele
;
int64_t
intele
;
...
@@ -204,7 +204,7 @@ void setTypeConvert(robj *setobj, int enc) {
...
@@ -204,7 +204,7 @@ void setTypeConvert(robj *setobj, int enc) {
si
=
setTypeInitIterator
(
setobj
);
si
=
setTypeInitIterator
(
setobj
);
while
(
setTypeNext
(
si
,
NULL
,
&
intele
)
!=
-
1
)
{
while
(
setTypeNext
(
si
,
NULL
,
&
intele
)
!=
-
1
)
{
element
=
createStringObjectFromLongLong
(
intele
);
element
=
createStringObjectFromLongLong
(
intele
);
redisAssert
(
dictAdd
(
d
,
element
,
NULL
)
==
DICT_OK
);
redisAssert
WithInfo
(
NULL
,
element
,
dictAdd
(
d
,
element
,
NULL
)
==
DICT_OK
);
}
}
setTypeReleaseIterator
(
si
);
setTypeReleaseIterator
(
si
);
...
...
src/t_zset.c
View file @
eab0e26e
...
@@ -578,7 +578,7 @@ unsigned char *zzlFind(unsigned char *zl, robj *ele, double *score) {
...
@@ -578,7 +578,7 @@ unsigned char *zzlFind(unsigned char *zl, robj *ele, double *score) {
ele
=
getDecodedObject
(
ele
);
ele
=
getDecodedObject
(
ele
);
while
(
eptr
!=
NULL
)
{
while
(
eptr
!=
NULL
)
{
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
redisAssert
(
sptr
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
ele
,
sptr
!=
NULL
);
if
(
ziplistCompare
(
eptr
,
ele
->
ptr
,
sdslen
(
ele
->
ptr
)))
{
if
(
ziplistCompare
(
eptr
,
ele
->
ptr
,
sdslen
(
ele
->
ptr
)))
{
/* Matching element, pull out score. */
/* Matching element, pull out score. */
...
@@ -612,7 +612,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
...
@@ -612,7 +612,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
int
scorelen
;
int
scorelen
;
size_t
offset
;
size_t
offset
;
redisAssert
(
ele
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
NULL
,
ele
,
ele
->
encoding
==
REDIS_ENCODING_RAW
);
scorelen
=
d2string
(
scorebuf
,
sizeof
(
scorebuf
),
score
);
scorelen
=
d2string
(
scorebuf
,
sizeof
(
scorebuf
),
score
);
if
(
eptr
==
NULL
)
{
if
(
eptr
==
NULL
)
{
zl
=
ziplistPush
(
zl
,
ele
->
ptr
,
sdslen
(
ele
->
ptr
),
ZIPLIST_TAIL
);
zl
=
ziplistPush
(
zl
,
ele
->
ptr
,
sdslen
(
ele
->
ptr
),
ZIPLIST_TAIL
);
...
@@ -624,7 +624,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
...
@@ -624,7 +624,7 @@ unsigned char *zzlInsertAt(unsigned char *zl, unsigned char *eptr, robj *ele, do
eptr
=
zl
+
offset
;
eptr
=
zl
+
offset
;
/* Insert score after the element. */
/* Insert score after the element. */
redisAssert
(
(
sptr
=
ziplistNext
(
zl
,
eptr
))
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
ele
,
(
sptr
=
ziplistNext
(
zl
,
eptr
))
!=
NULL
);
zl
=
ziplistInsert
(
zl
,
sptr
,(
unsigned
char
*
)
scorebuf
,
scorelen
);
zl
=
ziplistInsert
(
zl
,
sptr
,(
unsigned
char
*
)
scorebuf
,
scorelen
);
}
}
...
@@ -640,7 +640,7 @@ unsigned char *zzlInsert(unsigned char *zl, robj *ele, double score) {
...
@@ -640,7 +640,7 @@ unsigned char *zzlInsert(unsigned char *zl, robj *ele, double score) {
ele
=
getDecodedObject
(
ele
);
ele
=
getDecodedObject
(
ele
);
while
(
eptr
!=
NULL
)
{
while
(
eptr
!=
NULL
)
{
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
redisAssert
(
sptr
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
ele
,
sptr
!=
NULL
);
s
=
zzlGetScore
(
sptr
);
s
=
zzlGetScore
(
sptr
);
if
(
s
>
score
)
{
if
(
s
>
score
)
{
...
@@ -745,13 +745,13 @@ void zsetConvert(robj *zobj, int encoding) {
...
@@ -745,13 +745,13 @@ void zsetConvert(robj *zobj, int encoding) {
zs
->
zsl
=
zslCreate
();
zs
->
zsl
=
zslCreate
();
eptr
=
ziplistIndex
(
zl
,
0
);
eptr
=
ziplistIndex
(
zl
,
0
);
redisAssert
(
eptr
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
zobj
,
eptr
!=
NULL
);
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
redisAssert
(
sptr
!=
NULL
);
redisAssert
WithInfo
(
NULL
,
zobj
,
sptr
!=
NULL
);
while
(
eptr
!=
NULL
)
{
while
(
eptr
!=
NULL
)
{
score
=
zzlGetScore
(
sptr
);
score
=
zzlGetScore
(
sptr
);
redisAssert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vlong
));
redisAssert
WithInfo
(
NULL
,
zobj
,
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vlong
));
if
(
vstr
==
NULL
)
if
(
vstr
==
NULL
)
ele
=
createStringObjectFromLongLong
(
vlong
);
ele
=
createStringObjectFromLongLong
(
vlong
);
else
else
...
@@ -759,7 +759,7 @@ void zsetConvert(robj *zobj, int encoding) {
...
@@ -759,7 +759,7 @@ void zsetConvert(robj *zobj, int encoding) {
/* Has incremented refcount since it was just created. */
/* Has incremented refcount since it was just created. */
node
=
zslInsert
(
zs
->
zsl
,
score
,
ele
);
node
=
zslInsert
(
zs
->
zsl
,
score
,
ele
);
redisAssert
(
dictAdd
(
zs
->
dict
,
ele
,
&
node
->
score
)
==
DICT_OK
);
redisAssert
WithInfo
(
NULL
,
zobj
,
dictAdd
(
zs
->
dict
,
ele
,
&
node
->
score
)
==
DICT_OK
);
incrRefCount
(
ele
);
/* Added to dictionary. */
incrRefCount
(
ele
);
/* Added to dictionary. */
zzlNext
(
zl
,
&
eptr
,
&
sptr
);
zzlNext
(
zl
,
&
eptr
,
&
sptr
);
}
}
...
@@ -918,7 +918,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
...
@@ -918,7 +918,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
* delete the key object from the skiplist, since the
* delete the key object from the skiplist, since the
* dictionary still has a reference to it. */
* dictionary still has a reference to it. */
if
(
score
!=
curscore
)
{
if
(
score
!=
curscore
)
{
redisAssert
(
zslDelete
(
zs
->
zsl
,
curscore
,
curobj
));
redisAssert
WithInfo
(
c
,
curobj
,
zslDelete
(
zs
->
zsl
,
curscore
,
curobj
));
znode
=
zslInsert
(
zs
->
zsl
,
score
,
curobj
);
znode
=
zslInsert
(
zs
->
zsl
,
score
,
curobj
);
incrRefCount
(
curobj
);
/* Re-inserted in skiplist. */
incrRefCount
(
curobj
);
/* Re-inserted in skiplist. */
dictGetEntryVal
(
de
)
=
&
znode
->
score
;
/* Update score ptr. */
dictGetEntryVal
(
de
)
=
&
znode
->
score
;
/* Update score ptr. */
...
@@ -929,7 +929,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
...
@@ -929,7 +929,7 @@ void zaddGenericCommand(redisClient *c, int incr) {
}
else
{
}
else
{
znode
=
zslInsert
(
zs
->
zsl
,
score
,
ele
);
znode
=
zslInsert
(
zs
->
zsl
,
score
,
ele
);
incrRefCount
(
ele
);
/* Inserted in skiplist. */
incrRefCount
(
ele
);
/* Inserted in skiplist. */
redisAssert
(
dictAdd
(
zs
->
dict
,
ele
,
&
znode
->
score
)
==
DICT_OK
);
redisAssert
WithInfo
(
c
,
curobj
,
dictAdd
(
zs
->
dict
,
ele
,
&
znode
->
score
)
==
DICT_OK
);
incrRefCount
(
ele
);
/* Added to dictionary. */
incrRefCount
(
ele
);
/* Added to dictionary. */
signalModifiedKey
(
c
->
db
,
key
);
signalModifiedKey
(
c
->
db
,
key
);
...
@@ -988,7 +988,7 @@ void zremCommand(redisClient *c) {
...
@@ -988,7 +988,7 @@ void zremCommand(redisClient *c) {
/* Delete from the skiplist */
/* Delete from the skiplist */
score
=
*
(
double
*
)
dictGetEntryVal
(
de
);
score
=
*
(
double
*
)
dictGetEntryVal
(
de
);
redisAssert
(
zslDelete
(
zs
->
zsl
,
score
,
c
->
argv
[
j
]));
redisAssert
WithInfo
(
c
,
c
->
argv
[
j
],
zslDelete
(
zs
->
zsl
,
score
,
c
->
argv
[
j
]));
/* Delete from the hash table */
/* Delete from the hash table */
dictDelete
(
zs
->
dict
,
c
->
argv
[
j
]);
dictDelete
(
zs
->
dict
,
c
->
argv
[
j
]);
...
@@ -1698,12 +1698,12 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
...
@@ -1698,12 +1698,12 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
else
else
eptr
=
ziplistIndex
(
zl
,
2
*
start
);
eptr
=
ziplistIndex
(
zl
,
2
*
start
);
redisAssert
(
eptr
!=
NULL
);
redisAssert
WithInfo
(
c
,
zobj
,
eptr
!=
NULL
);
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
while
(
rangelen
--
)
{
while
(
rangelen
--
)
{
redisAssert
(
eptr
!=
NULL
&&
sptr
!=
NULL
);
redisAssert
WithInfo
(
c
,
zobj
,
eptr
!=
NULL
&&
sptr
!=
NULL
);
redisAssert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vlong
));
redisAssert
WithInfo
(
c
,
zobj
,
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vlong
));
if
(
vstr
==
NULL
)
if
(
vstr
==
NULL
)
addReplyBulkLongLong
(
c
,
vlong
);
addReplyBulkLongLong
(
c
,
vlong
);
else
else
...
@@ -1736,7 +1736,7 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
...
@@ -1736,7 +1736,7 @@ void zrangeGenericCommand(redisClient *c, int reverse) {
}
}
while
(
rangelen
--
)
{
while
(
rangelen
--
)
{
redisAssert
(
ln
!=
NULL
);
redisAssert
WithInfo
(
c
,
zobj
,
ln
!=
NULL
);
ele
=
ln
->
obj
;
ele
=
ln
->
obj
;
addReplyBulk
(
c
,
ele
);
addReplyBulk
(
c
,
ele
);
if
(
withscores
)
if
(
withscores
)
...
@@ -1828,7 +1828,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
...
@@ -1828,7 +1828,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
}
}
/* Get score pointer for the first element. */
/* Get score pointer for the first element. */
redisAssert
(
eptr
!=
NULL
);
redisAssert
WithInfo
(
c
,
zobj
,
eptr
!=
NULL
);
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
/* We don't know in advance how many matching elements there are in the
/* We don't know in advance how many matching elements there are in the
...
@@ -1857,7 +1857,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
...
@@ -1857,7 +1857,7 @@ void genericZrangebyscoreCommand(redisClient *c, int reverse) {
}
}
/* We know the element exists, so ziplistGet should always succeed */
/* We know the element exists, so ziplistGet should always succeed */
redisAssert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vlong
));
redisAssert
WithInfo
(
c
,
zobj
,
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vlong
));
rangelen
++
;
rangelen
++
;
if
(
vstr
==
NULL
)
{
if
(
vstr
==
NULL
)
{
...
@@ -1984,7 +1984,7 @@ void zcountCommand(redisClient *c) {
...
@@ -1984,7 +1984,7 @@ void zcountCommand(redisClient *c) {
/* First element is in range */
/* First element is in range */
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
score
=
zzlGetScore
(
sptr
);
score
=
zzlGetScore
(
sptr
);
redisAssert
(
zslValueLteMax
(
score
,
&
range
));
redisAssert
WithInfo
(
c
,
zobj
,
zslValueLteMax
(
score
,
&
range
));
/* Iterate over elements in range */
/* Iterate over elements in range */
while
(
eptr
)
{
while
(
eptr
)
{
...
@@ -2079,15 +2079,15 @@ void zrankGenericCommand(redisClient *c, int reverse) {
...
@@ -2079,15 +2079,15 @@ void zrankGenericCommand(redisClient *c, int reverse) {
checkType
(
c
,
zobj
,
REDIS_ZSET
))
return
;
checkType
(
c
,
zobj
,
REDIS_ZSET
))
return
;
llen
=
zsetLength
(
zobj
);
llen
=
zsetLength
(
zobj
);
redisAssert
(
ele
->
encoding
==
REDIS_ENCODING_RAW
);
redisAssert
WithInfo
(
c
,
ele
,
ele
->
encoding
==
REDIS_ENCODING_RAW
);
if
(
zobj
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
if
(
zobj
->
encoding
==
REDIS_ENCODING_ZIPLIST
)
{
unsigned
char
*
zl
=
zobj
->
ptr
;
unsigned
char
*
zl
=
zobj
->
ptr
;
unsigned
char
*
eptr
,
*
sptr
;
unsigned
char
*
eptr
,
*
sptr
;
eptr
=
ziplistIndex
(
zl
,
0
);
eptr
=
ziplistIndex
(
zl
,
0
);
redisAssert
(
eptr
!=
NULL
);
redisAssert
WithInfo
(
c
,
zobj
,
eptr
!=
NULL
);
sptr
=
ziplistNext
(
zl
,
eptr
);
sptr
=
ziplistNext
(
zl
,
eptr
);
redisAssert
(
sptr
!=
NULL
);
redisAssert
WithInfo
(
c
,
zobj
,
sptr
!=
NULL
);
rank
=
1
;
rank
=
1
;
while
(
eptr
!=
NULL
)
{
while
(
eptr
!=
NULL
)
{
...
@@ -2116,7 +2116,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
...
@@ -2116,7 +2116,7 @@ void zrankGenericCommand(redisClient *c, int reverse) {
if
(
de
!=
NULL
)
{
if
(
de
!=
NULL
)
{
score
=
*
(
double
*
)
dictGetEntryVal
(
de
);
score
=
*
(
double
*
)
dictGetEntryVal
(
de
);
rank
=
zslGetRank
(
zsl
,
score
,
ele
);
rank
=
zslGetRank
(
zsl
,
score
,
ele
);
redisAssert
(
rank
);
/* Existing elements always have a rank. */
redisAssert
WithInfo
(
c
,
ele
,
rank
);
/* Existing elements always have a rank. */
if
(
reverse
)
if
(
reverse
)
addReplyLongLong
(
c
,
llen
-
rank
);
addReplyLongLong
(
c
,
llen
-
rank
);
else
else
...
...
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