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
99871803
Commit
99871803
authored
Sep 10, 2014
by
Salvatore Sanfilippo
Browse files
Merge pull request #1993 from xiaost/limit-scan-iter-count
Limit the *SCAN command `dictScan` iterations
parents
b892ea70
acfc1963
Changes
1
Show whitespace changes
Inline
Side-by-side
src/db.c
View file @
99871803
...
@@ -493,6 +493,11 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) {
...
@@ -493,6 +493,11 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) {
if
(
ht
)
{
if
(
ht
)
{
void
*
privdata
[
2
];
void
*
privdata
[
2
];
/* We set the max number of iterations to ten times the specified
* COUNT, so if the hash table is in a pathological state (very
* sparsely populated) we avoid to block too much time at the cost
* of returning no or very few elements. */
long
maxiterations
=
count
*
10
;
/* We pass two pointers to the callback: the list to which it will
/* We pass two pointers to the callback: the list to which it will
* add new elements, and the object containing the dictionary so that
* add new elements, and the object containing the dictionary so that
...
@@ -501,7 +506,9 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) {
...
@@ -501,7 +506,9 @@ void scanGenericCommand(redisClient *c, robj *o, unsigned long cursor) {
privdata
[
1
]
=
o
;
privdata
[
1
]
=
o
;
do
{
do
{
cursor
=
dictScan
(
ht
,
cursor
,
scanCallback
,
privdata
);
cursor
=
dictScan
(
ht
,
cursor
,
scanCallback
,
privdata
);
}
while
(
cursor
&&
listLength
(
keys
)
<
(
unsigned
long
)
count
);
}
while
(
cursor
&&
maxiterations
--
&&
listLength
(
keys
)
<
(
unsigned
long
)
count
);
}
else
if
(
o
->
type
==
REDIS_SET
)
{
}
else
if
(
o
->
type
==
REDIS_SET
)
{
int
pos
=
0
;
int
pos
=
0
;
int64_t
ll
;
int64_t
ll
;
...
...
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