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
eca01873
Commit
eca01873
authored
Sep 19, 2015
by
James Rouzier
Browse files
If the unit of a timeout is seconds treat it a float
parent
438ae496
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/blocked.c
View file @
eca01873
...
@@ -75,10 +75,18 @@
...
@@ -75,10 +75,18 @@
* is zero. */
* is zero. */
int
getTimeoutFromObjectOrReply
(
client
*
c
,
robj
*
object
,
mstime_t
*
timeout
,
int
unit
)
{
int
getTimeoutFromObjectOrReply
(
client
*
c
,
robj
*
object
,
mstime_t
*
timeout
,
int
unit
)
{
long
long
tval
;
long
long
tval
;
long
double
ftval
;
if
(
getLongLongFromObjectOrReply
(
c
,
object
,
&
tval
,
if
(
unit
==
UNIT_SECONDS
)
{
"timeout is not an integer or out of range"
)
!=
C_OK
)
if
(
getLongDoubleFromObjectOrReply
(
c
,
object
,
&
ftval
,
return
C_ERR
;
"timeout is not an float or out of range"
)
!=
C_OK
)
return
C_ERR
;
tval
=
(
long
long
)
(
ftval
*
1000
.
0
);
}
else
{
if
(
getLongLongFromObjectOrReply
(
c
,
object
,
&
tval
,
"timeout is not an integer or out of range"
)
!=
C_OK
)
return
C_ERR
;
}
if
(
tval
<
0
)
{
if
(
tval
<
0
)
{
addReplyError
(
c
,
"timeout is negative"
);
addReplyError
(
c
,
"timeout is negative"
);
...
@@ -86,7 +94,6 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int
...
@@ -86,7 +94,6 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int
}
}
if
(
tval
>
0
)
{
if
(
tval
>
0
)
{
if
(
unit
==
UNIT_SECONDS
)
tval
*=
1000
;
tval
+=
mstime
();
tval
+=
mstime
();
}
}
*
timeout
=
tval
;
*
timeout
=
tval
;
...
...
tests/unit/type/list.tcl
View file @
eca01873
...
@@ -436,8 +436,11 @@ start_server {
...
@@ -436,8 +436,11 @@ start_server {
test
"
$pop:
with non-integer timeout"
{
test
"
$pop:
with non-integer timeout"
{
set rd
[
redis_deferring_client
]
set rd
[
redis_deferring_client
]
$rd $pop blist1 1.1
r del blist1
assert_error
"ERR*not an integer*"
{
$rd
read
}
$rd $pop blist1 0.1
r rpush blist1 foo
assert_equal
{
blist1 foo
}
[
$rd
read
]
assert_equal 0
[
r exists blist1
]
}
}
test
"
$pop:
with zero timeout should block indefinitely"
{
test
"
$pop:
with zero timeout should block indefinitely"
{
...
...
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