Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
redis
提交
560e0499
R
redis
项目概览
别团等shy哥发育
/
redis
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
560e0499
编写于
1月 17, 2013
作者:
G
guiquanz
提交者:
antirez
1月 19, 2013
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed many typos.
上级
c2b43eac
变更
38
隐藏空白更改
内联
并排
Showing
38 changed file
with
137 addition
and
137 deletion
+137
-137
redis.conf
redis.conf
+1
-1
sentinel.conf
sentinel.conf
+1
-1
src/adlist.c
src/adlist.c
+3
-3
src/ae.c
src/ae.c
+3
-3
src/ae_evport.c
src/ae_evport.c
+6
-6
src/anet.c
src/anet.c
+2
-2
src/aof.c
src/aof.c
+1
-1
src/bio.c
src/bio.c
+1
-1
src/bitops.c
src/bitops.c
+2
-2
src/config.c
src/config.c
+3
-3
src/db.c
src/db.c
+3
-3
src/debug.c
src/debug.c
+2
-2
src/dict.c
src/dict.c
+1
-1
src/lzfP.h
src/lzfP.h
+4
-4
src/mkreleasehdr.sh
src/mkreleasehdr.sh
+1
-1
src/multi.c
src/multi.c
+2
-2
src/networking.c
src/networking.c
+4
-4
src/object.c
src/object.c
+1
-1
src/pubsub.c
src/pubsub.c
+1
-1
src/rdb.c
src/rdb.c
+5
-5
src/rdb.h
src/rdb.h
+1
-1
src/redis-check-dump.c
src/redis-check-dump.c
+2
-2
src/redis-cli.c
src/redis-cli.c
+3
-3
src/redis.c
src/redis.c
+14
-14
src/redis.h
src/redis.h
+11
-11
src/release.c
src/release.c
+2
-2
src/replication.c
src/replication.c
+5
-5
src/scripting.c
src/scripting.c
+6
-6
src/sds.c
src/sds.c
+2
-2
src/sentinel.c
src/sentinel.c
+10
-10
src/sha1.c
src/sha1.c
+18
-18
src/sort.c
src/sort.c
+3
-3
src/t_list.c
src/t_list.c
+5
-5
src/t_set.c
src/t_set.c
+2
-2
src/t_string.c
src/t_string.c
+2
-2
src/t_zset.c
src/t_zset.c
+2
-2
src/zmalloc.c
src/zmalloc.c
+1
-1
tests/unit/scripting.tcl
tests/unit/scripting.tcl
+1
-1
未找到文件。
redis.conf
浏览文件 @
560e0499
...
...
@@ -246,7 +246,7 @@ slave-priority 100
# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able
ot
configure the process file limit to allow for the specified limit
# able
to
configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
...
...
sentinel.conf
浏览文件 @
560e0499
...
...
@@ -71,7 +71,7 @@ sentinel parallel-syncs mymaster 1
# Default is 15 minutes.
sentinel
failover
-
timeout
mymaster
900000
# SCRIPTS EXECTION
# SCRIPTS EXEC
U
TION
#
# sentinel notification-script and sentinel reconfig-script are used in order
# to configure scripts that are called to notify the system administrator
...
...
src/adlist.c
浏览文件 @
560e0499
...
...
@@ -97,7 +97,7 @@ list *listAddNodeHead(list *list, void *value)
return
list
;
}
/* Add a new node to the list, to tail, contaning the specified 'value'
/* Add a new node to the list, to tail, conta
i
ning the specified 'value'
* pointer as value.
*
* On error, NULL is returned and no operation is performed (i.e. the
...
...
@@ -308,7 +308,7 @@ listNode *listSearchKey(list *list, void *key)
/* Return the element at the specified zero-based index
* where 0 is the head, 1 is the element next to head
* and so on. Negative integers are used in order to count
* from the tail, -1 is the last element, -2 the penultima
n
te
* from the tail, -1 is the last element, -2 the penultimate
* and so on. If the index is out of range NULL is returned. */
listNode
*
listIndex
(
list
*
list
,
long
index
)
{
listNode
*
n
;
...
...
@@ -330,7 +330,7 @@ void listRotate(list *list) {
if
(
listLength
(
list
)
<=
1
)
return
;
/* Deta
t
ch current tail */
/* Detach current tail */
list
->
tail
=
tail
->
prev
;
list
->
tail
->
next
=
NULL
;
/* Move it as head */
...
...
src/ae.c
浏览文件 @
560e0499
...
...
@@ -309,7 +309,7 @@ static int processTimeEvents(aeEventLoop *eventLoop) {
/* Process every pending time event, then every pending file event
* (that may be registered by time event callbacks just processed).
* Without special flags the function sleeps until some file event
* fires, or when the next time event occur
r
s (if any).
* fires, or when the next time event occurs (if any).
*
* If flags is 0, the function does nothing and returns.
* if flags has AE_ALL_EVENTS set, all the kind of events are processed.
...
...
@@ -356,7 +356,7 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
if
(
tvp
->
tv_usec
<
0
)
tvp
->
tv_usec
=
0
;
}
else
{
/* If we have to check for events but need to return
* ASAP because of AE_DONT_WAIT we need to se the timeout
* ASAP because of AE_DONT_WAIT we need to se
t
the timeout
* to zero */
if
(
flags
&
AE_DONT_WAIT
)
{
tv
.
tv_sec
=
tv
.
tv_usec
=
0
;
...
...
@@ -395,7 +395,7 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
return
processed
;
/* return the number of processed file/time events */
}
/* Wait for millseconds until the given file descriptor becomes
/* Wait for mill
i
seconds until the given file descriptor becomes
* writable/readable/exception */
int
aeWait
(
int
fd
,
int
mask
,
long
long
milliseconds
)
{
struct
pollfd
pfd
;
...
...
src/ae_evport.c
浏览文件 @
560e0499
...
...
@@ -50,15 +50,15 @@ static int evport_debug = 0;
* aeApiPoll, the corresponding file descriptors become dissociated from the
* port. This is necessary because poll events are level-triggered, so if the
* fd didn't become dissociated, it would immediately fire another event since
* the underlying state hasn't changed yet. We must reassociate the file
* the underlying state hasn't changed yet. We must re
-
associate the file
* descriptor, but only after we know that our caller has actually read from it.
* The ae API does not tell us exactly when that happens, but we do know that
* it must happen by the time aeApiPoll is called again. Our solution is to
* keep track of the last fds returned by aeApiPoll and reassociate them next
* keep track of the last fds returned by aeApiPoll and re
-
associate them next
* time aeApiPoll is invoked.
*
* To summarize, in this module, each fd association is EITHER (a) represented
* only via the in-kernel assocation OR (b) represented by pending_fds and
* only via the in-kernel assoc
i
ation OR (b) represented by pending_fds and
* pending_masks. (b) is only true for the last fds we returned from aeApiPoll,
* and only until we enter aeApiPoll again (at which point we restore the
* in-kernel association).
...
...
@@ -164,7 +164,7 @@ static int aeApiAddEvent(aeEventLoop *eventLoop, int fd, int mask) {
* This fd was recently returned from aeApiPoll. It should be safe to
* assume that the consumer has processed that poll event, but we play
* it safer by simply updating pending_mask. The fd will be
* reassociated as usual when aeApiPoll is called again.
* re
-
associated as usual when aeApiPoll is called again.
*/
if
(
evport_debug
)
fprintf
(
stderr
,
"aeApiAddEvent: adding to pending fd %d
\n
"
,
fd
);
...
...
@@ -228,7 +228,7 @@ static void aeApiDelEvent(aeEventLoop *eventLoop, int fd, int mask) {
* ENOMEM is a potentially transient condition, but the kernel won't
* generally return it unless things are really bad. EAGAIN indicates
* we've reached an resource limit, for which it doesn't make sense to
* retry (counterintuitively). All other errors indicate a bug. In any
* retry (counter
-
intuitively). All other errors indicate a bug. In any
* of these cases, the best we can do is to abort.
*/
abort
();
/* will not return */
...
...
@@ -243,7 +243,7 @@ static int aeApiPoll(aeEventLoop *eventLoop, struct timeval *tvp) {
port_event_t
event
[
MAX_EVENT_BATCHSZ
];
/*
* If we've returned fd events before, we must reassociate them with the
* If we've returned fd events before, we must re
-
associate them with the
* port now, before calling port_get(). See the block comment at the top of
* this file for an explanation of why.
*/
...
...
src/anet.c
浏览文件 @
560e0499
...
...
@@ -61,7 +61,7 @@ int anetNonBlock(char *err, int fd)
{
int
flags
;
/* Set the socket nonblocking.
/* Set the socket non
-
blocking.
* Note that fcntl(2) for F_GETFL and F_SETFL can't be
* interrupted by a signal. */
if
((
flags
=
fcntl
(
fd
,
F_GETFL
))
==
-
1
)
{
...
...
@@ -132,7 +132,7 @@ static int anetCreateSocket(char *err, int domain) {
return
ANET_ERR
;
}
/* Make sure connection-intensive things like the redis benc
k
mark
/* Make sure connection-intensive things like the redis benc
h
mark
* will be able to close/open sockets a zillion of times */
if
(
setsockopt
(
s
,
SOL_SOCKET
,
SO_REUSEADDR
,
&
on
,
sizeof
(
on
))
==
-
1
)
{
anetSetError
(
err
,
"setsockopt SO_REUSEADDR: %s"
,
strerror
(
errno
));
...
...
src/aof.c
浏览文件 @
560e0499
...
...
@@ -385,7 +385,7 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
sds
buf
=
sdsempty
();
robj
*
tmpargv
[
3
];
/* The DB this command was target
t
ing is not the same as the last command
/* The DB this command was targeting is not the same as the last command
* we appendend. To issue a SELECT command is needed. */
if
(
dictid
!=
server
.
aof_selected_db
)
{
char
seldb
[
64
];
...
...
src/bio.c
浏览文件 @
560e0499
...
...
@@ -73,7 +73,7 @@ static list *bio_jobs[REDIS_BIO_NUM_OPS];
static
unsigned
long
long
bio_pending
[
REDIS_BIO_NUM_OPS
];
/* This structure represents a background Job. It is only used locally to this
* file as the API d
eo
s not expose the internals at all. */
* file as the API d
oe
s not expose the internals at all. */
struct
bio_job
{
time_t
time
;
/* Time at which the job was created. */
/* Job specific arguments pointers. If we need to pass more than three
...
...
src/bitops.c
浏览文件 @
560e0499
...
...
@@ -34,7 +34,7 @@
* Helpers and low level bit functions.
* -------------------------------------------------------------------------- */
/* This helper function used by GETBIT / SETBIT parses the bit offset argu
em
nt
/* This helper function used by GETBIT / SETBIT parses the bit offset argu
me
nt
* making sure an error is returned if it is negative or if it overflows
* Redis 512 MB limit for the string value. */
static
int
getBitOffsetFromArgument
(
redisClient
*
c
,
robj
*
o
,
size_t
*
offset
)
{
...
...
@@ -189,7 +189,7 @@ void bitopCommand(redisClient *c) {
char
*
opname
=
c
->
argv
[
1
]
->
ptr
;
robj
*
o
,
*
targetkey
=
c
->
argv
[
2
];
long
op
,
j
,
numkeys
;
robj
**
objects
;
/* Array of so
ru
ce objects. */
robj
**
objects
;
/* Array of so
ur
ce objects. */
unsigned
char
**
src
;
/* Array of source strings pointers. */
long
*
len
,
maxlen
=
0
;
/* Array of length of src strings, and max len. */
long
minlen
=
0
;
/* Min len among the input keys. */
...
...
src/config.c
浏览文件 @
560e0499
...
...
@@ -329,7 +329,7 @@ void loadServerConfigFromString(char *config) {
goto
loaderr
;
}
/* If the target command name is the em
tp
y string we just
/* If the target command name is the em
pt
y string we just
* remove it from the command table. */
retval
=
dictDelete
(
server
.
commands
,
argv
[
1
]);
redisAssert
(
retval
==
DICT_OK
);
...
...
@@ -367,7 +367,7 @@ void loadServerConfigFromString(char *config) {
soft
=
memtoll
(
argv
[
3
],
NULL
);
soft_seconds
=
atoi
(
argv
[
4
]);
if
(
soft_seconds
<
0
)
{
err
=
"Negative number of seconds in soft limt is invalid"
;
err
=
"Negative number of seconds in soft lim
i
t is invalid"
;
goto
loaderr
;
}
server
.
client_obuf_limits
[
class
].
hard_limit_bytes
=
hard
;
...
...
@@ -412,7 +412,7 @@ loaderr:
* in the 'options' string to the config file before loading.
*
* Both filename and options can be NULL, in such a case are considered
* em
tp
y. This way loadServerConfig can be used to just load a file or
* em
pt
y. This way loadServerConfig can be used to just load a file or
* just load a string. */
void
loadServerConfig
(
char
*
filename
,
char
*
options
)
{
sds
config
=
sdsempty
();
...
...
src/db.c
浏览文件 @
560e0499
...
...
@@ -44,7 +44,7 @@ robj *lookupKey(redisDb *db, robj *key) {
if
(
de
)
{
robj
*
val
=
dictGetVal
(
de
);
/* Update the access time for the aging algorithm.
/* Update the access time for the ag
e
ing algorithm.
* Don't do it if we have a saving child, as this will trigger
* a copy on write madness. */
if
(
server
.
rdb_child_pid
==
-
1
&&
server
.
aof_child_pid
==
-
1
)
...
...
@@ -85,7 +85,7 @@ robj *lookupKeyWriteOrReply(redisClient *c, robj *key, robj *reply) {
}
/* Add the key to the DB. It's up to the caller to increment the reference
* counte of the value if needed.
* counte
r
of the value if needed.
*
* The program is aborted if the key already exists. */
void
dbAdd
(
redisDb
*
db
,
robj
*
key
,
robj
*
val
)
{
...
...
@@ -538,7 +538,7 @@ int expireIfNeeded(redisDb *db, robj *key) {
* for *AT variants of the command, or the current time for relative expires).
*
* unit is either UNIT_SECONDS or UNIT_MILLISECONDS, and is only used for
* the argv[2] parameter. The basetime is always specified in milli
es
conds. */
* the argv[2] parameter. The basetime is always specified in milli
se
conds. */
void
expireGenericCommand
(
redisClient
*
c
,
long
long
basetime
,
int
unit
)
{
dictEntry
*
de
;
robj
*
key
=
c
->
argv
[
1
],
*
param
=
c
->
argv
[
2
];
...
...
src/debug.c
浏览文件 @
560e0499
...
...
@@ -42,7 +42,7 @@
/* ================================= Debugging ============================== */
/* Compute the sha1 of string at 's' with 'len' bytes long.
* The SHA1 is then xored againt the string pointed by digest.
* The SHA1 is then xored again
s
t the string pointed by digest.
* Since xor is commutative, this operation is used in order to
* "add" digests relative to unordered elements.
*
...
...
@@ -67,7 +67,7 @@ void xorObjectDigest(unsigned char *digest, robj *o) {
}
/* This function instead of just computing the SHA1 and xoring it
* against diget, also perform the digest of "digest" itself and
* against dige
s
t, also perform the digest of "digest" itself and
* replace the old value with the new one.
*
* So the final digest will be:
...
...
src/dict.c
浏览文件 @
560e0499
...
...
@@ -610,7 +610,7 @@ static int _dictExpandIfNeeded(dict *d)
/* Incremental rehashing already in progress. Return. */
if
(
dictIsRehashing
(
d
))
return
DICT_OK
;
/* If the hash table is empty expand it to the intial size. */
/* If the hash table is empty expand it to the in
i
tial size. */
if
(
d
->
ht
[
0
].
size
==
0
)
return
dictExpand
(
d
,
DICT_HT_INITIAL_SIZE
);
/* If we reached the 1:1 ratio, and we are allowed to resize the hash
...
...
src/lzfP.h
浏览文件 @
560e0499
...
...
@@ -93,7 +93,7 @@
/*
* Avoid assigning values to errno variable? for some embedding purposes
* (linux kernel for example), this is nec
c
essary. NOTE: this breaks
* (linux kernel for example), this is necessary. NOTE: this breaks
* the documentation in lzf.h.
*/
#ifndef AVOID_ERRNO
...
...
@@ -101,7 +101,7 @@
#endif
/*
* Wether to pass the LZF_STATE variable as argument, or allocate it
* W
h
ether to pass the LZF_STATE variable as argument, or allocate it
* on the stack. For small-stack environments, define this to 1.
* NOTE: this breaks the prototype in lzf.h.
*/
...
...
@@ -110,11 +110,11 @@
#endif
/*
* Wether to add extra checks for input validity in lzf_decompress
* W
h
ether to add extra checks for input validity in lzf_decompress
* and return EINVAL if the input stream has been corrupted. This
* only shields against overflowing the input buffer and will not
* detect most corrupted streams.
* This check is not normally noticable on modern hardware
* This check is not normally notic
e
able on modern hardware
* (<1% slowdown), but might slow down older cpus considerably.
*/
#ifndef CHECK_INPUT
...
...
src/mkreleasehdr.sh
浏览文件 @
560e0499
...
...
@@ -3,7 +3,7 @@ GIT_SHA1=`(git show-ref --head --hash=8 2> /dev/null || echo 00000000) | head -n
GIT_DIRTY
=
`
git diff 2> /dev/null |
wc
-l
`
test
-f
release.h
||
touch
release.h
(
cat
release.h |
grep
SHA1 |
grep
$GIT_SHA1
)
&&
\
(
cat
release.h |
grep
DIRTY |
grep
$GIT_DIRTY
)
&&
exit
0
# Already up
to
date
(
cat
release.h |
grep
DIRTY |
grep
$GIT_DIRTY
)
&&
exit
0
# Already up
-to-
date
echo
"#define REDIS_GIT_SHA1
\"
$GIT_SHA1
\"
"
>
release.h
echo
"#define REDIS_GIT_DIRTY
\"
$GIT_DIRTY
\"
"
>>
release.h
touch
release.c
# Force recompile of release.c
src/multi.c
浏览文件 @
560e0499
...
...
@@ -102,7 +102,7 @@ void discardCommand(redisClient *c) {
}
/* Send a MULTI command to all the slaves and AOF file. Check the execCommand
* impleme
m
ntation for more information. */
* implementation for more information. */
void
execCommandReplicateMulti
(
redisClient
*
c
)
{
robj
*
multistring
=
createStringObject
(
"MULTI"
,
5
);
...
...
@@ -223,7 +223,7 @@ void watchForKey(redisClient *c, robj *key) {
incrRefCount
(
key
);
}
listAddNodeTail
(
clients
,
c
);
/* Add the new key to the li
ts
of keys watched by this client */
/* Add the new key to the li
st
of keys watched by this client */
wk
=
zmalloc
(
sizeof
(
*
wk
));
wk
->
key
=
key
;
wk
->
db
=
c
->
db
;
...
...
src/networking.c
浏览文件 @
560e0499
...
...
@@ -378,7 +378,7 @@ void *addDeferredMultiBulkLength(redisClient *c) {
return
listLast
(
c
->
reply
);
}
/* Populate the length object and try glu
e
ing it to the next chunk. */
/* Populate the length object and try gluing it to the next chunk. */
void
setDeferredMultiBulkLength
(
redisClient
*
c
,
void
*
node
,
long
length
)
{
listNode
*
ln
=
(
listNode
*
)
node
;
robj
*
len
,
*
next
;
...
...
@@ -404,7 +404,7 @@ void setDeferredMultiBulkLength(redisClient *c, void *node, long length) {
asyncCloseClientOnOutputBufferLimitReached
(
c
);
}
/* Add a duble as a bulk reply */
/* Add a d
o
uble as a bulk reply */
void
addReplyDouble
(
redisClient
*
c
,
double
d
)
{
char
dbuf
[
128
],
sbuf
[
128
];
int
dlen
,
slen
;
...
...
@@ -526,7 +526,7 @@ static void acceptCommonHandler(int fd, int flags) {
}
/* If maxclient directive is set and this is one client more... close the
* connection. Note that we create the client instead to check before
* for this condition, since now the socket is already set in nonblocking
* for this condition, since now the socket is already set in non
-
blocking
* mode and we can send an error for free using the Kernel I/O */
if
(
listLength
(
server
.
clients
)
>
server
.
maxclients
)
{
char
*
err
=
"-ERR max number of clients reached
\r\n
"
;
...
...
@@ -941,7 +941,7 @@ int processMultibulkBuffer(redisClient *c) {
/* Not enough data (+2 == trailing \r\n) */
break
;
}
else
{
/* Optimization: if the buffer conta
ni
ns JUST our bulk element
/* Optimization: if the buffer conta
in
ns JUST our bulk element
* instead of creating a new object by *copying* the sds we
* just use the current sds string. */
if
(
pos
==
0
&&
...
...
src/object.c
浏览文件 @
560e0499
...
...
@@ -72,7 +72,7 @@ robj *createStringObjectFromLongDouble(long double value) {
int
len
;
/* We use 17 digits precision since with 128 bit floats that precision
* after rouding is able to represent most small decimal numbers in a way
* after rou
n
ding is able to represent most small decimal numbers in a way
* that is "non surprising" for the user (that is, most small decimal
* numbers will be represented in a way that when converted back into
* a string are exactly the same as what the user typed.) */
...
...
src/pubsub.c
浏览文件 @
560e0499
...
...
@@ -117,7 +117,7 @@ int pubsubUnsubscribeChannel(redisClient *c, robj *channel, int notify) {
return
retval
;
}
/* Subscribe a client to a pattern. Returns 1 if the operation succeeded, or 0 if the cli
ne
t was already subscribed to that pattern. */
/* Subscribe a client to a pattern. Returns 1 if the operation succeeded, or 0 if the cli
en
t was already subscribed to that pattern. */
int
pubsubSubscribePattern
(
redisClient
*
c
,
robj
*
pattern
)
{
int
retval
=
0
;
...
...
src/rdb.c
浏览文件 @
560e0499
...
...
@@ -265,7 +265,7 @@ err:
return
NULL
;
}
/* Save a string objet as [len][data] on disk. If the object is a string
/* Save a string obje
c
t as [len][data] on disk. If the object is a string
* representation of an integer value we try to save it in a special form */
int
rdbSaveRawString
(
rio
*
rdb
,
unsigned
char
*
s
,
size_t
len
)
{
int
enclen
;
...
...
@@ -321,7 +321,7 @@ int rdbSaveLongLongAsStringObject(rio *rdb, long long value) {
/* Like rdbSaveStringObjectRaw() but handle encoded objects */
int
rdbSaveStringObject
(
rio
*
rdb
,
robj
*
obj
)
{
/* Avoid to decode the object, then encode it again, if the
* object is alrady integer encoded. */
* object is alr
e
ady integer encoded. */
if
(
obj
->
encoding
==
REDIS_ENCODING_INT
)
{
return
rdbSaveLongLongAsStringObject
(
rdb
,(
long
)
obj
->
ptr
);
}
else
{
...
...
@@ -367,7 +367,7 @@ robj *rdbLoadEncodedStringObject(rio *rdb) {
}
/* Save a double value. Doubles are saved as strings prefixed by an unsigned
* 8 bit integer specifing the length of the representation.
* 8 bit integer specif
y
ing the length of the representation.
* This 8 bit integer has special values in order to specify the following
* conditions:
* 253: not a number
...
...
@@ -606,7 +606,7 @@ off_t rdbSavedObjectLen(robj *o) {
/* Save a key-value pair, with expire time, type, key, value.
* On error -1 is returned.
* On success if the key was act
au
lly saved 1 is returned, otherwise 0
* On success if the key was act
ua
lly saved 1 is returned, otherwise 0
* is returned (the key was already expired). */
int
rdbSaveKeyValuePair
(
rio
*
rdb
,
robj
*
key
,
robj
*
val
,
long
long
expiretime
,
long
long
now
)
...
...
@@ -1109,7 +1109,7 @@ int rdbLoad(char *filename) {
/* We read the time so we need to read the object type again. */
if
((
type
=
rdbLoadType
(
&
rdb
))
==
-
1
)
goto
eoferr
;
/* the EXPIRETIME opcode specifies time in seconds, so convert
* into milli
es
conds. */
* into milli
se
conds. */
expiretime
*=
1000
;
}
else
if
(
type
==
REDIS_RDB_OPCODE_EXPIRETIME_MS
)
{
/* Milliseconds precision expire times introduced with RDB
...
...
src/rdb.h
浏览文件 @
560e0499
...
...
@@ -51,7 +51,7 @@
* number specify the kind of object that follows.
* See the REDIS_RDB_ENC_* defines.
*
* Leng
ht
s up to 63 are stored using a single byte, most DB keys, and may
* Leng
th
s up to 63 are stored using a single byte, most DB keys, and may
* values, will fit inside. */
#define REDIS_RDB_6BITLEN 0
#define REDIS_RDB_14BITLEN 1
...
...
src/redis-check-dump.c
浏览文件 @
560e0499
...
...
@@ -78,7 +78,7 @@
* number specify the kind of object that follows.
* See the REDIS_RDB_ENC_* defines.
*
* Leng
ht
s up to 63 are stored using a single byte, most DB keys, and may
* Leng
th
s up to 63 are stored using a single byte, most DB keys, and may
* values, will fit inside. */
#define REDIS_RDB_6BITLEN 0
#define REDIS_RDB_14BITLEN 1
...
...
@@ -132,7 +132,7 @@ typedef struct {
char
success
;
}
entry
;
/* Global vars that are actally used as constants. The following double
/* Global vars that are act
u
ally used as constants. The following double
* values are used for double on-disk serialization, and are initialized
* at runtime to avoid strange compiler optimizations. */
static
double
R_Zero
,
R_PosInf
,
R_NegInf
,
R_Nan
;
...
...
src/redis-cli.c
浏览文件 @
560e0499
...
...
@@ -308,7 +308,7 @@ static int cliSelect() {
return
REDIS_ERR
;
}
/* Connect to the
client
. If force is not zero the connection is performed
/* Connect to the
server
. If force is not zero the connection is performed
* even if there is already a connected socket. */
static
int
cliConnect
(
int
force
)
{
if
(
context
==
NULL
||
force
)
{
...
...
@@ -976,7 +976,7 @@ static void slaveMode(void) {
char
buf
[
1024
];
fprintf
(
stderr
,
"SYNC with master, discarding %llu "
"bytes of bulk tranfer...
\n
"
,
payload
);
"bytes of bulk tran
s
fer...
\n
"
,
payload
);
/* Discard the payload. */
while
(
payload
)
{
...
...
@@ -1141,7 +1141,7 @@ static void pipeMode(void) {
int
j
;
eof
=
1
;
/* Everything transfered, so we queue a special
/* Everything transfer
r
ed, so we queue a special
* ECHO command that we can match in the replies
* to make sure everything was read from the server. */
for
(
j
=
0
;
j
<
20
;
j
++
)
...
...
src/redis.c
浏览文件 @
560e0499
...
...
@@ -99,7 +99,7 @@ struct redisCommand *commandTable;
* m: may increase memory usage once called. Don't allow if out of memory.
* a: admin command, like SAVE or SHUTDOWN.
* p: Pub/Sub related command.
* f: force replication of this command, regarless of server.dirty.
* f: force replication of this command, regar
d
less of server.dirty.
* s: command not allowed in scripts.
* R: random command. Command is not deterministic, that is, the same command
* with the same arguments, with the same key space, may have different
...
...
@@ -288,7 +288,7 @@ void redisLogRaw(int level, const char *msg) {
if
(
server
.
syslog_enabled
)
syslog
(
syslogLevelMap
[
level
],
"%s"
,
msg
);
}
/* Like redisLogRaw() but with printf-alike support. This is the func
it
on that
/* Like redisLogRaw() but with printf-alike support. This is the func
ti
on that
* is used across the code. The raw version is only used in order to dump
* the INFO output on crash. */
void
redisLog
(
int
level
,
const
char
*
fmt
,
...)
{
...
...
@@ -363,7 +363,7 @@ void exitFromChild(int retcode) {
/*====================== Hash table type implementation ==================== */
/* This is an hash table type that uses the SDS dynamic strings libary as
/* This is an hash table type that uses the SDS dynamic strings lib
r
ary as
* keys and radis objects as values (objects can hold SDS strings,
* lists, sets). */
...
...
@@ -537,7 +537,7 @@ dictType commandTableDictType = {
NULL
/* val destructor */
};
/* Hash type hash table (note that small hashes are represented with zi
mp
aps) */
/* Hash type hash table (note that small hashes are represented with zi
pm
aps) */
dictType
hashDictType
=
{
dictEncObjHash
,
/* hash function */
NULL
,
/* key dup */
...
...
@@ -738,7 +738,7 @@ int clientsCronHandleTimeout(redisClient *c) {
/* The client query buffer is an sds.c string that can end with a lot of
* free space not used, this function reclaims space if needed.
*
* The func
it
on always returns 0 as it never terminates the client. */
* The func
ti
on always returns 0 as it never terminates the client. */
int
clientsCronResizeQueryBuffer
(
redisClient
*
c
)
{
size_t
querybuf_size
=
sdsAllocSize
(
c
->
querybuf
);
time_t
idletime
=
server
.
unixtime
-
c
->
lastinteraction
;
...
...
@@ -796,11 +796,11 @@ void clientsCron(void) {
*
* - Active expired keys collection (it is also performed in a lazy way on
* lookup).
* - Software watchdo
n
g.
* - Software watchdog.
* - Update some statistic.
* - Incremental rehashing of the DBs hash tables.
* - Triggering BGSAVE / AOF rewrite, and handling of terminated children.
* - Clients timeout of differ
ne
t kinds.
* - Clients timeout of differ
en
t kinds.
* - Replication reconnection.
* - Many more...
*
...
...
@@ -829,7 +829,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
/* We have just 22 bits per object for LRU information.
* So we use an (eventually wrapping) LRU clock with 10 seconds resolution.
* 2^22 bits with 10 seconds resoluton is more or less 1.5 years.
* 2^22 bits with 10 seconds resolut
i
on is more or less 1.5 years.
*
* Note that even if this will wrap after 1.5 years it's not a problem,
* everything will still work but just some object will appear younger
...
...
@@ -867,7 +867,7 @@ int serverCron(struct aeEventLoop *eventLoop, long long id, void *clientData) {
}
}
/* We don't want to resize the hash tables while a bacground saving
/* We don't want to resize the hash tables while a bac
k
ground saving
* is in progress: the saving child is created using fork() that is
* implemented with a copy-on-write semantic in most modern systems, so
* if we resize the HT while there is the saving child at work actually
...
...
@@ -1178,7 +1178,7 @@ void initServerConfig() {
R_NegInf
=
-
1
.
0
/
R_Zero
;
R_Nan
=
R_Zero
/
R_Zero
;
/* Command table -- we intiialize it here as it is part of the
/* Command table -- we in
i
tiialize it here as it is part of the
* initial configuration, since command names may be changed via
* redis.conf using the rename-command directive. */
server
.
commands
=
dictCreate
(
&
commandTableDictType
,
NULL
);
...
...
@@ -1488,7 +1488,7 @@ void call(redisClient *c, int flags) {
long
long
dirty
,
start
=
ustime
(),
duration
;
/* Sent the command to clients in MONITOR mode, only if the commands are
* not geneated from reading an AOF. */
* not gene
r
ated from reading an AOF. */
if
(
listLength
(
server
.
monitors
)
&&
!
server
.
loading
&&
!
(
c
->
cmd
->
flags
&
REDIS_CMD_SKIP_MONITOR
))
...
...
@@ -1550,8 +1550,8 @@ void call(redisClient *c, int flags) {
* server for a bulk read from the client.
*
* If 1 is returned the client is still alive and valid and
*
and
other operations can be performed by the caller. Otherwise
* if 0 is returned the client was destro
i
ed (i.e. after QUIT). */
* other operations can be performed by the caller. Otherwise
* if 0 is returned the client was destro
y
ed (i.e. after QUIT). */
int
processCommand
(
redisClient
*
c
)
{
/* The QUIT command is handled separately. Normal command procs will
* go through checking for replication and QUIT will cause trouble
...
...
@@ -1804,7 +1804,7 @@ void echoCommand(redisClient *c) {
void
timeCommand
(
redisClient
*
c
)
{
struct
timeval
tv
;
/* gettimeofday() can only fail if &tv is a bad address
s
so we
/* gettimeofday() can only fail if &tv is a bad address so we
* don't check for errors. */
gettimeofday
(
&
tv
,
NULL
);
addReplyMultiBulkLen
(
c
,
2
);
...
...
src/redis.h
浏览文件 @
560e0499
...
...
@@ -142,12 +142,12 @@
*
* 00|000000 => if the two MSB are 00 the len is the 6 bits of this byte
* 01|000000 00000000 => 01, the len is 14 byes, 6 bits + 8 bits of next byte
* 10|000000 [32 bit integer] => if it's
01
, a full 32 bit len will follow
* 10|000000 [32 bit integer] => if it's
10
, a full 32 bit len will follow
* 11|000000 this means: specially encoded object will follow. The six bits
* number specify the kind of object that follows.
* See the REDIS_RDB_ENC_* defines.
*
* Leng
ht
s up to 63 are stored using a single byte, most DB keys, and may
* Leng
th
s up to 63 are stored using a single byte, most DB keys, and may
* values, will fit inside. */
#define REDIS_RDB_6BITLEN 0
#define REDIS_RDB_14BITLEN 1
...
...
@@ -317,7 +317,7 @@ typedef struct redisObject {
void
*
ptr
;
}
robj
;
/* Macro used to initalize a Redis object allocated on the stack.
/* Macro used to init
i
alize a Redis object allocated on the stack.
* Note that this macro is taken near the structure definition to make sure
* we'll update it when the structure is changed, to avoid bugs like
* bug #85 introduced exactly in this way. */
...
...
@@ -374,7 +374,7 @@ typedef struct readyList {
robj
*
key
;
}
readyList
;
/* With multiplexing we need to take per-cli
ne
t state.
/* With multiplexing we need to take per-cli
en
t state.
* Clients are taken in a liked list. */
typedef
struct
redisClient
{
int
fd
;
...
...
@@ -536,7 +536,7 @@ struct redisServer {
long
long
stat_keyspace_hits
;
/* Number of successful lookups of keys */
long
long
stat_keyspace_misses
;
/* Number of failed lookups of keys */
size_t
stat_peak_memory
;
/* Max used memory record */
long
long
stat_fork_time
;
/* Time needed to perform late
ts
fork() */
long
long
stat_fork_time
;
/* Time needed to perform late
st
fork() */
long
long
stat_rejected_conn
;
/* Clients rejected because of maxclients */
list
*
slowlog
;
/* SLOWLOG list of commands */
long
long
slowlog_entry_id
;
/* SLOWLOG current entry ID */
...
...
@@ -585,7 +585,7 @@ struct redisServer {
char
*
rdb_filename
;
/* Name of RDB file */
int
rdb_compression
;
/* Use compression in RDB? */
int
rdb_checksum
;
/* Use RDB checksum? */
time_t
lastsave
;
/* Unix time of last s
ave succeeed
e */
time_t
lastsave
;
/* Unix time of last s
uccessful sav
e */
time_t
rdb_save_time_last
;
/* Time used by last RDB save run. */
time_t
rdb_save_time_start
;
/* Current RDB save start time. */
int
lastbgsave_status
;
/* REDIS_OK or REDIS_ERR */
...
...
@@ -620,7 +620,7 @@ struct redisServer {
/* Limits */
unsigned
int
maxclients
;
/* Max number of simultaneous clients */
unsigned
long
long
maxmemory
;
/* Max number of memory bytes to use */
int
maxmemory_policy
;
/* Policy for key evition */
int
maxmemory_policy
;
/* Policy for key evi
c
tion */
int
maxmemory_samples
;
/* Pricision of random sampling */
/* Blocked clients */
unsigned
int
bpop_blocked_clients
;
/* Number of clients blocked by lists */
...
...
@@ -657,7 +657,7 @@ struct redisServer {
int
lua_timedout
;
/* True if we reached the time limit for script
execution. */
int
lua_kill
;
/* Kill the script if true. */
/* Assert & bug reporti
gn
*/
/* Assert & bug reporti
ng
*/
char
*
assert_failed
;
char
*
assert_file
;
int
assert_line
;
...
...
@@ -676,13 +676,13 @@ struct redisCommand {
char
*
name
;
redisCommandProc
*
proc
;
int
arity
;
char
*
sflags
;
/* Flags as string represenation, one char per flag. */
char
*
sflags
;
/* Flags as string represen
t
ation, one char per flag. */
int
flags
;
/* The actual flags, obtained from the 'sflags' field. */
/* Use a function to determine keys arguments in a command line. */
redisGetKeysProc
*
getkeys_proc
;
/* What keys should be loaded in background when calling this command? */
int
firstkey
;
/* The first argument that's a key (0 = no keys) */
int
lastkey
;
/* T
H
e last argument that's a key */
int
lastkey
;
/* T
h
e last argument that's a key */
int
keystep
;
/* The step between first and last key */
long
long
microseconds
,
calls
;
};
...
...
@@ -729,7 +729,7 @@ typedef struct {
dictIterator
*
di
;
}
setTypeIterator
;
/* Structure to hold hash iteration abstration. Note that iteration over
/* Structure to hold hash iteration abstra
c
tion. Note that iteration over
* hashes involves both fields and values. Because it is possible that
* not both are required, store pointers in the iterator to avoid
* unnecessary memory allocation for fields/values. */
...
...
src/release.c
浏览文件 @
560e0499
...
...
@@ -27,8 +27,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
/* Every time the Redis Git SHA1 or Dirty status changes only this
file
*
small
file is recompiled, as we access this information in all the other
/* Every time the Redis Git SHA1 or Dirty status changes only this
small
* file is recompiled, as we access this information in all the other
* files using this functions. */
#include "release.h"
...
...
src/replication.c
浏览文件 @
560e0499
...
...
@@ -52,7 +52,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
if
(
slave
->
replstate
==
REDIS_REPL_WAIT_BGSAVE_START
)
continue
;
/* Feed slaves that are waiting for the initial SYNC (so these commands
* are queued in the output buffer until the intial SYNC completes),
* are queued in the output buffer until the in
i
tial SYNC completes),
* or are already in sync with the master. */
if
(
slave
->
slaveseldb
!=
dictid
)
{
robj
*
selectcmd
;
...
...
@@ -115,7 +115,7 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **
}
void
syncCommand
(
redisClient
*
c
)
{
/* ignore SYNC if aleady slave or in monitor mode */
/* ignore SYNC if al
r
eady slave or in monitor mode */
if
(
c
->
flags
&
REDIS_SLAVE
)
return
;
/* Refuse SYNC requests if we are a slave but the link with our master
...
...
@@ -229,7 +229,7 @@ void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
if
(
slave
->
repldboff
==
0
)
{
/* Write the bulk write count before to transfer the DB. In theory here
* we don't know how much room there is in the output buffer of the
* socket, but in pratice SO_SNDLOWAT (the minimum count for output
* socket, but in pra
c
tice SO_SNDLOWAT (the minimum count for output
* operations) will never be smaller than the few bytes we need. */
sds
bulkcount
;
...
...
@@ -272,7 +272,7 @@ void sendBulkToSlave(aeEventLoop *el, int fd, void *privdata, int mask) {
}
}
/* This function is called at the end of every backgrond saving.
/* This function is called at the end of every backgro
u
nd saving.
* The argument bgsaveerr is REDIS_OK if the background saving succeeded
* otherwise REDIS_ERR is passed to the function.
*
...
...
@@ -451,7 +451,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
stopAppendOnly
();
while
(
retry
--
&&
startAppendOnly
()
==
REDIS_ERR
)
{
redisLog
(
REDIS_WARNING
,
"Failed enabling the AOF after successful master synchrnization! Trying it again in one second."
);
redisLog
(
REDIS_WARNING
,
"Failed enabling the AOF after successful master synchr
o
nization! Trying it again in one second."
);
sleep
(
1
);
}
if
(
!
retry
)
{
...
...
src/scripting.c
浏览文件 @
560e0499
...
...
@@ -48,7 +48,7 @@ void sha1hex(char *digest, char *script, size_t len);
/* Take a Redis reply in the Redis protocol format and convert it into a
* Lua type. Thanks to this function, and the introduction of not connected
* clients, it is trvial to implement the redis() lua function.
* clients, it is tr
i
vial to implement the redis() lua function.
*
* Basically we take the arguments, execute the Redis command in the context
* of a non connected client, then take the generated reply and convert it
...
...
@@ -58,7 +58,7 @@ void sha1hex(char *digest, char *script, size_t len);
*
* Note: in this function we do not do any sanity check as the reply is
* generated by Redis directly. This allows us to go faster.
* The reply string can be altered during the parsing as it is discared
* The reply string can be altered during the parsing as it is discar
d
ed
* after the conversion is completed.
*
* Errors are returned as a table with a single 'err' field set to the
...
...
@@ -597,7 +597,7 @@ void scriptingInit(void) {
lua_setglobal
(
lua
,
"math"
);
/* Add a helper func
it
on that we use to sort the multi bulk output of non
/* Add a helper func
ti
on that we use to sort the multi bulk output of non
* deterministic commands, when containing 'false' elements. */
{
char
*
compare_func
=
"function __redis__compare_helper(a,b)
\n
"
...
...
@@ -638,7 +638,7 @@ void scriptingReset(void) {
scriptingInit
();
}
/* Perform the SHA1 of the input string. We use this both for hasing script
/* Perform the SHA1 of the input string. We use this both for has
h
ing script
* bodies in order to obtain the Lua function name, and in the implementation
* of redis.sha1().
*
...
...
@@ -677,7 +677,7 @@ void luaReplyToRedisReply(redisClient *c, lua_State *lua) {
case
LUA_TTABLE
:
/* We need to check if it is an array, an error, or a status reply.
* Error are returned as a single element table with 'err' field.
* Status replies are returned as single elment table with 'ok' field */
* Status replies are returned as single el
e
ment table with 'ok' field */
lua_pushstring
(
lua
,
"err"
);
lua_gettable
(
lua
,
-
2
);
t
=
lua_type
(
lua
,
-
1
);
...
...
@@ -834,7 +834,7 @@ void evalGenericCommand(redisClient *c, int evalsha) {
if
(
lua_isnil
(
lua
,
1
))
{
lua_pop
(
lua
,
1
);
/* remove the nil from the stack */
/* Function not defined... let's define it if we have the
* body of the func
it
on. If this is an EVALSHA call we can just
* body of the func
ti
on. If this is an EVALSHA call we can just
* return an error. */
if
(
evalsha
)
{
addReply
(
c
,
shared
.
noscripterr
);
...
...
src/sds.c
浏览文件 @
560e0499
...
...
@@ -141,7 +141,7 @@ size_t sdsAllocSize(sds s) {
* right-trim the string.
*
* Using sdsIncrLen() and sdsMakeRoomFor() it is possible to mount the
* following schema to cat bytes coming from the ker
en
l to the end of an
* following schema to cat bytes coming from the ker
ne
l to the end of an
* sds string new things without copying into an intermediate buffer:
*
* oldlen = sdslen(s);
...
...
@@ -596,7 +596,7 @@ void sdssplitargs_free(sds *argv, int argc) {
}
/* Modify the string substituting all the occurrences of the set of
* characters specifed in the 'from' string to the corresponding character
* characters specif
i
ed in the 'from' string to the corresponding character
* in the 'to' array.
*
* For instance: sdsmapchars(mystring, "ho", "01", 2)
...
...
src/sentinel.c
浏览文件 @
560e0499
...
...
@@ -969,9 +969,9 @@ const char *sentinelRedisInstanceTypeStr(sentinelRedisInstance *ri) {
* a master's Sentinels dictionary, we want to be very sure about not
* having duplicated instances for any reason. This is so important because
* we use those other sentinels in order to run our quorum protocol to
* understand if it's time to procee
e
d with the fail over.
* understand if it's time to proceed with the fail over.
*
* Making sure no duplication is possible we great
e
ly improve the robustness
* Making sure no duplication is possible we greatly improve the robustness
* of the quorum (otherwise we may end counting the same instance multiple
* times for some reason).
*
...
...
@@ -1238,7 +1238,7 @@ void sentinelKillLink(sentinelRedisInstance *ri, redisAsyncContext *c) {
* cleanup needed.
*
* Note: we don't free the hiredis context as hiredis will do it for us
* for async con
en
ctions. */
* for async con
ne
ctions. */
void
sentinelDisconnectInstanceFromContext
(
const
redisAsyncContext
*
c
)
{
sentinelRedisInstance
*
ri
=
c
->
data
;
int
pubsub
;
...
...
@@ -1647,7 +1647,7 @@ void sentinelReceiveHelloMessages(redisAsyncContext *c, void *reply, void *privd
/* Update the last activity in the pubsub channel. Note that since we
* receive our messages as well this timestamp can be used to detect
* if the link is probably diconnected even if it seems otherwise. */
* if the link is probably di
s
connected even if it seems otherwise. */
ri
->
pc_last_activity
=
mstime
();
/* Sanity check in the reply we expect, so that the code that follows
...
...
@@ -1939,7 +1939,7 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
setDeferredMultiBulkLength
(
c
,
mbl
,
fields
*
2
);
}
/* Output a number of instances conta
n
ined inside a dictionary as
/* Output a number of instances contained inside a dictionary as
* Redis protocol. */
void
addReplyDictOfRedisInstances
(
redisClient
*
c
,
dict
*
instances
)
{
dictIterator
*
di
;
...
...
@@ -2535,7 +2535,7 @@ void sentinelStartFailoverIfNeeded(sentinelRedisInstance *master) {
* 3) info_refresh more recent than SENTINEL_INFO_VALIDITY_TIME.
* 4) master_link_down_time no more than:
* (now - master->s_down_since_time) + (master->down_after_period * 10).
* 5) Slave priority can't be zero, otherwise the slave is discar
e
ded.
* 5) Slave priority can't be zero, otherwise the slave is discarded.
*
* Among all the slaves matching the above conditions we select the slave
* with lower slave_priority. If priority is the same we select the slave
...
...
@@ -2611,10 +2611,10 @@ void sentinelFailoverWaitStart(sentinelRedisInstance *ri) {
/* If we in "wait start" but the master is no longer in ODOWN nor in
* SDOWN condition we abort the failover. This is important as it
* prevents a useless failover in a a notable case of netsplit, where
* the sen
it
nels are split from the redis instances. In this case
* the sen
ti
nels are split from the redis instances. In this case
* the failover will not start while there is the split because no
* good slave can be reached. However when the split is resolved, we
* can go to waitstart if the slave is back rechable a few milliseconds
* can go to waitstart if the slave is back re
a
chable a few milliseconds
* before the master is. In that case when the master is back online
* we cancel the failover. */
if
((
ri
->
flags
&
(
SRI_S_DOWN
|
SRI_O_DOWN
|
SRI_FORCE_FAILOVER
))
==
0
)
{
...
...
@@ -3026,13 +3026,13 @@ void sentinelHandleDictOfRedisInstances(dict *instances) {
* following conditions happen:
*
* 1) The Sentiel process for some time is blocked, for every kind of
* random reason: the load is huge, the computer was fr
eezed
for some time
* random reason: the load is huge, the computer was fr
ozen
for some time
* in I/O or alike, the process was stopped by a signal. Everything.
* 2) The system clock was altered significantly.
*
* Under both this conditions we'll see everything as timed out and failing
* without good reasons. Instead we enter the TILT mode and wait
* for SENTI
EN
L_TILT_PERIOD to elapse before starting to act again.
* for SENTI
NE
L_TILT_PERIOD to elapse before starting to act again.
*
* During TILT time we still collect information, we just do not act. */
void
sentinelCheckTiltCondition
(
void
)
{
...
...
src/sha1.c
浏览文件 @
560e0499
...
...
@@ -57,13 +57,13 @@ A million repetitions of "a"
void
SHA1Transform
(
u_int32_t
state
[
5
],
const
unsigned
char
buffer
[
64
])
{
u_int32_t
a
,
b
,
c
,
d
,
e
;
typedef
union
{
unsigned
char
c
[
64
];
u_int32_t
l
[
16
];
}
CHAR64LONG16
;
u_int32_t
a
,
b
,
c
,
d
,
e
;
typedef
union
{
unsigned
char
c
[
64
];
u_int32_t
l
[
16
];
}
CHAR64LONG16
;
#ifdef SHA1HANDSOFF
CHAR64LONG16
block
[
1
];
/* use array to appear as a pointer */
CHAR64LONG16
block
[
1
];
/* use array to appear as a pointer */
memcpy
(
block
,
buffer
,
64
);
#else
/* The following had better never be used because it causes the
...
...
@@ -71,7 +71,7 @@ CHAR64LONG16 block[1]; /* use array to appear as a pointer */
* And the result is written through. I threw a "const" in, hoping
* this will cause a diagnostic.
*/
CHAR64LONG16
*
block
=
(
const
CHAR64LONG16
*
)
buffer
;
CHAR64LONG16
*
block
=
(
const
CHAR64LONG16
*
)
buffer
;
#endif
/* Copy context->state[] to working vars */
a
=
state
[
0
];
...
...
@@ -132,12 +132,11 @@ void SHA1Init(SHA1_CTX* context)
void
SHA1Update
(
SHA1_CTX
*
context
,
const
unsigned
char
*
data
,
u_int32_t
len
)
{
u_int32_t
i
;
u_int32_t
j
;
u_int32_t
i
,
j
;
j
=
context
->
count
[
0
];
if
((
context
->
count
[
0
]
+=
len
<<
3
)
<
j
)
context
->
count
[
1
]
++
;
context
->
count
[
1
]
++
;
context
->
count
[
1
]
+=
(
len
>>
29
);
j
=
(
j
>>
3
)
&
63
;
if
((
j
+
len
)
>
63
)
{
...
...
@@ -157,9 +156,9 @@ u_int32_t j;
void
SHA1Final
(
unsigned
char
digest
[
20
],
SHA1_CTX
*
context
)
{
unsigned
i
;
unsigned
char
finalcount
[
8
];
unsigned
char
c
;
unsigned
i
;
unsigned
char
finalcount
[
8
];
unsigned
char
c
;
#if 0 /* untested "improvement" by DHR */
/* Convert context->count to a sequence of bytes
...
...
@@ -170,12 +169,12 @@ unsigned char c;
unsigned char *fcp = &finalcount[8];
for (i = 0; i < 2; i++)
{
u_int32_t t = context->count[i];
int j;
{
u_int32_t t = context->count[i];
int j;
for (j = 0; j < 4; t >>= 8, j++)
*--fcp = (unsigned char) t
for (j = 0; j < 4; t >>= 8, j++)
*--fcp = (unsigned char) t;
}
#else
for
(
i
=
0
;
i
<
8
;
i
++
)
{
...
...
@@ -226,3 +225,4 @@ main(int argc, char **argv)
}
#endif
src/sort.c
浏览文件 @
560e0499
...
...
@@ -45,7 +45,7 @@ redisSortOperation *createSortOperation(int type, robj *pattern) {
/* Return the value associated to the key with a name obtained using
* the following rules:
*
* 1) The first occurence of '*' in 'pattern' is substituted with 'subst'.
* 1) The first occur
r
ence of '*' in 'pattern' is substituted with 'subst'.
*
* 2) If 'pattern' matches the "->" string, everything on the left of
* the arrow is treated as the name of an hash field, and the part on the
...
...
@@ -147,7 +147,7 @@ int sortCompare(const void *s1, const void *s2) {
cmp
=
-
1
;
}
else
{
/* Objects have the same score, but we don't want the comparison
* to be undefined, so we compare objects lexicograph
y
cally.
* to be undefined, so we compare objects lexicograph
i
cally.
* This way the result of SORT is deterministic. */
cmp
=
compareStringObjects
(
so1
->
obj
,
so2
->
obj
);
}
...
...
@@ -205,7 +205,7 @@ void sortCommand(redisClient *c) {
/* Now we need to protect sortval incrementing its count, in the future
* SORT may have options able to overwrite/delete keys during the sorting
* and the sorted key itself may get destro
i
ed */
* and the sorted key itself may get destro
y
ed */
if
(
sortval
)
incrRefCount
(
sortval
);
else
...
...
src/t_list.c
浏览文件 @
560e0499
...
...
@@ -45,10 +45,10 @@ void listTypeTryConversion(robj *subject, robj *value) {
listTypeConvert
(
subject
,
REDIS_ENCODING_LINKEDLIST
);
}
/* The function pushes an el
mene
t to the specified list object 'subject',
/* The function pushes an el
emen
t to the specified list object 'subject',
* at head or tail position as specified by 'where'.
*
* There is no need for the caller to increm
ne
t the refcount of 'value' as
* There is no need for the caller to increm
en
t the refcount of 'value' as
* the function takes care of it if needed. */
void
listTypePush
(
robj
*
subject
,
robj
*
value
,
int
where
)
{
/* Check if we need to convert the ziplist */
...
...
@@ -825,7 +825,7 @@ void unblockClientWaitingData(redisClient *c) {
/* If the specified key has clients blocked waiting for list pushes, this
* function will put the key reference into the server.ready_keys list.
* Note that db->ready_keys is an hash table that allows us to avoid putting
* the same key again
s
and again in the list in case of multiple pushes
* the same key again and again in the list in case of multiple pushes
* made by a script or in the context of MULTI/EXEC.
*
* The list will be finally processed by handleClientsBlockedOnLists() */
...
...
@@ -858,7 +858,7 @@ void signalListAsReady(redisClient *c, robj *key) {
*
* 1) Provide the client with the 'value' element.
* 2) If the dstkey is not NULL (we are serving a BRPOPLPUSH) also push the
* 'value' element on the desti
o
nation list (the LPUSH side of the command).
* 'value' element on the destination list (the LPUSH side of the command).
* 3) Propagate the resulting BRPOP, BLPOP and additional LPUSH if any into
* the AOF and replication channel.
*
...
...
@@ -868,7 +868,7 @@ void signalListAsReady(redisClient *c, robj *key) {
*
* The function returns REDIS_OK if we are able to serve the client, otherwise
* REDIS_ERR is returned to signal the caller that the list POP operation
* should be undo
ed
as the client was not served: This only happens for
* should be undo
ne
as the client was not served: This only happens for
* BRPOPLPUSH that fails to push the value to the destination key as it is
* of the wrong type. */
int
serveClientBlockedOnList
(
redisClient
*
receiver
,
robj
*
key
,
robj
*
dstkey
,
redisDb
*
db
,
robj
*
value
,
int
where
)
...
...
src/t_set.c
浏览文件 @
560e0499
...
...
@@ -188,7 +188,7 @@ robj *setTypeNextObject(setTypeIterator *si) {
* The caller provides both pointers to be populated with the right
* object. The return value of the function is the object->encoding
* field of the object and is used by the caller to check if the
* int64_t pointer or the redis object pointer
e
was populated.
* int64_t pointer or the redis object pointer was populated.
*
* When an object is returned (the set was a real set) the ref count
* of the object is not incremented so this function can be considered
...
...
@@ -598,7 +598,7 @@ void sinterGenericCommand(redisClient *c, robj **setkeys, unsigned long setnum,
sets
[
j
]
=
setobj
;
}
/* Sort sets from the smallest to largest, this will improve our
* algorithm's performace */
* algorithm's performa
n
ce */
qsort
(
sets
,
setnum
,
sizeof
(
robj
*
),
qsortCompareSetsByCardinality
);
/* The first thing we should output is the total number of elements...
...
...
src/t_string.c
浏览文件 @
560e0499
...
...
@@ -43,7 +43,7 @@ static int checkStringLength(redisClient *c, long long size) {
}
void
setGenericCommand
(
redisClient
*
c
,
int
nx
,
robj
*
key
,
robj
*
val
,
robj
*
expire
,
int
unit
)
{
long
long
milliseconds
=
0
;
/* initialized to avoid an harmness warning */
long
long
milliseconds
=
0
;
/* initialized to avoid an
y
harmness warning */
if
(
expire
)
{
if
(
getLongLongFromObjectOrReply
(
c
,
expire
,
&
milliseconds
,
NULL
)
!=
REDIS_OK
)
...
...
@@ -340,7 +340,7 @@ void incrbyfloatCommand(redisClient *c) {
addReplyBulk
(
c
,
new
);
/* Always replicate INCRBYFLOAT as a SET command with the final value
* in order to make sure that differences in float pr
i
cision or formatting
* in order to make sure that differences in float pr
r
cision or formatting
* will not create differences in replicas or after an AOF restart. */
aux
=
createStringObject
(
"SET"
,
3
);
rewriteClientCommandArgument
(
c
,
0
,
aux
);
...
...
src/t_zset.c
浏览文件 @
560e0499
...
...
@@ -125,7 +125,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, robj *obj) {
}
/* we assume the key is not already inside, since we allow duplicated
* scores, and the re-insertion of score and redis object should never
* happ
p
en since the caller of zslInsert() should test in the hash table
* happen since the caller of zslInsert() should test in the hash table
* if the element is already inside or not. */
level
=
zslRandomLevel
();
if
(
level
>
zsl
->
level
)
{
...
...
@@ -285,7 +285,7 @@ zskiplistNode *zslLastInRange(zskiplist *zsl, zrangespec range) {
}
/* Delete all the elements with score between min and max from the skiplist.
* Min and mx are inclusive, so a score >= min || score <= max is deleted.
* Min and m
a
x are inclusive, so a score >= min || score <= max is deleted.
* Note that this function takes the reference to the hash table view of the
* sorted set, in order to remove the elements from the hash table too. */
unsigned
long
zslDeleteRangeByScore
(
zskiplist
*
zsl
,
zrangespec
range
,
dict
*
dict
)
{
...
...
src/zmalloc.c
浏览文件 @
560e0499
...
...
@@ -250,7 +250,7 @@ void zmalloc_set_oom_handler(void (*oom_handler)(size_t)) {
*
* For this kind of "fast RSS reporting" usages use instead the
* function RedisEstimateRSS() that is a much faster (and less precise)
* version of the func
it
on. */
* version of the func
ti
on. */
#if defined(HAVE_PROCFS)
#include <unistd.h>
...
...
tests/unit/scripting.tcl
浏览文件 @
560e0499
...
...
@@ -34,7 +34,7 @@ start_server {tags {"scripting"}} {
r eval
{
return
{
1,2,3,'ciao',
{
1,2
}}}
0
}
{
1 2 3 ciao
{
1 2
}}
test
{
EVAL - Are the KEYS and ARG
S
arrays populated correctly?
}
{
test
{
EVAL - Are the KEYS and ARG
V
arrays populated correctly?
}
{
r eval
{
return
{
KEYS
[
1
]
,KEYS
[
2
]
,ARGV
[
1
]
,ARGV
[
2
]}}
2 a b c d
}
{
a b c d
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录