tevent: move some common tevent_fd related functions into tevent_fd.c
authorStefan Metzmacher <metze@samba.org>
Sat, 3 Jan 2009 10:18:14 +0000 (11:18 +0100)
committerStefan Metzmacher <metze@samba.org>
Sat, 3 Jan 2009 18:58:50 +0000 (19:58 +0100)
metze

lib/tevent/config.mk
lib/tevent/libtevent.m4
lib/tevent/tevent_aio.c
lib/tevent/tevent_epoll.c
lib/tevent/tevent_fd.c [new file with mode: 0644]
lib/tevent/tevent_internal.h
lib/tevent/tevent_select.c
lib/tevent/tevent_standard.c

index e4fb9a8088f1773bcf9f7c6c3b00d12f9ce0cbe2..90548b636a03e861ea40045ba8b2e38a81e745d7 100644 (file)
@@ -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)
index 24cdd8c27fd7305b3e06709afac6981aab92736e..19892823ae104e6fa5b4f4c7dc711dc1124d4882 100644 (file)
@@ -15,7 +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"
+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"
 AC_LIBREPLACE_NETWORK_CHECKS
 
 SMB_ENABLE(TEVENT_EPOLL, NO)
index ba798cc79918e83c308ab647f1c2f5c2ffb182a4..bfe3f070dbd32e2b6fc01151aae50efb89bf2ac4 100644 (file)
@@ -447,15 +447,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 +551,7 @@ 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,
+       .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,
index 380d9461c9fa9752fc2ab15d5d968f4aa01b2a22..8fb662e168522aea5edd00699b032e9516af7015 100644 (file)
@@ -405,15 +405,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 +463,7 @@ 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,
+       .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/lib/tevent/tevent_fd.c b/lib/tevent/tevent_fd.c
new file mode 100644 (file)
index 0000000..eb9cdab
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   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 "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+uint16_t tevent_common_fd_get_flags(struct tevent_fd *fde)
+{
+       return fde->flags;
+}
+
+void tevent_common_fd_set_flags(struct tevent_fd *fde, uint16_t flags)
+{
+       if (fde->flags == flags) return;
+       fde->flags = flags;
+}
index 46ba1b1655f1fcd71d0318b81811fe90241178d0..6099387362a00ebf710c828e29fe48dbc4ac993c 100644 (file)
@@ -146,6 +146,9 @@ struct tevent_context {
 
 bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
 
+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,
index e21b3c44b9477394315b4a0841403bcafc5ff352..f6790ab0f456d717dbdf8fd34f0495fcde3676ee 100644 (file)
@@ -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,8 @@ 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,
+       .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,
index 5769eac5892a59eb6fec04d01930890221b14fa5..3a674152b1a35568b4ad8a08517219657f9bfa58 100644 (file)
@@ -440,15 +440,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;
-}
-
 /*
   set the fd event flags
 */
@@ -593,7 +584,7 @@ static int std_event_loop_wait(struct tevent_context *ev)
 static const struct tevent_ops std_event_ops = {
        .context_init   = std_event_context_init,
        .add_fd         = std_event_add_fd,
-       .get_fd_flags   = std_event_get_fd_flags,
+       .get_fd_flags   = tevent_common_fd_get_flags,
        .set_fd_flags   = std_event_set_fd_flags,
        .add_timer      = tevent_common_add_timer,
        .add_signal     = tevent_common_add_signal,