forked from Minki/linux
select: change do_poll() to return -ERESTARTNOHAND rather than -EINTR
do_poll() returns -EINTR if interrupted and after that all its callers have to translate it into -ERESTARTNOHAND. Change do_poll() to return -ERESTARTNOHAND and update (simplify) the callers. Note that this also unifies all users of restore_saved_sigmask_unless(), see the next patch. Linus: : The *right* return value will actually be then chosen by : poll_select_copy_remaining(), which will turn ERESTARTNOHAND to EINTR : when it can't update the timeout. : : Except for the cases that use restart_block and do that instead and : don't have the whole timeout restart issue as a result. Link: http://lkml.kernel.org/r/20190606140852.GB13440@redhat.com Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Arnd Bergmann <arnd@arndb.de> Cc: David Laight <David.Laight@aculab.com> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Deepa Dinamani <deepa.kernel@gmail.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Eric Wong <e@80x24.org> Cc: Jason Baron <jbaron@akamai.com> Cc: Jens Axboe <axboe@kernel.dk> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
b772434be0
commit
8cf8b5539a
30
fs/select.c
30
fs/select.c
@ -925,7 +925,7 @@ static int do_poll(struct poll_list *list, struct poll_wqueues *wait,
|
||||
if (!count) {
|
||||
count = wait->error;
|
||||
if (signal_pending(current))
|
||||
count = -EINTR;
|
||||
count = -ERESTARTNOHAND;
|
||||
}
|
||||
if (count || timed_out)
|
||||
break;
|
||||
@ -1040,7 +1040,7 @@ static long do_restart_poll(struct restart_block *restart_block)
|
||||
|
||||
ret = do_sys_poll(ufds, nfds, to);
|
||||
|
||||
if (ret == -EINTR) {
|
||||
if (ret == -ERESTARTNOHAND) {
|
||||
restart_block->fn = do_restart_poll;
|
||||
ret = -ERESTART_RESTARTBLOCK;
|
||||
}
|
||||
@ -1061,7 +1061,7 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds,
|
||||
|
||||
ret = do_sys_poll(ufds, nfds, to);
|
||||
|
||||
if (ret == -EINTR) {
|
||||
if (ret == -ERESTARTNOHAND) {
|
||||
struct restart_block *restart_block;
|
||||
|
||||
restart_block = ¤t->restart_block;
|
||||
@ -1102,11 +1102,7 @@ SYSCALL_DEFINE5(ppoll, struct pollfd __user *, ufds, unsigned int, nfds,
|
||||
return ret;
|
||||
|
||||
ret = do_sys_poll(ufds, nfds, to);
|
||||
|
||||
restore_saved_sigmask_unless(ret == -EINTR);
|
||||
/* We can restart this syscall, usually */
|
||||
if (ret == -EINTR)
|
||||
ret = -ERESTARTNOHAND;
|
||||
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
|
||||
ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret);
|
||||
|
||||
return ret;
|
||||
@ -1135,11 +1131,7 @@ SYSCALL_DEFINE5(ppoll_time32, struct pollfd __user *, ufds, unsigned int, nfds,
|
||||
return ret;
|
||||
|
||||
ret = do_sys_poll(ufds, nfds, to);
|
||||
|
||||
restore_saved_sigmask_unless(ret == -EINTR);
|
||||
/* We can restart this syscall, usually */
|
||||
if (ret == -EINTR)
|
||||
ret = -ERESTARTNOHAND;
|
||||
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
|
||||
ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret);
|
||||
|
||||
return ret;
|
||||
@ -1413,11 +1405,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll_time32, struct pollfd __user *, ufds,
|
||||
return ret;
|
||||
|
||||
ret = do_sys_poll(ufds, nfds, to);
|
||||
|
||||
restore_saved_sigmask_unless(ret == -EINTR);
|
||||
/* We can restart this syscall, usually */
|
||||
if (ret == -EINTR)
|
||||
ret = -ERESTARTNOHAND;
|
||||
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
|
||||
ret = poll_select_copy_remaining(&end_time, tsp, PT_OLD_TIMESPEC, ret);
|
||||
|
||||
return ret;
|
||||
@ -1446,11 +1434,7 @@ COMPAT_SYSCALL_DEFINE5(ppoll_time64, struct pollfd __user *, ufds,
|
||||
return ret;
|
||||
|
||||
ret = do_sys_poll(ufds, nfds, to);
|
||||
|
||||
restore_saved_sigmask_unless(ret == -EINTR);
|
||||
/* We can restart this syscall, usually */
|
||||
if (ret == -EINTR)
|
||||
ret = -ERESTARTNOHAND;
|
||||
restore_saved_sigmask_unless(ret == -ERESTARTNOHAND);
|
||||
ret = poll_select_copy_remaining(&end_time, tsp, PT_TIMESPEC, ret);
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user