summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-02-09 13:16:55 +1100
committerJeremy Allison <jra@samba.org>2012-02-16 15:49:21 -0800
commit367c567c5f35db202474c8d3f730484538e1fb97 (patch)
tree6d4a05b6e2f2923fec8564d360eb7085a831d128 /lib/util
parentab80995580f092811d6380caa9e71e4c5fda06f4 (diff)
downloadsamba-367c567c5f35db202474c8d3f730484538e1fb97.tar.gz
samba-367c567c5f35db202474c8d3f730484538e1fb97.tar.bz2
samba-367c567c5f35db202474c8d3f730484538e1fb97.zip
lib/util: Remove sys_poll as it is no longer needed
sys_poll() is only needed if the signal pipe is set up and used, but as no signal handler ever writes to the pipe, this can all be removed. signal based events are now handled via tevent. Andrew Bartlett Signed-off-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/select.c90
-rw-r--r--lib/util/select.h1
2 files changed, 0 insertions, 91 deletions
diff --git a/lib/util/select.c b/lib/util/select.c
index 63be55cf0c..5e66344c9d 100644
--- a/lib/util/select.c
+++ b/lib/util/select.c
@@ -23,96 +23,6 @@
#include "system/select.h"
#include "lib/util/select.h"
-/* This is here because it allows us to avoid a nasty race in signal handling.
- We need to guarantee that when we get a signal we get out of a select immediately
- but doing that involves a race condition. We can avoid the race by getting the
- signal handler to write to a pipe that is in the select/poll list
-
- This means all Samba signal handlers should call sys_select_signal().
-*/
-
-static pid_t initialised;
-static int select_pipe[2];
-static volatile unsigned pipe_written, pipe_read;
-
-/*
- * sys_poll expects pollfd's to be a talloc'ed array.
- *
- * It expects the talloc_array_length(fds) >= num_fds+1 to give space
- * to the signal pipe.
- */
-
-int sys_poll(struct pollfd *fds, int num_fds, int timeout)
-{
- int ret;
-
- if (talloc_array_length(fds) < num_fds+1) {
- errno = ENOSPC;
- return -1;
- }
-
- if (initialised != sys_getpid()) {
- if (pipe(select_pipe) == -1)
- {
- int saved_errno = errno;
- DEBUG(0, ("sys_poll: pipe failed (%s)\n",
- strerror(errno)));
- errno = saved_errno;
- return -1;
- }
-
- /*
- * These next two lines seem to fix a bug with the Linux
- * 2.0.x kernel (and probably other UNIXes as well) where
- * the one byte read below can block even though the
- * select returned that there is data in the pipe and
- * the pipe_written variable was incremented. Thanks to
- * HP for finding this one. JRA.
- */
-
- if(set_blocking(select_pipe[0],0)==-1)
- smb_panic("select_pipe[0]: O_NONBLOCK failed");
- if(set_blocking(select_pipe[1],0)==-1)
- smb_panic("select_pipe[1]: O_NONBLOCK failed");
-
- initialised = sys_getpid();
- }
-
- ZERO_STRUCT(fds[num_fds]);
- fds[num_fds].fd = select_pipe[0];
- fds[num_fds].events = POLLIN|POLLHUP;
-
- errno = 0;
- ret = poll(fds, num_fds+1, timeout);
-
- if ((ret >= 0) && (fds[num_fds].revents & (POLLIN|POLLHUP|POLLERR))) {
- char c;
- int saved_errno = errno;
-
- if (read(select_pipe[0], &c, 1) == 1) {
- pipe_read += 1;
-
- /* Mark Weaver <mark-clist@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;
-#if 0
- /* JRA - we can use this to debug the signal messaging... */
- DEBUG(0,("select got %u signal\n", (unsigned int)c));
-#endif
- errno = EINTR;
- } else {
- ret -= 1;
- errno = saved_errno;
- }
- }
-
- return ret;
-}
-
int sys_poll_intr(struct pollfd *fds, int num_fds, int timeout)
{
int orig_timeout = timeout;
diff --git a/lib/util/select.h b/lib/util/select.h
index bfc78a99d2..fa1970ec01 100644
--- a/lib/util/select.h
+++ b/lib/util/select.h
@@ -24,7 +24,6 @@
/* The following definitions come from lib/util/select.c */
-int sys_poll(struct pollfd *fds, int num_fds, int timeout);
int sys_poll_intr(struct pollfd *fds, int num_fds, int timeout);
#endif