[SCM] Samba Shared Repository - branch master updated - 47d532fa685d46752650225c807f579ce658b323

Stefan Metzmacher metze at samba.org
Sat Jan 3 18:59:57 GMT 2009


The branch, master has been updated
       via  47d532fa685d46752650225c807f579ce658b323 (commit)
       via  1c8580cfa937bef1b15842b5b0615d7926b12402 (commit)
       via  c72cbce6eed1eab67649d7965eb16212d52bf833 (commit)
       via  c652b426126d97ae8fad256bf5b96beed414a385 (commit)
       via  67810019a0bc3ab2d02f9506a3f93ee1fa3062ca (commit)
       via  2c8a10fe88a94e8d591d920487106f27b4e6f020 (commit)
       via  5fa0d3d56824f4ef3dfdb0f97c836554a62c4875 (commit)
       via  b1be241ca5d7f02be93bd3582b98d428b1e207ce (commit)
       via  193eba85a9a6eff7c314f6afaaeff6bf3cff1399 (commit)
       via  e45ed828d042acca09cb1ed5b6dd7a24eb5e7ffd (commit)
       via  e928d863e2bb654d16ac9094e3406ef6a207c023 (commit)
       via  1a26b67ee395ab49eb57a3773ec889f4ebbccb08 (commit)
       via  7dff14df46d38092d3fc7a9436a6412d54314d41 (commit)
      from  fafb9ecc613914ee49bfdb4c1eb249fcbbcf25f7 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 47d532fa685d46752650225c807f579ce658b323
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 15:24:31 2009 +0100

    s4:smbd: convert to tevent_* api
    
    metze

commit 1c8580cfa937bef1b15842b5b0615d7926b12402
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 12:49:50 2009 +0100

    s4:libcli/ldap: convert to tevent_* api
    
    metze

commit c72cbce6eed1eab67649d7965eb16212d52bf833
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 12:48:20 2009 +0100

    s4:auth/kerberos: convert to tevent_* api
    
    metze

commit c652b426126d97ae8fad256bf5b96beed414a385
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 11:36:04 2009 +0100

    tevent: raise version to 0.9.2 after AUTOCLOSE changes
    
    metze

commit 67810019a0bc3ab2d02f9506a3f93ee1fa3062ca
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 11:34:37 2009 +0100

    tevent: remove TEVENT_FD_AUTOCLOSE feature
    
    TEVENT_FD_AUTOCLOSE adds a dependency to SOCKET_WRAPPER,
    which is bad. Callers should use tevent_fd_set_close_fn() now.
    
    metze

commit 2c8a10fe88a94e8d591d920487106f27b4e6f020
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 11:30:21 2009 +0100

    tevent: remove dependency to SOCKET_WRAPPER via "system/network.h"
    
    metze

commit 5fa0d3d56824f4ef3dfdb0f97c836554a62c4875
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 12:47:24 2009 +0100

    s4:socket: use a socket_wrapper aware function to auto close the fd event for sockets
    
    metze

commit b1be241ca5d7f02be93bd3582b98d428b1e207ce
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 12:43:18 2009 +0100

    s4:sysdep/inotify: use tevent_fd_set_auto_close()
    
    metze

commit 193eba85a9a6eff7c314f6afaaeff6bf3cff1399
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 12:39:11 2009 +0100

    tevent: add tevent_fd_set_auto_close()
    
    tevent_fd_set_auto_close() is a simple wrapper
    arround tevent_fd_set_close_fn() with a callback
    that uses plain close(2).
    
    metze

commit e45ed828d042acca09cb1ed5b6dd7a24eb5e7ffd
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 11:27:00 2009 +0100

    tevent: add tevent_fd_set_close_fn()
    
    Let callers specify a close function
    as an alternative to TEVENT_FD_AUTOCLOSE.
    
    metze

commit e928d863e2bb654d16ac9094e3406ef6a207c023
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 11:18:14 2009 +0100

    tevent: move some common tevent_fd related functions into tevent_fd.c
    
    metze

commit 1a26b67ee395ab49eb57a3773ec889f4ebbccb08
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 10:42:10 2009 +0100

    tevent: specify argument names for the event handlers
    
    metze

