X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Ftimerfd.c;h=b86ab8eff79ac8f36ace73c604e554cb4efa8820;hb=d28619f1563140526e2f84eae436f39206f40a69;hp=1bfc95ad5f716a70dda692a250aee1231b4f608e;hpb=628ff7c1d8d8466a5ad8078bd0206a130f8b8a51;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/timerfd.c b/fs/timerfd.c index 1bfc95a..b86ab8e 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -109,31 +110,14 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, struct timerfd_ctx *ctx = file->private_data; ssize_t res; u64 ticks = 0; - DECLARE_WAITQUEUE(wait, current); if (count < sizeof(ticks)) return -EINVAL; spin_lock_irq(&ctx->wqh.lock); - res = -EAGAIN; - if (!ctx->ticks && !(file->f_flags & O_NONBLOCK)) { - __add_wait_queue(&ctx->wqh, &wait); - for (res = 0;;) { - set_current_state(TASK_INTERRUPTIBLE); - if (ctx->ticks) { - res = 0; - break; - } - if (signal_pending(current)) { - res = -ERESTARTSYS; - break; - } - spin_unlock_irq(&ctx->wqh.lock); - schedule(); - spin_lock_irq(&ctx->wqh.lock); - } - __remove_wait_queue(&ctx->wqh, &wait); - __set_current_state(TASK_RUNNING); - } + if (file->f_flags & O_NONBLOCK) + res = -EAGAIN; + else + res = wait_event_interruptible_locked_irq(ctx->wqh, ctx->ticks); if (ctx->ticks) { ticks = ctx->ticks; if (ctx->expired && ctx->tintv.tv64) {