X-Git-Url: http://ftp.safe.ca/?a=blobdiff_plain;f=fs%2Ftimerfd.c;h=b86ab8eff79ac8f36ace73c604e554cb4efa8820;hb=85640bd9d47f6ad0290558009e9313632a45861b;hp=b042bd7034b1fc74d6cd6399e24b3a2057689a2f;hpb=610d18f4128ebbd88845d0fc60cce67b49af881e;p=safe%2Fjmp%2Flinux-2.6 diff --git a/fs/timerfd.c b/fs/timerfd.c index b042bd7..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) { @@ -200,7 +184,7 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) hrtimer_init(&ctx->tmr, clockid, HRTIMER_MODE_ABS); ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, - flags & TFD_SHARED_FCNTL_FLAGS); + O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS)); if (ufd < 0) kfree(ctx);