commit 7dff14df46d38092d3fc7a9436a6412d54314d41
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Jan 3 10:41:17 2009 +0100

    tevent: fix standalone make test
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 lib/tevent/config.mk                              |    2 +-
 lib/tevent/configure.ac                           |    2 +-
 lib/tevent/libtevent.m4                           |    4 +-
 lib/tevent/testsuite.c                            |    3 +-
 lib/tevent/tevent.c                               |   24 +++++++++
 lib/tevent/tevent.h                               |   39 +++++++++-----
 lib/tevent/tevent.mk                              |   11 ++--
 lib/tevent/tevent_aio.c                           |   17 ++-----
 lib/tevent/tevent_epoll.c                         |   17 ++-----
 source3/lib/util_nscd.c => lib/tevent/tevent_fd.c |   37 +++++++-------
 lib/tevent/tevent_internal.h                      |   10 +++-
 lib/tevent/tevent_select.c                        |   34 ++-----------
 lib/tevent/tevent_standard.c                      |   17 ++-----
 source3/samba4.m4                                 |    2 +-
 source4/auth/kerberos/config.mk                   |    2 +-
 source4/auth/kerberos/krb5_init_context.c         |   34 ++++++------
 source4/configure.ac                              |    2 +-
 source4/lib/socket/socket.c                       |    9 +++
 source4/lib/socket/socket.h                       |    6 ++
 source4/libcli/ldap/config.mk                     |    2 +-
 source4/libcli/ldap/ldap_client.c                 |   33 ++++++------
 source4/ntvfs/sysdep/inotify.c                    |   20 ++++++-
 source4/smbd/config.mk                            |    3 +-
 source4/smbd/server.c                             |   18 +++---
 source4/smbd/service_named_pipe.c                 |    6 +-
 source4/smbd/service_stream.c                     |   55 +++++++++++++--------
 source4/smbd/service_task.c                       |    1 -
 27 files changed, 225 insertions(+), 185 deletions(-)
 copy source3/lib/util_nscd.c => lib/tevent/tevent_fd.c (57%)


Changeset truncated at 500 lines:

diff --git a/lib/tevent/config.mk b/lib/tevent/config.mk
index e4fb9a8..90548b6 100644
--- a/lib/tevent/config.mk
+++ b/lib/tevent/config.mk
@@ -41,6 +41,6 @@ CFLAGS = -I../lib/tevent
 # End SUBSYSTEM LIBTEVENT
 ################################################
 
-LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o)
+LIBTEVENT_OBJ_FILES = $(addprefix $(libteventsrcdir)/, tevent.o tevent_fd.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o)
 
 PUBLIC_HEADERS += $(addprefix $(libteventsrcdir)/, tevent.h tevent_internal.h)
diff --git a/lib/tevent/configure.ac b/lib/tevent/configure.ac
index fe246f5..747e479 100644
--- a/lib/tevent/configure.ac
+++ b/lib/tevent/configure.ac
@@ -3,7 +3,7 @@ AC_DEFUN([SMB_MODULE_DEFAULT], [echo -n ""])
 AC_DEFUN([SMB_LIBRARY_ENABLE], [echo -n ""])
 AC_DEFUN([SMB_ENABLE], [echo -n ""])
 AC_DEFUN([SMB_EXT_LIB], [echo -n ""])
-AC_INIT(tevent, 0.9.1)
+AC_INIT(tevent, 0.9.2)
 AC_CONFIG_SRCDIR([tevent.c])
 AC_CONFIG_HEADER(config.h)
 AC_LIBREPLACE_ALL_CHECKS
diff --git a/lib/tevent/libtevent.m4 b/lib/tevent/libtevent.m4
index 24cdd8c..df43265 100644
--- a/lib/tevent/libtevent.m4
+++ b/lib/tevent/libtevent.m4
@@ -15,8 +15,8 @@ if test x"$teventdir" = "x"; then
 	fi
 fi
 
-TEVENT_OBJ="tevent.o tevent_select.o tevent_signal.o tevent_timed.o tevent_standard.o tevent_debug.o tevent_util.o"
-AC_LIBREPLACE_NETWORK_CHECKS
+TEVENT_OBJ="tevent.o tevent_fd.o tevent_timed.o tevent_signal.o tevent_debug.o tevent_util.o"
+TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o"
 
 SMB_ENABLE(TEVENT_EPOLL, NO)
 SMB_ENABLE(TEVENT_AIO, NO)
