From f12299d6c86946eeba94b1346b5db5c06c38189f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 17 Apr 2011 23:41:24 -0700 Subject: [PATCH] Linux passes timeout test --- oio-unix.c | 32 +++++++++++++++++++++++++++++++- oio-unix.h | 1 + 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/oio-unix.c b/oio-unix.c index 08cf7c5a6..b6d6d6e83 100644 --- a/oio-unix.c +++ b/oio-unix.c @@ -535,8 +535,38 @@ int oio_write2(oio_req* req, const char* msg) { } +void oio__timeout(EV_P_ ev_timer* watcher, int revents) { + oio_req* req = watcher->data; + assert(watcher == &req->timer); + assert(EV_TIMER & revents); + + /* This watcher is not repeating. */ + assert(!ev_is_active(watcher)); + assert(!ev_is_pending(watcher)); + + if (req->cb) { + oio_timer_cb cb = req->cb; + cb(req, 0); + } +} + + +void oio_update_time() { + assert(0 && "implement me"); +} + + +int64_t oio_now() { + assert(0 && "implement me"); + return 0; +} + + int oio_timeout(oio_req *req, int64_t timeout) { - return -1; + ev_timer_init(&req->timer, oio__timeout, timeout / 1000.0, 0.0); + ev_timer_start(EV_DEFAULT_UC_ &req->timer); + req->timer.data = req; + return 0; } diff --git a/oio-unix.h b/oio-unix.h index 2506127be..15abf73db 100644 --- a/oio-unix.h +++ b/oio-unix.h @@ -22,6 +22,7 @@ typedef struct { oio_connect_cb connect_cb; \ ngx_queue_t read_reqs; \ oio_buf* read_bufs; \ + ev_timer timer; \ int read_bufcnt;