Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=3075d9da0b4ccc88959db30de80ebd11d2dde175
Commit:     3075d9da0b4ccc88959db30de80ebd11d2dde175
Parent:     7e341fa1f8ed25385e2321d7e5a49ce6aea2d702
Author:     Chris Wright <[EMAIL PROTECTED]>
AuthorDate: Tue Oct 16 23:27:18 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Wed Oct 17 08:42:53 2007 -0700

    Use ERESTART_RESTARTBLOCK if poll() is interrupted by a signal
    
    Lomesh reported poll returning EINTR during suspend/resume cycle.  This is
    caused by the STOP/CONT cycle that the freezer uses, generating a pending
    signal for what in effect is an ignored signal.  In general poll is a
    little eager in returning EINTR, when it could try not bother userspace and
    simply restart the syscall.  Both select and ppoll do use ERESTARTNOHAND to
    restart the syscall.  Oleg points out that simply using ERESTARTNOHAND will
    cause poll to restart with original timeout value.  which could ultimately
    lead to process never returning to userspace.  Instead use
    ERESTART_RESTARTBLOCK, and restart poll with updated timeout value.
    Inspired by Manfred's use ERESTARTNOHAND in poll patch.
    
    [EMAIL PROTECTED]: do_restart_poll() can become static]
    Cc: Manfred Spraul <[EMAIL PROTECTED]>
    Cc: Oleg Nesterov <[EMAIL PROTECTED]>
    Cc: Roland McGrath <[EMAIL PROTECTED]>
    Cc: "Agarwal, Lomesh" <[EMAIL PROTECTED]>
    Signed-off-by: Chris Wright <[EMAIL PROTECTED]>
    Signed-off-by: Adrian Bunk <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/select.c |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/fs/select.c b/fs/select.c
index e2fd58f..7dede89 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -714,10 +714,28 @@ out_fds:
        return err;
 }
 
+static long do_restart_poll(struct restart_block *restart_block)
+{
+       struct pollfd __user *ufds = (struct pollfd __user*)restart_block->arg0;
+       int nfds = restart_block->arg1;
+       s64 timeout = ((s64)restart_block->arg3<<32) | (s64)restart_block->arg2;
+       int ret;
+
+       ret = do_sys_poll(ufds, nfds, &timeout);
+       if (ret == -EINTR) {
+               restart_block->fn = do_restart_poll;
+               restart_block->arg2 = timeout & 0xFFFFFFFF;
+               restart_block->arg3 = (u64)timeout >> 32;
+               ret = -ERESTART_RESTARTBLOCK;
+       }
+       return ret;
+}
+
 asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds,
                        long timeout_msecs)
 {
        s64 timeout_jiffies;
+       int ret;
 
        if (timeout_msecs > 0) {
 #if HZ > 1000
@@ -732,7 +750,18 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, 
unsigned int nfds,
                timeout_jiffies = timeout_msecs;
        }
 
-       return do_sys_poll(ufds, nfds, &timeout_jiffies);
+       ret = do_sys_poll(ufds, nfds, &timeout_jiffies);
+       if (ret == -EINTR) {
+               struct restart_block *restart_block;
+               restart_block = &current_thread_info()->restart_block;
+               restart_block->fn = do_restart_poll;
+               restart_block->arg0 = (unsigned long)ufds;
+               restart_block->arg1 = nfds;
+               restart_block->arg2 = timeout_jiffies & 0xFFFFFFFF;
+               restart_block->arg3 = (u64)timeout_jiffies >> 32;
+               ret = -ERESTART_RESTARTBLOCK;
+       }
+       return ret;
 }
 
 #ifdef TIF_RESTORE_SIGMASK
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to