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
86cbddc4
Unverified
Commit
86cbddc4
authored
Feb 28, 2020
by
Salvatore Sanfilippo
Committed by
GitHub
Feb 28, 2020
Browse files
Merge pull request #6838 from oranagra/rm_scan_dict_rehash
RM_Scan disable dict rehashing
parents
4ccb56d0
28ef18a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/dict.c
View file @
86cbddc4
...
@@ -871,6 +871,10 @@ unsigned long dictScan(dict *d,
...
@@ -871,6 +871,10 @@ unsigned long dictScan(dict *d,
if
(
dictSize
(
d
)
==
0
)
return
0
;
if
(
dictSize
(
d
)
==
0
)
return
0
;
/* Having a safe iterator means no rehashing can happen, see _dictRehashStep.
* This is needed in case the scan callback tries to do dictFind or alike. */
d
->
iterators
++
;
if
(
!
dictIsRehashing
(
d
))
{
if
(
!
dictIsRehashing
(
d
))
{
t0
=
&
(
d
->
ht
[
0
]);
t0
=
&
(
d
->
ht
[
0
]);
m0
=
t0
->
sizemask
;
m0
=
t0
->
sizemask
;
...
@@ -937,6 +941,9 @@ unsigned long dictScan(dict *d,
...
@@ -937,6 +941,9 @@ unsigned long dictScan(dict *d,
}
while
(
v
&
(
m0
^
m1
));
}
while
(
v
&
(
m0
^
m1
));
}
}
/* undo the ++ at the top */
d
->
iterators
--
;
return
v
;
return
v
;
}
}
...
...
src/module.c
View file @
86cbddc4
...
@@ -6553,9 +6553,13 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) {
...
@@ -6553,9 +6553,13 @@ void RM_ScanCursorDestroy(RedisModuleScanCursor *cursor) {
* }
* }
* RedisModule_ScanCursorDestroy(c);
* RedisModule_ScanCursorDestroy(c);
*
*
* The function will return 1 if there are more elements to scan and 0 otherwise,
* The function will return 1 if there are more elements to scan and 0 otherwise,
* possibly setting errno if the call failed.
* possibly setting errno if the call failed.
* It is also possible to restart and existing cursor using RM_CursorRestart. */
* It is also possible to restart and existing cursor using RM_CursorRestart.
*
* NOTE: You must avoid doing any database changes from within the callback, you should avoid any
* RedisModule_OpenKey or RedisModule_Call, if you need to do these, you need to keep the key name
* and do any work you need to do after the call to Scan returns. */
int
RM_Scan
(
RedisModuleCtx
*
ctx
,
RedisModuleScanCursor
*
cursor
,
RedisModuleScanCB
fn
,
void
*
privdata
)
{
int
RM_Scan
(
RedisModuleCtx
*
ctx
,
RedisModuleScanCursor
*
cursor
,
RedisModuleScanCB
fn
,
void
*
privdata
)
{
if
(
cursor
->
done
)
{
if
(
cursor
->
done
)
{
errno
=
ENOENT
;
errno
=
ENOENT
;
...
@@ -6633,9 +6637,13 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) {
...
@@ -6633,9 +6637,13 @@ static void moduleScanKeyCallback(void *privdata, const dictEntry *de) {
* RedisModule_CloseKey(key);
* RedisModule_CloseKey(key);
* RedisModule_ScanCursorDestroy(c);
* RedisModule_ScanCursorDestroy(c);
*
*
* The function will return 1 if there are more elements to scan and 0 otherwise,
* The function will return 1 if there are more elements to scan and 0 otherwise,
* possibly setting errno if the call failed.
* possibly setting errno if the call failed.
* It is also possible to restart and existing cursor using RM_CursorRestart. */
* It is also possible to restart and existing cursor using RM_CursorRestart.
*
* NOTE: You must avoid doing any database changes from within the callback, you should avoid any
* RedisModule_OpenKey or RedisModule_Call, if you need to do these, you need to keep the field name
* and do any work you need to do after the call to Scan returns. */
int
RM_ScanKey
(
RedisModuleKey
*
key
,
RedisModuleScanCursor
*
cursor
,
RedisModuleScanKeyCB
fn
,
void
*
privdata
)
{
int
RM_ScanKey
(
RedisModuleKey
*
key
,
RedisModuleScanCursor
*
cursor
,
RedisModuleScanKeyCB
fn
,
void
*
privdata
)
{
if
(
key
==
NULL
||
key
->
value
==
NULL
)
{
if
(
key
==
NULL
||
key
->
value
==
NULL
)
{
errno
=
EINVAL
;
errno
=
EINVAL
;
...
...
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