svn commit: samba r6093 - in branches/SAMBA_4_0/source/lib: .
jra at samba.org
jra at samba.org
Mon Mar 28 03:31:45 GMT 2005
Author: jra
Date: 2005-03-28 03:31:44 +0000 (Mon, 28 Mar 2005)
New Revision: 6093
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6093
Log:
Patch to fix sys_select so it can't drop signals if another fd
is ready to read. Patch from Mark Weaver <mark-clist at npsl.co.uk>.
Jeremy.
Modified:
branches/SAMBA_4_0/source/lib/select.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/select.c
===================================================================
--- branches/SAMBA_4_0/source/lib/select.c 2005-03-28 03:27:44 UTC (rev 6092)
+++ branches/SAMBA_4_0/source/lib/select.c 2005-03-28 03:31:44 UTC (rev 6093)
@@ -100,20 +100,23 @@
FD_ZERO(writefds);
if (errorfds)
FD_ZERO(errorfds);
- }
-
- if (FD_ISSET(select_pipe[0], readfds2)) {
+ } else if (FD_ISSET(select_pipe[0], readfds2)) {
char c;
saved_errno = errno;
if (read(select_pipe[0], &c, 1) == 1) {
pipe_read++;
- }
- errno = saved_errno;
- FD_CLR(select_pipe[0], readfds2);
- ret--;
- if (ret == 0) {
+ /* Mark Weaver <mark-clist at npsl.co.uk> pointed out a critical
+ fix to ensure we don't lose signals. We must always
+ return -1 when the select pipe is set, otherwise if another
+ fd is also ready (so ret == 2) then we used to eat the
+ byte in the pipe and lose the signal. JRA.
+ */
ret = -1;
errno = EINTR;
+ } else {
+ FD_CLR(select_pipe[0], readfds2);
+ ret--;
+ errno = saved_errno;
}
}
@@ -146,7 +149,13 @@
if (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 at npsl.co.uk>
+ */
+
+ ret = select(maxfd, readfds2, writefds2, errorfds2, ptval);
} while (ret == -1 && errno == EINTR);
if (readfds)
More information about the samba-cvs
mailing list