diff options
author | YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp> | 2012-07-19 21:37:34 +0900 |
---|---|---|
committer | YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp> | 2013-05-17 17:21:28 +0900 |
commit | ae828676649f05feb113078fa166c78dd0ad0266 (patch) | |
tree | a191eb48e52d44500e7fd95c207b7d2f2de5ca51 /src/debug.c | |
parent | b2dd0849ce7f229ea5eb9fb88a112b7ad2c31642 (diff) | |
download | redis-ae828676649f05feb113078fa166c78dd0ad0266.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.
Diffstat (limited to 'src/debug.c')
-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 2f62bedb0..6cfa61b91 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) |