diff --git a/lib/tevent/testsuite.c b/lib/tevent/testsuite.c
index ec57c5a..1b811f5 100644
--- a/lib/tevent/testsuite.c
+++ b/lib/tevent/testsuite.c
@@ -81,8 +81,9 @@ static bool test_event_context(struct torture_context *test,
 	/* create a pipe */
 	pipe(fd);
 
-	fde = event_add_fd(ev_ctx, ev_ctx, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+	fde = event_add_fd(ev_ctx, ev_ctx, fd[0], EVENT_FD_READ,
 			   fde_handler, fd);
+	tevent_fd_set_auto_close(fde);
 
 	event_add_timed(ev_ctx, ev_ctx, timeval_current_ofs(2,0), 
 			finished_handler, &finished);
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index 9319177..5582b58 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -53,6 +53,7 @@
 
 */
 #include "replace.h"
+#include "system/filesys.h"
 #include "tevent.h"
 #include "tevent_internal.h"
 #include "tevent_util.h"
@@ -241,6 +242,29 @@ struct tevent_aio *_tevent_add_aio(struct tevent_context *ev,
 }
 
 /*
+  set a close function on the fd event
+*/
+void tevent_fd_set_close_fn(struct tevent_fd *fde,
+			    tevent_fd_close_fn_t close_fn)
+{
+	if (!fde) return;
+	fde->event_ctx->ops->set_fd_close_fn(fde, close_fn);
+}
+
+static void tevent_fd_auto_close_fn(struct tevent_context *ev,
+				    struct tevent_fd *fde,
+				    int fd,
+				    void *private_data)
+{
+	close(fd);
+}
+
+void tevent_fd_set_auto_close(struct tevent_fd *fde)
+{
+	tevent_fd_set_close_fn(fde, tevent_fd_auto_close_fn);
+}
+
+/*
   return the fd event flags
 */
 uint16_t tevent_fd_get_flags(struct tevent_fd *fde)
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 01e79df..b57d96f 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -33,18 +33,28 @@ struct tevent_aio;
 struct tevent_signal;
 
 /* event handler types */
-typedef void (*tevent_fd_handler_t)(struct tevent_context *,
-				    struct tevent_fd *,
-				    uint16_t , void *);
-typedef void (*tevent_timer_handler_t)(struct tevent_context *,
-				       struct tevent_timer *,
-				       struct timeval , void *);
-typedef void (*tevent_signal_handler_t)(struct tevent_context *,
-					struct tevent_signal *,
-				        int , int, void *, void *);
-typedef void (*tevent_aio_handler_t)(struct tevent_context *,
-				     struct tevent_aio *,
-				     int, void *);
+typedef void (*tevent_fd_handler_t)(struct tevent_context *ev,
+				    struct tevent_fd *fde,
+				    uint16_t flags,
+				    void *private_data);
+typedef void (*tevent_fd_close_fn_t)(struct tevent_context *ev,
+				     struct tevent_fd *fde,
+				     int fd,
+				     void *private_data);
+typedef void (*tevent_timer_handler_t)(struct tevent_context *ev,
+				       struct tevent_timer *te,
+				       struct timeval current_time,
+				       void *private_data);
+typedef void (*tevent_signal_handler_t)(struct tevent_context *ev,
+					struct tevent_signal *se,
+					int signum,
+					int count,
+					void *siginfo,
+					void *private_data);
+typedef void (*tevent_aio_handler_t)(struct tevent_context *ev,
+				     struct tevent_aio *ae,
+				     int ret,
+				     void *private_data);
 
 struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
 struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
@@ -101,13 +111,15 @@ struct tevent_aio *_tevent_add_aio(struct tevent_context *ev,
 int tevent_loop_once(struct tevent_context *ev);
 int tevent_loop_wait(struct tevent_context *ev);
 
+void tevent_fd_set_close_fn(struct tevent_fd *fde,
+			    tevent_fd_close_fn_t close_fn);
+void tevent_fd_set_auto_close(struct tevent_fd *fde);
 uint16_t tevent_fd_get_flags(struct tevent_fd *fde);
 void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
 
 /* bits for file descriptor event flags */
 #define TEVENT_FD_READ 1
 #define TEVENT_FD_WRITE 2
-#define TEVENT_FD_AUTOCLOSE 4
 
 #define TEVENT_FD_WRITEABLE(fde) \
 	tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_WRITE)
@@ -187,7 +199,6 @@ int tevent_set_debug_stderr(struct tevent_context *ev);
 
 #define EVENT_FD_READ		TEVENT_FD_READ
 #define EVENT_FD_WRITE		TEVENT_FD_WRITE
-#define EVENT_FD_AUTOCLOSE	TEVENT_FD_AUTOCLOSE
 
 #define EVENT_FD_WRITEABLE(fde) \
 	TEVENT_FD_WRITEABLE(fde)
diff --git a/lib/tevent/tevent.mk b/lib/tevent/tevent.mk
index 6538362..be7e298 100644
--- a/lib/tevent/tevent.mk
+++ b/lib/tevent/tevent.mk
@@ -1,11 +1,12 @@
-TEVENT_SONAME = libtevent.$(SHLIBEXT).0
-TEVENT_SOLIB = libtevent.$(SHLIBEXT).$(PACKAGE_VERSION)
+TEVENT_SOBASE = libtevent.$(SHLIBEXT)
+TEVENT_SONAME = $(TEVENT_SOBASE).0
+TEVENT_SOLIB = $(TEVENT_SOBASE).$(PACKAGE_VERSION)
 TEVENT_STLIB = libtevent.a
 
 $(TEVENT_STLIB): $(TEVENT_OBJ)
 	ar -rv $(TEVENT_STLIB) $(TEVENT_OBJ)
 
-libtevent.$(SHLIBEXT): $(TEVENT_SOLIB)
+$(TEVENT_SOBASE): $(TEVENT_SOLIB)
 	ln -fs $< $@
 
 $(TEVENT_SONAME): $(TEVENT_SOLIB)
@@ -31,7 +32,7 @@ installlibs:: installdirs
 install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET)
 
 clean::
-	rm -f $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB) libtevent.$(SHLIBEXT)
+	rm -f $(TEVENT_SOBASE) $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB)
 	rm -f tevent.pc
 	rm -f tevent.$(SHLIBEXT)
 
