diff --git a/src/server.c b/src/server.c index 617a5e3bc..cb0faf888 100644 --- a/src/server.c +++ b/src/server.c @@ -4373,7 +4373,7 @@ void echoCommand(client *c) { void timeCommand(client *c) { addReplyArrayLen(c,2); addReplyBulkLongLong(c, server.unixtime); - addReplyBulkLongLong(c, server.ustime-server.unixtime*1000000); + addReplyBulkLongLong(c, server.ustime-((long long)server.unixtime)*1000000); } typedef struct replyFlagNames { diff --git a/tests/unit/introspection-2.tcl b/tests/unit/introspection-2.tcl index dab8008e8..9576c39ab 100644 --- a/tests/unit/introspection-2.tcl +++ b/tests/unit/introspection-2.tcl @@ -3,6 +3,13 @@ proc cmdstat {cmd} { } start_server {tags {"introspection"}} { + test {The microsecond part of the TIME command will not overflow} { + set now [r time] + set microseconds [lindex $now 1] + assert_morethan $microseconds 0 + assert_lessthan $microseconds 1000000 + } + test {TTL, TYPE and EXISTS do not alter the last access time of a key} { r set foo bar after 3000