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
6fcb1800
Commit
6fcb1800
authored
Apr 08, 2010
by
antirez
Browse files
Skiplist theoretical fix
parent
454eea7c
Changes
2
Show whitespace changes
Inline
Side-by-side
redis.c
View file @
6fcb1800
...
...
@@ -5092,7 +5092,7 @@ static int zslRandomLevel(void) {
int
level
=
1
;
while
((
random
()
&
0xFFFF
)
<
(
ZSKIPLIST_P
*
0xFFFF
))
level
+=
1
;
return
level
;
return
(
level
<
ZSKIPLIST_MAXLEVEL
)
?
level
:
(
ZSKIPLIST_MAXLEVEL
-
1
)
;
}
static
void
zslInsert
(
zskiplist
*
zsl
,
double
score
,
robj
*
obj
)
{
...
...
redis.tcl
View file @
6fcb1800
...
...
@@ -33,6 +33,7 @@ array set ::redis::fd {}
array set ::redis::blocking
{}
array set ::redis::callback
{}
array set ::redis::state
{}
;
# State in non-blocking reply reading
array set ::redis::statestack
{}
;
# Stack of states, for nested mbulks
array set ::redis::bulkarg
{}
array set ::redis::multibulkarg
{}
...
...
@@ -117,6 +118,7 @@ proc ::redis::__method__close {id fd} {
catch
{
unset ::redis::fd
(
$id
)}
catch
{
unset ::redis::blocking
(
$id
)}
catch
{
unset ::redis::state
(
$id
)}
catch
{
unset ::redis::statestack
(
$id
)}
catch
{
unset ::redis::callback
(
$id
)}
catch
{
interp alias
{}
::redis::redisHandle$id
{}}
}
...
...
@@ -176,6 +178,7 @@ proc ::redis::redis_read_reply fd {
proc ::redis::redis_reset_state id
{
set ::redis::state
(
$id
)
[
dict create buf
{}
mbulk -1 bulk -1 reply
{}]
set ::redis::statestack
(
$id
)
{}
}
proc ::redis::redis_call_callback
{
id type reply
}
{
...
...
@@ -209,7 +212,13 @@ proc ::redis::redis_readable {fd id} {
::redis::redis_readable $fd $id
}
}
*
{
dict set ::redis::state
(
$id
)
mbulk
[
string range $line 1 end-1
]}
*
{
dict set ::redis::state
(
$id
)
mbulk
[
string range $line 1 end-1
]
# Handle *-1
if
{[
dict get $::redis::state
(
$id
)
mbulk
]
== -1
}
{
redis_call_callback $id reply
{}
}
}
default
{
redis_call_callback $id err
\
"Bad protocol,
$type
as reply type byte"
...
...
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