diff options
author | YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp> | 2012-07-19 21:37:34 +0900 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-06-26 15:20:56 +0200 |
commit | 30f3ae03a548156738cb12cfbd4e01801c5c5d96 (patch) | |
tree | f4cff40cac41f7a72954d172f3cd0513ed458a46 | |
parent | f27896a17d7730cfc202b44cd8a00e5c77bd8707 (diff) | |
download | redis-30f3ae03a548156738cb12cfbd4e01801c5c5d96.tar.gz |
use nanosleep instead of usleep
SUSv3 says that:
The useconds argument shall be less than one million. If the value of
useconds is 0, then the call has no effect.
and actually NetBSD's implementation rejects such a value with EINVAL.
use nanosleep which has no such a limitation instead.
-rw-r--r-- | src/debug.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/debug.c b/src/debug.c index 32d361200..0a947e564 100644 --- a/src/debug.c +++ b/src/debug.c @@ -329,8 +329,11 @@ void debugCommand(redisClient *c) { } else if (!strcasecmp(c->argv[1]->ptr,"sleep") && c->argc == 3) { double dtime = strtod(c->argv[2]->ptr,NULL); long long utime = dtime*1000000; + struct timespec tv; - usleep(utime); + tv.tv_sec = utime / 1000000; + tv.tv_nsec = (utime % 1000000) * 1000; + nanosleep(&tv, NULL); addReply(c,shared.ok); } else if (!strcasecmp(c->argv[1]->ptr,"set-active-expire") && c->argc == 3) |