X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fselect.c;h=5633fe98078179b472a878c444594c4628dbde28;hb=19e66a67e9b25874cd5e184e7d381ce1b955df11;hp=41c3571e64edff36a22a29b5dd7e707c9cb5cf2f;hpb=252e5725cfb55a89e54888317856903fef9d5031;p=linux-2.6 diff --git a/fs/select.c b/fs/select.c index 41c3571e64..5633fe9807 100644 --- a/fs/select.c +++ b/fs/select.c @@ -177,11 +177,6 @@ get_max: return max; } -#define BIT(i) (1UL << ((i)&(__NFDBITS-1))) -#define MEM(i,m) ((m)+(unsigned)(i)/__NFDBITS) -#define ISSET(i,m) (((i)&*(m)) != 0) -#define SET(i,m) (*(m) |= (i)) - #define POLLIN_SET (POLLRDNORM | POLLRDBAND | POLLIN | POLLHUP | POLLERR) #define POLLOUT_SET (POLLWRBAND | POLLWRNORM | POLLOUT | POLLERR) #define POLLEX_SET (POLLPRI) @@ -586,7 +581,7 @@ static int do_poll(unsigned int nfds, struct poll_list *list, /* Optimise the no-wait case */ if (!(*timeout)) pt = NULL; - + for (;;) { struct poll_list *walk; long __timeout; @@ -616,10 +611,12 @@ static int do_poll(unsigned int nfds, struct poll_list *list, * a poll_table to them on the next loop iteration. */ pt = NULL; - if (count || !*timeout || signal_pending(current)) - break; - count = wait->error; - if (count) + if (!count) { + count = wait->error; + if (signal_pending(current)) + count = -EINTR; + } + if (count || !*timeout) break; if (*timeout < 0) { @@ -689,8 +686,6 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds, s64 *timeout) poll_initwait(&table); fdcount = do_poll(nfds, head, &table, timeout); - if (!fdcount && signal_pending(current)) - fdcount = -EINTR; poll_freewait(&table); for (walk = head; walk; walk = walk->next) { @@ -714,10 +709,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 @@ -726,13 +739,24 @@ asmlinkage long sys_poll(struct pollfd __user *ufds, unsigned int nfds, timeout_jiffies = -1; else #endif - timeout_jiffies = msecs_to_jiffies(timeout_msecs); + timeout_jiffies = msecs_to_jiffies(timeout_msecs) + 1; } else { /* Infinite (< 0) or no (0) timeout */ 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 = ¤t_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