Skip to content

Commit

Permalink
use nanosleep instead of usleep
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yamt committed Jul 19, 2012
1 parent 8c13e40 commit 45ae74a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/debug.c
Expand Up @@ -294,8 +294,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 {
addReplyError(c,
Expand Down

0 comments on commit 45ae74a

Please sign in to comment.