summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in5
-rw-r--r--source3/client/client.c1
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/lib/events.c1
-rw-r--r--source3/lib/g_lock.c1
-rw-r--r--source3/lib/packet.c1
-rw-r--r--source3/lib/readline.c1
-rw-r--r--source3/lib/select.c207
-rw-r--r--source3/lib/util_sock.c1
-rw-r--r--source3/libsmb/nmblib.c1
-rw-r--r--source3/nmbd/nmbd_packets.c1
-rw-r--r--source3/smbd/process.c1
-rw-r--r--source3/utils/smbfilter.c1
-rw-r--r--source3/winbindd/winbindd_dual.c1
-rw-r--r--source3/wscript_build5
15 files changed, 17 insertions, 217 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 8a0364d174..139ea70909 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -430,7 +430,8 @@ UTIL_OBJ = ../lib/util/rbtree.o ../lib/util/signal.o ../lib/util/time.o \
../lib/util/become_daemon.o ../lib/util/system.o \
../lib/util/tevent_unix.o ../lib/util/tevent_ntstatus.o \
../lib/util/smb_threads.o ../lib/util/util_id.o \
- ../lib/util/blocking.o ../lib/util/rfc1738.o
+ ../lib/util/blocking.o ../lib/util/rfc1738.o \
+ ../lib/util/select.o
CRYPTO_OBJ = ../lib/crypto/crc32.o ../lib/crypto/md5.o \
../lib/crypto/hmacmd5.o ../lib/crypto/arcfour.o \
@@ -460,7 +461,7 @@ LIB_OBJ = $(LIBSAMBAUTIL_OBJ) $(UTIL_OBJ) $(CRYPTO_OBJ) \
lib/util.o lib/util_names.o \
lib/util_sock.o lib/sock_exec.o lib/util_sec.o \
lib/substitute.o lib/dbwrap_util.o \
- lib/ms_fnmatch.o lib/select.o lib/errmap_unix.o \
+ lib/ms_fnmatch.o lib/errmap_unix.o \
lib/tallocmsg.o lib/dmallocmsg.o \
libsmb/clisigning.o libsmb/smb_signing.o \
lib/iconv.o lib/pam_errors.o intl/lang_tdb.o \
diff --git a/source3/client/client.c b/source3/client/client.c
index 86d64f6afa..1432d95c22 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -25,6 +25,7 @@
#include "popt_common.h"
#include "client/client_proto.h"
#include "../librpc/gen_ndr/cli_srvsvc.h"
+#include "../lib/util/select.h"
#ifndef REGISTER
#define REGISTER 0
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 866836f99f..d19ce81a44 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -716,12 +716,6 @@ NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
const struct security_descriptor *parent_ctr,
bool container);
-/* The following definitions come from lib/select.c */
-
-void sys_select_signal(char c);
-int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval);
-int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval);
-
/* The following definitions come from lib/sendfile.c */
ssize_t sys_sendfile(int tofd, int fromfd, const DATA_BLOB *header, SMB_OFF_T offset, size_t count);
diff --git a/source3/lib/events.c b/source3/lib/events.c
index 21a13b63fb..70a0d7c302 100644
--- a/source3/lib/events.c
+++ b/source3/lib/events.c
@@ -20,6 +20,7 @@
#include "includes.h"
#include <tevent_internal.h>
+#include "../lib/util/select.h"
/*
* Return if there's something in the queue
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 2c065029e7..378e464b5c 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -21,6 +21,7 @@
#include "g_lock.h"
#include "librpc/gen_ndr/messaging.h"
#include "ctdbd_conn.h"
+#include "../lib/util/select.h"
static NTSTATUS g_lock_force_unlock(struct g_lock_ctx *ctx, const char *name,
struct server_id pid);
diff --git a/source3/lib/packet.c b/source3/lib/packet.c
index c131b973bc..fefb74a0c5 100644
--- a/source3/lib/packet.c
+++ b/source3/lib/packet.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "../lib/util/select.h"
struct packet_context {
int fd;
diff --git a/source3/lib/readline.c b/source3/lib/readline.c
index 4b82291eca..1be0e05f7d 100644
--- a/source3/lib/readline.c
+++ b/source3/lib/readline.c
@@ -19,6 +19,7 @@
*/
#include "includes.h"
+#include "../lib/util/select.h"
#ifdef HAVE_LIBREADLINE
# ifdef HAVE_READLINE_READLINE_H
diff --git a/source3/lib/select.c b/source3/lib/select.c
deleted file mode 100644
index 846e6af1de..0000000000
--- a/source3/lib/select.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- Unix SMB/Netbios implementation.
- Version 3.0
- Samba select/poll implementation
- Copyright (C) Andrew Tridgell 1992-1998
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#include "includes.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;
-
-/*******************************************************************
- Call this from all Samba signal handlers if you want to avoid a
- nasty signal race condition.
-********************************************************************/
-
-void sys_select_signal(char c)
-{
- int saved_errno = errno;
-
- if (!initialised) return;
-
- if (pipe_written > pipe_read+256) return;
-
- if (write(select_pipe[1], &c, 1) == 1) pipe_written++;
-
- errno = saved_errno;
-}
-
-/*******************************************************************
- Like select() but avoids the signal race using a pipe
- it also guuarantees that fds on return only ever contains bits set
- for file descriptors that were readable.
-********************************************************************/
-
-int sys_select(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval)
-{
- int ret, saved_errno;
- fd_set *readfds2, readfds_buf;
-
- if (initialised != sys_getpid()) {
- if (pipe(select_pipe) == -1)
- {
- DEBUG(0, ("sys_select: pipe failed (%s)\n",
- strerror(errno)));
- if (readfds != NULL)
- FD_ZERO(readfds);
- if (writefds != NULL)
- FD_ZERO(writefds);
- if (errorfds != NULL)
- FD_ZERO(errorfds);
- 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();
- }
-
- maxfd = MAX(select_pipe[0]+1, maxfd);
-
- /* If readfds is NULL we need to provide our own set. */
- if (readfds) {
- readfds2 = readfds;
- } else {
- readfds2 = &readfds_buf;
- FD_ZERO(readfds2);
- }
- FD_SET(select_pipe[0], readfds2);
-
- errno = 0;
- ret = select(maxfd,readfds2,writefds,errorfds,tval);
-
- if (ret <= 0) {
- FD_ZERO(readfds2);
- if (writefds)
- FD_ZERO(writefds);
- if (errorfds)
- FD_ZERO(errorfds);
- } else if (FD_ISSET(select_pipe[0], readfds2)) {
- char c;
- saved_errno = errno;
- if (read(select_pipe[0], &c, 1) == 1) {
- pipe_read++;
- /* 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 {
- FD_CLR(select_pipe[0], readfds2);
- ret--;
- errno = saved_errno;
- }
- }
-
- return ret;
-}
-
-/*******************************************************************
- Similar to sys_select() but catch EINTR and continue.
- This is what sys_select() used to do in Samba.
-********************************************************************/
-
-int sys_select_intr(int maxfd, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct timeval *tval)
-{
- int ret;
- fd_set *readfds2, readfds_buf, *writefds2, writefds_buf, *errorfds2, errorfds_buf;
- struct timeval tval2, *ptval;
- struct timespec end_time;
-
- readfds2 = (readfds ? &readfds_buf : NULL);
- writefds2 = (writefds ? &writefds_buf : NULL);
- errorfds2 = (errorfds ? &errorfds_buf : NULL);
- if (tval) {
- clock_gettime_mono(&end_time);
- end_time.tv_sec += tval->tv_sec;
- end_time.tv_nsec += tval->tv_usec *1000;
- end_time.tv_sec += end_time.tv_nsec / 1000000000;
- end_time.tv_nsec %= 1000000000;
- errno = 0;
- tval2 = *tval;
- ptval = &tval2;
- } else {
- ptval = NULL;
- }
-
- do {
- if (readfds)
- readfds_buf = *readfds;
- if (writefds)
- writefds_buf = *writefds;
- if (errorfds)
- errorfds_buf = *errorfds;
- if (ptval && (errno == EINTR)) {
- struct timespec now_time;
- int64_t tdif;
-
- clock_gettime_mono(&now_time);
- tdif = nsec_time_diff(&end_time,&now_time);
- if (tdif <= 0) {
- ret = 0; /* time expired. */
- break;
- }
- ptval->tv_sec = tdif / 1000000000;
- ptval->tv_usec = (tdif % 1000000000) / 1000;
- }
-
- /* 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);
-
- if (readfds)
- *readfds = readfds_buf;
- if (writefds)
- *writefds = writefds_buf;
- if (errorfds)
- *errorfds = errorfds_buf;
-
- return ret;
-}
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index 2b33816293..188e11702e 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "memcache.h"
#include "../lib/async_req/async_sock.h"
+#include "../lib/util/select.h"
/****************************************************************************
Get a port number in host byte order from a sockaddr_storage.
diff --git a/source3/libsmb/nmblib.c b/source3/libsmb/nmblib.c
index 1c95d0e99f..943cbcbe6d 100644
--- a/source3/libsmb/nmblib.c
+++ b/source3/libsmb/nmblib.c
@@ -20,6 +20,7 @@
*/
#include "includes.h"
+#include "../lib/util/select.h"
static const struct opcode_names {
const char *nmb_opcode_name;
diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c
index 2dd218aece..5d5a67bf62 100644
--- a/source3/nmbd/nmbd_packets.c
+++ b/source3/nmbd/nmbd_packets.c
@@ -22,6 +22,7 @@
#include "includes.h"
#include "nmbd/nmbd.h"
+#include "../lib/util/select.h"
extern int ClientNMB;
extern int ClientDGRAM;
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 4db54f39c0..a484dfd3f2 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -24,6 +24,7 @@
#include "librpc/gen_ndr/messaging.h"
#include "../lib/async_req/async_sock.h"
#include "ctdbd_conn.h"
+#include "../lib/util/select.h"
extern bool global_machine_password_needs_changing;
diff --git a/source3/utils/smbfilter.c b/source3/utils/smbfilter.c
index 65d846124b..9d3e46825f 100644
--- a/source3/utils/smbfilter.c
+++ b/source3/utils/smbfilter.c
@@ -18,6 +18,7 @@
*/
#include "includes.h"
+#include "../lib/util/select.h"
#define SECURITY_MASK 0
#define SECURITY_SET 0
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index a6cc64a7b5..a4d8b8ac41 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -32,6 +32,7 @@
#include "../../nsswitch/libwbclient/wbc_async.h"
#include "librpc/gen_ndr/messaging.h"
#include "secrets.h"
+#include "../lib/util/select.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_WINBIND
diff --git a/source3/wscript_build b/source3/wscript_build
index ff091b5e8a..0d70a936ec 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -162,7 +162,8 @@ UTIL_SRC = '''../lib/util/rbtree.c ../lib/util/signal.c ../lib/util/time.c
../lib/util/become_daemon.c ../lib/util/system.c
../lib/util/tevent_unix.c ../lib/util/tevent_ntstatus.c
../lib/util/smb_threads.c ../lib/util/util_id.c
- ../lib/util/blocking.c ../lib/util/rfc1738.c '''
+ ../lib/util/blocking.c ../lib/util/rfc1738.c
+ ../lib/util/select.c'''
LIBTEVENT_SRC0 = ''
@@ -194,7 +195,7 @@ LIB_SRC = '''${LIBSAMBAUTIL_SRC} ${UTIL_SRC}
lib/util.c lib/util_names.c
lib/util_sock.c lib/sock_exec.c lib/util_sec.c
lib/substitute.c lib/dbwrap_util.c
- lib/ms_fnmatch.c lib/select.c lib/errmap_unix.c
+ lib/ms_fnmatch.c lib/errmap_unix.c
lib/tallocmsg.c lib/dmallocmsg.c
libsmb/clisigning.c libsmb/smb_signing.c
lib/iconv.c lib/pam_errors.c intl/lang_tdb.c