@@ -45,7 +46,7 @@ build-python:: tevent.$(SHLIBEXT)
 pytevent.o: $(teventdir)/pytevent.c
 	$(CC) $(PICFLAG) -c $(teventdir)/pytevent.c $(CFLAGS) `$(PYTHON_CONFIG) --cflags`
 
-tevent.$(SHLIBEXT): libtevent.$(SHLIBEXT) pytevent.o
+tevent.$(SHLIBEXT): $(TEVENT_SOBASE) $(TEVENT_SONAME) pytevent.o
 	$(SHLD) $(SHLD_FLAGS) -o $@ pytevent.o -L. -ltevent `$(PYTHON_CONFIG) --libs`
 
 install-python:: build-python
diff --git a/lib/tevent/tevent_aio.c b/lib/tevent/tevent_aio.c
index ba798cc..f4ed6d8 100644
--- a/lib/tevent/tevent_aio.c
+++ b/lib/tevent/tevent_aio.c
@@ -32,7 +32,6 @@
 
 #include "replace.h"
 #include "system/filesys.h"
-#include "system/network.h"
 #include "system/select.h"
 #include "tevent.h"
 #include "tevent_internal.h"
@@ -400,8 +399,8 @@ static int aio_event_fd_destructor(struct tevent_fd *fde)
 
 	epoll_del_event(aio_ev, fde);
 
