From e570225e97bceaba2cb2b5a5c6edf4fdcdb61887 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 14 Oct 2014 21:52:30 +0900 Subject: [PATCH] tiny-nghttpd: Simplify timer event handling --- examples/tiny-nghttpd.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/tiny-nghttpd.c b/examples/tiny-nghttpd.c index 037155e3..38f3fc72 100644 --- a/examples/tiny-nghttpd.c +++ b/examples/tiny-nghttpd.c @@ -549,18 +549,12 @@ static int io_loop_run(io_loop *loop, server *serv) static int handle_timer(io_loop *loop, uint32_t events, void *ptr) { timer *tmr = ptr; - char buf[256]; + int64_t buf; + ssize_t nread; - /* We may get more than 8 bytes here? */ - for(;;) { - ssize_t nread; + while((nread = read(tmr->fd, &buf, sizeof(buf))) == -1 && errno == EINTR); - while((nread = read(tmr->fd, buf, sizeof(buf))) == -1 && errno == EINTR); - - if(nread == -1) { - break; - } - } + assert(nread == sizeof(buf)); update_date();