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
2d9e3eb1
Commit
2d9e3eb1
authored
Jul 26, 2015
by
antirez
Browse files
RDMF: redisAssert -> serverAssert.
parent
14ff5724
Changes
24
Hide whitespace changes
Inline
Side-by-side
src/aof.c
View file @
2d9e3eb1
...
...
@@ -204,7 +204,7 @@ void aof_background_fsync(int fd) {
/* Called when the user switches from "appendonly yes" to "appendonly no"
* at runtime using the CONFIG command. */
void
stopAppendOnly
(
void
)
{
redis
Assert
(
server
.
aof_state
!=
REDIS_AOF_OFF
);
server
Assert
(
server
.
aof_state
!=
REDIS_AOF_OFF
);
flushAppendOnlyFile
(
1
);
aof_fsync
(
server
.
aof_fd
);
close
(
server
.
aof_fd
);
...
...
@@ -235,7 +235,7 @@ void stopAppendOnly(void) {
int
startAppendOnly
(
void
)
{
server
.
aof_last_fsync
=
server
.
unixtime
;
server
.
aof_fd
=
open
(
server
.
aof_filename
,
O_WRONLY
|
O_APPEND
|
O_CREAT
,
0644
);
redis
Assert
(
server
.
aof_state
==
REDIS_AOF_OFF
);
server
Assert
(
server
.
aof_state
==
REDIS_AOF_OFF
);
if
(
server
.
aof_fd
==
-
1
)
{
serverLog
(
REDIS_WARNING
,
"Redis needs to enable the AOF but can't open the append only file: %s"
,
strerror
(
errno
));
return
REDIS_ERR
;
...
...
@@ -685,9 +685,9 @@ int loadAppendOnlyFile(char *filename) {
cmd
->
proc
(
fakeClient
);
/* The fake client should not have a reply */
redis
Assert
(
fakeClient
->
bufpos
==
0
&&
listLength
(
fakeClient
->
reply
)
==
0
);
server
Assert
(
fakeClient
->
bufpos
==
0
&&
listLength
(
fakeClient
->
reply
)
==
0
);
/* The fake client should never get blocked */
redis
Assert
((
fakeClient
->
flags
&
REDIS_BLOCKED
)
==
0
);
server
Assert
((
fakeClient
->
flags
&
REDIS_BLOCKED
)
==
0
);
/* Clean up. Command code may have changed argv/argc so we use the
* argv/argc of the client instead of the local variables. */
...
...
@@ -860,12 +860,12 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
double
score
;
eptr
=
ziplistIndex
(
zl
,
0
);
redis
Assert
(
eptr
!=
NULL
);
server
Assert
(
eptr
!=
NULL
);
sptr
=
ziplistNext
(
zl
,
eptr
);
redis
Assert
(
sptr
!=
NULL
);
server
Assert
(
sptr
!=
NULL
);
while
(
eptr
!=
NULL
)
{
redis
Assert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vll
));
server
Assert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vll
));
score
=
zzlGetScore
(
sptr
);
if
(
count
==
0
)
{
...
...
src/blocked.c
View file @
2d9e3eb1
...
...
@@ -112,7 +112,7 @@ void processUnblockedClients(void) {
while
(
listLength
(
server
.
unblocked_clients
))
{
ln
=
listFirst
(
server
.
unblocked_clients
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
c
=
ln
->
value
;
listDelNode
(
server
.
unblocked_clients
,
ln
);
c
->
flags
&=
~
REDIS_UNBLOCKED
;
...
...
src/cluster.c
View file @
2d9e3eb1
...
...
@@ -176,7 +176,7 @@ int clusterLoadConfig(char *filename) {
p
=
strchr
(
s
,
','
);
if
(
p
)
*
p
=
'\0'
;
if
(
!
strcasecmp
(
s
,
"myself"
))
{
redis
Assert
(
server
.
cluster
->
myself
==
NULL
);
server
Assert
(
server
.
cluster
->
myself
==
NULL
);
myself
=
server
.
cluster
->
myself
=
n
;
n
->
flags
|=
REDIS_NODE_MYSELF
;
}
else
if
(
!
strcasecmp
(
s
,
"master"
))
{
...
...
@@ -230,7 +230,7 @@ int clusterLoadConfig(char *filename) {
clusterNode
*
cn
;
p
=
strchr
(
argv
[
j
],
'-'
);
redis
Assert
(
p
!=
NULL
);
server
Assert
(
p
!=
NULL
);
*
p
=
'\0'
;
direction
=
p
[
1
];
/* Either '>' or '<' */
slot
=
atoi
(
argv
[
j
]
+
1
);
...
...
@@ -833,7 +833,7 @@ void freeClusterNode(clusterNode *n) {
/* Unlink from the set of nodes. */
nodename
=
sdsnewlen
(
n
->
name
,
REDIS_CLUSTER_NAMELEN
);
redis
Assert
(
dictDelete
(
server
.
cluster
->
nodes
,
nodename
)
==
DICT_OK
);
server
Assert
(
dictDelete
(
server
.
cluster
->
nodes
,
nodename
)
==
DICT_OK
);
sdsfree
(
nodename
);
/* Release link and associated data structures. */
...
...
@@ -915,7 +915,7 @@ void clusterRenameNode(clusterNode *node, char *newname) {
node
->
name
,
newname
);
retval
=
dictDelete
(
server
.
cluster
->
nodes
,
s
);
sdsfree
(
s
);
redis
Assert
(
retval
==
DICT_OK
);
server
Assert
(
retval
==
DICT_OK
);
memcpy
(
node
->
name
,
newname
,
REDIS_CLUSTER_NAMELEN
);
clusterAddNode
(
node
);
}
...
...
@@ -1183,7 +1183,7 @@ void markNodeAsFailingIfNeeded(clusterNode *node) {
void
clearNodeFailureIfNeeded
(
clusterNode
*
node
)
{
mstime_t
now
=
mstime
();
redis
Assert
(
nodeFailed
(
node
));
server
Assert
(
nodeFailed
(
node
));
/* For slaves we always clear the FAIL flag if we can contact the
* node again. */
...
...
@@ -2571,7 +2571,7 @@ int clusterGetSlaveRank(void) {
int
j
,
rank
=
0
;
clusterNode
*
master
;
redis
Assert
(
nodeIsSlave
(
myself
));
server
Assert
(
nodeIsSlave
(
myself
));
master
=
myself
->
slaveof
;
if
(
master
==
NULL
)
return
0
;
/* Never called by slaves without master. */
...
...
@@ -3360,7 +3360,7 @@ int clusterDelSlot(int slot) {
clusterNode
*
n
=
server
.
cluster
->
slots
[
slot
];
if
(
!
n
)
return
REDIS_ERR
;
redis
Assert
(
clusterNodeClearSlotBit
(
n
,
slot
)
==
1
);
server
Assert
(
clusterNodeClearSlotBit
(
n
,
slot
)
==
1
);
server
.
cluster
->
slots
[
slot
]
=
NULL
;
return
REDIS_OK
;
}
...
...
@@ -3567,8 +3567,8 @@ int verifyClusterConfigWithData(void) {
/* Set the specified node 'n' as master for this node.
* If this node is currently a master, it is turned into a slave. */
void
clusterSetMaster
(
clusterNode
*
n
)
{
redis
Assert
(
n
!=
myself
);
redis
Assert
(
myself
->
numslots
==
0
);
server
Assert
(
n
!=
myself
);
server
Assert
(
myself
->
numslots
==
0
);
if
(
nodeIsMaster
(
myself
))
{
myself
->
flags
&=
~
REDIS_NODE_MASTER
;
...
...
@@ -3894,7 +3894,7 @@ void clusterCommand(client *c) {
retval
=
del
?
clusterDelSlot
(
j
)
:
clusterAddSlot
(
myself
,
j
);
redis
AssertWithInfo
(
c
,
NULL
,
retval
==
REDIS_OK
);
server
AssertWithInfo
(
c
,
NULL
,
retval
==
REDIS_OK
);
}
}
zfree
(
slots
);
...
...
@@ -4315,8 +4315,8 @@ void createDumpPayload(rio *payload, robj *o) {
/* 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. */
rioInitWithBuffer
(
payload
,
sdsempty
());
redis
Assert
(
rdbSaveObjectType
(
payload
,
o
));
redis
Assert
(
rdbSaveObject
(
payload
,
o
));
server
Assert
(
rdbSaveObjectType
(
payload
,
o
));
server
Assert
(
rdbSaveObject
(
payload
,
o
));
/* Write the footer, this is how it looks like:
* ----------------+---------------------+---------------+
...
...
@@ -4610,9 +4610,9 @@ try_again:
/* Send the SELECT command if the current DB is not already selected. */
int
select
=
cs
->
last_dbid
!=
dbid
;
/* Should we emit SELECT? */
if
(
select
)
{
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
2
));
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"SELECT"
,
6
));
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkLongLong
(
&
cmd
,
dbid
));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
2
));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"SELECT"
,
6
));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkLongLong
(
&
cmd
,
dbid
));
}
/* Create RESTORE payload and generate the protocol to call the command. */
...
...
@@ -4621,28 +4621,28 @@ try_again:
ttl
=
expireat
-
mstime
();
if
(
ttl
<
1
)
ttl
=
1
;
}
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
replace
?
5
:
4
));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkCount
(
&
cmd
,
'*'
,
replace
?
5
:
4
));
if
(
server
.
cluster_enabled
)
redis
AssertWithInfo
(
c
,
NULL
,
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"RESTORE-ASKING"
,
14
));
else
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"RESTORE"
,
7
));
redis
AssertWithInfo
(
c
,
NULL
,
sdsEncodedObject
(
c
->
argv
[
3
]));
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
c
->
argv
[
3
]
->
ptr
,
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"RESTORE"
,
7
));
server
AssertWithInfo
(
c
,
NULL
,
sdsEncodedObject
(
c
->
argv
[
3
]));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
c
->
argv
[
3
]
->
ptr
,
sdslen
(
c
->
argv
[
3
]
->
ptr
)));
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkLongLong
(
&
cmd
,
ttl
));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkLongLong
(
&
cmd
,
ttl
));
/* Emit the payload argument, that is the serialized object using
* the DUMP format. */
createDumpPayload
(
&
payload
,
o
);
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
payload
.
io
.
buffer
.
ptr
,
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
payload
.
io
.
buffer
.
ptr
,
sdslen
(
payload
.
io
.
buffer
.
ptr
)));
sdsfree
(
payload
.
io
.
buffer
.
ptr
);
/* Add the REPLACE option to the RESTORE command if it was specified
* as a MIGRATE option. */
if
(
replace
)
redis
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"REPLACE"
,
7
));
server
AssertWithInfo
(
c
,
NULL
,
rioWriteBulkString
(
&
cmd
,
"REPLACE"
,
7
));
/* Transfer the query to the other node in 64K chunks. */
errno
=
0
;
...
...
src/config.c
View file @
2d9e3eb1
...
...
@@ -474,7 +474,7 @@ void loadServerConfigFromString(char *config) {
/* If the target command name is the empty string we just
* remove it from the command table. */
retval
=
dictDelete
(
server
.
commands
,
argv
[
1
]);
redis
Assert
(
retval
==
DICT_OK
);
server
Assert
(
retval
==
DICT_OK
);
/* Otherwise we re-add the command under a different name. */
if
(
sdslen
(
argv
[
2
])
!=
0
)
{
...
...
@@ -703,8 +703,8 @@ void configSetCommand(client *c) {
robj
*
o
;
long
long
ll
;
int
err
;
redis
AssertWithInfo
(
c
,
c
->
argv
[
2
],
sdsEncodedObject
(
c
->
argv
[
2
]));
redis
AssertWithInfo
(
c
,
c
->
argv
[
3
],
sdsEncodedObject
(
c
->
argv
[
3
]));
server
AssertWithInfo
(
c
,
c
->
argv
[
2
],
sdsEncodedObject
(
c
->
argv
[
2
]));
server
AssertWithInfo
(
c
,
c
->
argv
[
3
],
sdsEncodedObject
(
c
->
argv
[
3
]));
o
=
c
->
argv
[
3
];
if
(
0
)
{
/* this starts the config_set macros else-if chain. */
...
...
@@ -1030,7 +1030,7 @@ void configGetCommand(client *c) {
char
*
pattern
=
o
->
ptr
;
char
buf
[
128
];
int
matches
=
0
;
redis
AssertWithInfo
(
c
,
o
,
sdsEncodedObject
(
o
));
server
AssertWithInfo
(
c
,
o
,
sdsEncodedObject
(
o
));
/* String values */
config_get_string_field
(
"dbfilename"
,
server
.
rdb_filename
);
...
...
src/db.c
View file @
2d9e3eb1
...
...
@@ -119,7 +119,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
sds
copy
=
sdsdup
(
key
->
ptr
);
int
retval
=
dictAdd
(
db
->
dict
,
copy
,
val
);
redis
AssertWithInfo
(
NULL
,
key
,
retval
==
REDIS_OK
);
server
AssertWithInfo
(
NULL
,
key
,
retval
==
REDIS_OK
);
if
(
val
->
type
==
OBJ_LIST
)
signalListAsReady
(
db
,
key
);
if
(
server
.
cluster_enabled
)
slotToKeyAdd
(
key
);
}
...
...
@@ -132,7 +132,7 @@ void dbAdd(redisDb *db, robj *key, robj *val) {
void
dbOverwrite
(
redisDb
*
db
,
robj
*
key
,
robj
*
val
)
{
dictEntry
*
de
=
dictFind
(
db
->
dict
,
key
->
ptr
);
redis
AssertWithInfo
(
NULL
,
key
,
de
!=
NULL
);
server
AssertWithInfo
(
NULL
,
key
,
de
!=
NULL
);
dictReplace
(
db
->
dict
,
key
->
ptr
,
val
);
}
...
...
@@ -224,7 +224,7 @@ int dbDelete(redisDb *db, robj *key) {
* using an sdscat() call to append some data, or anything else.
*/
robj
*
dbUnshareStringValue
(
redisDb
*
db
,
robj
*
key
,
robj
*
o
)
{
redis
Assert
(
o
->
type
==
OBJ_STRING
);
server
Assert
(
o
->
type
==
OBJ_STRING
);
if
(
o
->
refcount
!=
1
||
o
->
encoding
!=
OBJ_ENCODING_RAW
)
{
robj
*
decoded
=
getDecodedObject
(
o
);
o
=
createRawStringObject
(
decoded
->
ptr
,
sdslen
(
decoded
->
ptr
));
...
...
@@ -460,7 +460,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
/* Object must be NULL (to iterate keys names), or the type of the object
* must be Set, Sorted Set, or Hash. */
redis
Assert
(
o
==
NULL
||
o
->
type
==
OBJ_SET
||
o
->
type
==
OBJ_HASH
||
server
Assert
(
o
==
NULL
||
o
->
type
==
OBJ_SET
||
o
->
type
==
OBJ_HASH
||
o
->
type
==
OBJ_ZSET
);
/* Set i to the first option argument. The previous one is the cursor. */
...
...
@@ -579,7 +579,7 @@ void scanGenericCommand(client *c, robj *o, unsigned long cursor) {
char
buf
[
REDIS_LONGSTR_SIZE
];
int
len
;
redis
Assert
(
kobj
->
encoding
==
OBJ_ENCODING_INT
);
server
Assert
(
kobj
->
encoding
==
OBJ_ENCODING_INT
);
len
=
ll2string
(
buf
,
sizeof
(
buf
),(
long
)
kobj
->
ptr
);
if
(
!
stringmatchlen
(
pat
,
patlen
,
buf
,
len
,
0
))
filter
=
1
;
}
...
...
@@ -799,7 +799,7 @@ void moveCommand(client *c) {
int
removeExpire
(
redisDb
*
db
,
robj
*
key
)
{
/* An expire may only be removed if there is a corresponding entry in the
* main dict. Otherwise, the key will never be freed. */
redis
AssertWithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
server
AssertWithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
return
dictDelete
(
db
->
expires
,
key
->
ptr
)
==
DICT_OK
;
}
...
...
@@ -808,7 +808,7 @@ void setExpire(redisDb *db, robj *key, long long when) {
/* Reuse the sds from the main dict in the expire dict */
kde
=
dictFind
(
db
->
dict
,
key
->
ptr
);
redis
AssertWithInfo
(
NULL
,
key
,
kde
!=
NULL
);
server
AssertWithInfo
(
NULL
,
key
,
kde
!=
NULL
);
de
=
dictReplaceRaw
(
db
->
expires
,
dictGetKey
(
kde
));
dictSetSignedIntegerVal
(
de
,
when
);
}
...
...
@@ -824,7 +824,7 @@ long long getExpire(redisDb *db, robj *key) {
/* The entry was found in the expire dict, this means it should also
* be present in the main dict (safety check). */
redis
AssertWithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
server
AssertWithInfo
(
NULL
,
key
,
dictFind
(
db
->
dict
,
key
->
ptr
)
!=
NULL
);
return
dictGetSignedIntegerVal
(
de
);
}
...
...
@@ -924,7 +924,7 @@ void expireGenericCommand(client *c, long long basetime, int unit) {
if
(
when
<=
mstime
()
&&
!
server
.
loading
&&
!
server
.
masterhost
)
{
robj
*
aux
;
redis
AssertWithInfo
(
c
,
key
,
dbDelete
(
c
->
db
,
key
));
server
AssertWithInfo
(
c
,
key
,
dbDelete
(
c
->
db
,
key
));
server
.
dirty
++
;
/* Replicate/AOF this as an explicit DEL. */
...
...
@@ -1025,7 +1025,7 @@ int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, in
if
(
last
<
0
)
last
=
argc
+
last
;
keys
=
zmalloc
(
sizeof
(
int
)
*
((
last
-
cmd
->
firstkey
)
+
1
));
for
(
j
=
cmd
->
firstkey
;
j
<=
last
;
j
+=
cmd
->
keystep
)
{
redis
Assert
(
j
<
argc
);
server
Assert
(
j
<
argc
);
keys
[
i
++
]
=
j
;
}
*
numkeys
=
i
;
...
...
src/debug.c
View file @
2d9e3eb1
...
...
@@ -181,12 +181,12 @@ void computeDatasetDigest(unsigned char *final) {
double
score
;
eptr
=
ziplistIndex
(
zl
,
0
);
redis
Assert
(
eptr
!=
NULL
);
server
Assert
(
eptr
!=
NULL
);
sptr
=
ziplistNext
(
zl
,
eptr
);
redis
Assert
(
sptr
!=
NULL
);
server
Assert
(
sptr
!=
NULL
);
while
(
eptr
!=
NULL
)
{
redis
Assert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vll
));
server
Assert
(
ziplistGet
(
eptr
,
&
vstr
,
&
vlen
,
&
vll
));
score
=
zzlGetScore
(
sptr
);
memset
(
eledigest
,
0
,
20
);
...
...
@@ -267,7 +267,7 @@ void debugCommand(client *c) {
addReply
(
c
,
shared
.
ok
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"assert"
))
{
if
(
c
->
argc
>=
3
)
c
->
argv
[
2
]
=
tryObjectEncoding
(
c
->
argv
[
2
]);
redis
AssertWithInfo
(
c
,
c
->
argv
[
0
],
1
==
2
);
server
AssertWithInfo
(
c
,
c
->
argv
[
0
],
1
==
2
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"reload"
))
{
if
(
rdbSave
(
server
.
rdb_filename
)
!=
REDIS_OK
)
{
addReply
(
c
,
shared
.
err
);
...
...
@@ -470,7 +470,7 @@ void debugCommand(client *c) {
/* =========================== Crash handling ============================== */
void
_
redis
Assert
(
char
*
estr
,
char
*
file
,
int
line
)
{
void
_
server
Assert
(
char
*
estr
,
char
*
file
,
int
line
)
{
bugReportStart
();
serverLog
(
REDIS_WARNING
,
"=== ASSERTION FAILED ==="
);
serverLog
(
REDIS_WARNING
,
"==> %s:%d '%s' is not true"
,
file
,
line
,
estr
);
...
...
@@ -483,7 +483,7 @@ void _redisAssert(char *estr, char *file, int line) {
*
((
char
*
)
-
1
)
=
'x'
;
}
void
_
redis
AssertPrintClientInfo
(
client
*
c
)
{
void
_
server
AssertPrintClientInfo
(
client
*
c
)
{
int
j
;
bugReportStart
();
...
...
@@ -531,16 +531,16 @@ void serverLogObjectDebugInfo(robj *o) {
}
}
void
_
redis
AssertPrintObject
(
robj
*
o
)
{
void
_
server
AssertPrintObject
(
robj
*
o
)
{
bugReportStart
();
serverLog
(
REDIS_WARNING
,
"=== ASSERTION FAILED OBJECT CONTEXT ==="
);
serverLogObjectDebugInfo
(
o
);
}
void
_
redis
AssertWithInfo
(
client
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
)
{
if
(
c
)
_
redis
AssertPrintClientInfo
(
c
);
if
(
o
)
_
redis
AssertPrintObject
(
o
);
_
redis
Assert
(
estr
,
file
,
line
);
void
_
server
AssertWithInfo
(
client
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
)
{
if
(
c
)
_
server
AssertPrintClientInfo
(
c
);
if
(
o
)
_
server
AssertPrintObject
(
o
);
_
server
Assert
(
estr
,
file
,
line
);
}
void
_redisPanic
(
char
*
msg
,
char
*
file
,
int
line
)
{
...
...
src/hyperloglog.c
View file @
2d9e3eb1
...
...
@@ -877,7 +877,7 @@ promote: /* Promote to dense representation. */
* is propagated to slaves / AOF, so if there is a sparse -> dense
* convertion, it will be performed in all the slaves as well. */
int
dense_retval
=
hllDenseAdd
(
hdr
->
registers
,
ele
,
elesize
);
redis
Assert
(
dense_retval
==
1
);
server
Assert
(
dense_retval
==
1
);
return
dense_retval
;
}
...
...
@@ -1108,7 +1108,7 @@ robj *createHLLObject(void) {
p
+=
2
;
aux
-=
xzero
;
}
redis
Assert
((
p
-
(
uint8_t
*
)
s
)
==
sparselen
);
server
Assert
((
p
-
(
uint8_t
*
)
s
)
==
sparselen
);
/* Create the actual object. */
o
=
createObject
(
OBJ_STRING
,
s
);
...
...
src/multi.c
View file @
2d9e3eb1
...
...
@@ -244,7 +244,7 @@ void unwatchAllKeys(client *c) {
* from the list */
wk
=
listNodeValue
(
ln
);
clients
=
dictFetchValue
(
wk
->
db
->
watched_keys
,
wk
->
key
);
redis
AssertWithInfo
(
c
,
NULL
,
clients
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
clients
!=
NULL
);
listDelNode
(
clients
,
listSearchKey
(
clients
,
c
));
/* Kill the entry at all if this was the only client */
if
(
listLength
(
clients
)
==
0
)
...
...
src/networking.c
View file @
2d9e3eb1
...
...
@@ -44,7 +44,7 @@ size_t sdsZmallocSize(sds s) {
/* Return the amount of memory used by the sds string at object->ptr
* for a string object. */
size_t
getStringObjectSdsUsedMemory
(
robj
*
o
)
{
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
switch
(
o
->
encoding
)
{
case
OBJ_ENCODING_RAW
:
return
sdsZmallocSize
(
o
->
ptr
);
case
OBJ_ENCODING_EMBSTR
:
return
zmalloc_size
(
o
)
-
sizeof
(
robj
);
...
...
@@ -186,7 +186,7 @@ int prepareClientToWrite(client *c) {
robj
*
dupLastObjectIfNeeded
(
list
*
reply
)
{
robj
*
new
,
*
cur
;
listNode
*
ln
;
redis
Assert
(
listLength
(
reply
)
>
0
);
server
Assert
(
listLength
(
reply
)
>
0
);
ln
=
listLast
(
reply
);
cur
=
listNodeValue
(
ln
);
if
(
cur
->
refcount
>
1
)
{
...
...
@@ -748,7 +748,7 @@ void freeClient(client *c) {
/* Remove from the list of clients */
if
(
c
->
fd
!=
-
1
)
{
ln
=
listSearchKey
(
server
.
clients
,
c
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
listDelNode
(
server
.
clients
,
ln
);
}
...
...
@@ -756,7 +756,7 @@ void freeClient(client *c) {
* remove it from the list of unblocked clients. */
if
(
c
->
flags
&
REDIS_UNBLOCKED
)
{
ln
=
listSearchKey
(
server
.
unblocked_clients
,
c
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
listDelNode
(
server
.
unblocked_clients
,
ln
);
}
...
...
@@ -769,7 +769,7 @@ void freeClient(client *c) {
}
list
*
l
=
(
c
->
flags
&
REDIS_MONITOR
)
?
server
.
monitors
:
server
.
slaves
;
ln
=
listSearchKey
(
l
,
c
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
listDelNode
(
l
,
ln
);
/* We need to remember the time when we started to have zero
* attached slaves, as after some time we'll free the replication
...
...
@@ -787,7 +787,7 @@ void freeClient(client *c) {
* from the queue. */
if
(
c
->
flags
&
REDIS_CLOSE_ASAP
)
{
ln
=
listSearchKey
(
server
.
clients_to_close
,
c
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
listDelNode
(
server
.
clients_to_close
,
ln
);
}
...
...
@@ -1000,7 +1000,7 @@ int processMultibulkBuffer(client *c) {
if
(
c
->
multibulklen
==
0
)
{
/* The client should have been reset */
redis
AssertWithInfo
(
c
,
NULL
,
c
->
argc
==
0
);
server
AssertWithInfo
(
c
,
NULL
,
c
->
argc
==
0
);
/* Multi bulk length cannot be read without a \r\n */
newline
=
strchr
(
c
->
querybuf
,
'\r'
);
...
...
@@ -1018,7 +1018,7 @@ int processMultibulkBuffer(client *c) {
/* We know for sure there is a whole line since newline != NULL,
* so go ahead and find out the multi bulk length. */
redis
AssertWithInfo
(
c
,
NULL
,
c
->
querybuf
[
0
]
==
'*'
);
server
AssertWithInfo
(
c
,
NULL
,
c
->
querybuf
[
0
]
==
'*'
);
ok
=
string2ll
(
c
->
querybuf
+
1
,
newline
-
(
c
->
querybuf
+
1
),
&
ll
);
if
(
!
ok
||
ll
>
1024
*
1024
)
{
addReplyError
(
c
,
"Protocol error: invalid multibulk length"
);
...
...
@@ -1039,7 +1039,7 @@ int processMultibulkBuffer(client *c) {
c
->
argv
=
zmalloc
(
sizeof
(
robj
*
)
*
c
->
multibulklen
);
}
redis
AssertWithInfo
(
c
,
NULL
,
c
->
multibulklen
>
0
);
server
AssertWithInfo
(
c
,
NULL
,
c
->
multibulklen
>
0
);
while
(
c
->
multibulklen
)
{
/* Read bulk length if unknown */
if
(
c
->
bulklen
==
-
1
)
{
...
...
@@ -1523,7 +1523,7 @@ void rewriteClientCommandVector(client *c, int argc, ...) {
c
->
argv
=
argv
;
c
->
argc
=
argc
;
c
->
cmd
=
lookupCommandOrOriginal
(
c
->
argv
[
0
]
->
ptr
);
redis
AssertWithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
va_end
(
ap
);
}
...
...
@@ -1534,7 +1534,7 @@ void replaceClientCommandVector(client *c, int argc, robj **argv) {
c
->
argv
=
argv
;
c
->
argc
=
argc
;
c
->
cmd
=
lookupCommandOrOriginal
(
c
->
argv
[
0
]
->
ptr
);
redis
AssertWithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
}
/* Rewrite a single item in the command vector.
...
...
@@ -1542,7 +1542,7 @@ void replaceClientCommandVector(client *c, int argc, robj **argv) {
void
rewriteClientCommandArgument
(
client
*
c
,
int
i
,
robj
*
newval
)
{
robj
*
oldval
;
redis
AssertWithInfo
(
c
,
NULL
,
i
<
c
->
argc
);
server
AssertWithInfo
(
c
,
NULL
,
i
<
c
->
argc
);
oldval
=
c
->
argv
[
i
];
c
->
argv
[
i
]
=
newval
;
incrRefCount
(
newval
);
...
...
@@ -1551,7 +1551,7 @@ void rewriteClientCommandArgument(client *c, int i, robj *newval) {
/* If this is the command name make sure to fix c->cmd. */
if
(
i
==
0
)
{
c
->
cmd
=
lookupCommandOrOriginal
(
c
->
argv
[
0
]
->
ptr
);
redis
AssertWithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
c
->
cmd
!=
NULL
);
}
}
...
...
@@ -1654,7 +1654,7 @@ int checkClientOutputBufferLimits(client *c) {
* called from contexts where the client can't be freed safely, i.e. from the
* lower level functions pushing data inside the client output buffers. */
void
asyncCloseClientOnOutputBufferLimitReached
(
client
*
c
)
{
redis
Assert
(
c
->
reply_bytes
<
SIZE_MAX
-
(
1024
*
64
));
server
Assert
(
c
->
reply_bytes
<
SIZE_MAX
-
(
1024
*
64
));
if
(
c
->
reply_bytes
==
0
||
c
->
flags
&
REDIS_CLOSE_ASAP
)
return
;
if
(
checkClientOutputBufferLimits
(
c
))
{
sds
client
=
catClientInfoString
(
sdsempty
(),
c
);
...
...
src/object.c
View file @
2d9e3eb1
...
...
@@ -163,7 +163,7 @@ robj *createStringObjectFromLongDouble(long double value, int humanfriendly) {
robj
*
dupStringObject
(
robj
*
o
)
{
robj
*
d
;
redis
Assert
(
o
->
type
==
OBJ_STRING
);
server
Assert
(
o
->
type
==
OBJ_STRING
);
switch
(
o
->
encoding
)
{
case
OBJ_ENCODING_RAW
:
...
...
@@ -348,7 +348,7 @@ int checkType(client *c, robj *o, int type) {
}
int
isObjectRepresentableAsLongLong
(
robj
*
o
,
long
long
*
llval
)
{
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
if
(
o
->
encoding
==
OBJ_ENCODING_INT
)
{
if
(
llval
)
*
llval
=
(
long
)
o
->
ptr
;
return
REDIS_OK
;
...
...
@@ -367,7 +367,7 @@ robj *tryObjectEncoding(robj *o) {
* in this function. Other types use encoded memory efficient
* representations but are handled by the commands implementing
* the type. */
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
/* We try some specialized encoding only for objects that are
* RAW or EMBSTR encoded, in other words objects that are still
...
...
@@ -469,7 +469,7 @@ robj *getDecodedObject(robj *o) {
#define REDIS_COMPARE_COLL (1<<1)
int
compareStringObjectsWithFlags
(
robj
*
a
,
robj
*
b
,
int
flags
)
{
redis
AssertWithInfo
(
NULL
,
a
,
a
->
type
==
OBJ_STRING
&&
b
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
a
,
a
->
type
==
OBJ_STRING
&&
b
->
type
==
OBJ_STRING
);
char
bufa
[
128
],
bufb
[
128
],
*
astr
,
*
bstr
;
size_t
alen
,
blen
,
minlen
;
...
...
@@ -526,7 +526,7 @@ int equalStringObjects(robj *a, robj *b) {
}
size_t
stringObjectLen
(
robj
*
o
)
{
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
if
(
sdsEncodedObject
(
o
))
{
return
sdslen
(
o
->
ptr
);
}
else
{
...
...
@@ -541,7 +541,7 @@ int getDoubleFromObject(robj *o, double *target) {
if
(
o
==
NULL
)
{
value
=
0
;
}
else
{
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
if
(
sdsEncodedObject
(
o
))
{
errno
=
0
;
value
=
strtod
(
o
->
ptr
,
&
eptr
);
...
...
@@ -583,7 +583,7 @@ int getLongDoubleFromObject(robj *o, long double *target) {
if
(
o
==
NULL
)
{
value
=
0
;
}
else
{
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
if
(
sdsEncodedObject
(
o
))
{
errno
=
0
;
value
=
strtold
(
o
->
ptr
,
&
eptr
);
...
...
@@ -621,7 +621,7 @@ int getLongLongFromObject(robj *o, long long *target) {
if
(
o
==
NULL
)
{
value
=
0
;
}
else
{
redis
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
server
AssertWithInfo
(
NULL
,
o
,
o
->
type
==
OBJ_STRING
);
if
(
sdsEncodedObject
(
o
))
{
errno
=
0
;
value
=
strtoll
(
o
->
ptr
,
&
eptr
,
10
);
...
...
src/pubsub.c
View file @
2d9e3eb1
...
...
@@ -98,10 +98,10 @@ int pubsubUnsubscribeChannel(client *c, robj *channel, int notify) {
retval
=
1
;
/* Remove the client from the channel -> clients list hash table */
de
=
dictFind
(
server
.
pubsub_channels
,
channel
);
redis
AssertWithInfo
(
c
,
NULL
,
de
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
de
!=
NULL
);
clients
=
dictGetVal
(
de
);
ln
=
listSearchKey
(
clients
,
c
);
redis
AssertWithInfo
(
c
,
NULL
,
ln
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
ln
!=
NULL
);
listDelNode
(
clients
,
ln
);
if
(
listLength
(
clients
)
==
0
)
{
/* Free the list and associated hash entry at all if this was
...
...
src/rdb.c
View file @
2d9e3eb1
...
...
@@ -357,7 +357,7 @@ ssize_t rdbSaveLongLongAsStringObject(rio *rdb, long long value) {
}
else
{
/* Encode as string */
enclen
=
ll2string
((
char
*
)
buf
,
32
,
value
);
redis
Assert
(
enclen
<
32
);
server
Assert
(
enclen
<
32
);
if
((
n
=
rdbSaveLen
(
rdb
,
enclen
))
==
-
1
)
return
-
1
;
nwritten
+=
n
;
if
((
n
=
rdbWriteRaw
(
rdb
,
buf
,
enclen
))
==
-
1
)
return
-
1
;
...
...
@@ -373,7 +373,7 @@ int rdbSaveStringObject(rio *rdb, robj *obj) {
if
(
obj
->
encoding
==
OBJ_ENCODING_INT
)
{
return
rdbSaveLongLongAsStringObject
(
rdb
,(
long
)
obj
->
ptr
);
}
else
{
redis
AssertWithInfo
(
NULL
,
obj
,
sdsEncodedObject
(
obj
));
server
AssertWithInfo
(
NULL
,
obj
,
sdsEncodedObject
(
obj
));
return
rdbSaveRawString
(
rdb
,
obj
->
ptr
,
sdslen
(
obj
->
ptr
));
}
}
...
...
@@ -666,7 +666,7 @@ ssize_t rdbSaveObject(rio *rdb, robj *o) {
* we could switch to a faster solution. */
size_t
rdbSavedObjectLen
(
robj
*
o
)
{
ssize_t
len
=
rdbSaveObject
(
NULL
,
o
);
redis
AssertWithInfo
(
NULL
,
o
,
len
!=
-
1
);
server
AssertWithInfo
(
NULL
,
o
,
len
!=
-
1
);
return
len
;
}
...
...
@@ -1051,10 +1051,10 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
/* Load raw strings */
field
=
rdbLoadStringObject
(
rdb
);
if
(
field
==
NULL
)
return
NULL
;
redis
Assert
(
sdsEncodedObject
(
field
));
server
Assert
(
sdsEncodedObject
(
field
));
value
=
rdbLoadStringObject
(
rdb
);
if
(
value
==
NULL
)
return
NULL
;
redis
Assert
(
sdsEncodedObject
(
value
));
server
Assert
(
sdsEncodedObject
(
value
));
/* Add pair to ziplist */
o
->
ptr
=
ziplistPush
(
o
->
ptr
,
field
->
ptr
,
sdslen
(
field
->
ptr
),
ZIPLIST_TAIL
);
...
...
@@ -1094,7 +1094,7 @@ robj *rdbLoadObject(int rdbtype, rio *rdb) {
}
/* All pairs should be read by now */
redis
Assert
(
len
==
0
);
server
Assert
(
len
==
0
);
}
else
if
(
rdbtype
==
REDIS_RDB_TYPE_LIST_QUICKLIST
)
{
if
((
len
=
rdbLoadLen
(
rdb
,
NULL
))
==
REDIS_RDB_LENERR
)
return
NULL
;
o
=
createQuicklistObject
();
...
...
src/redisassert.h
View file @
2d9e3eb1
...
...
@@ -40,8 +40,8 @@
#include <unistd.h>
/* for _exit() */
#define assert(_e) ((_e)?(void)0 : (_
redis
Assert(#_e,__FILE__,__LINE__),_exit(1)))
#define assert(_e) ((_e)?(void)0 : (_
server
Assert(#_e,__FILE__,__LINE__),_exit(1)))
void
_
redis
Assert
(
char
*
estr
,
char
*
file
,
int
line
);
void
_
server
Assert
(
char
*
estr
,
char
*
file
,
int
line
);
#endif
src/replication.c
View file @
2d9e3eb1
...
...
@@ -69,7 +69,7 @@ char *replicationGetSlaveName(client *c) {
/* ---------------------------------- MASTER -------------------------------- */
void
createReplicationBacklog
(
void
)
{
redis
Assert
(
server
.
repl_backlog
==
NULL
);
server
Assert
(
server
.
repl_backlog
==
NULL
);
server
.
repl_backlog
=
zmalloc
(
server
.
repl_backlog_size
);
server
.
repl_backlog_histlen
=
0
;
server
.
repl_backlog_idx
=
0
;
...
...
@@ -113,7 +113,7 @@ void resizeReplicationBacklog(long long newsize) {
}
void
freeReplicationBacklog
(
void
)
{
redis
Assert
(
listLength
(
server
.
slaves
)
==
0
);
server
Assert
(
listLength
(
server
.
slaves
)
==
0
);
zfree
(
server
.
repl_backlog
);
server
.
repl_backlog
=
NULL
;
}
...
...
@@ -175,7 +175,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
if
(
server
.
repl_backlog
==
NULL
&&
listLength
(
slaves
)
==
0
)
return
;
/* We can't have slaves attached and no backlog. */
redis
Assert
(
!
(
listLength
(
slaves
)
!=
0
&&
server
.
repl_backlog
==
NULL
));
server
Assert
(
!
(
listLength
(
slaves
)
!=
0
&&
server
.
repl_backlog
==
NULL
));
/* Send SELECT command to every slave if needed. */
if
(
server
.
slaveseldb
!=
dictid
)
{
...
...
@@ -821,7 +821,7 @@ void updateSlavesWaitingBgsave(int bgsaveerr, int type) {
/* Abort the async download of the bulk dataset while SYNC-ing with master */
void
replicationAbortSyncTransfer
(
void
)
{
redis
Assert
(
server
.
repl_state
==
REDIS_REPL_TRANSFER
);
server
Assert
(
server
.
repl_state
==
REDIS_REPL_TRANSFER
);
aeDeleteFileEvent
(
server
.
el
,
server
.
repl_transfer_s
,
AE_READABLE
);
close
(
server
.
repl_transfer_s
);
...
...
@@ -1411,7 +1411,7 @@ int connectWithMaster(void) {
void
undoConnectWithMaster
(
void
)
{
int
fd
=
server
.
repl_transfer_s
;
redis
Assert
(
server
.
repl_state
==
REDIS_REPL_CONNECTING
||
server
Assert
(
server
.
repl_state
==
REDIS_REPL_CONNECTING
||
server
.
repl_state
==
REDIS_REPL_RECEIVE_PONG
);
aeDeleteFileEvent
(
server
.
el
,
fd
,
AE_READABLE
|
AE_WRITABLE
);
close
(
fd
);
...
...
@@ -1603,13 +1603,13 @@ void replicationSendAck(void) {
void
replicationCacheMaster
(
client
*
c
)
{
listNode
*
ln
;
redis
Assert
(
server
.
master
!=
NULL
&&
server
.
cached_master
==
NULL
);
server
Assert
(
server
.
master
!=
NULL
&&
server
.
cached_master
==
NULL
);
serverLog
(
REDIS_NOTICE
,
"Caching the disconnected master state."
);
/* Remove from the list of clients, we don't want this client to be
* listed by CLIENT LIST or processed in any way by batch operations. */
ln
=
listSearchKey
(
server
.
clients
,
c
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
listDelNode
(
server
.
clients
,
ln
);
/* Save the master. Server.master will be set to null later by
...
...
@@ -1774,14 +1774,14 @@ void replicationScriptCacheAdd(sds sha1) {
sds
oldest
=
listNodeValue
(
ln
);
retval
=
dictDelete
(
server
.
repl_scriptcache_dict
,
oldest
);
redis
Assert
(
retval
==
DICT_OK
);
server
Assert
(
retval
==
DICT_OK
);
listDelNode
(
server
.
repl_scriptcache_fifo
,
ln
);
}
/* Add current. */
retval
=
dictAdd
(
server
.
repl_scriptcache_dict
,
key
,
NULL
);
listAddNodeHead
(
server
.
repl_scriptcache_fifo
,
key
);
redis
Assert
(
retval
==
DICT_OK
);
server
Assert
(
retval
==
DICT_OK
);
}
/* Returns non-zero if the specified entry exists inside the cache, that is,
...
...
@@ -1880,7 +1880,7 @@ void waitCommand(client *c) {
* instead. */
void
unblockClientWaitingReplicas
(
client
*
c
)
{
listNode
*
ln
=
listSearchKey
(
server
.
clients_waiting_acks
,
c
);
redis
Assert
(
ln
!=
NULL
);
server
Assert
(
ln
!=
NULL
);
listDelNode
(
server
.
clients_waiting_acks
,
ln
);
}
...
...
src/rio.c
View file @
2d9e3eb1
...
...
@@ -299,7 +299,7 @@ void rioGenericUpdateChecksum(rio *r, const void *buf, size_t len) {
* disk I/O concentrated in very little time. When we fsync in an explicit
* way instead the I/O pressure is more distributed across time. */
void
rioSetAutoSync
(
rio
*
r
,
off_t
bytes
)
{
redis
Assert
(
r
->
read
==
rioFileIO
.
read
);
server
Assert
(
r
->
read
==
rioFileIO
.
read
);
r
->
io
.
file
.
autosync
=
bytes
;
}
...
...
src/scripting.c
View file @
2d9e3eb1
...
...
@@ -914,7 +914,7 @@ int luaCreateFunction(client *c, lua_State *lua, char *funcname, robj *body) {
{
int
retval
=
dictAdd
(
server
.
lua_scripts
,
sdsnewlen
(
funcname
+
2
,
40
),
body
);
redis
AssertWithInfo
(
c
,
NULL
,
retval
==
DICT_OK
);
server
AssertWithInfo
(
c
,
NULL
,
retval
==
DICT_OK
);
incrRefCount
(
body
);
}
return
REDIS_OK
;
...
...
@@ -996,7 +996,7 @@ void evalGenericCommand(client *c, int evalsha) {
}
/* Now the following is guaranteed to return non nil */
lua_getglobal
(
lua
,
funcname
);
redis
Assert
(
!
lua_isnil
(
lua
,
-
1
));
server
Assert
(
!
lua_isnil
(
lua
,
-
1
));
}
/* Populate the argv and keys table accordingly to the arguments that
...
...
@@ -1081,7 +1081,7 @@ void evalGenericCommand(client *c, int evalsha) {
robj
*
script
=
dictFetchValue
(
server
.
lua_scripts
,
c
->
argv
[
1
]
->
ptr
);
replicationScriptCacheAdd
(
c
->
argv
[
1
]
->
ptr
);
redis
AssertWithInfo
(
c
,
NULL
,
script
!=
NULL
);
server
AssertWithInfo
(
c
,
NULL
,
script
!=
NULL
);
rewriteClientCommandArgument
(
c
,
0
,
resetRefCount
(
createStringObject
(
"EVAL"
,
4
)));
rewriteClientCommandArgument
(
c
,
1
,
script
);
...
...
src/sentinel.c
View file @
2d9e3eb1
...
...
@@ -454,7 +454,7 @@ void initSentinel(void) {
struct
redisCommand
*
cmd
=
sentinelcmds
+
j
;
retval
=
dictAdd
(
server
.
commands
,
sdsnew
(
cmd
->
name
),
cmd
);
redis
Assert
(
retval
==
DICT_OK
);
server
Assert
(
retval
==
DICT_OK
);
}
/* Initialize various data structures. */
...
...
@@ -705,7 +705,7 @@ void sentinelScheduleScriptExecution(char *path, ...) {
sentinelReleaseScriptJob
(
sj
);
break
;
}
redis
Assert
(
listLength
(
sentinel
.
scripts_queue
)
<=
server
Assert
(
listLength
(
sentinel
.
scripts_queue
)
<=
SENTINEL_SCRIPT_MAX_QUEUE
);
}
}
...
...
@@ -973,7 +973,7 @@ void instanceLinkCloseConnection(instanceLink *link, redisAsyncContext *c) {
* replies for an instance that no longer exists. */
instanceLink
*
releaseInstanceLink
(
instanceLink
*
link
,
sentinelRedisInstance
*
ri
)
{
redis
Assert
(
link
->
refcount
>
0
);
server
Assert
(
link
->
refcount
>
0
);
link
->
refcount
--
;
if
(
link
->
refcount
!=
0
)
{
if
(
ri
&&
ri
->
link
->
cc
)
{
...
...
@@ -1016,7 +1016,7 @@ instanceLink *releaseInstanceLink(instanceLink *link, sentinelRedisInstance *ri)
* different master and sharing was performed. Otherwise REDIS_ERR
* is returned. */
int
sentinelTryConnectionSharing
(
sentinelRedisInstance
*
ri
)
{
redis
Assert
(
ri
->
flags
&
SRI_SENTINEL
);
server
Assert
(
ri
->
flags
&
SRI_SENTINEL
);
dictIterator
*
di
;
dictEntry
*
de
;
...
...
@@ -1052,7 +1052,7 @@ int sentinelTryConnectionSharing(sentinelRedisInstance *ri) {
*
* Return the number of updated Sentinel addresses. */
int
sentinelUpdateSentinelAddressInAllMasters
(
sentinelRedisInstance
*
ri
)
{
redis
Assert
(
ri
->
flags
&
SRI_SENTINEL
);
server
Assert
(
ri
->
flags
&
SRI_SENTINEL
);
dictIterator
*
di
;
dictEntry
*
de
;
int
reconfigured
=
0
;
...
...
@@ -1140,8 +1140,8 @@ sentinelRedisInstance *createSentinelRedisInstance(char *name, int flags, char *
dict
*
table
=
NULL
;
char
slavename
[
REDIS_PEER_ID_LEN
],
*
sdsname
;
redis
Assert
(
flags
&
(
SRI_MASTER
|
SRI_SLAVE
|
SRI_SENTINEL
));
redis
Assert
((
flags
&
SRI_MASTER
)
||
master
!=
NULL
);
server
Assert
(
flags
&
(
SRI_MASTER
|
SRI_SLAVE
|
SRI_SENTINEL
));
server
Assert
((
flags
&
SRI_MASTER
)
||
master
!=
NULL
);
/* Check address validity. */
addr
=
createSentinelAddr
(
hostname
,
port
);
...
...
@@ -1262,7 +1262,7 @@ sentinelRedisInstance *sentinelRedisInstanceLookupSlave(
sentinelRedisInstance
*
slave
;
char
buf
[
REDIS_PEER_ID_LEN
];
redis
Assert
(
ri
->
flags
&
SRI_MASTER
);
server
Assert
(
ri
->
flags
&
SRI_MASTER
);
anetFormatAddr
(
buf
,
sizeof
(
buf
),
ip
,
port
);
key
=
sdsnew
(
buf
);
slave
=
dictFetchValue
(
ri
->
slaves
,
key
);
...
...
@@ -1320,7 +1320,7 @@ sentinelRedisInstance *getSentinelRedisInstanceByAddrAndRunID(dict *instances, c
dictEntry
*
de
;
sentinelRedisInstance
*
instance
=
NULL
;
redis
Assert
(
ip
||
runid
);
/* User must pass at least one search param. */
server
Assert
(
ip
||
runid
);
/* User must pass at least one search param. */
di
=
dictGetIterator
(
instances
);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
sentinelRedisInstance
*
ri
=
dictGetVal
(
de
);
...
...
@@ -1388,7 +1388,7 @@ void sentinelDelFlagsToDictOfRedisInstances(dict *instances, int flags) {
#define SENTINEL_RESET_NO_SENTINELS (1<<0)
void
sentinelResetMaster
(
sentinelRedisInstance
*
ri
,
int
flags
)
{
redis
Assert
(
ri
->
flags
&
SRI_MASTER
);
server
Assert
(
ri
->
flags
&
SRI_MASTER
);
dictRelease
(
ri
->
slaves
);
ri
->
slaves
=
dictCreate
(
&
instancesDictType
,
NULL
);
if
(
!
(
flags
&
SENTINEL_RESET_NO_SENTINELS
))
{
...
...
@@ -3606,7 +3606,7 @@ int sentinelLeaderIncr(dict *counters, char *runid) {
return
oldval
+
1
;
}
else
{
de
=
dictAddRaw
(
counters
,
runid
);
redis
Assert
(
de
!=
NULL
);
server
Assert
(
de
!=
NULL
);
dictSetUnsignedIntegerVal
(
de
,
1
);
return
1
;
}
...
...
@@ -3628,7 +3628,7 @@ char *sentinelGetLeader(sentinelRedisInstance *master, uint64_t epoch) {
uint64_t
leader_epoch
;
uint64_t
max_votes
=
0
;
redis
Assert
(
master
->
flags
&
(
SRI_O_DOWN
|
SRI_FAILOVER_IN_PROGRESS
));
server
Assert
(
master
->
flags
&
(
SRI_O_DOWN
|
SRI_FAILOVER_IN_PROGRESS
));
counters
=
dictCreate
(
&
leaderVotesDictType
,
NULL
);
voters
=
dictSize
(
master
->
sentinels
)
+
1
;
/* All the other sentinels and me. */
...
...
@@ -3751,7 +3751,7 @@ int sentinelSendSlaveOf(sentinelRedisInstance *ri, char *host, int port) {
/* Setup the master state to start a failover. */
void
sentinelStartFailover
(
sentinelRedisInstance
*
master
)
{
redis
Assert
(
master
->
flags
&
SRI_MASTER
);
server
Assert
(
master
->
flags
&
SRI_MASTER
);
master
->
failover_state
=
SENTINEL_FAILOVER_STATE_WAIT_START
;
master
->
flags
|=
SRI_FAILOVER_IN_PROGRESS
;
...
...
@@ -4137,7 +4137,7 @@ void sentinelFailoverSwitchToPromotedSlave(sentinelRedisInstance *master) {
}
void
sentinelFailoverStateMachine
(
sentinelRedisInstance
*
ri
)
{
redis
Assert
(
ri
->
flags
&
SRI_MASTER
);
server
Assert
(
ri
->
flags
&
SRI_MASTER
);
if
(
!
(
ri
->
flags
&
SRI_FAILOVER_IN_PROGRESS
))
return
;
...
...
@@ -4166,8 +4166,8 @@ void sentinelFailoverStateMachine(sentinelRedisInstance *ri) {
* the slave -> master switch. Otherwise the failover can't be aborted and
* will reach its end (possibly by timeout). */
void
sentinelAbortFailover
(
sentinelRedisInstance
*
ri
)
{
redis
Assert
(
ri
->
flags
&
SRI_FAILOVER_IN_PROGRESS
);
redis
Assert
(
ri
->
failover_state
<=
SENTINEL_FAILOVER_STATE_WAIT_PROMOTION
);
server
Assert
(
ri
->
flags
&
SRI_FAILOVER_IN_PROGRESS
);
server
Assert
(
ri
->
failover_state
<=
SENTINEL_FAILOVER_STATE_WAIT_PROMOTION
);
ri
->
flags
&=
~
(
SRI_FAILOVER_IN_PROGRESS
|
SRI_FORCE_FAILOVER
);
ri
->
failover_state
=
SENTINEL_FAILOVER_STATE_NONE
;
...
...
src/server.c
View file @
2d9e3eb1
...
...
@@ -1938,7 +1938,7 @@ void populateCommandTable(void) {
/* Populate an additional dictionary that will be unaffected
* by rename-command statements in redis.conf. */
retval2
=
dictAdd
(
server
.
orig_commands
,
sdsnew
(
c
->
name
),
c
);
redis
Assert
(
retval1
==
DICT_OK
&&
retval2
==
DICT_OK
);
server
Assert
(
retval1
==
DICT_OK
&&
retval2
==
DICT_OK
);
}
}
...
...
src/server.h
View file @
2d9e3eb1
...
...
@@ -412,8 +412,8 @@ typedef long long mstime_t; /* millisecond time type. */
#define run_with_period(_ms_) if ((_ms_ <= 1000/server.hz) || !(server.cronloops%((_ms_)/(1000/server.hz))))
/* We can print the stacktrace, so our assert is defined this way: */
#define
redis
AssertWithInfo(_c,_o,_e) ((_e)?(void)0 : (_
redis
AssertWithInfo(_c,_o,#_e,__FILE__,__LINE__),_exit(1)))
#define
redis
Assert(_e) ((_e)?(void)0 : (_
redis
Assert(#_e,__FILE__,__LINE__),_exit(1)))
#define
server
AssertWithInfo(_c,_o,_e) ((_e)?(void)0 : (_
server
AssertWithInfo(_c,_o,#_e,__FILE__,__LINE__),_exit(1)))
#define
server
Assert(_e) ((_e)?(void)0 : (_
server
Assert(#_e,__FILE__,__LINE__),_exit(1)))
#define redisPanic(_e) _redisPanic(#_e,__FILE__,__LINE__),_exit(1)
/*-----------------------------------------------------------------------------
...
...
@@ -1581,8 +1581,8 @@ void *realloc(void *ptr, size_t size) __attribute__ ((deprecated));
#endif
/* Debugging stuff */
void
_
redis
AssertWithInfo
(
client
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
);
void
_
redis
Assert
(
char
*
estr
,
char
*
file
,
int
line
);
void
_
server
AssertWithInfo
(
client
*
c
,
robj
*
o
,
char
*
estr
,
char
*
file
,
int
line
);
void
_
server
Assert
(
char
*
estr
,
char
*
file
,
int
line
);
void
_redisPanic
(
char
*
msg
,
char
*
file
,
int
line
);
void
bugReportStart
(
void
);
void
serverLogObjectDebugInfo
(
robj
*
o
);
...
...
src/sort.c
View file @
2d9e3eb1
...
...
@@ -416,7 +416,7 @@ void sortCommand(client *c) {
}
while
(
rangelen
--
)
{
redis
AssertWithInfo
(
c
,
sortval
,
ln
!=
NULL
);
server
AssertWithInfo
(
c
,
sortval
,
ln
!=
NULL
);
ele
=
ln
->
obj
;
vector
[
j
].
obj
=
ele
;
vector
[
j
].
u
.
score
=
0
;
...
...
@@ -442,7 +442,7 @@ void sortCommand(client *c) {
}
else
{
redisPanic
(
"Unknown type"
);
}
redis
AssertWithInfo
(
c
,
sortval
,
j
==
vectorlen
);
server
AssertWithInfo
(
c
,
sortval
,
j
==
vectorlen
);
/* Now it's time to load the right scores in the sorting vector */
if
(
dontsort
==
0
)
{
...
...
@@ -475,7 +475,7 @@ void sortCommand(client *c) {
* far. We can just cast it */
vector
[
j
].
u
.
score
=
(
long
)
byval
->
ptr
;
}
else
{
redis
AssertWithInfo
(
c
,
sortval
,
1
!=
1
);
server
AssertWithInfo
(
c
,
sortval
,
1
!=
1
);
}
}
...
...
@@ -526,7 +526,7 @@ void sortCommand(client *c) {
}
}
else
{
/* Always fails */
redis
AssertWithInfo
(
c
,
sortval
,
sop
->
type
==
REDIS_SORT_GET
);
server
AssertWithInfo
(
c
,
sortval
,
sop
->
type
==
REDIS_SORT_GET
);
}
}
}
...
...
@@ -557,7 +557,7 @@ void sortCommand(client *c) {
decrRefCount
(
val
);
}
else
{
/* Always fails */
redis
AssertWithInfo
(
c
,
sortval
,
sop
->
type
==
REDIS_SORT_GET
);
server
AssertWithInfo
(
c
,
sortval
,
sop
->
type
==
REDIS_SORT_GET
);
}
}
}
...
...
Prev
1
2
Next
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