-	if (fde->flags & TEVENT_FD_AUTOCLOSE) {
-		close(fde->fd);
+	if (fde->close_fn) {
+		fde->close_fn(ev, fde, fde->fd, fde->private_data);
 		fde->fd = -1;
 	}
 
@@ -447,15 +446,6 @@ static struct tevent_fd *aio_event_add_fd(struct tevent_context *ev, TALLOC_CTX
 	return fde;
 }
 
-
-/*
-  return the fd event flags
-*/
-static uint16_t aio_event_get_fd_flags(struct tevent_fd *fde)
-{
-	return fde->flags;
-}
-
 /*
   set the fd event flags
 */
@@ -560,7 +550,8 @@ static const struct tevent_ops aio_event_ops = {
 	.context_init	= aio_event_context_init,
 	.add_fd		= aio_event_add_fd,
 	.add_aio        = aio_event_add_aio,
-	.get_fd_flags	= aio_event_get_fd_flags,
+	.set_fd_close_fn= tevent_common_fd_set_close_fn,
+	.get_fd_flags	= tevent_common_fd_get_flags,
 	.set_fd_flags	= aio_event_set_fd_flags,
 	.add_timer	= tevent_common_add_timer,
 	.add_signal	= tevent_common_add_signal,
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index 380d946..0230419 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -22,7 +22,6 @@
 
 #include "replace.h"
 #include "system/filesys.h"
-#include "system/network.h"
 #include "system/select.h"
 #include "tevent.h"
 #include "tevent_internal.h"
@@ -358,8 +357,8 @@ static int epoll_event_fd_destructor(struct tevent_fd *fde)
 		
 	epoll_del_event(epoll_ev, fde);
 
-	if (fde->flags & TEVENT_FD_AUTOCLOSE) {
-		close(fde->fd);
+	if (fde->close_fn) {
+		fde->close_fn(ev, fde, fde->fd, fde->private_data);
 		fde->fd = -1;
 	}
 
@@ -405,15 +404,6 @@ static struct tevent_fd *epoll_event_add_fd(struct tevent_context *ev, TALLOC_CT
 	return fde;
 }
 
-
-/*
-  return the fd event flags
-*/
-static uint16_t epoll_event_get_fd_flags(struct tevent_fd *fde)
-{
-	return fde->flags;
-}
-
 /*
   set the fd event flags
 */
@@ -472,7 +462,8 @@ static int epoll_event_loop_wait(struct tevent_context *ev)
 static const struct tevent_ops epoll_event_ops = {
 	.context_init	= epoll_event_context_init,
 	.add_fd		= epoll_event_add_fd,
-	.get_fd_flags	= epoll_event_get_fd_flags,
+	.set_fd_close_fn= tevent_common_fd_set_close_fn,
+	.get_fd_flags	= tevent_common_fd_get_flags,
 	.set_fd_flags	= epoll_event_set_fd_flags,
 	.add_timer	= tevent_common_add_timer,
 	.add_signal	= tevent_common_add_signal,
diff --git a/source3/lib/util_nscd.c b/lib/tevent/tevent_fd.c
similarity index 57%
copy from source3/lib/util_nscd.c
copy to lib/tevent/tevent_fd.c
index f019bdd..d450e21 100644
--- a/source3/lib/util_nscd.c
+++ b/lib/tevent/tevent_fd.c
@@ -1,41 +1,42 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
-   Samba utility functions
-   Copyright (C) Guenther Deschner 2006
+
+   common events code for fd events
+
+   Copyright (C) Stefan Metzmacher	2009
 
    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"
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
 
-static void smb_nscd_flush_cache(const char *service)
+uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde)
 {
-#ifdef HAVE_NSCD_FLUSH_CACHE
-	if (!nscd_flush_cache(service)) {
-		DEBUG(10,("failed to flush nscd cache for '%s' service: %s. "
-			  "Is nscd running?\n",
-			  service, strerror(errno)));
-	}
-#endif
+	return fde->flags;
 }
 
-void smb_nscd_flush_user_cache(void)
+void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags)
 {
-	smb_nscd_flush_cache("passwd");
+	if (fde->flags == flags) return;
+	fde->flags = flags;
 }
 
-void smb_nscd_flush_group_cache(void)
+void tevent_common_fd_set_close_fn(struct tevent_fd *fde,
+				   tevent_fd_close_fn_t close_fn)
 {
-	smb_nscd_flush_cache("group");
+	fde->close_fn = close_fn;
 }
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 46ba1b1..f29e9c6 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -33,6 +33,8 @@ struct tevent_ops {
 				    void *private_data,
 				    const char *handler_name,
 				    const char *location);
+	void (*set_fd_close_fn)(struct tevent_fd *fde,
+				tevent_fd_close_fn_t close_fn);
 	uint16_t (*get_fd_flags)(struct tevent_fd *fde);
 	void (*set_fd_flags)(struct tevent_fd *fde, uint16_t flags);
 
@@ -70,8 +72,9 @@ struct tevent_fd {
 	struct tevent_fd *prev, *next;
 	struct tevent_context *event_ctx;
 	int fd;
-	uint16_t flags; /* see EVENT_FD_* flags */
+	uint16_t flags; /* see TEVENT_FD_* flags */
 	tevent_fd_handler_t handler;
+	tevent_fd_close_fn_t close_fn;
 	/* this is private for the specific handler */
 	void *private_data;
 	/* this is for debugging only! */
@@ -146,6 +149,11 @@ struct tevent_context {
 
 bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
 
+void tevent_common_fd_set_close_fn(struct tevent_fd *fde,
+				   tevent_fd_close_fn_t close_fn);
+uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde);
+void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
+
 bool ev_timeval_is_zero(const struct timeval *tv);
 struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
 					     TALLOC_CTX *mem_ctx,
diff --git a/lib/tevent/tevent_select.c b/lib/tevent/tevent_select.c
index e21b3c4..d94e473 100644
--- a/lib/tevent/tevent_select.c
+++ b/lib/tevent/tevent_select.c
@@ -103,8 +103,8 @@ static int select_event_fd_destructor(struct tevent_fd *fde)
 	DLIST_REMOVE(select_ev->fd_events, fde);
 	select_ev->destruction_count++;
 
-	if (fde->flags & TEVENT_FD_AUTOCLOSE) {
-		close(fde->fd);
+	if (fde->close_fn) {
+		fde->close_fn(ev, fde, fde->fd, fde->private_data);
 		fde->fd = -1;
 	}
 
@@ -148,31 +148,6 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
 	return fde;
 }
 
-
-/*
-  return the fd event flags
-*/
-static uint16_t select_event_get_fd_flags(struct tevent_fd *fde)
-{
-	return fde->flags;
-}
-
-/*
-  set the fd event flags
-*/
-static void select_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
-{
-	struct tevent_context *ev;
-	struct select_event_context *select_ev;
-
-	if (fde->flags == flags) return;
-
-	ev = fde->event_ctx;
-	select_ev = talloc_get_type(ev->additional_data, struct select_event_context);
-
-	fde->flags = flags;
-}
-
 /*
   event loop handling using select()
 */
@@ -291,8 +266,9 @@ static int select_event_loop_wait(struct tevent_context *ev)
 static const struct tevent_ops select_event_ops = {
 	.context_init	= select_event_context_init,
 	.add_fd		= select_event_add_fd,
-	.get_fd_flags	= select_event_get_fd_flags,
-	.set_fd_flags	= select_event_set_fd_flags,
+	.set_fd_close_fn= tevent_common_fd_set_close_fn,
+	.get_fd_flags	= tevent_common_fd_get_flags,
+	.set_fd_flags	= tevent_common_fd_set_flags,
 	.add_timer	= tevent_common_add_timer,
 	.add_signal	= tevent_common_add_signal,
 	.loop_once	= select_event_loop_once,
diff --git a/lib/tevent/tevent_standard.c b/lib/tevent/tevent_standard.c
index 5769eac..145f510 100644
--- a/lib/tevent/tevent_standard.c
+++ b/lib/tevent/tevent_standard.c
@@ -29,7 +29,6 @@
 
 #include "replace.h"
 #include "system/filesys.h"
-#include "system/network.h"
 #include "system/select.h"
 #include "tevent.h"
 #include "tevent_util.h"
@@ -392,8 +391,8 @@ static int std_event_fd_destructor(struct tevent_fd *fde)
 
 	epoll_del_event(std_ev, fde);
 
-	if (fde->flags & TEVENT_FD_AUTOCLOSE) {
-		close(fde->fd);
+	if (fde->close_fn) {
+		fde->close_fn(ev, fde, fde->fd, fde->private_data);
 		fde->fd = -1;
 	}
 
@@ -440,15 +439,6 @@ static struct tevent_fd *std_event_add_fd(struct tevent_context *ev, TALLOC_CTX
 	return fde;
 }
 
-
-/*
-  return the fd event flags
-*/
-static uint16_t std_event_get_fd_flags(struct tevent_fd *fde)
-{
-	return fde->flags;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list