1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

r6093: Patch to fix sys_select so it can't drop signals if another fd

is ready to read. Patch from Mark Weaver <mark-clist@npsl.co.uk>.
Jeremy.
(This used to be commit 857e98e8ea842bb94c93b81d7b69e3d304f100f5)
This commit is contained in:
Jeremy Allison 2005-03-28 03:31:44 +00:00 committed by Gerald (Jerry) Carter
parent e91fb065fa
commit 8c270fcedb

View File

@ -100,20 +100,23 @@ int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, s
FD_ZERO(writefds); FD_ZERO(writefds);
if (errorfds) if (errorfds)
FD_ZERO(errorfds); FD_ZERO(errorfds);
} } else if (FD_ISSET(select_pipe[0], readfds2)) {
if (FD_ISSET(select_pipe[0], readfds2)) {
char c; char c;
saved_errno = errno; saved_errno = errno;
if (read(select_pipe[0], &c, 1) == 1) { if (read(select_pipe[0], &c, 1) == 1) {
pipe_read++; pipe_read++;
} /* Mark Weaver <mark-clist@npsl.co.uk> pointed out a critical
errno = saved_errno; fix to ensure we don't lose signals. We must always
FD_CLR(select_pipe[0], readfds2); return -1 when the select pipe is set, otherwise if another
ret--; fd is also ready (so ret == 2) then we used to eat the
if (ret == 0) { byte in the pipe and lose the signal. JRA.
*/
ret = -1; ret = -1;
errno = EINTR; errno = EINTR;
} else {
FD_CLR(select_pipe[0], readfds2);
ret--;
errno = saved_errno;
} }
} }
@ -146,7 +149,13 @@ int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorf
if (tval) if (tval)
tval2 = *tval; tval2 = *tval;
ret = sys_select(maxfd, readfds2, writefds2, errorfds2, ptval); /* We must use select and not sys_select here. If we use
sys_select we'd lose the fact a signal occurred when sys_select
read a byte from the pipe. Fix from Mark Weaver
<mark-clist@npsl.co.uk>
*/
ret = select(maxfd, readfds2, writefds2, errorfds2, ptval);
} while (ret == -1 && errno == EINTR); } while (ret == -1 && errno == EINTR);
if (readfds) if (readfds)