summaryrefslogtreecommitdiff
path: root/src/blocked.c
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2019-03-12 18:10:28 +0100
committerGitHub <noreply@github.com>2019-03-12 18:10:28 +0100
commite5acc5ef4f1b163d5a98cf54895c2c6c7d9327fd (patch)
treea0ad820dcf951d9d38219dc960dcc47679be74bf /src/blocked.c
parentfba6e26e87da051dfc4aa55272b78861694f6ee2 (diff)
parenteca0187370c14aa2c126fe07e5310e44c2780a95 (diff)
downloadredis-e5acc5ef4f1b163d5a98cf54895c2c6c7d9327fd.tar.gz
Merge pull request #2774 from rouzier/blocking-list-commands-support-milliseconds-floating
Added millisecond resolution for blpop command && friends
Diffstat (limited to 'src/blocked.c')
-rw-r--r--src/blocked.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/blocked.c b/src/blocked.c
index f9e196626..1db657869 100644
--- a/src/blocked.c
+++ b/src/blocked.c
@@ -77,10 +77,18 @@ int serveClientBlockedOnList(client *receiver, robj *key, robj *dstkey, redisDb
* is zero. */
int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int unit) {
long long tval;
+ long double ftval;
- if (getLongLongFromObjectOrReply(c,object,&tval,
- "timeout is not an integer or out of range") != C_OK)
- return C_ERR;
+ if (unit == UNIT_SECONDS) {
+ if (getLongDoubleFromObjectOrReply(c,object,&ftval,
+ "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) {
addReplyError(c,"timeout is negative");
@@ -88,7 +96,6 @@ int getTimeoutFromObjectOrReply(client *c, robj *object, mstime_t *timeout, int
}
if (tval > 0) {
- if (unit == UNIT_SECONDS) tval *= 1000;
tval += mstime();
}
*timeout = tval;