event: Update events to latest Samba version 0.9.8
authorRusty Russell <rusty@rustcorp.com.au>
Tue, 17 Aug 2010 23:46:31 +0000 (09:16 +0930)
committerRusty Russell <rusty@rustcorp.com.au>
Tue, 17 Aug 2010 23:46:31 +0000 (09:16 +0930)
In Samba this is now called "tevent", and while we use the backwards
compatibility wrappers they don't offer EVENT_FD_AUTOCLOSE: that is now
a separate tevent_fd_set_auto_close() function.

This is based on Samba version 7f29f817fa939ef1bbb740584f09e76e2ecd5b06.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(This used to be ctdb commit 85e5e760cc91eb3157d3a88996ce474491646726)

108 files changed:
ctdb/Makefile.in
ctdb/autogen.sh
ctdb/client/ctdb_client.c
ctdb/common/cmdline.c
ctdb/common/ctdb_io.c
ctdb/common/ctdb_logging.c
ctdb/common/ctdb_ltdb.c
ctdb/common/ctdb_message.c
ctdb/common/ctdb_util.c
ctdb/common/system_linux.c
ctdb/configure.ac
ctdb/ib/ibw_ctdb.c
ctdb/ib/ibw_ctdb_init.c
ctdb/ib/ibwrapper_test.c
ctdb/include/ctdb_client.h
ctdb/include/ctdb_private.h
ctdb/lib/events/config.m4 [deleted file]
ctdb/lib/events/config.mk [deleted file]
ctdb/lib/events/events.c [deleted file]
ctdb/lib/events/events.h [deleted file]
ctdb/lib/events/events_aio.c [deleted file]
ctdb/lib/events/events_internal.h [deleted file]
ctdb/lib/events/events_select.c [deleted file]
ctdb/lib/events/events_signal.c [deleted file]
ctdb/lib/events/events_timed.c [deleted file]
ctdb/lib/events/libevents.m4 [deleted file]
ctdb/lib/replace/replace.h
ctdb/lib/tevent/ABI/tevent-0.9.9.sigs [new file with mode: 0644]
ctdb/lib/tevent/Makefile.in [new file with mode: 0644]
ctdb/lib/tevent/autogen-waf.sh [new symlink]
ctdb/lib/tevent/autogen.sh [new file with mode: 0755]
ctdb/lib/tevent/build_macros.m4 [new file with mode: 0644]
ctdb/lib/tevent/config.guess [new file with mode: 0755]
ctdb/lib/tevent/config.sub [new file with mode: 0755]
ctdb/lib/tevent/configure.ac [new file with mode: 0644]
ctdb/lib/tevent/doc/mainpage.dox [new file with mode: 0644]
ctdb/lib/tevent/doc/tutorials.dox [new file with mode: 0644]
ctdb/lib/tevent/doxy.config [new file with mode: 0644]
ctdb/lib/tevent/install-sh [new file with mode: 0755]
ctdb/lib/tevent/libtalloc.m4 [new file with mode: 0644]
ctdb/lib/tevent/libtevent.m4 [new file with mode: 0644]
ctdb/lib/tevent/pkg.m4 [new file with mode: 0644]
ctdb/lib/tevent/release-script.sh [new file with mode: 0755]
ctdb/lib/tevent/rules.mk [new file with mode: 0644]
ctdb/lib/tevent/samba.m4 [new file with mode: 0644]
ctdb/lib/tevent/script/abi_checks.sh [new file with mode: 0755]
ctdb/lib/tevent/script/abi_checks_gcc.sh [new file with mode: 0755]
ctdb/lib/tevent/script/mksigs.pl [new file with mode: 0755]
ctdb/lib/tevent/script/mksyms.awk [new file with mode: 0644]
ctdb/lib/tevent/script/mksyms.sh [new file with mode: 0755]
ctdb/lib/tevent/testsuite.c [new file with mode: 0644]
ctdb/lib/tevent/tevent.c [new file with mode: 0644]
ctdb/lib/tevent/tevent.exports [new file with mode: 0644]
ctdb/lib/tevent/tevent.h [new file with mode: 0644]
ctdb/lib/tevent/tevent.mk [new file with mode: 0644]
ctdb/lib/tevent/tevent.pc.in [new file with mode: 0644]
ctdb/lib/tevent/tevent.signatures [new file with mode: 0644]
ctdb/lib/tevent/tevent_debug.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_epoll.c [moved from ctdb/lib/events/events_epoll.c with 53% similarity]
ctdb/lib/tevent/tevent_fd.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_immediate.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_internal.h [new file with mode: 0644]
ctdb/lib/tevent/tevent_liboop.c [moved from ctdb/lib/events/events_liboop.c with 67% similarity]
ctdb/lib/tevent/tevent_queue.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_req.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_select.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_signal.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_standard.c [moved from ctdb/lib/events/events_standard.c with 62% similarity]
ctdb/lib/tevent/tevent_timed.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_util.c [new file with mode: 0644]
ctdb/lib/tevent/tevent_util.h [new file with mode: 0644]
ctdb/lib/tevent/tevent_wakeup.c [new file with mode: 0644]
ctdb/lib/tevent/wscript [new file with mode: 0644]
ctdb/lib/util/db_wrap.c
ctdb/server/ctdb_banning.c
ctdb/server/ctdb_call.c
ctdb/server/ctdb_control.c
ctdb/server/ctdb_daemon.c
ctdb/server/ctdb_freeze.c
ctdb/server/ctdb_keepalive.c
ctdb/server/ctdb_lockwait.c
ctdb/server/ctdb_logging.c
ctdb/server/ctdb_ltdb_server.c
ctdb/server/ctdb_monitor.c
ctdb/server/ctdb_persistent.c
ctdb/server/ctdb_recover.c
ctdb/server/ctdb_recoverd.c
ctdb/server/ctdb_server.c
ctdb/server/ctdb_takeover.c
ctdb/server/ctdb_traverse.c
ctdb/server/ctdb_uptime.c
ctdb/server/ctdb_vacuum.c
ctdb/server/ctdbd.c
ctdb/server/eventscript.c
ctdb/tcp/tcp_connect.c
ctdb/tcp/tcp_init.c
ctdb/tcp/tcp_io.c
ctdb/tests/src/ctdb_bench.c
ctdb/tests/src/ctdb_fetch.c
ctdb/tests/src/ctdb_fetch_one.c
ctdb/tests/src/ctdb_persistent.c
ctdb/tests/src/ctdb_randrec.c
ctdb/tests/src/ctdb_store.c
ctdb/tests/src/ctdb_transaction.c
ctdb/tests/src/ctdb_traverse.c
ctdb/tests/src/rb_test.c
ctdb/tools/ctdb.c
ctdb/tools/ctdb_vacuum.c

index d2e0dea921549934d4b1867eb413dcfb9d0665e7..a039a08259a15853bbb78d9b8d332aabf2d57d58 100755 (executable)
@@ -16,7 +16,7 @@ sbindir = @sbindir@
 mandir = @mandir@
 localstatedir = @localstatedir@
 logdir = @LOGDIR@
-VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@
+VPATH = @srcdir@:@tdbdir@:@tallocdir@:@libreplacedir@:@poptdir@:@teventdir@:
 srcdir = @srcdir@
 etcdir = @sysconfdir@
 builddir = @builddir@
@@ -54,7 +54,7 @@ CTDB_TCP_OBJ = tcp/tcp_connect.o tcp/tcp_io.o tcp/tcp_init.o
 
 CTDB_CLIENT_OBJ = client/ctdb_client.o \
        $(CTDB_COMMON_OBJ) $(POPT_OBJ) $(UTIL_OBJ) @TALLOC_OBJ@ @TDB_OBJ@ \
-       @LIBREPLACEOBJ@ $(EXTRA_OBJ) @EVENTS_OBJ@ 
+       @LIBREPLACEOBJ@ $(EXTRA_OBJ) @TEVENT_OBJ@
 
 CTDB_SERVER_OBJ = server/ctdbd.o server/ctdb_daemon.o server/ctdb_lockwait.o \
        server/ctdb_recoverd.o server/ctdb_recover.o server/ctdb_freeze.o \
index e3338987dc924a3af05b088edca4b1393e997a44..12603d29d157d058317e12c6338ff46ec05af16e 100755 (executable)
@@ -7,7 +7,7 @@ IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace"
 IPATHS="$IPATHS -I lib/talloc -I talloc -I ../talloc"
 IPATHS="$IPATHS -I lib/tdb -I tdb -I ../tdb"
 IPATHS="$IPATHS -I lib/popt -I popt -I ../popt"
-IPATHS="$IPATHS -I lib/events"
+IPATHS="$IPATHS -I lib/tevent"
 
 autoheader $IPATHS || exit 1
 autoconf $IPATHS || exit 1
index adba17c2c144aeb8eacbee9dffad91c19d73d319..1d854d15c53b5d3b27ae461374ac151a512cce42 100644 (file)
@@ -22,7 +22,7 @@
 #include "db_wrap.h"
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/network.h"
 #include "system/filesys.h"
 #include "system/locale.h"
index 38af6ebb693c94e9ad2c76ece8d861a0ead4aea7..145a13a81b7be3b2b97dc3b2d2e5fa8e02793650 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "../include/ctdb_client.h"
index 102f0b6ac2289b5d1fb90d7900357f977a988b1b..81f9451396b1e62e888c7903077f8de0fe076155 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "includes.h"
 #include "lib/tdb/include/tdb.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -357,11 +357,12 @@ int ctdb_queue_set_fd(struct ctdb_queue *queue, int fd)
        queue->fde = NULL;
 
        if (fd != -1) {
-               queue->fde = event_add_fd(queue->ctdb->ev, queue, fd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+               queue->fde = event_add_fd(queue->ctdb->ev, queue, fd, EVENT_FD_READ,
                                          queue_io_handler, queue);
                if (queue->fde == NULL) {
                        return -1;
                }
+               tevent_fd_set_auto_close(queue->fde);
 
                if (queue->out_queue) {
                        EVENT_FD_WRITEABLE(queue->fde);         
index 18aafa23322383851cc7372b3555e9d283591668..4691208b9bd34750e6f3e11c545b5e4d32c53bde 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/time.h"
 #include "../include/ctdb_private.h"
index 6ce5c90138b8808abd8bb757923cec30b1d53fb3..7dc28ddf9930ca9b0b9bc022d674e8456b94f34f 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
index 326b5572d4921ff6322345068cf7cbd530dd038b..03a4b55389c01ae6f9068e9673f233c6706593c6 100644 (file)
@@ -21,7 +21,7 @@
   protocol design and packet details
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
index b928c7eda50cc8aceb3d53490cfe1130edd075e7..add2c3a95bd721f708301ae8b6cc16a11dea7972 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
index b8aace422ad429e02355c8f54b5d65efd43801f5..a498ab2d686999f6b596d526e2b3f8736f1ef64f 100644 (file)
@@ -23,7 +23,7 @@
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "../include/ctdb_private.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include <netinet/if_ether.h>
 #include <netinet/ip6.h>
 #include <netinet/icmp6.h>
index f159c293e0d8d058862a2b56e049c31edb0b4a1f..cc3a1143daa743d3d465a2863a8a2b386460245a 100644 (file)
@@ -58,7 +58,7 @@ EXTRA_OBJ=""
 m4_include(libpopt.m4)
 m4_include(libtalloc.m4)
 m4_include(libtdb.m4)
-m4_include(libevents.m4)
+m4_include(libtevent.m4)
 m4_include(ib/config.m4)
 m4_include(lib/util/signal.m4)
 m4_include(lib/util/fault.m4)
index 78d960a458a5cccc5733057a72733b6fd979ff6d..5664c193acb95bbc1c776ef0826f244de2240fe6 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include <system/network.h>
 #include <assert.h>
 #include "ctdb_private.h"
index 170ce302af271f5b6c568504f51e063e9e29d71b..fed1381f6dfb8daca1d3f169aae4d688ac4925f6 100644 (file)
@@ -21,7 +21,7 @@
  */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include <system/network.h>
 #include <assert.h>
 #include "ctdb_private.h"
index b9c80ae2ae2d001170b24b8ce3316ae1d7fcc998..eb0d58858ff745e01159550c79100c1680c98c08 100644 (file)
@@ -37,7 +37,7 @@
 #include <time.h>
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "ib/ibwrapper.h"
 
 struct ibwtest_ctx {
@@ -546,7 +546,7 @@ int main(int argc, char *argv[])
 {
        int     rc, op;
        int     result = 1;
-       struct event_context *ev = NULL;
+       struct tevent_context *ev = NULL;
        struct ibwtest_ctx *tcx = NULL;
        float   usec;
 
index e9aa8d17fb14c5477d00a09b6ff8d0a95fb158f0..3029d0fa36ac08b98cac10efbe7cb580ffaf3281 100644 (file)
@@ -52,12 +52,12 @@ struct ctdb_client_notify_deregister {
        uint64_t srvid;
 };
 
-struct event_context;
+struct tevent_context;
 
 /*
   initialise ctdb subsystem
 */
-struct ctdb_context *ctdb_init(struct event_context *ev);
+struct ctdb_context *ctdb_init(struct tevent_context *ev);
 
 /*
   choose the transport
@@ -193,7 +193,7 @@ int ctdb_register_message_handler(struct ctdb_context *ctdb,
 struct ctdb_db_context *find_ctdb_db(struct ctdb_context *ctdb, uint32_t id);
 
 
-struct ctdb_context *ctdb_cmdline_client(struct event_context *ev);
+struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev);
 
 struct ctdb_statistics;
 int ctdb_ctrl_statistics(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_statistics *status);
index ca3d613f5bc65533d4ee98ea052551c79847febb..af271f4bfb5c839ae64bc539f22a33d115b90fad 100644 (file)
@@ -382,7 +382,7 @@ enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN
 #define NUM_DB_PRIORITIES 3
 /* main state of the ctdb daemon */
 struct ctdb_context {
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct timeval ctdbd_start_time;
        struct timeval last_recovery_started;
        struct timeval last_recovery_finished;
diff --git a/ctdb/lib/events/config.m4 b/ctdb/lib/events/config.m4
deleted file mode 100644 (file)
index 180b58c..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# check for EPOLL and native Linux AIO interface
-SMB_ENABLE(EVENTS_EPOLL, NO)
-SMB_ENABLE(EVENTS_AIO, NO)
-AC_CHECK_HEADERS(sys/epoll.h)
-AC_CHECK_FUNCS(epoll_create)
-if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes";then
-       SMB_ENABLE(EVENTS_EPOLL,YES)
-       AC_DEFINE(HAVE_EVENTS_EPOLL, 1, [Whether epoll is available])
-
-       # check for native Linux AIO interface
-       AC_CHECK_HEADERS(libaio.h)
-       AC_CHECK_LIB_EXT(aio, AIO_LIBS, io_getevents)
-       if test x"$ac_cv_header_libaio_h" = x"yes" -a x"$ac_cv_lib_ext_aio_io_getevents" = x"yes";then
-               SMB_ENABLE(EVENTS_AIO,YES)
-               AC_DEFINE(HAVE_LINUX_AIO, 1, [Whether Linux AIO is available])
-       fi
-fi
-SMB_EXT_LIB(LIBAIO_LINUX, $AIO_LIBS)
diff --git a/ctdb/lib/events/config.mk b/ctdb/lib/events/config.mk
deleted file mode 100644 (file)
index 2e0a8a6..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-##############################
-[MODULE::EVENTS_AIO]
-OBJ_FILES = events_aio.o
-PRIVATE_DEPENDENCIES = LIBAIO_LINUX
-SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = s4_events_aio_init
-##############################
-
-##############################
-[MODULE::EVENTS_EPOLL]
-OBJ_FILES = events_epoll.o
-SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = s4_events_epoll_init
-##############################
-
-##############################
-[MODULE::EVENTS_SELECT]
-OBJ_FILES = events_select.o
-SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = s4_events_select_init
-##############################
-
-##############################
-[MODULE::EVENTS_STANDARD]
-OBJ_FILES = events_standard.o
-SUBSYSTEM = LIBEVENTS
-INIT_FUNCTION = s4_events_standard_init
-##############################
-
-
-##############################
-# Start SUBSYSTEM LIBEVENTS
-[SUBSYSTEM::LIBEVENTS]
-OBJ_FILES = events.o events_timed.o events_signal.o
-PUBLIC_HEADERS = events.h events_internal.h
-PUBLIC_DEPENDENCIES = LIBTALLOC
-# End SUBSYSTEM LIBEVENTS
-##############################
diff --git a/ctdb/lib/events/events.c b/ctdb/lib/events/events.c
deleted file mode 100644 (file)
index 9ba3254..0000000
+++ /dev/null
@@ -1,321 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   main select loop and event handling
-   Copyright (C) Andrew Tridgell 2003
-   
-   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/>.
-*/
-
-/*
-  PLEASE READ THIS BEFORE MODIFYING!
-
-  This module is a general abstraction for the main select loop and
-  event handling. Do not ever put any localised hacks in here, instead
-  register one of the possible event types and implement that event
-  somewhere else.
-
-  There are 2 types of event handling that are handled in this module:
-
-  1) a file descriptor becoming readable or writeable. This is mostly
-     used for network sockets, but can be used for any type of file
-     descriptor. You may only register one handler for each file
-     descriptor/io combination or you will get unpredictable results
-     (this means that you can have a handler for read events, and a
-     separate handler for write events, but not two handlers that are
-     both handling read events)
-
-  2) a timed event. You can register an event that happens at a
-     specific time.  You can register as many of these as you
-     like. They are single shot - add a new timed event in the event
-     handler to get another event.
-
-  To setup a set of events you first need to create a event_context
-  structure using the function event_context_init(); This returns a
-  'struct event_context' that you use in all subsequent calls.
-
-  After that you can add/remove events that you are interested in
-  using event_add_*() and talloc_free()
-
-  Finally, you call event_loop_wait_once() to block waiting for one of the
-  events to occor or event_loop_wait() which will loop
-  forever.
-
-*/
-
-#include "includes.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-#include "lib/util/dlinklist.h"
-#if _SAMBA_BUILD_
-#include "build.h"
-#endif
-
-struct event_ops_list {
-       struct event_ops_list *next, *prev;
-       const char *name;
-       const struct event_ops *ops;
-};
-
-/* list of registered event backends */
-static struct event_ops_list *event_backends;
-
-static char *event_default_backend = NULL;
-
-/*
-  register an events backend
-*/
-bool event_register_backend(const char *name, const struct event_ops *ops)
-{
-       struct event_ops_list *e;
-       e = talloc(talloc_autofree_context(), struct event_ops_list);
-       if (e == NULL) return False;
-       e->name = name;
-       e->ops = ops;
-       DLIST_ADD(event_backends, e);
-       return True;
-}
-
-/*
-  set the default event backend
- */
-void event_set_default_backend(const char *backend)
-{
-       if (event_default_backend) free(event_default_backend);
-       event_default_backend = strdup(backend);
-}
-
-/*
-  initialise backends if not already done
-*/
-static void event_backend_init(void)
-{
-#if _SAMBA_BUILD_
-       init_module_fn static_init[] = STATIC_LIBEVENTS_MODULES;
-       init_module_fn *shared_init;
-       if (event_backends) return;
-       shared_init = load_samba_modules(NULL, "LIBEVENTS");
-       run_init_functions(static_init);
-       run_init_functions(shared_init);
-#else
-       bool events_standard_init(void);
-       bool events_select_init(void);
-       events_select_init();
-       events_standard_init();
-#if HAVE_EVENTS_EPOLL
-       {
-               bool events_epoll_init(void);
-               events_epoll_init();
-       }
-#endif
-#endif
-}
-
-/*
-  list available backends
-*/
-const char **event_backend_list(TALLOC_CTX *mem_ctx)
-{
-       const char **list = NULL;
-       struct event_ops_list *e;
-
-       event_backend_init();
-
-       for (e=event_backends;e;e=e->next) {
-               list = str_list_add(list, e->name);
-       }
-
-       talloc_steal(mem_ctx, list);
-
-       return list;
-}
-
-/*
-  create a event_context structure for a specific implemementation.
-  This must be the first events call, and all subsequent calls pass
-  this event_context as the first element. Event handlers also
-  receive this as their first argument.
-
-  This function is for allowing third-party-applications to hook in gluecode
-  to their own event loop code, so that they can make async usage of our client libs
-
-  NOTE: use event_context_init() inside of samba!
-*/
-static struct event_context *event_context_init_ops(TALLOC_CTX *mem_ctx, 
-                                                   const struct event_ops *ops)
-{
-       struct event_context *ev;
-       int ret;
-
-       ev = talloc_zero(mem_ctx, struct event_context);
-       if (!ev) return NULL;
-
-       ev->ops = ops;
-
-       ret = ev->ops->context_init(ev);
-       if (ret != 0) {
-               talloc_free(ev);
-               return NULL;
-       }
-
-       return ev;
-}
-
-/*
-  create a event_context structure. This must be the first events
-  call, and all subsequent calls pass this event_context as the first
-  element. Event handlers also receive this as their first argument.
-*/
-struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name)
-{
-       struct event_ops_list *e;
-
-       event_backend_init();
-
-#if _SAMBA_BUILD_
-       if (name == NULL) {
-               name = lp_parm_string(-1, "event", "backend");
-       }
-#endif
-       if (name == NULL) {
-               name = event_default_backend;
-       }
-       if (name == NULL) {
-               name = "standard";
-       }
-
-       for (e=event_backends;e;e=e->next) {
-               if (strcmp(name, e->name) == 0) {
-                       return event_context_init_ops(mem_ctx, e->ops);
-               }
-       }
-       return NULL;
-}
-
-
-/*
-  create a event_context structure. This must be the first events
-  call, and all subsequent calls pass this event_context as the first
-  element. Event handlers also receive this as their first argument.
-*/
-struct event_context *event_context_init(TALLOC_CTX *mem_ctx)
-{
-       return event_context_init_byname(mem_ctx, NULL);
-}
-
-/*
-  add a fd based event
-  return NULL on failure (memory allocation error)
-
-  if flags contains EVENT_FD_AUTOCLOSE then the fd will be closed when
-  the returned fd_event context is freed
-*/
-struct fd_event *event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                             int fd, uint16_t flags, event_fd_handler_t handler,
-                             void *private_data)
-{
-       return ev->ops->add_fd(ev, mem_ctx, fd, flags, handler, private_data);
-}
-
-/*
-  add a disk aio event
-*/
-struct aio_event *event_add_aio(struct event_context *ev,
-                               TALLOC_CTX *mem_ctx,
-                               struct iocb *iocb,
-                               event_aio_handler_t handler,
-                               void *private_data)
-{
-       if (ev->ops->add_aio == NULL) return NULL;
-       return ev->ops->add_aio(ev, mem_ctx, iocb, handler, private_data);
-}
-
-/*
-  return the fd event flags
-*/
-uint16_t event_get_fd_flags(struct fd_event *fde)
-{
-       if (!fde) return 0;
-       return fde->event_ctx->ops->get_fd_flags(fde);
-}
-
-/*
-  set the fd event flags
-*/
-void event_set_fd_flags(struct fd_event *fde, uint16_t flags)
-{
-       if (!fde) return;
-       fde->event_ctx->ops->set_fd_flags(fde, flags);
-}
-
-/*
-  add a timed event
-  return NULL on failure
-*/
-struct timed_event *event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                   struct timeval next_event, 
-                                   event_timed_handler_t handler, 
-                                   void *private_data)
-{
-       return ev->ops->add_timed(ev, mem_ctx, next_event, handler, private_data);
-}
-
-/*
-  add a signal event
-
-  sa_flags are flags to sigaction(2)
-
-  return NULL on failure
-*/
-struct signal_event *event_add_signal(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                     int signum,
-                                     int sa_flags,
-                                     event_signal_handler_t handler, 
-                                     void *private_data)
-{
-       return ev->ops->add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data);
-}
-
-/*
-  do a single event loop using the events defined in ev 
-*/
-_PUBLIC_ int event_loop_once(struct event_context *ev)
-{
-       return ev->ops->loop_once(ev);
-}
-
-/*
-  return on failure or (with 0) if all fd events are removed
-*/
-int event_loop_wait(struct event_context *ev)
-{
-       return ev->ops->loop_wait(ev);
-}
-
-/*
-  find an event context that is a parent of the given memory context,
-  or create a new event context as a child of the given context if
-  none is found
-
-  This should be used in preference to event_context_init() in places
-  where you would prefer to use the existing event context if possible
-  (which is most situations)
-*/
-struct event_context *event_context_find(TALLOC_CTX *mem_ctx)
-{
-       struct event_context *ev = talloc_find_parent_bytype(mem_ctx, struct event_context);
-       if (ev == NULL) {               
-               ev = event_context_init(mem_ctx);
-       }
-       return ev;
-}
diff --git a/ctdb/lib/events/events.h b/ctdb/lib/events/events.h
deleted file mode 100644 (file)
index 0c0e8fe..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-
-   generalised event loop handling
-
-   Copyright (C) Andrew Tridgell 2005
-   
-   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/>.
-*/
-
-#ifndef __EVENTS_H__
-#define __EVENTS_H__
-
-#include "talloc/talloc.h"
-#include <stdlib.h>
-
-struct event_context;
-struct event_ops;
-struct fd_event;
-struct timed_event;
-struct aio_event;
-struct signal_event;
-
-/* event handler types */
-typedef void (*event_fd_handler_t)(struct event_context *, struct fd_event *, 
-                                  uint16_t , void *);
-typedef void (*event_timed_handler_t)(struct event_context *, struct timed_event *, 
-                                     struct timeval , void *);
-typedef void (*event_signal_handler_t)(struct event_context *, struct signal_event *, 
-                                      int , int, void *, void *);
-typedef void (*event_aio_handler_t)(struct event_context *, struct aio_event *, 
-                                   int, void *);
-
-struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
-struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
-const char **event_backend_list(TALLOC_CTX *mem_ctx);
-void event_set_default_backend(const char *backend);
-
-struct fd_event *event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                             int fd, uint16_t flags, event_fd_handler_t handler,
-                             void *private);
-
-struct timed_event *event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                   struct timeval next_event, 
-                                   event_timed_handler_t handler, 
-                                   void *private);
-
-struct signal_event *event_add_signal(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                     int signum, int sa_flags,
-                                     event_signal_handler_t handler, 
-                                     void *private);
-
-struct iocb;
-struct aio_event *event_add_aio(struct event_context *ev,
-                               TALLOC_CTX *mem_ctx,
-                               struct iocb *iocb,
-                               event_aio_handler_t handler,
-                               void *private);
-
-int event_loop_once(struct event_context *ev);
-int event_loop_wait(struct event_context *ev);
-
-uint16_t event_get_fd_flags(struct fd_event *fde);
-void event_set_fd_flags(struct fd_event *fde, uint16_t flags);
-
-struct event_context *event_context_find(TALLOC_CTX *mem_ctx);
-
-/* bits for file descriptor event flags */
-#define EVENT_FD_READ 1
-#define EVENT_FD_WRITE 2
-#define EVENT_FD_AUTOCLOSE 4
-
-#define EVENT_FD_WRITEABLE(fde) \
-       event_set_fd_flags(fde, event_get_fd_flags(fde) | EVENT_FD_WRITE)
-#define EVENT_FD_READABLE(fde) \
-       event_set_fd_flags(fde, event_get_fd_flags(fde) | EVENT_FD_READ)
-
-#define EVENT_FD_NOT_WRITEABLE(fde) \
-       event_set_fd_flags(fde, event_get_fd_flags(fde) & ~EVENT_FD_WRITE)
-#define EVENT_FD_NOT_READABLE(fde) \
-       event_set_fd_flags(fde, event_get_fd_flags(fde) & ~EVENT_FD_READ)
-
-#endif /* __EVENTS_H__ */
diff --git a/ctdb/lib/events/events_aio.c b/ctdb/lib/events/events_aio.c
deleted file mode 100644 (file)
index a041738..0000000
+++ /dev/null
@@ -1,577 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-
-   main select loop and event handling - aio/epoll hybrid implementation
-
-   Copyright (C) Andrew Tridgell       2006
-
-   based on events_standard.c
-   
-   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/>.
-*/
-/*
-  this is a very strange beast. The Linux AIO implementation doesn't
-  yet integrate properly with epoll, but there is a kernel patch that
-  allows the aio wait primitives to be used to wait for epoll events,
-  and this can be used to give us a unified event system incorporating
-  both aio events and epoll events
-
-  this is _very_ experimental code
-*/
-
-#include "includes.h"
-#include "system/filesys.h"
-#include "system/network.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-#include <sys/epoll.h>
-#include <libaio.h>
-
-#define MAX_AIO_QUEUE_DEPTH    100
-#ifndef IOCB_CMD_EPOLL_WAIT
-#define IOCB_CMD_EPOLL_WAIT    9
-#endif
-
-struct aio_event_context {
-       /* a pointer back to the generic event_context */
-       struct event_context *ev;
-
-       /* list of filedescriptor events */
-       struct fd_event *fd_events;
-
-       /* number of registered fd event handlers */
-       int num_fd_events;
-
-       uint32_t destruction_count;
-
-       io_context_t ioctx;
-
-       struct epoll_event epevent[MAX_AIO_QUEUE_DEPTH];
-
-       struct iocb *epoll_iocb;
-
-       int epoll_fd;
-       int is_epoll_set;
-       pid_t pid;
-};
-
-struct aio_event {
-       struct event_context *event_ctx;
-       struct iocb iocb;
-       void *private_data;
-       event_aio_handler_t handler;
-};
-
-/*
-  map from EVENT_FD_* to EPOLLIN/EPOLLOUT
-*/
-static uint32_t epoll_map_flags(uint16_t flags)
-{
-       uint32_t ret = 0;
-       if (flags & EVENT_FD_READ) ret |= (EPOLLIN | EPOLLERR | EPOLLHUP);
-       if (flags & EVENT_FD_WRITE) ret |= (EPOLLOUT | EPOLLERR | EPOLLHUP);
-       return ret;
-}
-
-/*
- free the epoll fd
-*/
-static int aio_ctx_destructor(struct aio_event_context *aio_ev)
-{
-       io_queue_release(aio_ev->ioctx);
-       close(aio_ev->epoll_fd);
-       aio_ev->epoll_fd = -1;
-       return 0;
-}
-
-static void epoll_add_event(struct aio_event_context *aio_ev, struct fd_event *fde);
-
-/*
-  reopen the epoll handle when our pid changes
-  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an 
-  demonstration of why this is needed
- */
-static void epoll_check_reopen(struct aio_event_context *aio_ev)
-{
-       struct fd_event *fde;
-
-       if (aio_ev->pid == getpid()) {
-               return;
-       }
-
-       close(aio_ev->epoll_fd);
-       aio_ev->epoll_fd = epoll_create(MAX_AIO_QUEUE_DEPTH);
-       if (aio_ev->epoll_fd == -1) {
-               DEBUG(0,("Failed to recreate epoll handle after fork\n"));
-               return;
-       }
-       aio_ev->pid = getpid();
-       for (fde=aio_ev->fd_events;fde;fde=fde->next) {
-               epoll_add_event(aio_ev, fde);
-       }
-}
-
-#define EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT     (1<<0)
-#define EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR  (1<<1)
-#define EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR     (1<<2)
-
-/*
- add the epoll event to the given fd_event
-*/
-static void epoll_add_event(struct aio_event_context *aio_ev, struct fd_event *fde)
-{
-       struct epoll_event event;
-       if (aio_ev->epoll_fd == -1) return;
-
-       fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
-
-       /* if we don't want events yet, don't add an aio_event */
-       if (fde->flags == 0) return;
-
-       ZERO_STRUCT(event);
-       event.events = epoll_map_flags(fde->flags);
-       event.data.ptr = fde;
-       epoll_ctl(aio_ev->epoll_fd, EPOLL_CTL_ADD, fde->fd, &event);
-       fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT;
-
-       /* only if we want to read we want to tell the event handler about errors */
-       if (fde->flags & EVENT_FD_READ) {
-               fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
-       }
-}
-
-/*
- delete the epoll event for given fd_event
-*/
-static void epoll_del_event(struct aio_event_context *aio_ev, struct fd_event *fde)
-{
-       struct epoll_event event;
-
-       DLIST_REMOVE(aio_ev->fd_events, fde);
-
-       if (aio_ev->epoll_fd == -1) return;
-
-       fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
-
-       /* if there's no aio_event, we don't need to delete it */
-       if (!(fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT)) return;
-
-       ZERO_STRUCT(event);
-       event.events = epoll_map_flags(fde->flags);
-       event.data.ptr = fde;
-       epoll_ctl(aio_ev->epoll_fd, EPOLL_CTL_DEL, fde->fd, &event);
-
-       fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT;
-}
-
-/*
- change the epoll event to the given fd_event
-*/
-static void epoll_mod_event(struct aio_event_context *aio_ev, struct fd_event *fde)
-{
-       struct epoll_event event;
-       if (aio_ev->epoll_fd == -1) return;
-
-       fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
-
-       ZERO_STRUCT(event);
-       event.events = epoll_map_flags(fde->flags);
-       event.data.ptr = fde;
-       epoll_ctl(aio_ev->epoll_fd, EPOLL_CTL_MOD, fde->fd, &event);
-
-       /* only if we want to read we want to tell the event handler about errors */
-       if (fde->flags & EVENT_FD_READ) {
-               fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
-       }
-}
-
-static void epoll_change_event(struct aio_event_context *aio_ev, struct fd_event *fde)
-{
-       bool got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
-       bool want_read = (fde->flags & EVENT_FD_READ);
-       bool want_write= (fde->flags & EVENT_FD_WRITE);
-
-       if (aio_ev->epoll_fd == -1) return;
-
-       fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
-
-       /* there's already an event */
-       if (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT) {
-               if (want_read || (want_write && !got_error)) {
-                       epoll_mod_event(aio_ev, fde);
-                       return;
-               }
-               epoll_del_event(aio_ev, fde);
-               return;
-       }
-
-       /* there's no aio_event attached to the fde */
-       if (want_read || (want_write && !got_error)) {
-               DLIST_ADD(aio_ev->fd_events, fde);
-               epoll_add_event(aio_ev, fde);
-               return;
-       }
-}
-
-static int setup_epoll_wait(struct aio_event_context *aio_ev)
-{
-       if (aio_ev->is_epoll_set) {
-               return 0;
-       }
-       memset(aio_ev->epoll_iocb, 0, sizeof(*aio_ev->epoll_iocb));
-       aio_ev->epoll_iocb->aio_fildes = aio_ev->epoll_fd;
-       aio_ev->epoll_iocb->aio_lio_opcode = IOCB_CMD_EPOLL_WAIT;
-       aio_ev->epoll_iocb->aio_reqprio = 0;
-
-       aio_ev->epoll_iocb->u.c.nbytes = MAX_AIO_QUEUE_DEPTH;
-       aio_ev->epoll_iocb->u.c.offset = -1;
-       aio_ev->epoll_iocb->u.c.buf = aio_ev->epevent;
-
-       if (io_submit(aio_ev->ioctx, 1, &aio_ev->epoll_iocb) != 1) {
-               return -1;
-       }
-       aio_ev->is_epoll_set = 1;
-
-       return 0;
-}
-
-
-/*
-  event loop handling using aio/epoll hybrid
-*/
-static int aio_event_loop(struct aio_event_context *aio_ev, struct timeval *tvalp)
-{
-       int ret, i;
-       uint32_t destruction_count = ++aio_ev->destruction_count;
-       struct timespec timeout;
-       struct io_event events[8];
-
-       if (aio_ev->epoll_fd == -1) return -1;
-
-       if (aio_ev->ev->num_signal_handlers && 
-           common_event_check_signal(aio_ev->ev)) {
-               return 0;
-       }
-
-       if (tvalp) {
-               timeout.tv_sec = tvalp->tv_sec;
-               timeout.tv_nsec = tvalp->tv_usec;
-               timeout.tv_nsec *= 1000;
-       }
-
-       if (setup_epoll_wait(aio_ev) < 0) 
-               return -1;
-
-       ret = io_getevents(aio_ev->ioctx, 1, 8,
-                          events, tvalp?&timeout:NULL);
-
-       if (ret == -EINTR) {
-               if (aio_ev->ev->num_signal_handlers) {
-                       common_event_check_signal(aio_ev->ev);
-               }
-               return 0;
-       }
-
-       if (ret == 0 && tvalp) {
-               /* we don't care about a possible delay here */
-               common_event_loop_timer_delay(aio_ev->ev);
-               return 0;
-       }
-
-       for (i=0;i<ret;i++) {
-               struct io_event *event = &events[i];
-               struct iocb *finished = event->obj;
-
-               switch (finished->aio_lio_opcode) {
-               case IO_CMD_PWRITE:
-               case IO_CMD_PREAD: {
-                       struct aio_event *ae = talloc_get_type(finished->data, 
-                                                              struct aio_event);
-                       if (ae) {
-                               talloc_set_destructor(ae, NULL);
-                               ae->handler(ae->event_ctx, ae, 
-                                           event->res, ae->private_data);
-                               talloc_free(ae);
-                       }
-                       break;
-               }
-               case IOCB_CMD_EPOLL_WAIT: {
-                       struct epoll_event *ep = (struct epoll_event *)finished->u.c.buf;
-                       struct fd_event *fde;
-                       uint16_t flags = 0;
-                       int j;
-
-                       aio_ev->is_epoll_set = 0;
-
-                       for (j=0; j<event->res; j++, ep++) {
-                               fde = talloc_get_type(ep->data.ptr, 
-                                                     struct fd_event);
-                               if (fde == NULL) {
-                                       return -1;
-                               }
-                               if (ep->events & (EPOLLHUP|EPOLLERR)) {
-                                       fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR;
-                                       if (!(fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR)) {
-                                               epoll_del_event(aio_ev, fde);
-                                               continue;
-                                       }
-                                       flags |= EVENT_FD_READ;
-                               }
-                               if (ep->events & EPOLLIN) flags |= EVENT_FD_READ;
-                               if (ep->events & EPOLLOUT) flags |= EVENT_FD_WRITE;
-                               if (flags) {
-                                       fde->handler(aio_ev->ev, fde, flags, fde->private_data);
-                               }
-                       }
-                       break;
-               }
-               }
-               if (destruction_count != aio_ev->destruction_count) {
-                       return 0;
-               }
-       }
-
-       return 0;
-}
-
-/*
-  create a aio_event_context structure.
-*/
-static int aio_event_context_init(struct event_context *ev)
-{
-       struct aio_event_context *aio_ev;
-       
-       aio_ev = talloc_zero(ev, struct aio_event_context);
-       if (!aio_ev) return -1;
-
-       aio_ev->ev = ev;
-       aio_ev->epoll_iocb = talloc(aio_ev, struct iocb);
-
-       if (io_queue_init(MAX_AIO_QUEUE_DEPTH, &aio_ev->ioctx) != 0) {
-               talloc_free(aio_ev);
-               return -1;
-       }
-
-       aio_ev->epoll_fd = epoll_create(MAX_AIO_QUEUE_DEPTH);
-       if (aio_ev->epoll_fd == -1) {
-               talloc_free(aio_ev);
-               return -1;
-       }
-       aio_ev->pid = getpid();
-
-       talloc_set_destructor(aio_ev, aio_ctx_destructor);
-
-       ev->additional_data = aio_ev;
-
-       if (setup_epoll_wait(aio_ev) < 0) {
-               talloc_free(aio_ev);
-               return -1;
-       }
-
-       return 0;
-}
-
-/*
-  destroy an fd_event
-*/
-static int aio_event_fd_destructor(struct fd_event *fde)
-{
-       struct event_context *ev = fde->event_ctx;
-       struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
-                                                          struct aio_event_context);
-
-       epoll_check_reopen(aio_ev);
-
-       aio_ev->num_fd_events--;
-       aio_ev->destruction_count++;
-
-       epoll_del_event(aio_ev, fde);
-
-       if (fde->flags & EVENT_FD_AUTOCLOSE) {
-               close(fde->fd);
-               fde->fd = -1;
-       }
-
-       return 0;
-}
-
-/*
-  add a fd based event
-  return NULL on failure (memory allocation error)
-*/
-static struct fd_event *aio_event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                        int fd, uint16_t flags,
-                                        event_fd_handler_t handler,
-                                        void *private_data)
-{
-       struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
-                                                          struct aio_event_context);
-       struct fd_event *fde;
-
-       epoll_check_reopen(aio_ev);
-
-       fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event);
-       if (!fde) return NULL;
-
-       fde->event_ctx          = ev;
-       fde->fd                 = fd;
-       fde->flags              = flags;
-       fde->handler            = handler;
-       fde->private_data       = private_data;
-       fde->additional_flags   = 0;
-       fde->additional_data    = NULL;
-
-       aio_ev->num_fd_events++;
-       talloc_set_destructor(fde, aio_event_fd_destructor);
-
-       DLIST_ADD(aio_ev->fd_events, fde);
-       epoll_add_event(aio_ev, fde);
-
-       return fde;
-}
-
-
-/*
-  return the fd event flags
-*/
-static uint16_t aio_event_get_fd_flags(struct fd_event *fde)
-{
-       return fde->flags;
-}
-
-/*
-  set the fd event flags
-*/
-static void aio_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
-{
-       struct event_context *ev;
-       struct aio_event_context *aio_ev;
-
-       if (fde->flags == flags) return;
-
-       ev = fde->event_ctx;
-       aio_ev = talloc_get_type(ev->additional_data, struct aio_event_context);
-
-       fde->flags = flags;
-
-       epoll_check_reopen(aio_ev);
-
-       epoll_change_event(aio_ev, fde);
-}
-
-/*
-  do a single event loop using the events defined in ev 
-*/
-static int aio_event_loop_once(struct event_context *ev)
-{
-       struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
-                                                          struct aio_event_context);
-       struct timeval tval;
-
-       tval = common_event_loop_timer_delay(ev);
-       if (timeval_is_zero(&tval)) {
-               return 0;
-       }
-
-       epoll_check_reopen(aio_ev);
-
-       return aio_event_loop(aio_ev, &tval);
-}
-
-/*
-  return on failure or (with 0) if all fd events are removed
-*/
-static int aio_event_loop_wait(struct event_context *ev)
-{
-       struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
-                                                          struct aio_event_context);
-       while (aio_ev->num_fd_events) {
-               if (aio_event_loop_once(ev) != 0) {
-                       break;
-               }
-       }
-
-       return 0;
-}
-
-/*
-  called when a disk IO event needs to be cancelled
-*/
-static int aio_destructor(struct aio_event *ae)
-{
-       struct event_context *ev = ae->event_ctx;
-       struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
-                                                          struct aio_event_context);
-       struct io_event result;
-       io_cancel(aio_ev->ioctx, &ae->iocb, &result);
-       /* TODO: handle errors from io_cancel()! */
-       return 0;
-}
-
-/* submit an aio disk IO event */
-static struct aio_event *aio_event_add_aio(struct event_context *ev, 
-                                          TALLOC_CTX *mem_ctx,
-                                          struct iocb *iocb,
-                                          event_aio_handler_t handler,
-                                          void *private_data)
-{
-       struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
-                                                          struct aio_event_context);
-       struct iocb *iocbp;
-       struct aio_event *ae = talloc(mem_ctx?mem_ctx:ev, struct aio_event);
-       if (ae == NULL) return NULL;
-
-       ae->event_ctx    = ev;
-       ae->iocb         = *iocb;
-       ae->handler      = handler;
-       ae->private_data = private_data;
-       iocbp = &ae->iocb;
-
-       if (io_submit(aio_ev->ioctx, 1, &iocbp) != 1) {
-               talloc_free(ae);
-               return NULL;
-       }
-       ae->iocb.data = ae;
-       talloc_set_destructor(ae, aio_destructor);
-
-       return ae;
-}
-
-static const struct event_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_flags   = aio_event_set_fd_flags,
-       .add_timed      = common_event_add_timed,
-       .add_signal     = common_event_add_signal,
-       .loop_once      = aio_event_loop_once,
-       .loop_wait      = aio_event_loop_wait,
-};
-
-bool events_aio_init(void)
-{
-       return event_register_backend("aio", &aio_event_ops);
-}
-
-#if _SAMBA_BUILD_
-NTSTATUS s4_events_aio_init(void)
-{
-       if (!events_aio_init()) {
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-       return NT_STATUS_OK;
-}
-#endif
diff --git a/ctdb/lib/events/events_internal.h b/ctdb/lib/events/events_internal.h
deleted file mode 100644 (file)
index 98d94fe..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-
-   generalised event loop handling
-
-   Internal structs
-
-   Copyright (C) Stefan Metzmacher 2005
-   
-   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/>.
-*/
-
-struct event_ops {
-       /* conntext init */
-       int (*context_init)(struct event_context *ev);
-
-       /* fd_event functions */
-       struct fd_event *(*add_fd)(struct event_context *ev,
-                                  TALLOC_CTX *mem_ctx,
-                                  int fd, uint16_t flags,
-                                  event_fd_handler_t handler,
-                                  void *private_data);
-       uint16_t (*get_fd_flags)(struct fd_event *fde);
-       void (*set_fd_flags)(struct fd_event *fde, uint16_t flags);
-
-       /* timed_event functions */
-       struct timed_event *(*add_timed)(struct event_context *ev,
-                                        TALLOC_CTX *mem_ctx,
-                                        struct timeval next_event,
-                                        event_timed_handler_t handler,
-                                        void *private_data);
-       /* disk aio event functions */
-       struct aio_event *(*add_aio)(struct event_context *ev,
-                                    TALLOC_CTX *mem_ctx,
-                                    struct iocb *iocb, 
-                                    event_aio_handler_t handler, 
-                                    void *private_data);
-       /* signal functions */
-       struct signal_event *(*add_signal)(struct event_context *ev, 
-                                          TALLOC_CTX *mem_ctx,
-                                          int signum, int sa_flags,
-                                          event_signal_handler_t handler, 
-                                          void *private_data);
-
-       /* loop functions */
-       int (*loop_once)(struct event_context *ev);
-       int (*loop_wait)(struct event_context *ev);
-};
-
-struct fd_event {
-       struct fd_event *prev, *next;
-       struct event_context *event_ctx;
-       int fd;
-       uint16_t flags; /* see EVENT_FD_* flags */
-       event_fd_handler_t handler;
-       /* this is private for the specific handler */
-       void *private_data;
-       /* this is private for the events_ops implementation */
-       uint16_t additional_flags;
-       void *additional_data;
-};
-
-struct signal_event {
-       struct signal_event *prev, *next;
-       struct event_context *event_ctx;
-       event_signal_handler_t handler;
-       void *private_data;
-       int signum;
-       int sa_flags;
-};
-
-/* aio event is private to the aio backend */
-struct aio_event;
-
-struct event_context { 
-       /* the specific events implementation */
-       const struct event_ops *ops;
-
-       /* list of timed events - used by common code */
-       struct timed_event *timed_events;
-
-       /* this is private for the events_ops implementation */
-       void *additional_data;
-
-       /* number of signal event handlers */
-       int num_signal_handlers;
-
-       /* pipe hack used with signal handlers */
-       struct fd_event *pipe_fde;
-};
-
-
-bool event_register_backend(const char *name, const struct event_ops *ops);
-
-struct timed_event *common_event_add_timed(struct event_context *, TALLOC_CTX *,
-                                          struct timeval, event_timed_handler_t, void *);
-struct timeval common_event_loop_timer_delay(struct event_context *);
-
-struct signal_event *common_event_add_signal(struct event_context *ev, 
-                                            TALLOC_CTX *mem_ctx,
-                                            int signum,
-                                            int sa_flags,
-                                            event_signal_handler_t handler, 
-                                            void *private_data);
-int common_event_check_signal(struct event_context *ev);
-
diff --git a/ctdb/lib/events/events_select.c b/ctdb/lib/events/events_select.c
deleted file mode 100644 (file)
index 4b60f4e..0000000
+++ /dev/null
@@ -1,320 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-   main select loop and event handling
-   Copyright (C) Andrew Tridgell       2003-2005
-   Copyright (C) Stefan Metzmacher     2005
-   
-   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/>.
-*/
-
-/*
-  This is SAMBA's default event loop code
-
-*/
-
-#include "includes.h"
-#include "system/time.h"
-#include "system/filesys.h"
-#include "system/select.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-
-extern pid_t ctdbd_pid;
-
-struct select_event_context {
-       /* a pointer back to the generic event_context */
-       struct event_context *ev;
-
-       /* list of filedescriptor events */
-       struct fd_event *fd_events;
-
-       /* list of timed events */
-       struct timed_event *timed_events;
-
-       /* the maximum file descriptor number in fd_events */
-       int maxfd;
-
-       /* information for exiting from the event loop */
-       int exit_code;
-};
-
-/*
-  create a select_event_context structure.
-*/
-static int select_event_context_init(struct event_context *ev)
-{
-       struct select_event_context *select_ev;
-
-       select_ev = talloc_zero(ev, struct select_event_context);
-       if (!select_ev) return -1;
-       select_ev->ev = ev;
-
-       ev->additional_data = select_ev;
-       return 0;
-}
-
-/*
-  recalculate the maxfd
-*/
-static void calc_maxfd(struct select_event_context *select_ev)
-{
-       struct fd_event *fde;
-
-       select_ev->maxfd = 0;
-       for (fde = select_ev->fd_events; fde; fde = fde->next) {
-               if (fde->fd > select_ev->maxfd) {
-                       select_ev->maxfd = fde->fd;
-               }
-       }
-}
-
-
-/* to mark the ev->maxfd invalid
- * this means we need to recalculate it
- */
-#define EVENT_INVALID_MAXFD (-1)
-
-/*
-  destroy an fd_event
-*/
-static int select_event_fd_destructor(struct fd_event *fde)
-{
-       struct event_context *ev = fde->event_ctx;
-       struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
-                                                          struct select_event_context);
-
-       if (select_ev->maxfd == fde->fd) {
-               select_ev->maxfd = EVENT_INVALID_MAXFD;
-       }
-
-       DLIST_REMOVE(select_ev->fd_events, fde);
-
-       if (fde->flags & EVENT_FD_AUTOCLOSE) {
-               close(fde->fd);
-               fde->fd = -1;
-       }
-
-       return 0;
-}
-
-/*
-  add a fd based event
-  return NULL on failure (memory allocation error)
-*/
-static struct fd_event *select_event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                        int fd, uint16_t flags,
-                                        event_fd_handler_t handler,
-                                        void *private_data)
-{
-       struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
-                                                          struct select_event_context);
-       struct fd_event *fde;
-
-       fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event);
-       if (!fde) return NULL;
-
-       fde->event_ctx          = ev;
-       fde->fd                 = fd;
-       fde->flags              = flags;
-       fde->handler            = handler;
-       fde->private_data       = private_data;
-       fde->additional_flags   = 0;
-       fde->additional_data    = NULL;
-
-       DLIST_ADD(select_ev->fd_events, fde);
-       if (fde->fd > select_ev->maxfd) {
-               select_ev->maxfd = fde->fd;
-       }
-       talloc_set_destructor(fde, select_event_fd_destructor);
-
-       return fde;
-}
-
-
-/*
-  return the fd event flags
-*/
-static uint16_t select_event_get_fd_flags(struct fd_event *fde)
-{
-       return fde->flags;
-}
-
-/*
-  set the fd event flags
-*/
-static void select_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
-{
-       struct event_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()
-*/
-static int select_event_loop_select(struct select_event_context *select_ev, struct timeval *tvalp)
-{
-       fd_set r_fds, w_fds;
-       struct fd_event *fde;
-       int selrtn;
-
-       /* we maybe need to recalculate the maxfd */
-       if (select_ev->maxfd == EVENT_INVALID_MAXFD) {
-               calc_maxfd(select_ev);
-       }
-
-       FD_ZERO(&r_fds);
-       FD_ZERO(&w_fds);
-
-       /* setup any fd events */
-       for (fde = select_ev->fd_events; fde; fde = fde->next) {
-               if (fde->flags & EVENT_FD_READ) {
-                       FD_SET(fde->fd, &r_fds);
-               }
-               if (fde->flags & EVENT_FD_WRITE) {
-                       FD_SET(fde->fd, &w_fds);
-               }
-       }
-
-       if (select_ev->ev->num_signal_handlers && 
-           common_event_check_signal(select_ev->ev)) {
-               return 0;
-       }
-
-       selrtn = select(select_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp);
-
-       if (selrtn == -1 && errno == EINTR && 
-           select_ev->ev->num_signal_handlers) {
-               common_event_check_signal(select_ev->ev);
-               return 0;
-       }
-
-       if (selrtn == -1 && errno == EBADF) {
-               /* the socket is dead! this should never
-                  happen as the socket should have first been
-                  made readable and that should have removed
-                  the event, so this must be a bug. This is a
-                  fatal error. */
-               DEBUG(0,("ERROR: EBADF on select_event_loop_once\n"));
-               select_ev->exit_code = EBADF;
-               return -1;
-       }
-
-       if (selrtn == 0 && tvalp) {
-               /* we don't care about a possible delay here */
-               common_event_loop_timer_delay(select_ev->ev);
-               return 0;
-       }
-
-       if (selrtn > 0) {
-               /* at least one file descriptor is ready - check
-                  which ones and call the handler, being careful to allow
-                  the handler to remove itself when called */
-               for (fde = select_ev->fd_events; fde; fde = fde->next) {
-                       uint16_t flags = 0;
-
-                       if (FD_ISSET(fde->fd, &r_fds)) flags |= EVENT_FD_READ;
-                       if (FD_ISSET(fde->fd, &w_fds)) flags |= EVENT_FD_WRITE;
-                       if (flags) {
-                               fde->handler(select_ev->ev, fde, flags, fde->private_data);
-                               break;
-                       }
-               }
-       }
-
-       return 0;
-}              
-
-/*
-  do a single event loop using the events defined in ev 
-*/
-static int select_event_loop_once(struct event_context *ev)
-{
-       struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
-                                                          struct select_event_context);
-       struct timeval tval;
-
-       tval = common_event_loop_timer_delay(ev);
-       if (timeval_is_zero(&tval)) {
-               return 0;
-       }
-
-       return select_event_loop_select(select_ev, &tval);
-}
-
-/*
-  return on failure or (with 0) if all fd events are removed
-*/
-static int select_event_loop_wait(struct event_context *ev)
-{
-       static time_t t=0;
-       time_t new_t;
-       struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
-                                                          struct select_event_context);
-       select_ev->exit_code = 0;
-
-       while (select_ev->fd_events && select_ev->exit_code == 0) {
-               if (select_event_loop_once(ev) != 0) {
-                       break;
-               }
-               if (getpid() == ctdbd_pid) {
-                       new_t=time(NULL);
-                       if (t != 0) {
-                               if (t > new_t) {
-                                       DEBUG(0,(__location__ " ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
-                               }
-                               /* We assume here that we get at least one event every 5 seconds */
-                               if (new_t > (t+5)) {
-                                       DEBUG(0,(__location__ " ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
-                               }
-                       }
-                       t=new_t;
-               }
-       }
-
-       return select_ev->exit_code;
-}
-
-static const struct event_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,
-       .add_timed      = common_event_add_timed,
-       .add_signal     = common_event_add_signal,
-       .loop_once      = select_event_loop_once,
-       .loop_wait      = select_event_loop_wait,
-};
-
-bool events_select_init(void)
-{
-       return event_register_backend("select", &select_event_ops);
-}
-
-#if _SAMBA_BUILD_
-NTSTATUS s4_events_select_init(void)
-{
-       if (!events_select_init()) {
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-       return NT_STATUS_OK;
-}
-#endif
diff --git a/ctdb/lib/events/events_signal.c b/ctdb/lib/events/events_signal.c
deleted file mode 100644 (file)
index 128a9bc..0000000
+++ /dev/null
@@ -1,291 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-
-   common events code for signal events
-
-   Copyright (C) Andrew Tridgell       2007
-   
-   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 "system/filesys.h"
-#include "system/select.h"
-#include "system/wait.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-
-#define NUM_SIGNALS 64
-
-/* maximum number of SA_SIGINFO signals to hold in the queue */
-#define SA_INFO_QUEUE_COUNT 10
-
-struct sigcounter {
-       uint32_t count;
-       uint32_t seen;
-};
-
-#define SIG_INCREMENT(s) (s).count++
-#define SIG_SEEN(s, n) (s).seen += (n)
-#define SIG_PENDING(s) ((s).seen != (s).count)
-
-
-/*
-  the poor design of signals means that this table must be static global
-*/
-static struct sig_state {
-       struct signal_event *sig_handlers[NUM_SIGNALS+1];
-       struct sigaction *oldact[NUM_SIGNALS+1];
-       struct sigcounter signal_count[NUM_SIGNALS+1];
-       struct sigcounter got_signal;
-       int pipe_hack[2];
-#ifdef SA_SIGINFO
-       /* with SA_SIGINFO we get quite a lot of info per signal */
-       siginfo_t *sig_info[NUM_SIGNALS+1];
-       struct sigcounter sig_blocked[NUM_SIGNALS+1];
-#endif
-} *sig_state;
-
-/*
-  return number of sigcounter events not processed yet
-*/
-static uint32_t sig_count(struct sigcounter s)
-{
-       if (s.count >= s.seen) {
-               return s.count - s.seen;
-       }
-       return 1 + (0xFFFFFFFF & ~(s.seen - s.count));
-}
-
-/*
-  signal handler - redirects to registered signals
-*/
-static void signal_handler(int signum)
-{
-       char c = 0;
-       SIG_INCREMENT(sig_state->signal_count[signum]);
-       SIG_INCREMENT(sig_state->got_signal);
-       /* doesn't matter if this pipe overflows */
-       write(sig_state->pipe_hack[1], &c, 1);
-}
-
-#ifdef SA_SIGINFO
-/*
-  signal handler with SA_SIGINFO - redirects to registered signals
-*/
-static void signal_handler_info(int signum, siginfo_t *info, void *uctx)
-{
-       uint32_t count = sig_count(sig_state->signal_count[signum]);
-       sig_state->sig_info[signum][count] = *info;
-
-       signal_handler(signum);
-
-       /* handle SA_SIGINFO */
-       if (count+1 == SA_INFO_QUEUE_COUNT) {
-               /* we've filled the info array - block this signal until
-                  these ones are delivered */
-               sigset_t set;
-               sigemptyset(&set);
-               sigaddset(&set, signum);
-               sigprocmask(SIG_BLOCK, &set, NULL);
-               SIG_INCREMENT(sig_state->sig_blocked[signum]);
-       }
-}
-#endif
-
-/*
-  destroy a signal event
-*/
-static int signal_event_destructor(struct signal_event *se)
-{
-       se->event_ctx->num_signal_handlers--;
-       DLIST_REMOVE(sig_state->sig_handlers[se->signum], se);
-       if (sig_state->sig_handlers[se->signum] == NULL) {
-               /* restore old handler, if any */
-               sigaction(se->signum, sig_state->oldact[se->signum], NULL);
-               sig_state->oldact[se->signum] = NULL;
-#ifdef SA_SIGINFO
-               if (se->sa_flags & SA_SIGINFO) {
-                       talloc_free(sig_state->sig_info[se->signum]);
-                       sig_state->sig_info[se->signum] = NULL;
-               }
-#endif
-       }
-       return 0;
-}
-
-/*
-  this is part of the pipe hack needed to avoid the signal race condition
-*/
-static void signal_pipe_handler(struct event_context *ev, struct fd_event *fde, 
-                               uint16_t flags, void *private)
-{
-       char c[16];
-       /* its non-blocking, doesn't matter if we read too much */
-       read(sig_state->pipe_hack[0], c, sizeof(c));
-}
-
-/*
-  add a signal event
-  return NULL on failure (memory allocation error)
-*/
-struct signal_event *common_event_add_signal(struct event_context *ev, 
-                                            TALLOC_CTX *mem_ctx,
-                                            int signum,
-                                            int sa_flags,
-                                            event_signal_handler_t handler, 
-                                            void *private_data) 
-{
-       struct signal_event *se;
-
-       if (signum >= NUM_SIGNALS) {
-               return NULL;
-       }
-
-       /* the sig_state needs to be on a global context as it can last across
-          multiple event contexts */
-       if (sig_state == NULL) {
-               sig_state = talloc_zero(talloc_autofree_context(), struct sig_state);
-               if (sig_state == NULL) {
-                       return NULL;
-               }
-       }
-
-       se = talloc(mem_ctx?mem_ctx:ev, struct signal_event);
-       if (se == NULL) return NULL;
-
-       se->event_ctx           = ev;
-       se->handler             = handler;
-       se->private_data        = private_data;
-       se->signum              = signum;
-       se->sa_flags            = sa_flags;
-       
-       /* Ensure, no matter the destruction order, that we always have a handle on the global sig_state */
-       if (!talloc_reference(se, sig_state)) {
-               return NULL;
-       }
-
-       /* only install a signal handler if not already installed */
-       if (sig_state->sig_handlers[signum] == NULL) {
-               struct sigaction act;
-               ZERO_STRUCT(act);
-               act.sa_handler   = signal_handler;
-               act.sa_flags = sa_flags;
-#ifdef SA_SIGINFO
-               if (sa_flags & SA_SIGINFO) {
-                       act.sa_handler   = NULL;
-                       act.sa_sigaction = signal_handler_info;
-                       if (sig_state->sig_info[signum] == NULL) {
-                               sig_state->sig_info[signum] = talloc_array(sig_state, siginfo_t, SA_INFO_QUEUE_COUNT);
-                               if (sig_state->sig_info[signum] == NULL) {
-                                       talloc_free(se);
-                                       return NULL;
-                               }
-                       }
-               }
-#endif
-               sig_state->oldact[signum] = talloc(sig_state, struct sigaction);
-               if (sig_state->oldact[signum] == NULL) {
-                       talloc_free(se);
-                       return NULL;                    
-               }
-               if (sigaction(signum, &act, sig_state->oldact[signum]) == -1) {
-                       talloc_free(se);
-                       return NULL;
-               }
-       }
-
-       DLIST_ADD(sig_state->sig_handlers[signum], se);
-
-       talloc_set_destructor(se, signal_event_destructor);
-
-       /* we need to setup the pipe hack handler if not already
-          setup */
-       if (ev->pipe_fde == NULL) {
-               if (sig_state->pipe_hack[0] == 0 && 
-                   sig_state->pipe_hack[1] == 0) {
-                       pipe(sig_state->pipe_hack);
-                       set_blocking(sig_state->pipe_hack[0], False);
-                       set_blocking(sig_state->pipe_hack[1], False);
-               }
-               ev->pipe_fde = event_add_fd(ev, ev, sig_state->pipe_hack[0],
-                                           EVENT_FD_READ, signal_pipe_handler, NULL);
-       }
-       ev->num_signal_handlers++;
-
-       return se;
-}
-
-
-/*
-  check if a signal is pending
-  return != 0 if a signal was pending
-*/
-int common_event_check_signal(struct event_context *ev)
-{
-       int i;
-
-       if (!sig_state || !SIG_PENDING(sig_state->got_signal)) {
-               return 0;
-       }
-       
-       for (i=0;i<NUM_SIGNALS+1;i++) {
-               struct signal_event *se, *next;
-               struct sigcounter counter = sig_state->signal_count[i];
-               uint32_t count = sig_count(counter);
-
-               if (count == 0) {
-                       continue;
-               }
-               for (se=sig_state->sig_handlers[i];se;se=next) {
-                       next = se->next;
-#ifdef SA_SIGINFO
-                       if (se->sa_flags & SA_SIGINFO) {
-                               int j;
-                               for (j=0;j<count;j++) {
-                                       /* note the use of the sig_info array as a
-                                          ring buffer */
-                                       int ofs = (counter.count + j) % SA_INFO_QUEUE_COUNT;
-                                       se->handler(ev, se, i, 1, 
-                                                   (void*)&sig_state->sig_info[i][ofs], 
-                                                   se->private_data);
-                               }
-                               if (SIG_PENDING(sig_state->sig_blocked[i])) {
-                                       /* we'd filled the queue, unblock the
-                                          signal now */
-                                       sigset_t set;
-                                       sigemptyset(&set);
-                                       sigaddset(&set, i);
-                                       SIG_SEEN(sig_state->sig_blocked[i], 
-                                                sig_count(sig_state->sig_blocked[i]));
-                                       sigprocmask(SIG_UNBLOCK, &set, NULL);
-                               }
-                               if (se->sa_flags & SA_RESETHAND) {
-                                       talloc_free(se);
-                               }
-                               continue;
-                       }
-#endif
-                       se->handler(ev, se, i, count, NULL, se->private_data);
-                       if (se->sa_flags & SA_RESETHAND) {
-                               talloc_free(se);
-                       }
-               }
-               SIG_SEEN(sig_state->signal_count[i], count);
-               SIG_SEEN(sig_state->got_signal, count);
-       }
-
-       return 1;
-}
diff --git a/ctdb/lib/events/events_timed.c b/ctdb/lib/events/events_timed.c
deleted file mode 100644 (file)
index 344a1a4..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* 
-   Unix SMB/CIFS implementation.
-
-   common events code for timed events
-
-   Copyright (C) Andrew Tridgell       2003-2006
-   Copyright (C) Stefan Metzmacher     2005
-   
-   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 "system/filesys.h"
-#include "system/select.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-
-struct timed_event {
-       struct timed_event *prev, *next;
-       struct event_context *event_ctx;
-       struct timeval next_event;
-       event_timed_handler_t handler;
-       /* this is private for the specific handler */
-       void *private_data;
-       /* this is private for the events_ops implementation */
-       void *additional_data;
-};
-
-/*
-  destroy a timed event
-*/
-static int common_event_timed_destructor(struct timed_event *te)
-{
-       struct event_context *ev = talloc_get_type(te->event_ctx,
-                                                  struct event_context);
-       DLIST_REMOVE(ev->timed_events, te);
-       return 0;
-}
-
-static int common_event_timed_deny_destructor(struct timed_event *te)
-{
-       return -1;
-}
-
-/*
-  add a timed event
-  return NULL on failure (memory allocation error)
-*/
-struct timed_event *common_event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                          struct timeval next_event, 
-                                          event_timed_handler_t handler, 
-                                          void *private_data) 
-{
-       struct timed_event *te, *last_te, *cur_te;
-
-       te = talloc(mem_ctx?mem_ctx:ev, struct timed_event);
-       if (te == NULL) return NULL;
-
-       te->event_ctx           = ev;
-       te->next_event          = next_event;
-       te->handler             = handler;
-       te->private_data        = private_data;
-       te->additional_data     = NULL;
-
-       /* keep the list ordered */
-       last_te = NULL;
-       for (cur_te = ev->timed_events; cur_te; cur_te = cur_te->next) {
-               /* if the new event comes before the current one break */
-               if (timeval_compare(&te->next_event, &cur_te->next_event) < 0) {
-                       break;
-               }
-
-               last_te = cur_te;
-       }
-
-       DLIST_ADD_AFTER(ev->timed_events, te, last_te);
-
-       talloc_set_destructor(te, common_event_timed_destructor);
-
-       return te;
-}
-
-/*
-  do a single event loop using the events defined in ev
-
-  return the delay untill the next timed event,
-  or zero if a timed event was triggered
-*/
-struct timeval common_event_loop_timer_delay(struct event_context *ev)
-{
-       struct timeval current_time = timeval_zero();
-       struct timed_event *te = ev->timed_events;
-
-       if (!te) {
-               /* have a default tick time of 30 seconds. This guarantees
-                  that code that uses its own timeout checking will be
-                  able to proceeed eventually */
-               return timeval_set(30, 0);
-       }
-
-       /*
-        * work out the right timeout for the next timed event
-        *
-        * avoid the syscall to gettimeofday() if the timed event should
-        * be triggered directly
-        *
-        * if there's a delay till the next timed event, we're done
-        * with just returning the delay
-        */
-       if (!timeval_is_zero(&te->next_event)) {
-               struct timeval delay;
-
-               current_time = timeval_current();
-
-               delay = timeval_until(&current_time, &te->next_event);
-               if (!timeval_is_zero(&delay)) {
-                       return delay;
-               }
-       }
-
-       /*
-        * ok, we have a timed event that we'll process ...
-        */
-
-       /* deny the handler to free the event */
-       talloc_set_destructor(te, common_event_timed_deny_destructor);
-
-       /* We need to remove the timer from the list before calling the
-        * handler because in a semi-async inner event loop called from the
-        * handler we don't want to come across this event again -- vl */
-       DLIST_REMOVE(ev->timed_events, te);
-
-       /*
-        * If the timed event was registered for a zero current_time,
-        * then we pass a zero timeval here too! To avoid the
-        * overhead of gettimeofday() calls.
-        *
-        * otherwise we pass the current time
-        */
-       te->handler(ev, te, current_time, te->private_data);
-
-       /* The destructor isn't necessary anymore, we've already removed the
-        * event from the list. */
-       talloc_set_destructor(te, NULL);
-
-       talloc_free(te);
-
-       return timeval_zero();
-}
-
diff --git a/ctdb/lib/events/libevents.m4 b/ctdb/lib/events/libevents.m4
deleted file mode 100644 (file)
index 99a47dc..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-EVENTS_OBJ="lib/events/events.o lib/events/events_select.o lib/events/events_signal.o lib/events/events_timed.o lib/events/events_standard.o"
-
-AC_CHECK_HEADERS(sys/epoll.h)
-AC_CHECK_FUNCS(epoll_create)
-
-if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes"; then
-   EVENTS_OBJ="$EVENTS_OBJ lib/events/events_epoll.o"
-   AC_DEFINE(HAVE_EVENTS_EPOLL, 1, [Whether epoll available])
-fi
-
-AC_SUBST(EVENTS_OBJ)
index f8a89a7213b7dfd6a14d134a3a0df15a1d1937d3..c212f433a441cf8e699fabc4af39d20ff3e346ab 100644 (file)
@@ -546,4 +546,7 @@ typedef int bool;
 #define QSORT_CAST (int (*)(const void *, const void *))
 #endif
 
+/* These should be properly defined for libraries to control visibility. */
+#define _PRIVATE_
+#define _PUBLIC_
 #endif /* _LIBREPLACE_REPLACE_H */
diff --git a/ctdb/lib/tevent/ABI/tevent-0.9.9.sigs b/ctdb/lib/tevent/ABI/tevent-0.9.9.sigs
new file mode 100644 (file)
index 0000000..9adaba5
--- /dev/null
@@ -0,0 +1,73 @@
+_tevent_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+_tevent_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+_tevent_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+_tevent_create_immediate: struct tevent_immediate *(TALLOC_CTX *, const char *)
+_tevent_loop_once: int (struct tevent_context *, const char *)
+_tevent_loop_until: int (struct tevent_context *, bool (*)(void *), void *, const char *)
+_tevent_loop_wait: int (struct tevent_context *, const char *)
+_tevent_queue_create: struct tevent_queue *(TALLOC_CTX *, const char *, const char *)
+_tevent_req_callback_data: void *(struct tevent_req *)
+_tevent_req_cancel: bool (struct tevent_req *, const char *)
+_tevent_req_create: struct tevent_req *(TALLOC_CTX *, void *, size_t, const char *, const char *)
+_tevent_req_data: void *(struct tevent_req *)
+_tevent_req_done: void (struct tevent_req *, const char *)
+_tevent_req_error: bool (struct tevent_req *, uint64_t, const char *)
+_tevent_req_nomem: bool (const void *, struct tevent_req *, const char *)
+_tevent_req_notify_callback: void (struct tevent_req *, const char *)
+_tevent_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_backend_list: const char **(TALLOC_CTX *)
+tevent_cleanup_pending_signal_handlers: void (struct tevent_signal *)
+tevent_common_add_fd: struct tevent_fd *(struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *)
+tevent_common_add_signal: struct tevent_signal *(struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *)
+tevent_common_add_timer: struct tevent_timer *(struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *)
+tevent_common_check_signal: int (struct tevent_context *)
+tevent_common_context_destructor: int (struct tevent_context *)
+tevent_common_fd_destructor: int (struct tevent_fd *)
+tevent_common_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_common_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_common_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_common_loop_immediate: bool (struct tevent_context *)
+tevent_common_loop_timer_delay: struct timeval (struct tevent_context *)
+tevent_common_loop_wait: int (struct tevent_context *, const char *)
+tevent_common_schedule_immediate: void (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *)
+tevent_context_init: struct tevent_context *(TALLOC_CTX *)
+tevent_context_init_byname: struct tevent_context *(TALLOC_CTX *, const char *)
+tevent_debug: void (struct tevent_context *, enum tevent_debug_level, const char *, ...)
+tevent_fd_get_flags: uint16_t (struct tevent_fd *)
+tevent_fd_set_auto_close: void (struct tevent_fd *)
+tevent_fd_set_close_fn: void (struct tevent_fd *, tevent_fd_close_fn_t)
+tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
+tevent_loop_allow_nesting: void (struct tevent_context *)
+tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *)
+tevent_queue_add: bool (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
+tevent_queue_length: size_t (struct tevent_queue *)
+tevent_queue_start: void (struct tevent_queue *)
+tevent_queue_stop: void (struct tevent_queue *)
+tevent_re_initialise: int (struct tevent_context *)
+tevent_register_backend: bool (const char *, const struct tevent_ops *)
+tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *)
+tevent_req_is_error: bool (struct tevent_req *, enum tevent_req_state *, uint64_t *)
+tevent_req_is_in_progress: bool (struct tevent_req *)
+tevent_req_poll: bool (struct tevent_req *, struct tevent_context *)
+tevent_req_post: struct tevent_req *(struct tevent_req *, struct tevent_context *)
+tevent_req_print: char *(TALLOC_CTX *, struct tevent_req *)
+tevent_req_received: void (struct tevent_req *)
+tevent_req_set_callback: void (struct tevent_req *, tevent_req_fn, void *)
+tevent_req_set_cancel_fn: void (struct tevent_req *, tevent_req_cancel_fn)
+tevent_req_set_endtime: bool (struct tevent_req *, struct tevent_context *, struct timeval)
+tevent_req_set_print_fn: void (struct tevent_req *, tevent_req_print_fn)
+tevent_set_abort_fn: void (void (*)(const char *))
+tevent_set_debug: int (struct tevent_context *, void (*)(void *, enum tevent_debug_level, const char *, va_list), void *)
+tevent_set_debug_stderr: int (struct tevent_context *)
+tevent_set_default_backend: void (const char *)
+tevent_signal_support: bool (struct tevent_context *)
+tevent_timeval_add: struct timeval (const struct timeval *, uint32_t, uint32_t)
+tevent_timeval_compare: int (const struct timeval *, const struct timeval *)
+tevent_timeval_current: struct timeval (void)
+tevent_timeval_current_ofs: struct timeval (uint32_t, uint32_t)
+tevent_timeval_is_zero: bool (const struct timeval *)
+tevent_timeval_set: struct timeval (uint32_t, uint32_t)
+tevent_timeval_until: struct timeval (const struct timeval *, const struct timeval *)
+tevent_timeval_zero: struct timeval (void)
+tevent_wakeup_recv: bool (struct tevent_req *)
+tevent_wakeup_send: struct tevent_req *(TALLOC_CTX *, struct tevent_context *, struct timeval)
diff --git a/ctdb/lib/tevent/Makefile.in b/ctdb/lib/tevent/Makefile.in
new file mode 100644 (file)
index 0000000..f3deb9d
--- /dev/null
@@ -0,0 +1,79 @@
+#!gmake
+#
+# Makefile for tdb directory
+#
+
+CC = @CC@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+includedir = @includedir@
+libdir = @libdir@
+VPATH = @srcdir@:@libreplacedir@
+srcdir = @srcdir@
+builddir = @builddir@
+sharedbuilddir = @sharedbuilddir@
+INSTALLCMD = @INSTALL@
+CPPFLAGS = @CPPFLAGS@ -I$(srcdir)/include -Iinclude -I.
+LDFLAGS = @LDFLAGS@
+EXEEXT = @EXEEXT@
+SHLD = @SHLD@
+SHLD_FLAGS = @SHLD_FLAGS@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PICFLAG = @PICFLAG@
+SHLIBEXT = @SHLIBEXT@
+LIB_PATH_VAR = @LIB_PATH_VAR@
+teventdir = @teventdir@
+
+TALLOC_CFLAGS = @TALLOC_CFLAGS@
+TALLOC_LDFLAGS = @TALLOC_CFLAGS@
+TALLOC_LIBS = @TALLOC_LIBS@
+
+TEVENT_CFLAGS = @TEVENT_CFLAGS@
+TEVENT_LDFLAGS = @TEVENT_CFLAGS@
+TEVENT_LIBS = @TEVENT_LIBS@
+
+CFLAGS = $(CPPFLAGS) $(TALLOC_CFLAGS) $(TEVENT_CFLAGS) @CFLAGS@
+LDFLAGS = $(TALLOC_LDFLAGS) $(TEVENT_LDFLAGS) @LDFLAGS@
+LIBS = $(TALLOC_LIBS) $(TEVENT_LIBS) @LIBS@
+
+TEVENT_OBJ = @TEVENT_OBJ@ @LIBREPLACEOBJ@
+
+SONAMEFLAG = @SONAMEFLAG@
+VERSIONSCRIPT = @VERSIONSCRIPT@
+EXPORTSFILE = @EXPORTSFILE@
+
+default: all
+
+include $(teventdir)/tevent.mk
+include $(teventdir)/rules.mk
+
+all:: showflags dirs $(PROGS) $(TEVENT_SOLIB) libtevent.a
+
+install:: all
+$(TEVENT_SOLIB): $(TEVENT_OBJ)
+       $(SHLD) $(SHLD_FLAGS) $(LDFLAGS) $(LIBS) -o $@ $(TEVENT_OBJ) $(VERSIONSCRIPT) $(EXPORTSFILE) $(SONAMEFLAG)$(TEVENT_SONAME)
+
+shared-build: all
+       ${INSTALLCMD} -d $(sharedbuilddir)/lib
+       ${INSTALLCMD} -m 644 libtevent.a $(sharedbuilddir)/lib
+       ${INSTALLCMD} -m 755 $(TEVENT_SOLIB) $(sharedbuilddir)/lib
+       ln -sf $(TEVENT_SOLIB) $(sharedbuilddir)/lib/$(TEVENT_SONAME)
+       ln -sf $(TEVENT_SOLIB) $(sharedbuilddir)/lib/libtevent.so
+       ${INSTALLCMD} -d $(sharedbuilddir)/include
+       ${INSTALLCMD} -m 644 $(srcdir)/tevent.h $(sharedbuilddir)/include
+
+check: test
+
+installcheck:: test install
+
+clean::
+       rm -f *.o *.a */*.o
+       rm -fr abi
+
+distclean:: clean
+       rm -f config.log config.status config.h config.cache
+       rm -f Makefile
+
+realdistclean:: distclean
+       rm -f configure config.h.in
diff --git a/ctdb/lib/tevent/autogen-waf.sh b/ctdb/lib/tevent/autogen-waf.sh
new file mode 120000 (symlink)
index 0000000..99150f3
--- /dev/null
@@ -0,0 +1 @@
+../../buildtools/scripts/autogen-waf.sh
\ No newline at end of file
diff --git a/ctdb/lib/tevent/autogen.sh b/ctdb/lib/tevent/autogen.sh
new file mode 100755 (executable)
index 0000000..e87940f
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+rm -rf autom4te.cache
+rm -f configure config.h.in
+
+IPATHS="-I libreplace -I lib/replace -I ../libreplace -I ../replace -I ../../../lib/replace"
+autoconf $IPATHS || exit 1
+autoheader $IPATHS || exit 1
+
+rm -rf autom4te.cache
+
+echo "Now run ./configure and then make."
+exit 0
diff --git a/ctdb/lib/tevent/build_macros.m4 b/ctdb/lib/tevent/build_macros.m4
new file mode 100644 (file)
index 0000000..7d795d4
--- /dev/null
@@ -0,0 +1,14 @@
+AC_DEFUN(BUILD_WITH_SHARED_BUILD_DIR,
+  [ AC_ARG_WITH([shared-build-dir],
+                [AC_HELP_STRING([--with-shared-build-dir=DIR],
+                                [temporary build directory where libraries are installed [$srcdir/sharedbuild]])])
+
+    sharedbuilddir="$srcdir/sharedbuild"
+    if test x"$with_shared_build_dir" != x; then
+        sharedbuilddir=$with_shared_build_dir
+        CFLAGS="$CFLAGS -I$with_shared_build_dir/include"
+        CPPFLAGS="$CPPFLAGS -I$with_shared_build_dir/include"
+        LDFLAGS="$LDFLAGS -L$with_shared_build_dir/lib"
+    fi
+    AC_SUBST(sharedbuilddir)
+  ])
diff --git a/ctdb/lib/tevent/config.guess b/ctdb/lib/tevent/config.guess
new file mode 100755 (executable)
index 0000000..1e2ae58
--- /dev/null
@@ -0,0 +1,1561 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
+
+timestamp='2009-04-27'
+
+# This file 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           sh5el) machine=sh5le-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    *:SolidBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    s390x:SunOS:*:*)
+       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+       eval $set_cc_for_build
+       SUN_ARCH="i386"
+       # If there is a compiler, see if it is configured for 64-bit objects.
+       # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+       # This test works for both compilers.
+       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+           if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               grep IS_64BIT_ARCH >/dev/null
+           then
+               SUN_ARCH="x86_64"
+           fi
+       fi
+       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[456])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep __LP64__ >/dev/null
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       case ${UNAME_MACHINE} in
+           pc98)
+               echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           amd64)
+               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+           *)
+               echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+       esac
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    *:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    *:Interix*:[3456]*)
+       case ${UNAME_MACHINE} in
+           x86)
+               echo i586-pc-interix${UNAME_RELEASE}
+               exit ;;
+           EM64T | authenticamd | genuineintel)
+               echo x86_64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+           IA64)
+               echo ia64-unknown-interix${UNAME_RELEASE}
+               exit ;;
+       esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    arm*:Linux:*:*)
+       eval $set_cc_for_build
+       if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+           | grep -q __ARM_EABI__
+       then
+           echo ${UNAME_MACHINE}-unknown-linux-gnu
+       else
+           echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+       fi
+       exit ;;
+    avr32*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips
+       #undef mipsel
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mipsel
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^CPU/{
+               s: ::g
+               p
+           }'`"
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips64
+       #undef mips64el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mips64el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips64
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^CPU/{
+               s: ::g
+               p
+           }'`"
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    or32:Linux:*:*)
+       echo or32-unknown-linux-gnu
+       exit ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    padre:Linux:*:*)
+       echo sparc-unknown-linux-gnu
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    vax:Linux:*:*)
+       echo ${UNAME_MACHINE}-dec-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    xtensa*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       # Set LC_ALL=C to ensure ld outputs messages in English.
+       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+                        | sed -ne '/supported targets:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported targets: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_targets" in
+         elf32-i386)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         a.out-i386-linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit ;;
+         "")
+               # Either a pre-BFD a.out linker (linux-gnuoldld) or
+               # one that does not give us useful --help.
+               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+               exit ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <features.h>
+       #ifdef __ELF__
+       # ifdef __GLIBC__
+       #  if __GLIBC__ >= 2
+       LIBC=gnu
+       #  else
+       LIBC=gnulibc1
+       #  endif
+       # else
+       LIBC=gnulibc1
+       # endif
+       #else
+       #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+       LIBC=gnu
+       #else
+       LIBC=gnuaout
+       #endif
+       #endif
+       #ifdef __dietlibc__
+       LIBC=dietlibc
+       #endif
+EOF
+       eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+           /^LIBC/{
+               s: ::g
+               p
+           }'`"
+       test x"${LIBC}" != x && {
+               echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+               exit
+       }
+       test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+       ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i586.
+       # Note: whatever this is, it MUST be the same as what config.sub
+       # prints for the "djgpp" host, or else GDB configury will decide that
+       # this is a cross-build.
+       echo i586-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+       OS_REL='.3'
+       test -r /etc/.relid \
+           && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    BePC:Haiku:*:*)    # Haiku running on Intel PC compatible.
+       echo i586-pc-haiku
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-7:SUPER-UX:*:*)
+       echo sx7-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8:SUPER-UX:*:*)
+       echo sx8-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-8R:SUPER-UX:*:*)
+       echo sx8r-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+    i*86:rdos:*:*)
+       echo ${UNAME_MACHINE}-pc-rdos
+       exit ;;
+    i*86:AROS:*:*)
+       echo ${UNAME_MACHINE}-pc-aros
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/ctdb/lib/tevent/config.sub b/ctdb/lib/tevent/config.sub
new file mode 100755 (executable)
index 0000000..b5b9c1e
--- /dev/null
@@ -0,0 +1,1686 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+#   Free Software Foundation, Inc.
+
+timestamp='2009-04-17'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file 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 2 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, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco6)
+               os=-sco5v6
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fido | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | lm32 \
+       | m32c | m32r | m32rle | m68000 | m68k | m88k \
+       | maxq | mb | microblaze | mcore | mep | metag \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64octeon | mips64octeonel \
+       | mips64orion | mips64orionel \
+       | mips64r5900 | mips64r5900el \
+       | mips64vr | mips64vrel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | moxie \
+       | mt \
+       | msp430 \
+       | nios | nios2 \
+       | ns16k | ns32k \
+       | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | score \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+       | spu | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | z8k | z80)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+       ms1)
+               basic_machine=mt-unknown
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* | avr32-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | lm32-* \
+       | m32c-* | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64octeon-* | mips64octeonel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64r5900-* | mips64r5900el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | mt-* \
+       | msp430-* \
+       | nios-* | nios2-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
+       | tron-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa*-* \
+       | ymp-* \
+       | z8k-* | z80-*)
+               ;;
+       # Recognize the basic CPU types without company name, with glob match.
+       xtensa*)
+               basic_machine=$basic_machine-unknown
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aros)
+               basic_machine=i386-pc
+               os=-aros
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       blackfin)
+               basic_machine=bfin-unknown
+               os=-linux
+               ;;
+       blackfin-*)
+               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+        cegcc)
+               basic_machine=arm-unknown
+               os=-cegcc
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16)
+               basic_machine=cr16-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       dicos)
+               basic_machine=i686-pc
+               os=-dicos
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m68knommu)
+               basic_machine=m68k-unknown
+               os=-linux
+               ;;
+       m68knommu-*)
+               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       mingw32ce)
+               basic_machine=arm-unknown
+               os=-mingw32ce
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       ms1-*)
+               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       parisc)
+               basic_machine=hppa-unknown
+               os=-linux
+               ;;
+       parisc-*)
+               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+               os=-linux
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pc98)
+               basic_machine=i386-pc
+               ;;
+       pc98-*)
+               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rdos)
+               basic_machine=i386-pc
+               os=-rdos
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sde)
+               basic_machine=mipsisa32-sde
+               os=-elf
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh5el)
+               basic_machine=sh5le-unknown
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tile*)
+               basic_machine=tile-unknown
+               os=-linux-gnu
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       z80-*-coff)
+               basic_machine=z80-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -kopensolaris* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* | -aros* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+             | -openbsd* | -solidbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* | -cegcc* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+             | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+        -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+        -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -dicos*)
+               os=-dicos
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+        score-*)
+               os=-elf
+               ;;
+        spu-*)
+               os=-elf
+               ;;
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+        c4x-* | tic4x-*)
+               os=-coff
+               ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+        mep-*)
+               os=-elf
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/ctdb/lib/tevent/configure.ac b/ctdb/lib/tevent/configure.ac
new file mode 100644 (file)
index 0000000..b77a4ab
--- /dev/null
@@ -0,0 +1,25 @@
+AC_PREREQ(2.50)
+AC_INIT(tevent, 0.9.9)
+AC_CONFIG_SRCDIR([tevent.c])
+AC_CONFIG_HEADER(config.h)
+
+AC_LIBREPLACE_ALL_CHECKS
+
+AC_LD_EXPORT_DYNAMIC
+AC_LD_SONAMEFLAG
+AC_LD_VERSIONSCRIPT
+AC_LD_PICFLAG
+AC_LD_SHLIBEXT
+AC_LIBREPLACE_SHLD
+AC_LIBREPLACE_SHLD_FLAGS
+AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
+
+m4_include(build_macros.m4)
+BUILD_WITH_SHARED_BUILD_DIR
+
+m4_include(pkg.m4)
+m4_include(libtalloc.m4)
+
+m4_include(libtevent.m4)
+
+AC_OUTPUT(Makefile tevent.pc)
diff --git a/ctdb/lib/tevent/doc/mainpage.dox b/ctdb/lib/tevent/doc/mainpage.dox
new file mode 100644 (file)
index 0000000..5cd3969
--- /dev/null
@@ -0,0 +1,42 @@
+/**
+ * @mainpage
+ *
+ * Tevent is an event system based on the talloc memory management library. It
+ * is the core event system used in Samba.
+ *
+ * The low level tevent has support for many event types, including timers,
+ * signals, and the classic file descriptor events.
+ *
+ * Tevent also provide helpers to deal with asynchronous code providing the
+ * tevent_req (tevent tequest) functions.
+ *
+ * @section tevent_download Download
+ *
+ * You can download the latest releases of tevent from the
+ * <a href="http://samba.org/ftp/tevent" target="_blank">tevent directory</a>
+ * on the samba public source archive.
+ *
+ * @section tevent_bugs Discussion and bug reports
+ *
+ * tevent does not currently have its own mailing list or bug tracking system.
+ * For now, please use the
+ * <a href="https://lists.samba.org/mailman/listinfo/samba-technical" target="_blank">samba-technical</a>
+ * mailing list, and the
+ * <a href="http://bugzilla.samba.org/" target="_blank">Samba bugzilla</a>
+ * bug tracking system.
+ *
+ * @section tevent_devel Development
+ * You can download the latest code either via git or rsync.
+ *
+ * To fetch via git see the following guide:
+ *
+ * <a href="http://wiki.samba.org/index.php/Using_Git_for_Samba_Development" target="_blank">Using Git for Samba Development</a>
+ *
+ * Once you have cloned the tree switch to the master branch and cd into the
+ * lib/tevent directory.
+ *
+ * To fetch via rsync use this command:
+ *
+ *   rsync -Pavz samba.org::ftp/unpacked/standalone_projects/lib/tevent .
+ *
+ */
diff --git a/ctdb/lib/tevent/doc/tutorials.dox b/ctdb/lib/tevent/doc/tutorials.dox
new file mode 100644 (file)
index 0000000..e8beed7
--- /dev/null
@@ -0,0 +1,43 @@
+/**
+ * @page tevent_queue_tutorial The tevent_queue tutorial
+ *
+ * @section Introduction
+ *
+ * A tevent_queue is used to queue up async requests that must be
+ * serialized. For example writing buffers into a socket must be
+ * serialized. Writing a large lump of data into a socket can require
+ * multiple write(2) or send(2) system calls. If more than one async
+ * request is outstanding to write large buffers into a socket, every
+ * request must individually be completed before the next one begins,
+ * even if multiple syscalls are required.
+ *
+ * To do this, every socket gets assigned a tevent_queue struct.
+ *
+ * Creating a serialized async request follows the usual convention to
+ * return a tevent_req structure with an embedded state structure. To
+ * serialize the work the requests is about to so, instead of directly
+ * starting or doing that work, tevent_queue_add must be called. When it
+ * is time for the serialized async request to do its work, the trigger
+ * callback function tevent_queue_add was given is called. In the example
+ * of writing to a socket, the trigger is called when the write request
+ * can begin accessing the socket.
+ *
+ * How does this engine work behind the scenes? When the queue is empty,
+ * tevent_queue_add schedules an immediate call to the trigger
+ * callback. The trigger callback starts its work, likely by starting
+ * other async subrequests. While these async subrequests are working,
+ * more requests can accumulate in the queue by tevent_queue_add. While
+ * there is no function to explicitly trigger the next waiter in line, it
+ * still works: When the active request in the queue is done, it will be
+ * destroyed by talloc_free. Talloc_free of an serialized async request
+ * that had been added to a queue will trigger the next request in the
+ * queue via a talloc destructor attached to a child of the serialized
+ * request. This way the queue will be kept busy when an async request
+ * finishes.
+ *
+ * @section Example
+ *
+ * @code
+ *      Metze: Please add a code example here.
+ * @endcode
+ */
diff --git a/ctdb/lib/tevent/doxy.config b/ctdb/lib/tevent/doxy.config
new file mode 100644 (file)
index 0000000..578ecaf
--- /dev/null
@@ -0,0 +1,1538 @@
+# Doxyfile 1.6.1
+
+# This file describes the settings to be used by the documentation system
+# doxygen (www.doxygen.org) for a project
+#
+# All text after a hash (#) is considered a comment and will be ignored
+# The format is:
+#       TAG = value [value, ...]
+# For lists items can also be appended using:
+#       TAG += value [value, ...]
+# Values that contain spaces should be placed between quotes (" ")
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+
+# This tag specifies the encoding used for all characters in the config file
+# that follow. The default is UTF-8 which is also the encoding used for all
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the
+# iconv built into libc) for the transcoding. See
+# http://www.gnu.org/software/libiconv for the list of possible encodings.
+
+DOXYFILE_ENCODING      = UTF-8
+
+# The PROJECT_NAME tag is a single word (or a sequence of words surrounded
+# by quotes) that should identify the project.
+
+PROJECT_NAME           = tevent
+
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.
+# This could be handy for archiving the generated documentation or
+# if some version control system is used.
+
+PROJECT_NUMBER         = 0.9.8
+
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
+# base path where the generated documentation will be put.
+# If a relative path is entered, it will be relative to the location
+# where doxygen was started. If left blank the current directory will be used.
+
+OUTPUT_DIRECTORY       = doc
+
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create
+# 4096 sub-directories (in 2 levels) under the output directory of each output
+# format and will distribute the generated files over these directories.
+# Enabling this option can be useful when feeding doxygen a huge amount of
+# source files, where putting all generated files in the same directory would
+# otherwise cause performance problems for the file system.
+
+CREATE_SUBDIRS         = NO
+
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all
+# documentation generated by doxygen is written. Doxygen will use this
+# information to generate all constant output in the proper language.
+# The default language is English, other supported languages are:
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak,
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.
+
+OUTPUT_LANGUAGE        = English
+
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will
+# include brief member descriptions after the members that are listed in
+# the file and class documentation (similar to JavaDoc).
+# Set to NO to disable this.
+
+BRIEF_MEMBER_DESC      = YES
+
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend
+# the brief description of a member or function before the detailed description.
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the
+# brief descriptions will be completely suppressed.
+
+REPEAT_BRIEF           = YES
+
+# This tag implements a quasi-intelligent brief description abbreviator
+# that is used to form the text in various listings. Each string
+# in this list, if found as the leading text of the brief description, will be
+# stripped from the text and the result after processing the whole list, is
+# used as the annotated text. Otherwise, the brief description is used as-is.
+# If left blank, the following values are used ("$name" is automatically
+# replaced with the name of the entity): "The $name class" "The $name widget"
+# "The $name file" "is" "provides" "specifies" "contains"
+# "represents" "a" "an" "the"
+
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then
+# Doxygen will generate a detailed section even if there is only a brief
+# description.
+
+ALWAYS_DETAILED_SEC    = NO
+
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all
+# inherited members of a class in the documentation of that class as if those
+# members were ordinary class members. Constructors, destructors and assignment
+# operators of the base classes will not be shown.
+
+INLINE_INHERITED_MEMB  = NO
+
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full
+# path before files name in the file list and in the header files. If set
+# to NO the shortest path that makes the file name unique will be used.
+
+FULL_PATH_NAMES        = YES
+
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag
+# can be used to strip a user-defined part of the path. Stripping is
+# only done if one of the specified strings matches the left-hand part of
+# the path. The tag can be used to show relative paths in the file list.
+# If left blank the directory from which doxygen is run is used as the
+# path to strip.
+
+STRIP_FROM_PATH        =
+
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of
+# the path mentioned in the documentation of a class, which tells
+# the reader which header file to include in order to use a class.
+# If left blank only the name of the header file containing the class
+# definition is used. Otherwise one should specify the include paths that
+# are normally passed to the compiler using the -I flag.
+
+STRIP_FROM_INC_PATH    =
+
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter
+# (but less readable) file names. This can be useful is your file systems
+# doesn't support long names like on DOS, Mac, or CD-ROM.
+
+SHORT_NAMES            = NO
+
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen
+# will interpret the first line (until the first dot) of a JavaDoc-style
+# comment as the brief description. If set to NO, the JavaDoc
+# comments will behave just like regular Qt-style comments
+# (thus requiring an explicit @brief command for a brief description.)
+
+JAVADOC_AUTOBRIEF      = YES
+
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will
+# interpret the first line (until the first dot) of a Qt-style
+# comment as the brief description. If set to NO, the comments
+# will behave just like regular Qt-style comments (thus requiring
+# an explicit \brief command for a brief description.)
+
+QT_AUTOBRIEF           = NO
+
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///
+# comments) as a brief description. This used to be the default behaviour.
+# The new default is to treat a multi-line C++ comment block as a detailed
+# description. Set this tag to YES if you prefer the old behaviour instead.
+
+MULTILINE_CPP_IS_BRIEF = NO
+
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented
+# member inherits the documentation from any documented member that it
+# re-implements.
+
+INHERIT_DOCS           = YES
+
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce
+# a new page for each member. If set to NO, the documentation of a member will
+# be part of the file/class/namespace that contains it.
+
+SEPARATE_MEMBER_PAGES  = NO
+
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.
+# Doxygen uses this value to replace tabs by spaces in code fragments.
+
+TAB_SIZE               = 8
+
+# This tag can be used to specify a number of aliases that acts
+# as commands in the documentation. An alias has the form "name=value".
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to
+# put the command \sideeffect (or @sideeffect) in the documentation, which
+# will result in a user-defined paragraph with heading "Side Effects:".
+# You can put \n's in the value part of an alias to insert newlines.
+
+ALIASES                =
+
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
+# sources only. Doxygen will then generate output that is more tailored for C.
+# For instance, some of the names that are used will be different. The list
+# of all members will be omitted, etc.
+
+OPTIMIZE_OUTPUT_FOR_C  = YES
+
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java
+# sources only. Doxygen will then generate output that is more tailored for
+# Java. For instance, namespaces will be presented as packages, qualified
+# scopes will look different, etc.
+
+OPTIMIZE_OUTPUT_JAVA   = NO
+
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran
+# sources only. Doxygen will then generate output that is more tailored for
+# Fortran.
+
+OPTIMIZE_FOR_FORTRAN   = NO
+
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL
+# sources. Doxygen will then generate output that is tailored for
+# VHDL.
+
+OPTIMIZE_OUTPUT_VHDL   = NO
+
+# Doxygen selects the parser to use depending on the extension of the files it parses.
+# With this tag you can assign which parser to use for a given extension.
+# Doxygen has a built-in mapping, but you can override or extend it using this tag.
+# The format is ext=language, where ext is a file extension, and language is one of
+# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP,
+# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat
+# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran),
+# use: inc=Fortran f=C. Note that for custom extensions you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.
+
+EXTENSION_MAPPING      =
+
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want
+# to include (a tag file for) the STL sources as input, then you should
+# set this tag to YES in order to let doxygen match functions declarations and
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.
+# func(std::string) {}). This also make the inheritance and collaboration
+# diagrams that involve STL classes more complete and accurate.
+
+BUILTIN_STL_SUPPORT    = NO
+
+# If you use Microsoft's C++/CLI language, you should set this option to YES to
+# enable parsing support.
+
+CPP_CLI_SUPPORT        = NO
+
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.
+# Doxygen will parse them like normal C++ but will assume all classes use public
+# instead of private inheritance when no explicit protection keyword is present.
+
+SIP_SUPPORT            = NO
+
+# For Microsoft's IDL there are propget and propput attributes to indicate getter
+# and setter methods for a property. Setting this option to YES (the default)
+# will make doxygen to replace the get and set methods by a property in the
+# documentation. This will only work if the methods are indeed getting or
+# setting a simple type. If this is not the case, or you want to show the
+# methods anyway, you should set this option to NO.
+
+IDL_PROPERTY_SUPPORT   = YES
+
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC
+# tag is set to YES, then doxygen will reuse the documentation of the first
+# member in the group (if any) for the other members of the group. By default
+# all members of a group must be documented explicitly.
+
+DISTRIBUTE_GROUP_DOC   = NO
+
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of
+# the same type (for instance a group of public functions) to be put as a
+# subgroup of that type (e.g. under the Public Functions section). Set it to
+# NO to prevent subgrouping. Alternatively, this can be done per class using
+# the \nosubgrouping command.
+
+SUBGROUPING            = YES
+
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum
+# is documented as struct, union, or enum with the name of the typedef. So
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct
+# with name TypeT. When disabled the typedef will appear as a member of a file,
+# namespace, or class. And the struct will be named TypeS. This can typically
+# be useful for C code in case the coding convention dictates that all compound
+# types are typedef'ed and only the typedef is referenced, never the tag name.
+
+TYPEDEF_HIDES_STRUCT   = NO
+
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to
+# determine which symbols to keep in memory and which to flush to disk.
+# When the cache is full, less often used symbols will be written to disk.
+# For small to medium size projects (<1000 input files) the default value is
+# probably good enough. For larger projects a too small cache size can cause
+# doxygen to be busy swapping symbols to and from disk most of the time
+# causing a significant performance penality.
+# If the system has enough physical memory increasing the cache will improve the
+# performance by keeping more symbols in memory. Note that the value works on
+# a logarithmic scale so increasing the size by one will rougly double the
+# memory usage. The cache size is given by this formula:
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,
+# corresponding to a cache size of 2^16 = 65536 symbols
+
+SYMBOL_CACHE_SIZE      = 0
+
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
+# documentation are documented, even if no documentation was available.
+# Private class members and static file members will be hidden unless
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
+
+EXTRACT_ALL            = NO
+
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
+# will be included in the documentation.
+
+EXTRACT_PRIVATE        = NO
+
+# If the EXTRACT_STATIC tag is set to YES all static members of a file
+# will be included in the documentation.
+
+EXTRACT_STATIC         = NO
+
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
+# defined locally in source files will be included in the documentation.
+# If set to NO only classes defined in header files are included.
+
+EXTRACT_LOCAL_CLASSES  = NO
+
+# This flag is only useful for Objective-C code. When set to YES local
+# methods, which are defined in the implementation section but not in
+# the interface are included in the documentation.
+# If set to NO (the default) only methods in the interface are included.
+
+EXTRACT_LOCAL_METHODS  = NO
+
+# If this flag is set to YES, the members of anonymous namespaces will be
+# extracted and appear in the documentation as a namespace called
+# 'anonymous_namespace{file}', where file will be replaced with the base
+# name of the file that contains the anonymous namespace. By default
+# anonymous namespace are hidden.
+
+EXTRACT_ANON_NSPACES   = NO
+
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
+# undocumented members of documented classes, files or namespaces.
+# If set to NO (the default) these members will be included in the
+# various overviews, but no documentation section is generated.
+# This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_MEMBERS     = YES
+
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
+# undocumented classes that are normally visible in the class hierarchy.
+# If set to NO (the default) these classes will be included in the various
+# overviews. This option has no effect if EXTRACT_ALL is enabled.
+
+HIDE_UNDOC_CLASSES     = YES
+
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
+# friend (class|struct|union) declarations.
+# If set to NO (the default) these declarations will be included in the
+# documentation.
+
+HIDE_FRIEND_COMPOUNDS  = NO
+
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any
+# documentation blocks found inside the body of a function.
+# If set to NO (the default) these blocks will be appended to the
+# function's detailed documentation block.
+
+HIDE_IN_BODY_DOCS      = NO
+
+# The INTERNAL_DOCS tag determines if documentation
+# that is typed after a \internal command is included. If the tag is set
+# to NO (the default) then the documentation will be excluded.
+# Set it to YES to include the internal documentation.
+
+INTERNAL_DOCS          = NO
+
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate
+# file names in lower-case letters. If set to YES upper-case letters are also
+# allowed. This is useful if you have classes or files whose names only differ
+# in case and if your file system supports case sensitive file names. Windows
+# and Mac users are advised to set this option to NO.
+
+CASE_SENSE_NAMES       = YES
+
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen
+# will show members with their full class and namespace scopes in the
+# documentation. If set to YES the scope will be hidden.
+
+HIDE_SCOPE_NAMES       = NO
+
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen
+# will put a list of the files that are included by a file in the documentation
+# of that file.
+
+SHOW_INCLUDE_FILES     = YES
+
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]
+# is inserted in the documentation for inline members.
+
+INLINE_INFO            = YES
+
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen
+# will sort the (detailed) documentation of file and class members
+# alphabetically by member name. If set to NO the members will appear in
+# declaration order.
+
+SORT_MEMBER_DOCS       = YES
+
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the
+# brief documentation of file, namespace and class members alphabetically
+# by member name. If set to NO (the default) the members will appear in
+# declaration order.
+
+SORT_BRIEF_DOCS        = NO
+
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen will sort the (brief and detailed) documentation of class members so that constructors and destructors are listed first. If set to NO (the default) the constructors will appear in the respective orders defined by SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.
+
+SORT_MEMBERS_CTORS_1ST = NO
+
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the
+# hierarchy of group names into alphabetical order. If set to NO (the default)
+# the group names will appear in their defined order.
+
+SORT_GROUP_NAMES       = NO
+
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be
+# sorted by fully-qualified names, including namespaces. If set to
+# NO (the default), the class list will be sorted only by class name,
+# not including the namespace part.
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.
+# Note: This option applies only to the class list, not to the
+# alphabetical list.
+
+SORT_BY_SCOPE_NAME     = NO
+
+# The GENERATE_TODOLIST tag can be used to enable (YES) or
+# disable (NO) the todo list. This list is created by putting \todo
+# commands in the documentation.
+
+GENERATE_TODOLIST      = YES
+
+# The GENERATE_TESTLIST tag can be used to enable (YES) or
+# disable (NO) the test list. This list is created by putting \test
+# commands in the documentation.
+
+GENERATE_TESTLIST      = YES
+
+# The GENERATE_BUGLIST tag can be used to enable (YES) or
+# disable (NO) the bug list. This list is created by putting \bug
+# commands in the documentation.
+
+GENERATE_BUGLIST       = YES
+
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or
+# disable (NO) the deprecated list. This list is created by putting
+# \deprecated commands in the documentation.
+
+GENERATE_DEPRECATEDLIST= YES
+
+# The ENABLED_SECTIONS tag can be used to enable conditional
+# documentation sections, marked by \if sectionname ... \endif.
+
+ENABLED_SECTIONS       =
+
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines
+# the initial value of a variable or define consists of for it to appear in
+# the documentation. If the initializer consists of more lines than specified
+# here it will be hidden. Use a value of 0 to hide initializers completely.
+# The appearance of the initializer of individual variables and defines in the
+# documentation can be controlled using \showinitializer or \hideinitializer
+# command in the documentation regardless of this setting.
+
+MAX_INITIALIZER_LINES  = 30
+
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated
+# at the bottom of the documentation of classes and structs. If set to YES the
+# list will mention the files that were used to generate the documentation.
+
+SHOW_USED_FILES        = YES
+
+# If the sources in your project are distributed over multiple directories
+# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy
+# in the documentation. The default is NO.
+
+SHOW_DIRECTORIES       = NO
+
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.
+# This will remove the Files entry from the Quick Index and from the
+# Folder Tree View (if specified). The default is YES.
+
+SHOW_FILES             = YES
+
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the
+# Namespaces page.
+# This will remove the Namespaces entry from the Quick Index
+# and from the Folder Tree View (if specified). The default is YES.
+
+SHOW_NAMESPACES        = YES
+
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that
+# doxygen should invoke to get the current version for each file (typically from
+# the version control system). Doxygen will invoke the program by executing (via
+# popen()) the command <command> <input-file>, where <command> is the value of
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file
+# provided by doxygen. Whatever the program writes to standard output
+# is used as the file version. See the manual for examples.
+
+FILE_VERSION_FILTER    =
+
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by
+# doxygen. The layout file controls the global structure of the generated output files
+# in an output format independent way. The create the layout file that represents
+# doxygen's defaults, run doxygen with the -l option. You can optionally specify a
+# file name after the option, if omitted DoxygenLayout.xml will be used as the name
+# of the layout file.
+
+LAYOUT_FILE            =
+
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+
+# The QUIET tag can be used to turn on/off the messages that are generated
+# by doxygen. Possible values are YES and NO. If left blank NO is used.
+
+QUIET                  = NO
+
+# The WARNINGS tag can be used to turn on/off the warning messages that are
+# generated by doxygen. Possible values are YES and NO. If left blank
+# NO is used.
+
+WARNINGS               = YES
+
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will
+# automatically be disabled.
+
+WARN_IF_UNDOCUMENTED   = YES
+
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for
+# potential errors in the documentation, such as not documenting some
+# parameters in a documented function, or documenting parameters that
+# don't exist or using markup commands wrongly.
+
+WARN_IF_DOC_ERROR      = YES
+
+# This WARN_NO_PARAMDOC option can be abled to get warnings for
+# functions that are documented, but have no documentation for their parameters
+# or return value. If set to NO (the default) doxygen will only warn about
+# wrong or incomplete parameter documentation, but not about the absence of
+# documentation.
+
+WARN_NO_PARAMDOC       = NO
+
+# The WARN_FORMAT tag determines the format of the warning messages that
+# doxygen can produce. The string should contain the $file, $line, and $text
+# tags, which will be replaced by the file and line number from which the
+# warning originated and the warning text. Optionally the format may contain
+# $version, which will be replaced by the version of the file (if it could
+# be obtained via FILE_VERSION_FILTER)
+
+WARN_FORMAT            = "$file:$line: $text"
+
+# The WARN_LOGFILE tag can be used to specify a file to which warning
+# and error messages should be written. If left blank the output is written
+# to stderr.
+
+WARN_LOGFILE           =
+
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+
+# The INPUT tag can be used to specify the files and/or directories that contain
+# documented source files. You may enter file names like "myfile.cpp" or
+# directories like "/usr/src/myproject". Separate the files or directories
+# with spaces.
+
+INPUT                  = . doc
+
+# This tag can be used to specify the character encoding of the source files
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
+# also the default input encoding. Doxygen uses libiconv (or the iconv built
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for
+# the list of possible encodings.
+
+INPUT_ENCODING         = UTF-8
+
+# If the value of the INPUT tag contains directories, you can use the
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank the following patterns are tested:
+# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
+# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
+
+FILE_PATTERNS          = *.cpp \
+                         *.cc \
+                         *.c \
+                         *.h \
+                         *.hh \
+                         *.hpp \
+                         *.dox
+
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories
+# should be searched for input files as well. Possible values are YES and NO.
+# If left blank NO is used.
+
+RECURSIVE              = NO
+
+# The EXCLUDE tag can be used to specify files and/or directories that should
+# excluded from the INPUT source files. This way you can easily exclude a
+# subdirectory from a directory tree whose root is specified with the INPUT tag.
+
+EXCLUDE                =
+
+# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
+# directories that are symbolic links (a Unix filesystem feature) are excluded
+# from the input.
+
+EXCLUDE_SYMLINKS       = NO
+
+# If the value of the INPUT tag contains directories, you can use the
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude
+# certain files from those directories. Note that the wildcards are matched
+# against the file with absolute path, so to exclude all test directories
+# for example use the pattern */test/*
+
+EXCLUDE_PATTERNS       = */.git/* \
+                         */.svn/* \
+                         */cmake/* \
+                         */build/*
+
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
+# (namespaces, classes, functions, etc.) that should be excluded from the
+# output. The symbol name can be a fully qualified name, a word, or if the
+# wildcard * is used, a substring. Examples: ANamespace, AClass,
+# AClass::ANamespace, ANamespace::*Test
+
+EXCLUDE_SYMBOLS        =
+
+# The EXAMPLE_PATH tag can be used to specify one or more files or
+# directories that contain example code fragments that are included (see
+# the \include command).
+
+EXAMPLE_PATH           =
+
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
+# and *.h) to filter out the source-files in the directories. If left
+# blank all files are included.
+
+EXAMPLE_PATTERNS       =
+
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be
+# searched for input files to be used with the \include or \dontinclude
+# commands irrespective of the value of the RECURSIVE tag.
+# Possible values are YES and NO. If left blank NO is used.
+
+EXAMPLE_RECURSIVE      = NO
+
+# The IMAGE_PATH tag can be used to specify one or more files or
+# directories that contain image that are included in the documentation (see
+# the \image command).
+
+IMAGE_PATH             =
+
+# The INPUT_FILTER tag can be used to specify a program that doxygen should
+# invoke to filter for each input file. Doxygen will invoke the filter program
+# by executing (via popen()) the command <filter> <input-file>, where <filter>
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an
+# input file. Doxygen will then use the output that the filter program writes
+# to standard output.
+# If FILTER_PATTERNS is specified, this tag will be
+# ignored.
+
+INPUT_FILTER           =
+
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
+# basis.
+# Doxygen will compare the file name with each pattern and apply the
+# filter if there is a match.
+# The filters are a list of the form:
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further
+# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER
+# is applied to all files.
+
+FILTER_PATTERNS        =
+
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using
+# INPUT_FILTER) will be used to filter the input files when producing source
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).
+
+FILTER_SOURCE_FILES    = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will
+# be generated. Documented entities will be cross-referenced with these sources.
+# Note: To get rid of all source code in the generated output, make sure also
+# VERBATIM_HEADERS is set to NO.
+
+SOURCE_BROWSER         = NO
+
+# Setting the INLINE_SOURCES tag to YES will include the body
+# of functions and classes directly in the documentation.
+
+INLINE_SOURCES         = NO
+
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct
+# doxygen to hide any special comment blocks from generated source code
+# fragments. Normal C and C++ comments will always remain visible.
+
+STRIP_CODE_COMMENTS    = YES
+
+# If the REFERENCED_BY_RELATION tag is set to YES
+# then for each documented function all documented
+# functions referencing it will be listed.
+
+REFERENCED_BY_RELATION = NO
+
+# If the REFERENCES_RELATION tag is set to YES
+# then for each documented function all documented entities
+# called/used by that function will be listed.
+
+REFERENCES_RELATION    = NO
+
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will
+# link to the source code.
+# Otherwise they will link to the documentation.
+
+REFERENCES_LINK_SOURCE = YES
+
+# If the USE_HTAGS tag is set to YES then the references to source code
+# will point to the HTML generated by the htags(1) tool instead of doxygen
+# built-in source browser. The htags tool is part of GNU's global source
+# tagging system (see http://www.gnu.org/software/global/global.html). You
+# will need version 4.8.6 or higher.
+
+USE_HTAGS              = NO
+
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen
+# will generate a verbatim copy of the header file for each class for
+# which an include is specified. Set to NO to disable this.
+
+VERBATIM_HEADERS       = YES
+
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index
+# of all compounds will be generated. Enable this if the project
+# contains a lot of classes, structs, unions or interfaces.
+
+ALPHABETICAL_INDEX     = NO
+
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns
+# in which this list will be split (can be a number in the range [1..20])
+
+COLS_IN_ALPHA_INDEX    = 5
+
+# In case all classes in a project start with a common prefix, all
+# classes will be put under the same header in the alphabetical index.
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that
+# should be ignored while generating the index headers.
+
+IGNORE_PREFIX          =
+
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will
+# generate HTML output.
+
+GENERATE_HTML          = YES
+
+# If the HTML_FOOTER_DESCRIPTION tag is set to YES, Doxygen will
+# add generated date, project name and doxygen version to HTML footer.
+
+HTML_FOOTER_DESCRIPTION= NO
+
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `html' will be used as the default path.
+
+HTML_OUTPUT            = html
+
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank
+# doxygen will generate files with .html extension.
+
+HTML_FILE_EXTENSION    = .html
+
+# The HTML_HEADER tag can be used to specify a personal HTML header for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard header.
+
+HTML_HEADER            =
+
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for
+# each generated HTML page. If it is left blank doxygen will generate a
+# standard footer.
+
+HTML_FOOTER            =
+
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading
+# style sheet that is used by each HTML page. It can be used to
+# fine-tune the look of the HTML output. If the tag is left blank doxygen
+# will generate a default style sheet. Note that doxygen will try to copy
+# the style sheet file to the HTML output directory, so don't put your own
+# stylesheet in the HTML output directory as well, or it will be erased!
+
+HTML_STYLESHEET        =
+
+# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes,
+# files or namespaces will be aligned in HTML using tables. If set to
+# NO a bullet list will be used.
+
+HTML_ALIGN_MEMBERS     = YES
+
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML
+# documentation will contain sections that can be hidden and shown after the
+# page has loaded. For this to work a browser that supports
+# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox
+# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari).
+
+HTML_DYNAMIC_SECTIONS  = NO
+
+# If the GENERATE_DOCSET tag is set to YES, additional index files
+# will be generated that can be used as input for Apple's Xcode 3
+# integrated development environment, introduced with OSX 10.5 (Leopard).
+# To create a documentation set, doxygen will generate a Makefile in the
+# HTML output directory. Running make will produce the docset in that
+# directory and running "make install" will install the docset in
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find
+# it at startup.
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information.
+
+GENERATE_DOCSET        = NO
+
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the
+# feed. A documentation feed provides an umbrella under which multiple
+# documentation sets from a single provider (such as a company or product suite)
+# can be grouped.
+
+DOCSET_FEEDNAME        = "Doxygen generated docs"
+
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that
+# should uniquely identify the documentation set bundle. This should be a
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen
+# will append .docset to the name.
+
+DOCSET_BUNDLE_ID       = org.doxygen.Project
+
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files
+# will be generated that can be used as input for tools like the
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)
+# of the generated HTML documentation.
+
+GENERATE_HTMLHELP      = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can
+# be used to specify the file name of the resulting .chm file. You
+# can add a path in front of the file if the result should not be
+# written to the html output directory.
+
+CHM_FILE               =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can
+# be used to specify the location (absolute path including file name) of
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run
+# the HTML help compiler on the generated index.hhp.
+
+HHC_LOCATION           =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag
+# controls if a separate .chi index file is generated (YES) or that
+# it should be included in the master .chm file (NO).
+
+GENERATE_CHI           = NO
+
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file
+# content.
+
+CHM_INDEX_ENCODING     =
+
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag
+# controls whether a binary table of contents is generated (YES) or a
+# normal table of contents (NO) in the .chm file.
+
+BINARY_TOC             = NO
+
+# The TOC_EXPAND flag can be set to YES to add extra items for group members
+# to the contents of the HTML help documentation and to the tree view.
+
+TOC_EXPAND             = NO
+
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER
+# are set, an additional index file will be generated that can be used as input for
+# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated
+# HTML documentation.
+
+GENERATE_QHP           = NO
+
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can
+# be used to specify the file name of the resulting .qch file.
+# The path specified is relative to the HTML output folder.
+
+QCH_FILE               =
+
+# The QHP_NAMESPACE tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#namespace
+
+QHP_NAMESPACE          =
+
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating
+# Qt Help Project output. For more information please see
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders
+
+QHP_VIRTUAL_FOLDER     = doc
+
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add.
+# For more information please see
+# http://doc.trolltech.com/qthelpproject.html#custom-filters
+
+QHP_CUST_FILTER_NAME   =
+
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">Qt Help Project / Custom Filters</a>.
+
+QHP_CUST_FILTER_ATTRS  =
+
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's
+# filter section matches.
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">Qt Help Project / Filter Attributes</a>.
+
+QHP_SECT_FILTER_ATTRS  =
+
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can
+# be used to specify the location of Qt's qhelpgenerator.
+# If non-empty doxygen will try to run qhelpgenerator on the generated
+# .qhp file.
+
+QHG_LOCATION           =
+
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index at
+# top of each HTML page. The value NO (the default) enables the index and
+# the value YES disables it.
+
+DISABLE_INDEX          = NO
+
+# This tag can be used to set the number of enum values (range [1..20])
+# that doxygen will group on one line in the generated HTML documentation.
+
+ENUM_VALUES_PER_LINE   = 4
+
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index
+# structure should be generated to display hierarchical information.
+# If the tag value is set to YES, a side panel will be generated
+# containing a tree-like index structure (just like the one that
+# is generated for HTML Help). For this to work a browser that supports
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).
+# Windows users are probably better off using the HTML help feature.
+
+GENERATE_TREEVIEW      = NONE
+
+# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories,
+# and Class Hierarchy pages using a tree view instead of an ordered list.
+
+USE_INLINE_TREES       = NO
+
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be
+# used to set the initial width (in pixels) of the frame in which the tree
+# is shown.
+
+TREEVIEW_WIDTH         = 250
+
+# Use this tag to change the font size of Latex formulas included
+# as images in the HTML documentation. The default is 10. Note that
+# when you change the font size after a successful doxygen run you need
+# to manually remove any form_*.png images from the HTML output directory
+# to force them to be regenerated.
+
+FORMULA_FONTSIZE       = 10
+
+# When the SEARCHENGINE tag is enable doxygen will generate a search box for the HTML output. The underlying search engine uses javascript
+# and DHTML and should work on any modern browser. Note that when using HTML help (GENERATE_HTMLHELP) or Qt help (GENERATE_QHP)
+# there is already a search function so this one should typically
+# be disabled.
+
+SEARCHENGINE           = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will
+# generate Latex output.
+
+GENERATE_LATEX         = YES
+
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `latex' will be used as the default path.
+
+LATEX_OUTPUT           = latex
+
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be
+# invoked. If left blank `latex' will be used as the default command name.
+
+LATEX_CMD_NAME         = latex
+
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to
+# generate index for LaTeX. If left blank `makeindex' will be used as the
+# default command name.
+
+MAKEINDEX_CMD_NAME     = makeindex
+
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact
+# LaTeX documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_LATEX          = NO
+
+# The PAPER_TYPE tag can be used to set the paper type that is used
+# by the printer. Possible values are: a4, a4wide, letter, legal and
+# executive. If left blank a4wide will be used.
+
+PAPER_TYPE             = a4wide
+
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX
+# packages that should be included in the LaTeX output.
+
+EXTRA_PACKAGES         =
+
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for
+# the generated latex document. The header should contain everything until
+# the first chapter. If it is left blank doxygen will generate a
+# standard header. Notice: only use this tag if you know what you are doing!
+
+LATEX_HEADER           =
+
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will
+# contain links (just like the HTML output) instead of page references
+# This makes the output suitable for online browsing using a pdf viewer.
+
+PDF_HYPERLINKS         = YES
+
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of
+# plain latex in the generated Makefile. Set this option to YES to get a
+# higher quality PDF documentation.
+
+USE_PDFLATEX           = YES
+
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.
+# command to the generated LaTeX files. This will instruct LaTeX to keep
+# running if errors occur, instead of asking the user for help.
+# This option is also used when generating formulas in HTML.
+
+LATEX_BATCHMODE        = NO
+
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not
+# include the index chapters (such as File Index, Compound Index, etc.)
+# in the output.
+
+LATEX_HIDE_INDICES     = NO
+
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include source code with syntax highlighting in the LaTeX output. Note that which sources are shown also depends on other settings such as SOURCE_BROWSER.
+
+LATEX_SOURCE_CODE      = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output
+# The RTF output is optimized for Word 97 and may not look very pretty with
+# other RTF readers or editors.
+
+GENERATE_RTF           = NO
+
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `rtf' will be used as the default path.
+
+RTF_OUTPUT             = rtf
+
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact
+# RTF documents. This may be useful for small projects and may help to
+# save some trees in general.
+
+COMPACT_RTF            = NO
+
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated
+# will contain hyperlink fields. The RTF file will
+# contain links (just like the HTML output) instead of page references.
+# This makes the output suitable for online browsing using WORD or other
+# programs which support those fields.
+# Note: wordpad (write) and others do not support links.
+
+RTF_HYPERLINKS         = NO
+
+# Load stylesheet definitions from file. Syntax is similar to doxygen's
+# config file, i.e. a series of assignments. You only have to provide
+# replacements, missing definitions are set to their default value.
+
+RTF_STYLESHEET_FILE    =
+
+# Set optional variables used in the generation of an rtf document.
+# Syntax is similar to doxygen's config file.
+
+RTF_EXTENSIONS_FILE    =
+
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will
+# generate man pages
+
+GENERATE_MAN           = YES
+
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `man' will be used as the default path.
+
+MAN_OUTPUT             = man
+
+# The MAN_EXTENSION tag determines the extension that is added to
+# the generated man pages (default is the subroutine's section .3)
+
+MAN_EXTENSION          = .3
+
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,
+# then it will generate one additional man file for each entity
+# documented in the real man page(s). These additional files
+# only source the real man page, but without them the man command
+# would be unable to find the correct page. The default is NO.
+
+MAN_LINKS              = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_XML tag is set to YES Doxygen will
+# generate an XML file that captures the structure of
+# the code including all documentation.
+
+GENERATE_XML           = NO
+
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be
+# put in front of it. If left blank `xml' will be used as the default path.
+
+XML_OUTPUT             = xml
+
+# The XML_SCHEMA tag can be used to specify an XML schema,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_SCHEMA             =
+
+# The XML_DTD tag can be used to specify an XML DTD,
+# which can be used by a validating XML parser to check the
+# syntax of the XML files.
+
+XML_DTD                =
+
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will
+# dump the program listings (including syntax highlighting
+# and cross-referencing information) to the XML output. Note that
+# enabling this will significantly increase the size of the XML output.
+
+XML_PROGRAMLISTING     = YES
+
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will
+# generate an AutoGen Definitions (see autogen.sf.net) file
+# that captures the structure of the code including all
+# documentation. Note that this feature is still experimental
+# and incomplete at the moment.
+
+GENERATE_AUTOGEN_DEF   = NO
+
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will
+# generate a Perl module file that captures the structure of
+# the code including all documentation. Note that this
+# feature is still experimental and incomplete at the
+# moment.
+
+GENERATE_PERLMOD       = NO
+
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able
+# to generate PDF and DVI output from the Perl module output.
+
+PERLMOD_LATEX          = NO
+
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be
+# nicely formatted so it can be parsed by a human reader.
+# This is useful
+# if you want to understand what is going on.
+# On the other hand, if this
+# tag is set to NO the size of the Perl module output will be much smaller
+# and Perl will parse it just the same.
+
+PERLMOD_PRETTY         = YES
+
+# The names of the make variables in the generated doxyrules.make file
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.
+# This is useful so different doxyrules.make files included by the same
+# Makefile don't overwrite each other's variables.
+
+PERLMOD_MAKEVAR_PREFIX =
+
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will
+# evaluate all C-preprocessor directives found in the sources and include
+# files.
+
+ENABLE_PREPROCESSING   = YES
+
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro
+# names in the source code. If set to NO (the default) only conditional
+# compilation will be performed. Macro expansion can be done in a controlled
+# way by setting EXPAND_ONLY_PREDEF to YES.
+
+MACRO_EXPANSION        = YES
+
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES
+# then the macro expansion is limited to the macros specified with the
+# PREDEFINED and EXPAND_AS_DEFINED tags.
+
+EXPAND_ONLY_PREDEF     = YES
+
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files
+# in the INCLUDE_PATH (see below) will be search if a #include is found.
+
+SEARCH_INCLUDES        = YES
+
+# The INCLUDE_PATH tag can be used to specify one or more directories that
+# contain include files that are not input files but should be processed by
+# the preprocessor.
+
+INCLUDE_PATH           =
+
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard
+# patterns (like *.h and *.hpp) to filter out the header-files in the
+# directories. If left blank, the patterns specified with FILE_PATTERNS will
+# be used.
+
+INCLUDE_FILE_PATTERNS  =
+
+# The PREDEFINED tag can be used to specify one or more macro names that
+# are defined before the preprocessor is started (similar to the -D option of
+# gcc). The argument of the tag is a list of macros of the form: name
+# or name=definition (no spaces). If the definition and the = are
+# omitted =1 is assumed. To prevent a macro definition from being
+# undefined via #undef or recursively expanded use the := operator
+# instead of the = operator.
+
+PREDEFINED             = DOXYGEN PRINTF_ATTRIBUTE(x,y)=
+
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
+# this tag can be used to specify a list of macro names that should be expanded.
+# The macro definition that is found in the sources will be used.
+# Use the PREDEFINED tag if you want to use a different macro definition.
+
+EXPAND_AS_DEFINED      =
+
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then
+# doxygen's preprocessor will remove all function-like macros that are alone
+# on a line, have an all uppercase name, and do not end with a semicolon. Such
+# function macros are typically used for boiler-plate code, and will confuse
+# the parser if not removed.
+
+SKIP_FUNCTION_MACROS   = YES
+
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+
+# The TAGFILES option can be used to specify one or more tagfiles.
+# Optionally an initial location of the external documentation
+# can be added for each tagfile. The format of a tag file without
+# this location is as follows:
+#
+# TAGFILES = file1 file2 ...
+# Adding location for the tag files is done as follows:
+#
+# TAGFILES = file1=loc1 "file2 = loc2" ...
+# where "loc1" and "loc2" can be relative or absolute paths or
+# URLs. If a location is present for each tag, the installdox tool
+# does not have to be run to correct the links.
+# Note that each tag file must have a unique name
+# (where the name does NOT include the path)
+# If a tag file is not located in the directory in which doxygen
+# is run, you must also specify the path to the tagfile here.
+
+TAGFILES               =
+
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create
+# a tag file that is based on the input files it reads.
+
+GENERATE_TAGFILE       =
+
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed
+# in the class index. If set to NO only the inherited external classes
+# will be listed.
+
+ALLEXTERNALS           = NO
+
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed
+# in the modules index. If set to NO, only the current project's groups will
+# be listed.
+
+EXTERNAL_GROUPS        = YES
+
+# The PERL_PATH should be the absolute path and name of the perl script
+# interpreter (i.e. the result of `which perl').
+
+PERL_PATH              = /usr/bin/perl
+
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base
+# or super classes. Setting the tag to NO turns the diagrams off. Note that
+# this option is superseded by the HAVE_DOT option below. This is only a
+# fallback. It is recommended to install and use dot, since it yields more
+# powerful graphs.
+
+CLASS_DIAGRAMS         = YES
+
+# You can define message sequence charts within doxygen comments using the \msc
+# command. Doxygen will then run the mscgen tool (see
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where
+# the mscgen tool resides. If left empty the tool is assumed to be found in the
+# default search path.
+
+MSCGEN_PATH            =
+
+# If set to YES, the inheritance and collaboration graphs will hide
+# inheritance and usage relations if the target is undocumented
+# or is not a class.
+
+HIDE_UNDOC_RELATIONS   = YES
+
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is
+# available from the path. This tool is part of Graphviz, a graph visualization
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section
+# have no effect if this option is set to NO (the default)
+
+HAVE_DOT               = NO
+
+# By default doxygen will write a font called FreeSans.ttf to the output
+# directory and reference it in all dot files that doxygen generates. This
+# font does not include all possible unicode characters however, so when you need
+# these (or just want a differently looking font) you can specify the font name
+# using DOT_FONTNAME. You need need to make sure dot is able to find the font,
+# which can be done by putting it in a standard location or by setting the
+# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory
+# containing the font.
+
+DOT_FONTNAME           = FreeSans
+
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.
+# The default size is 10pt.
+
+DOT_FONTSIZE           = 10
+
+# By default doxygen will tell dot to use the output directory to look for the
+# FreeSans.ttf font (which doxygen will put there itself). If you specify a
+# different font using DOT_FONTNAME you can set the path where dot
+# can find it using this tag.
+
+DOT_FONTPATH           =
+
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect inheritance relations. Setting this tag to YES will force the
+# the CLASS_DIAGRAMS tag to NO.
+
+CLASS_GRAPH            = YES
+
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for each documented class showing the direct and
+# indirect implementation dependencies (inheritance, containment, and
+# class references variables) of the class with other documented classes.
+
+COLLABORATION_GRAPH    = YES
+
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
+# will generate a graph for groups, showing the direct groups dependencies
+
+GROUP_GRAPHS           = YES
+
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and
+# collaboration diagrams in a style similar to the OMG's Unified Modeling
+# Language.
+
+UML_LOOK               = NO
+
+# If set to YES, the inheritance and collaboration graphs will show the
+# relations between templates and their instances.
+
+TEMPLATE_RELATIONS     = NO
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT
+# tags are set to YES then doxygen will generate a graph for each documented
+# file showing the direct and indirect include dependencies of the file with
+# other documented files.
+
+INCLUDE_GRAPH          = YES
+
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each
+# documented header file showing the documented files that directly or
+# indirectly include this file.
+
+INCLUDED_BY_GRAPH      = YES
+
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then
+# doxygen will generate a call dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable call graphs
+# for selected functions only using the \callgraph command.
+
+CALL_GRAPH             = NO
+
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then
+# doxygen will generate a caller dependency graph for every global function
+# or class method. Note that enabling this option will significantly increase
+# the time of a run. So in most cases it will be better to enable caller
+# graphs for selected functions only using the \callergraph command.
+
+CALLER_GRAPH           = NO
+
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen
+# will graphical hierarchy of all classes instead of a textual one.
+
+GRAPHICAL_HIERARCHY    = YES
+
+# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES
+# then doxygen will show the dependencies a directory has on other directories
+# in a graphical way. The dependency relations are determined by the #include
+# relations between the files in the directories.
+
+DIRECTORY_GRAPH        = YES
+
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images
+# generated by dot. Possible values are png, jpg, or gif
+# If left blank png will be used.
+
+DOT_IMAGE_FORMAT       = png
+
+# The tag DOT_PATH can be used to specify the path where the dot tool can be
+# found. If left blank, it is assumed the dot tool can be found in the path.
+
+DOT_PATH               =
+
+# The DOTFILE_DIRS tag can be used to specify one or more directories that
+# contain dot files that are included in the documentation (see the
+# \dotfile command).
+
+DOTFILE_DIRS           =
+
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of
+# nodes that will be shown in the graph. If the number of nodes in a graph
+# becomes larger than this value, doxygen will truncate the graph, which is
+# visualized by representing a node as a red box. Note that doxygen if the
+# number of direct children of the root node in a graph is already larger than
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.
+
+DOT_GRAPH_MAX_NODES    = 50
+
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the
+# graphs generated by dot. A depth value of 3 means that only nodes reachable
+# from the root by following a path via at most 3 edges will be shown. Nodes
+# that lay further from the root node will be omitted. Note that setting this
+# option to 1 or 2 may greatly reduce the computation time needed for large
+# code bases. Also note that the size of a graph can be further restricted by
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.
+
+MAX_DOT_GRAPH_DEPTH    = 0
+
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent
+# background. This is disabled by default, because dot on Windows does not
+# seem to support this out of the box. Warning: Depending on the platform used,
+# enabling this option may lead to badly anti-aliased labels on the edges of
+# a graph (i.e. they become hard to read).
+
+DOT_TRANSPARENT        = YES
+
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output
+# files in one run (i.e. multiple -o and -T options on the command line). This
+# makes dot run faster, but since only newer versions of dot (>1.8.10)
+# support this, this feature is disabled by default.
+
+DOT_MULTI_TARGETS      = NO
+
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will
+# generate a legend page explaining the meaning of the various boxes and
+# arrows in the dot generated graphs.
+
+GENERATE_LEGEND        = YES
+
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will
+# remove the intermediate dot files that are used to generate
+# the various graphs.
+
+DOT_CLEANUP            = YES
diff --git a/ctdb/lib/tevent/install-sh b/ctdb/lib/tevent/install-sh
new file mode 100755 (executable)
index 0000000..ba5e22a
--- /dev/null
@@ -0,0 +1,238 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+       -c) instcmd="$cpprog"
+           shift
+           continue;;
+
+       -d) dir_arg=true
+           shift
+           continue;;
+
+       -m) chmodcmd="$chmodprog $2"
+           shift
+           shift
+           continue;;
+
+       -o) chowncmd="$chownprog $2"
+           shift
+           shift
+           continue;;
+
+       -g) chgrpcmd="$chgrpprog $2"
+           shift
+           shift
+           continue;;
+
+       -s) stripcmd="$stripprog"
+           shift
+           continue;;
+
+       -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+           shift
+           continue;;
+
+       -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+           shift
+           continue;;
+
+       *)  if [ x"$src" = x ]
+           then
+               src=$1
+           else
+               # this colon is to work around a 386BSD /bin/sh bug
+               :
+               dst=$1
+           fi
+           shift
+           continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+       echo "install:  no input file specified"
+       exit 1
+else
+       true
+fi
+
+if [ x"$dir_arg" != x ]; then
+       dst=$src
+       src=""
+
+       if [ -d $dst ]; then
+               instcmd=:
+       else
+               instcmd=mkdir
+       fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+       if [ -f $src -o -d $src ]
+       then
+               true
+       else
+               echo "install:  $src does not exist"
+               exit 1
+       fi
+
+       if [ x"$dst" = x ]
+       then
+               echo "install:  no destination specified"
+               exit 1
+       else
+               true
+       fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+       if [ -d $dst ]
+       then
+               dst="$dst"/`basename $src`
+       else
+               true
+       fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+       pathcomp="${pathcomp}${1}"
+       shift
+
+       if [ ! -d "${pathcomp}" ] ;
+        then
+               $mkdirprog "${pathcomp}"
+       else
+               true
+       fi
+
+       pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+       $doit $instcmd $dst &&
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+       if [ x"$transformarg" = x ]
+       then
+               dstfile=`basename $dst`
+       else
+               dstfile=`basename $dst $transformbasename |
+                       sed $transformarg`$transformbasename
+       fi
+
+# don't allow the sed command to completely eliminate the filename
+
+       if [ x"$dstfile" = x ]
+       then
+               dstfile=`basename $dst`
+       else
+               true
+       fi
+
+# Make a temp file name in the proper directory.
+
+       dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+       $doit $instcmd $src $dsttmp &&
+
+       trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+       if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+       if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+       if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+       if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+       $doit $rmcmd -f $dstdir/$dstfile &&
+       $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/ctdb/lib/tevent/libtalloc.m4 b/ctdb/lib/tevent/libtalloc.m4
new file mode 100644 (file)
index 0000000..a4c5b8a
--- /dev/null
@@ -0,0 +1,7 @@
+AC_SUBST(TALLOC_OBJ)
+AC_SUBST(TALLOC_CFLAGS)
+AC_SUBST(TALLOC_LIBS)
+
+AC_CHECK_HEADER(talloc.h,
+   [AC_CHECK_LIB(talloc, talloc_init, [TALLOC_LIBS="-ltalloc"]) ],
+   [PKG_CHECK_MODULES(TALLOC, talloc)])
diff --git a/ctdb/lib/tevent/libtevent.m4 b/ctdb/lib/tevent/libtevent.m4
new file mode 100644 (file)
index 0000000..8bb969c
--- /dev/null
@@ -0,0 +1,44 @@
+dnl find the tevent sources. This is meant to work both for
+dnl standalone builds, and builds of packages using libtevent
+
+AC_SUBST(teventdir)
+
+if test x"$teventdir" = "x"; then
+       teventdir=""
+       teventpaths="$srcdir $srcdir/lib/tevent $srcdir/tevent $srcdir/../tevent"
+       for d in $teventpaths; do
+               if test -f "$d/tevent.c"; then
+                       teventdir="$d"
+                       break;
+               fi
+       done
+       if test x"$teventdir" = "x"; then
+          AC_MSG_ERROR([cannot find libtevent source in $teventpaths])
+       fi
+fi
+
+TEVENT_OBJ=""
+TEVENT_CFLAGS=""
+TEVENT_LIBS=""
+AC_SUBST(TEVENT_OBJ)
+AC_SUBST(TEVENT_CFLAGS)
+AC_SUBST(TEVENT_LIBS)
+
+TEVENT_CFLAGS="-I$teventdir"
+
+TEVENT_OBJ="tevent.o tevent_debug.o tevent_util.o"
+TEVENT_OBJ="$TEVENT_OBJ tevent_fd.o tevent_timed.o tevent_immediate.o tevent_signal.o"
+TEVENT_OBJ="$TEVENT_OBJ tevent_req.o tevent_wakeup.o tevent_queue.o"
+TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o"
+
+AC_CHECK_HEADERS(sys/epoll.h)
+AC_CHECK_FUNCS(epoll_create)
+if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes"; then
+   TEVENT_OBJ="$TEVENT_OBJ tevent_epoll.o"
+   AC_DEFINE(HAVE_EPOLL, 1, [Whether epoll available])
+fi
+
+if test x"$VERSIONSCRIPT" != "x"; then
+    EXPORTSFILE=tevent.exports
+    AC_SUBST(EXPORTSFILE)
+fi
diff --git a/ctdb/lib/tevent/pkg.m4 b/ctdb/lib/tevent/pkg.m4
new file mode 100644 (file)
index 0000000..568127f
--- /dev/null
@@ -0,0 +1,156 @@
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+#
+# Copyright Â© 2004 Scott James Remnant <scott@netsplit.com>.
+#
+# 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/>.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+       AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+       _pkg_min_version=m4_default([$1], [0.9.0])
+       AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+       if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+               AC_MSG_RESULT([yes])
+       else
+               AC_MSG_RESULT([no])
+               PKG_CONFIG=""
+       fi
+
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+#
+# Similar to PKG_CHECK_MODULES, make sure that the first instance of
+# this or PKG_CHECK_MODULES is called, or make sure to call
+# PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_ifval([$2], [$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$PKG_CONFIG"; then
+    if test -n "$$1"; then
+        pkg_cv_[]$1="$$1"
+    else
+        PKG_CHECK_EXISTS([$3],
+                         [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
+                        [pkg_failed=yes])
+    fi
+else
+       pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
+        else
+               $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+        fi
+       # Put the nasty error message in config.log where it belongs
+       echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+       ifelse([$4], , [AC_MSG_ERROR(dnl
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT
+])],
+               [AC_MSG_RESULT([no])
+                $4])
+elif test $pkg_failed = untried; then
+       ifelse([$4], , [AC_MSG_FAILURE(dnl
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
+               [$4])
+else
+       $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+       $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+       ifelse([$3], , :, [$3])
+fi[]dnl
+])# PKG_CHECK_MODULES
diff --git a/ctdb/lib/tevent/release-script.sh b/ctdb/lib/tevent/release-script.sh
new file mode 100755 (executable)
index 0000000..077f562
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+if [ "$1" = "" ]; then
+    echo "Please provide version string, eg: 1.2.0"
+    exit 1
+fi
+
+if [ ! -d "lib/tevent" ]; then
+    echo "Run this script from the samba base directory."
+    exit 1
+fi
+
+git clean -f -x -d lib/tevent
+git clean -f -x -d lib/replace
+
+curbranch=`git-branch |grep "^*" | tr -d "* "`
+
+version=$1
+strver=`echo ${version} | tr "." "-"`
+
+# Checkout the release tag
+git branch -f tevent-release-script-${strver} tevent-${strver}
+if [ ! "$?" = "0" ];  then
+    echo "Unable to checkout tevent-${strver} release"
+    exit 1
+fi
+
+git checkout tevent-release-script-${strver}
+
+# Test configure agrees with us
+confver=`grep "^AC_INIT" lib/tevent/configure.ac | tr -d "AC_INIT(tevent, " | tr -d ")"`
+if [ ! "$confver" = "$version" ]; then
+    echo "Wrong version, requested release for ${version}, found ${confver}"
+    exit 1
+fi
+
+# Now build tarball
+cp -a lib/tevent tevent-${version}
+cp -a lib/replace tevent-${version}/libreplace
+pushd tevent-${version}
+./autogen.sh
+popd
+tar cvzf tevent-${version}.tar.gz tevent-${version}
+rm -fr tevent-${version}
+
+#Clean up
+git checkout $curbranch
+git branch -d tevent-release-script-${strver}
diff --git a/ctdb/lib/tevent/rules.mk b/ctdb/lib/tevent/rules.mk
new file mode 100644 (file)
index 0000000..c197e93
--- /dev/null
@@ -0,0 +1,18 @@
+.SUFFIXES: .i _wrap.c
+
+showflags::
+       @echo 'libtevent will be compiled with flags:'
+       @echo '  CFLAGS = $(CFLAGS)'
+       @echo '  CPPFLAGS = $(CPPFLAGS)'
+       @echo '  LDFLAGS = $(LDFLAGS)'
+       @echo '  LIBS = $(LIBS)'
+
+.SUFFIXES: .c .o
+
+.c.o:
+       @echo Compiling $*.c
+       @mkdir -p `dirname $@`
+       @$(CC) $(PICFLAG) $(CFLAGS) $(ABI_CHECK) -c $< -o $@
+
+distclean::
+       rm -f *~ */*~
diff --git a/ctdb/lib/tevent/samba.m4 b/ctdb/lib/tevent/samba.m4
new file mode 100644 (file)
index 0000000..549f39d
--- /dev/null
@@ -0,0 +1,11 @@
+
+teventdir="\$(libteventsrcdir)"
+m4_include(../lib/tevent/libtevent.m4)
+
+SMB_EXT_LIB(LIBTEVENT_EXT, [${TEVENT_LIBS}])
+SMB_ENABLE(LIBTEVENT_EXT)
+
+SMB_SUBSYSTEM(LIBTEVENT,
+       [\$(addprefix \$(libteventsrcdir)/, ${TEVENT_OBJ})],
+       [LIBTEVENT_EXT],
+       [${TEVENT_CFLAGS}])
diff --git a/ctdb/lib/tevent/script/abi_checks.sh b/ctdb/lib/tevent/script/abi_checks.sh
new file mode 100755 (executable)
index 0000000..c34a659
--- /dev/null
@@ -0,0 +1,91 @@
+#!/bin/sh
+
+#
+# abi_checks.sh - check for possible abi changes
+#
+# Copyright (C) 2009 Micheal Adam <obnox@samba.org>
+#
+# 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/>.
+#
+
+#
+# USAGE: abi_checks.sh LIBNAME header1 [header2 ...]
+#
+# This script creates symbol and signature lists from the provided header
+# files with the aid of the mksyms.sh and mksigs.pl scripts (saved as
+# $LIBNAME.exports.check and $LIBNAME.sigatures.check). It then compares
+# the resulting files with the files $LIBNAME.exports and $LIBNME.signatures
+# which it expects to find in the current directory.
+#
+
+LANG=C; export LANG
+LC_ALL=C; export LC_ALL
+LC_COLLATE=C; export LC_COLLATE
+
+script=$0
+dir_name=$(dirname ${script})
+
+if test x"$1" = "x" ; then
+       echo "USAGE: ${script} libname header [header ...]"
+       exit 1
+fi
+
+libname="$1"
+shift
+
+if test x"$1" = "x" ; then
+       echo "USAGE: ${script} libname header [header ...]"
+       exit 1
+fi
+
+headers="$*"
+
+exports_file=${libname}.exports
+exports_file_check=${exports_file}.check
+signatures_file=${libname}.signatures
+signatures_file_check=${signatures_file}.check
+
+
+${dir_name}/mksyms.sh awk ${exports_file_check} ${headers} 2>&1 > /dev/null
+
+cat ${headers} | ${dir_name}/mksigs.pl > ${signatures_file_check} 2> /dev/null
+
+normalize_exports_file() {
+       filename=$1
+       cat ${filename} \
+       | sed -e 's/^[ \t]*//g' \
+       | sed -e 's/^$//g' \
+       | sed -e 's/^#.*$//g' \
+       | sort | uniq > ${filename}.sort
+}
+
+normalize_exports_file ${exports_file}
+normalize_exports_file ${exports_file_check}
+
+normalize_exports_file ${signatures_file}
+normalize_exports_file ${signatures_file_check}
+
+diff -u ${exports_file}.sort ${exports_file_check}.sort
+if test "x$?" != "x0" ; then
+       echo "WARNING: possible ABI change detected in exports!"
+else
+       echo "exports check: OK"
+fi
+
+diff -u ${signatures_file}.sort ${signatures_file_check}.sort
+if test "x$?" != "x0" ; then
+       echo "WARNING: possible ABI change detected in signatures!"
+else
+       echo "signatures check: OK"
+fi
diff --git a/ctdb/lib/tevent/script/abi_checks_gcc.sh b/ctdb/lib/tevent/script/abi_checks_gcc.sh
new file mode 100755 (executable)
index 0000000..9518209
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+make clean
+
+mkdir abi
+ABI_CHECKS="-aux-info abi/\$@.X"
+make ABI_CHECK="$ABI_CHECKS" CC="/usr/bin/gcc"
+
+for i in abi/*.X; do cat $i | grep 'tevent\.h'; done | sort | uniq | awk -F "extern " '{ print $2 }' | sort> abi/signatures
+
+cat > abi/exports << EOF
+{
+    global:
+EOF
+cat abi/signatures | awk -F '(' '{ print $1 }' | awk -F ' ' '{ print "           "$NF";" }' | tr -d '*' | sort >> abi/exports
+cat >> abi/exports << EOF
+
+    local: *;
+};
+EOF
+
+rm -fr abi/*.X
+
+diff -u tevent.signatures abi/signatures
+if [ "$?" != "0" ]; then
+    echo "WARNING: Possible ABI Change!!"
+fi
+
+diff -u tevent.exports abi/exports
+if [ "$?" != "0" ]; then
+    echo "WARNING: Export file may be outdated!!"
+fi
diff --git a/ctdb/lib/tevent/script/mksigs.pl b/ctdb/lib/tevent/script/mksigs.pl
new file mode 100755 (executable)
index 0000000..755cd79
--- /dev/null
@@ -0,0 +1,183 @@
+#!/usr/bin/perl
+
+# mksigs.pl - extract signatures from C headers
+#
+# Copyright (C) Michael Adam 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/>.
+
+# USAGE:  cat $header_files | mksigs.pl > $signature_file
+#
+# The header files to parse are read from stdin.
+# The output is in a form as produced by gcc with the -aux-info switch
+# and printed to stdout.
+
+use strict;
+use warnings;
+
+my $in_comment = 0;
+my $extern_C_block = 0;
+
+while (my $LINE = <>) {
+       # find end of started multi-line-comment
+       if ($in_comment) {
+               if ($LINE =~ /^.*?\*\/(.*)$/) {
+                       $LINE = $1;
+                       $in_comment = 0;
+               } else {
+                       # whole line within comment
+                       next;
+               }
+       }
+
+       # strip C++-style comments
+       $LINE =~ s/^(.*?)\/\/.*$/$1/;
+
+       # strip in-line-comments:
+       while ($LINE =~ /\/\*.*?\*\//) {
+               $LINE =~ s/\/\*.*?\*\///;
+       }
+
+       # find starts of multi-line-comments
+       if ($LINE =~ /^(.*)\/\*/) {
+               $in_comment = 1;
+               $LINE = $1;
+       }
+
+       # skip empty lines
+       next if $LINE =~ /^\s*$/;
+
+       # remove leading spaces
+       $LINE =~ s/^\s*(.*)$/$1/;
+
+       # concatenate lines split with "\" (usually macro defines)
+       while ($LINE =~ /^(.*?)\s+\\$/) {
+               my $LINE2 = <>;
+               $LINE = $1;
+               $LINE2 =~ s/^\s*(.*)$/$1/;
+               $LINE .= " " . $LINE2;
+       }
+
+       # remove all preprocessor directives
+       next if ($LINE =~ /^#/);
+
+       if ($LINE =~ /^extern\s+"C"\s+\{/) {
+               $extern_C_block = 1;
+               next;
+       }
+
+       if (($LINE =~ /^[^\{]*\}/) and $extern_C_block) {
+               $extern_C_block = 0;
+               next;
+       }
+
+       $LINE =~ s/^extern\s//;
+
+       # concatenate braces stretched over multiple lines
+       # (from structs or enums)
+       my $REST = $LINE;
+       my $braces = 0;
+       while (($REST =~ /[\{\}]/) or ($braces)) {
+               while ($REST =~ /[\{\}]/) {
+                       # collect opening
+                       while ($REST =~ /^[^\{\}]*\{(.*)$/) {
+                               $braces++;
+                               $REST = $1;
+                       }
+
+                       # collect closing
+                       while ($REST =~ /^[^\{\}]*\}(.*)$/) {
+                               $braces--;
+                               $REST = $1;
+                       }
+               }
+
+               # concatenate if not balanced
+               if ($braces) {
+                       if (my $LINE2 = <>) {
+                               $LINE2 =~ s/^\s*(.*)$/$1/;
+                               chomp($LINE);
+                               $LINE .= " " . $LINE2;
+                               chomp $REST;
+                               $REST .= " " . $LINE2;
+                       } else {
+                               print "ERROR: unbalanced braces ($braces)\n";
+                               last;
+                       }
+               }
+       }
+
+       # concetenate function prototypes that stretch over multiple lines
+       $REST = $LINE;
+       my $parenthesis = 0;
+       while (($REST =~ /[\(\)]/) or ($parenthesis)) {
+               while ($REST =~ /[\(\)]/) {
+                       # collect opening
+                       while ($REST =~ /^[^\(\)]*\((.*)$/) {
+                               $parenthesis++;
+                               $REST = $1;
+                       }
+
+                       # collect closing
+                       while ($REST =~ /^[^\(\)]*\)(.*)$/) {
+                               $parenthesis--;
+                               $REST = $1;
+                       }
+               }
+
+               # concatenate if not balanced
+               if ($parenthesis) {
+                       if (my $LINE2 = <>) {
+                               $LINE2 =~ s/^\s*(.*)$/$1/;
+                               chomp($LINE);
+                               $LINE .= " " . $LINE2;
+                               chomp($REST);
+                               $REST .= " " . $LINE2;
+                       } else {
+                               print "ERROR: unbalanced parantheses ($parenthesis)\n";
+                               last;
+                       }
+               }
+       }
+
+       next if ($LINE =~ /^typedef\s/);
+       next if ($LINE =~ /^enum\s+[^\{\(]+\s+\{/);
+       next if ($LINE =~ /^struct\s+[^\{\(]+\s+\{.*\}\s*;/);
+       next if ($LINE =~ /^struct\s+[a-zA-Z0-9_]+\s*;/);
+
+       # remove trailing spaces
+       $LINE =~ s/(.*?)\s*$/$1/;
+
+       $LINE =~ s/^(.*\))\s+PRINTF_ATTRIBUTE\([^\)]*\)(\s*[;,])/$1$2/;
+       $LINE =~ s/^(.*\))\s*[a-zA-Z0-9_]+\s*;$/$1;/;
+
+       # remove parameter names - slightly too coarse probably
+       $LINE =~ s/([\s\(]\*?)[_0-9a-zA-Z]+\s*([,\)])/$1$2/g;
+
+       # remedy (void) from last line
+       $LINE =~ s/\(\)/(void)/g;
+
+       # normalize spaces
+       $LINE =~ s/\s*\)\s*/)/g;
+       $LINE =~ s/\s*\(\s*/ (/g;
+       $LINE =~ s/\s*,\s*/, /g;
+
+       # normalize unsigned
+       $LINE =~ s/([\s,\(])unsigned([,\)])/$1unsigned int$2/g;
+
+       # normalize bool
+       $LINE =~ s/(\b)bool(\b)/_Bool/g;
+
+       print $LINE . "\n";
+}
diff --git a/ctdb/lib/tevent/script/mksyms.awk b/ctdb/lib/tevent/script/mksyms.awk
new file mode 100644 (file)
index 0000000..63ff9db
--- /dev/null
@@ -0,0 +1,75 @@
+#
+# mksyms.awk
+#
+# Extract symbols to export from C-header files.
+# output in version-script format for linking shared libraries.
+#
+# Copyright (C) 2008 Michael Adam <obnox@samba.org>
+#
+BEGIN {
+       inheader=0;
+       current_file="";
+       print "#"
+       print "# This file is automatically generated with \"make symbols\". DO NOT EDIT "
+       print "#"
+       print "{"
+       print "\tglobal:"
+}
+
+END {
+       print""
+       print "\tlocal: *;"
+       print "};"
+}
+
+{
+       if (FILENAME!=current_file) {
+               print "\t\t# The following definitions come from",FILENAME
+               current_file=FILENAME
+       }
+       if (inheader) {
+               if (match($0,"[)][^()]*[;][ \t]*$")) {
+                       inheader = 0;
+               }
+               next;
+       }
+}
+
+/^static/ || /^[ \t]*typedef/ || !/^[a-zA-Z\_]/ {
+       next;
+}
+
+/^extern[ \t]+[^()]+[;][ \t]*$/ {
+       gsub(/[^ \t]+[ \t]+/, "");
+       sub(/[;][ \t]*$/, "");
+       printf "\t\t%s;\n", $0;
+       next;
+}
+
+# look for function headers:
+{
+       gotstart = 0;
+       if ($0 ~ /^[A-Za-z_][A-Za-z0-9_]+/) {
+       gotstart = 1;
+       }
+       if(!gotstart) {
+               next;
+       }
+}
+
+/[_A-Za-z0-9]+[ \t]*[(].*[)][^()]*;[ \t]*$/ {
+       sub(/[(].*$/, "");
+       gsub(/[^ \t]+[ \t]+/, "");
+       gsub(/^[*]+/, "");
+       printf "\t\t%s;\n",$0;
+       next;
+}
+
+/[_A-Za-z0-9]+[ \t]*[(]/ {
+       inheader=1;
+       sub(/[(].*$/, "");
+       gsub(/[^ \t]+[ \t]+/, "");
+       gsub(/^[*]/, "");
+       printf "\t\t%s;\n",$0;
+       next;
+}
diff --git a/ctdb/lib/tevent/script/mksyms.sh b/ctdb/lib/tevent/script/mksyms.sh
new file mode 100755 (executable)
index 0000000..7fb4031
--- /dev/null
@@ -0,0 +1,45 @@
+#! /bin/sh
+
+#
+# mksyms.sh
+#
+# Extract symbols to export from C-header files.
+# output in version-script format for linking shared libraries.
+#
+# This is the shell wrapper for the mksyms.awk core script.
+#
+# Copyright (C) 2008 Michael Adam <obnox@samba.org>
+#
+
+LANG=C; export LANG
+LC_ALL=C; export LC_ALL
+LC_COLLATE=C; export LC_COLLATE
+
+if [ $# -lt 2 ]
+then
+  echo "Usage: $0 awk output_file header_files"
+  exit 1
+fi
+
+awk="$1"
+shift
+
+symsfile="$1"
+shift
+symsfile_tmp="$symsfile.$$.tmp~"
+
+proto_src="`echo $@ | tr ' ' '\n' | sort | uniq `"
+
+echo creating $symsfile
+
+mkdir -p `dirname $symsfile`
+
+${awk} -f `dirname $0`/mksyms.awk $proto_src > $symsfile_tmp
+
+if cmp -s $symsfile $symsfile_tmp 2>/dev/null
+then
+  echo "$symsfile unchanged"
+  rm $symsfile_tmp
+else
+  mv $symsfile_tmp $symsfile
+fi
diff --git a/ctdb/lib/tevent/testsuite.c b/ctdb/lib/tevent/testsuite.c
new file mode 100644 (file)
index 0000000..3a763de
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   testing of the events subsystem
+
+   Copyright (C) Stefan Metzmacher 2006-2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "lib/events/events.h"
+#include "system/filesys.h"
+#include "torture/torture.h"
+
+static int fde_count;
+
+static void fde_handler(struct tevent_context *ev_ctx, struct tevent_fd *f,
+                       uint16_t flags, void *private_data)
+{
+       int *fd = (int *)private_data;
+       char c;
+#ifdef SA_SIGINFO
+       kill(getpid(), SIGUSR1);
+#endif
+       kill(getpid(), SIGALRM);
+       read(fd[0], &c, 1);
+       write(fd[1], &c, 1);
+       fde_count++;
+}
+
+static void finished_handler(struct tevent_context *ev_ctx, struct tevent_timer *te,
+                            struct timeval tval, void *private_data)
+{
+       int *finished = (int *)private_data;
+       (*finished) = 1;
+}
+
+static void count_handler(struct tevent_context *ev_ctx, struct signal_event *te,
+                         int signum, int count, void *info, void *private_data)
+{
+       int *countp = (int *)private_data;
+       (*countp) += count;
+}
+
+static bool test_event_context(struct torture_context *test,
+                              const void *test_data)
+{
+       struct tevent_context *ev_ctx;
+       int fd[2] = { -1, -1 };
+       const char *backend = (const char *)test_data;
+       int alarm_count=0, info_count=0;
+       struct tevent_fd *fde;
+#ifdef SA_RESTART
+       struct tevent_signal *se1 = NULL;
+#endif
+       struct tevent_signal *se2 = NULL;
+#ifdef SA_SIGINFO
+       struct tevent_signal *se3 = NULL;
+#endif
+       int finished=0;
+       struct timeval t;
+       char c = 0;
+
+       ev_ctx = event_context_init_byname(test, backend);
+       if (ev_ctx == NULL) {
+               torture_comment(test, "event backend '%s' not supported\n", backend);
+               return true;
+       }
+
+       torture_comment(test, "Testing event backend '%s'\n", backend);
+
+       /* reset globals */
+       fde_count = 0;
+
+       /* create a pipe */
+       pipe(fd);
+
+       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);
+
+#ifdef SA_RESTART
+       se1 = event_add_signal(ev_ctx, ev_ctx, SIGALRM, SA_RESTART, count_handler, &alarm_count);
+#endif
+       se2 = event_add_signal(ev_ctx, ev_ctx, SIGALRM, SA_RESETHAND, count_handler, &alarm_count);
+#ifdef SA_SIGINFO
+       se3 = event_add_signal(ev_ctx, ev_ctx, SIGUSR1, SA_SIGINFO, count_handler, &info_count);
+#endif
+
+       write(fd[1], &c, 1);
+
+       t = timeval_current();
+       while (!finished) {
+               errno = 0;
+               if (event_loop_once(ev_ctx) == -1) {
+                       talloc_free(ev_ctx);
+                       torture_fail(test, talloc_asprintf(test, "Failed event loop %s\n", strerror(errno)));
+               }
+       }
+
+       talloc_free(fde);
+       close(fd[1]);
+
+       while (alarm_count < fde_count+1) {
+               if (event_loop_once(ev_ctx) == -1) {
+                       break;
+               }
+       }
+
+       torture_comment(test, "Got %.2f pipe events/sec\n", fde_count/timeval_elapsed(&t));
+
+#ifdef SA_RESTART
+       talloc_free(se1);
+#endif
+
+       torture_assert_int_equal(test, alarm_count, 1+fde_count, "alarm count mismatch");
+
+#ifdef SA_SIGINFO
+       talloc_free(se3);
+       torture_assert_int_equal(test, info_count, fde_count, "info count mismatch");
+#endif
+
+       talloc_free(ev_ctx);
+
+       return true;
+}
+
+struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx)
+{
+       struct torture_suite *suite = torture_suite_create(mem_ctx, "EVENT");
+       const char **list = event_backend_list(suite);
+       int i;
+
+       for (i=0;list && list[i];i++) {
+               torture_suite_add_simple_tcase_const(suite, list[i],
+                                              test_event_context,
+                                              (const void *)list[i]);
+       }
+
+       return suite;
+}
diff --git a/ctdb/lib/tevent/tevent.c b/ctdb/lib/tevent/tevent.c
new file mode 100644 (file)
index 0000000..8cc9ce5
--- /dev/null
@@ -0,0 +1,630 @@
+/*
+   Unix SMB/CIFS implementation.
+   main select loop and event handling
+   Copyright (C) Andrew Tridgell 2003
+   Copyright (C) Stefan Metzmacher 2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+/*
+  PLEASE READ THIS BEFORE MODIFYING!
+
+  This module is a general abstraction for the main select loop and
+  event handling. Do not ever put any localised hacks in here, instead
+  register one of the possible event types and implement that event
+  somewhere else.
+
+  There are 2 types of event handling that are handled in this module:
+
+  1) a file descriptor becoming readable or writeable. This is mostly
+     used for network sockets, but can be used for any type of file
+     descriptor. You may only register one handler for each file
+     descriptor/io combination or you will get unpredictable results
+     (this means that you can have a handler for read events, and a
+     separate handler for write events, but not two handlers that are
+     both handling read events)
+
+  2) a timed event. You can register an event that happens at a
+     specific time.  You can register as many of these as you
+     like. They are single shot - add a new timed event in the event
+     handler to get another event.
+
+  To setup a set of events you first need to create a event_context
+  structure using the function tevent_context_init(); This returns a
+  'struct tevent_context' that you use in all subsequent calls.
+
+  After that you can add/remove events that you are interested in
+  using tevent_add_*() and talloc_free()
+
+  Finally, you call tevent_loop_wait_once() to block waiting for one of the
+  events to occor or tevent_loop_wait() which will loop
+  forever.
+
+*/
+#include "replace.h"
+#include "system/filesys.h"
+#define TEVENT_DEPRECATED 1
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+struct tevent_ops_list {
+       struct tevent_ops_list *next, *prev;
+       const char *name;
+       const struct tevent_ops *ops;
+};
+
+/* list of registered event backends */
+static struct tevent_ops_list *tevent_backends = NULL;
+static char *tevent_default_backend = NULL;
+
+/*
+  register an events backend
+*/
+bool tevent_register_backend(const char *name, const struct tevent_ops *ops)
+{
+       struct tevent_ops_list *e;
+
+       for (e = tevent_backends; e != NULL; e = e->next) {
+               if (0 == strcmp(e->name, name)) {
+                       /* already registered, skip it */
+                       return true;
+               }
+       }
+
+       e = talloc(talloc_autofree_context(), struct tevent_ops_list);
+       if (e == NULL) return false;
+
+       e->name = name;
+       e->ops = ops;
+       DLIST_ADD(tevent_backends, e);
+
+       return true;
+}
+
+/*
+  set the default event backend
+ */
+void tevent_set_default_backend(const char *backend)
+{
+       talloc_free(tevent_default_backend);
+       tevent_default_backend = talloc_strdup(talloc_autofree_context(),
+                                              backend);
+}
+
+/*
+  initialise backends if not already done
+*/
+static void tevent_backend_init(void)
+{
+       tevent_select_init();
+       tevent_standard_init();
+#ifdef HAVE_EPOLL
+       tevent_epoll_init();
+#endif
+}
+
+/*
+  list available backends
+*/
+const char **tevent_backend_list(TALLOC_CTX *mem_ctx)
+{
+       const char **list = NULL;
+       struct tevent_ops_list *e;
+
+       tevent_backend_init();
+
+       for (e=tevent_backends;e;e=e->next) {
+               list = ev_str_list_add(list, e->name);
+       }
+
+       talloc_steal(mem_ctx, list);
+
+       return list;
+}
+
+int tevent_common_context_destructor(struct tevent_context *ev)
+{
+       struct tevent_fd *fd, *fn;
+       struct tevent_timer *te, *tn;
+       struct tevent_immediate *ie, *in;
+       struct tevent_signal *se, *sn;
+
+       if (ev->pipe_fde) {
+               talloc_free(ev->pipe_fde);
+               close(ev->pipe_fds[0]);
+               close(ev->pipe_fds[1]);
+               ev->pipe_fde = NULL;
+       }
+
+       for (fd = ev->fd_events; fd; fd = fn) {
+               fn = fd->next;
+               fd->event_ctx = NULL;
+               DLIST_REMOVE(ev->fd_events, fd);
+       }
+
+       for (te = ev->timer_events; te; te = tn) {
+               tn = te->next;
+               te->event_ctx = NULL;
+               DLIST_REMOVE(ev->timer_events, te);
+       }
+
+       for (ie = ev->immediate_events; ie; ie = in) {
+               in = ie->next;
+               ie->event_ctx = NULL;
+               ie->cancel_fn = NULL;
+               DLIST_REMOVE(ev->immediate_events, ie);
+       }
+
+       for (se = ev->signal_events; se; se = sn) {
+               sn = se->next;
+               se->event_ctx = NULL;
+               DLIST_REMOVE(ev->signal_events, se);
+               /*
+                * This is important, Otherwise signals
+                * are handled twice in child. eg, SIGHUP.
+                * one added in parent, and another one in
+                * the child. -- BoYang
+                */
+               tevent_cleanup_pending_signal_handlers(se);
+       }
+
+       return 0;
+}
+
+/*
+  create a event_context structure for a specific implemementation.
+  This must be the first events call, and all subsequent calls pass
+  this event_context as the first element. Event handlers also
+  receive this as their first argument.
+
+  This function is for allowing third-party-applications to hook in gluecode
+  to their own event loop code, so that they can make async usage of our client libs
+
+  NOTE: use tevent_context_init() inside of samba!
+*/
+static struct tevent_context *tevent_context_init_ops(TALLOC_CTX *mem_ctx,
+                                                     const struct tevent_ops *ops)
+{
+       struct tevent_context *ev;
+       int ret;
+
+       ev = talloc_zero(mem_ctx, struct tevent_context);
+       if (!ev) return NULL;
+
+       talloc_set_destructor(ev, tevent_common_context_destructor);
+
+       ev->ops = ops;
+
+       ret = ev->ops->context_init(ev);
+       if (ret != 0) {
+               talloc_free(ev);
+               return NULL;
+       }
+
+       return ev;
+}
+
+/*
+  create a event_context structure. This must be the first events
+  call, and all subsequent calls pass this event_context as the first
+  element. Event handlers also receive this as their first argument.
+*/
+struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx,
+                                                 const char *name)
+{
+       struct tevent_ops_list *e;
+
+       tevent_backend_init();
+
+       if (name == NULL) {
+               name = tevent_default_backend;
+       }
+       if (name == NULL) {
+               name = "standard";
+       }
+
+       for (e=tevent_backends;e;e=e->next) {
+               if (strcmp(name, e->name) == 0) {
+                       return tevent_context_init_ops(mem_ctx, e->ops);
+               }
+       }
+       return NULL;
+}
+
+
+/*
+  create a event_context structure. This must be the first events
+  call, and all subsequent calls pass this event_context as the first
+  element. Event handlers also receive this as their first argument.
+*/
+struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx)
+{
+       return tevent_context_init_byname(mem_ctx, NULL);
+}
+
+/*
+  add a fd based event
+  return NULL on failure (memory allocation error)
+*/
+struct tevent_fd *_tevent_add_fd(struct tevent_context *ev,
+                                TALLOC_CTX *mem_ctx,
+                                int fd,
+                                uint16_t flags,
+                                tevent_fd_handler_t handler,
+                                void *private_data,
+                                const char *handler_name,
+                                const char *location)
+{
+       return ev->ops->add_fd(ev, mem_ctx, fd, flags, handler, private_data,
+                              handler_name, location);
+}
+
+/*
+  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;
+       if (!fde->event_ctx) 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)
+{
+       if (!fde) return 0;
+       if (!fde->event_ctx) return 0;
+       return fde->event_ctx->ops->get_fd_flags(fde);
+}
+
+/*
+  set the fd event flags
+*/
+void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags)
+{
+       if (!fde) return;
+       if (!fde->event_ctx) return;
+       fde->event_ctx->ops->set_fd_flags(fde, flags);
+}
+
+bool tevent_signal_support(struct tevent_context *ev)
+{
+       if (ev->ops->add_signal) {
+               return true;
+       }
+       return false;
+}
+
+static void (*tevent_abort_fn)(const char *reason);
+
+void tevent_set_abort_fn(void (*abort_fn)(const char *reason))
+{
+       tevent_abort_fn = abort_fn;
+}
+
+static void tevent_abort(struct tevent_context *ev, const char *reason)
+{
+       tevent_debug(ev, TEVENT_DEBUG_FATAL,
+                    "abort: %s\n", reason);
+
+       if (!tevent_abort_fn) {
+               abort();
+       }
+
+       tevent_abort_fn(reason);
+}
+
+/*
+  add a timer event
+  return NULL on failure
+*/
+struct tevent_timer *_tevent_add_timer(struct tevent_context *ev,
+                                      TALLOC_CTX *mem_ctx,
+                                      struct timeval next_event,
+                                      tevent_timer_handler_t handler,
+                                      void *private_data,
+                                      const char *handler_name,
+                                      const char *location)
+{
+       return ev->ops->add_timer(ev, mem_ctx, next_event, handler, private_data,
+                                 handler_name, location);
+}
+
+/*
+  allocate an immediate event
+  return NULL on failure (memory allocation error)
+*/
+struct tevent_immediate *_tevent_create_immediate(TALLOC_CTX *mem_ctx,
+                                                 const char *location)
+{
+       struct tevent_immediate *im;
+
+       im = talloc(mem_ctx, struct tevent_immediate);
+       if (im == NULL) return NULL;
+
+       im->prev                = NULL;
+       im->next                = NULL;
+       im->event_ctx           = NULL;
+       im->create_location     = location;
+       im->handler             = NULL;
+       im->private_data        = NULL;
+       im->handler_name        = NULL;
+       im->schedule_location   = NULL;
+       im->cancel_fn           = NULL;
+       im->additional_data     = NULL;
+
+       return im;
+}
+
+/*
+  schedule an immediate event
+  return NULL on failure
+*/
+void _tevent_schedule_immediate(struct tevent_immediate *im,
+                               struct tevent_context *ev,
+                               tevent_immediate_handler_t handler,
+                               void *private_data,
+                               const char *handler_name,
+                               const char *location)
+{
+       ev->ops->schedule_immediate(im, ev, handler, private_data,
+                                   handler_name, location);
+}
+
+/*
+  add a signal event
+
+  sa_flags are flags to sigaction(2)
+
+  return NULL on failure
+*/
+struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
+                                        TALLOC_CTX *mem_ctx,
+                                        int signum,
+                                        int sa_flags,
+                                        tevent_signal_handler_t handler,
+                                        void *private_data,
+                                        const char *handler_name,
+                                        const char *location)
+{
+       return ev->ops->add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data,
+                                  handler_name, location);
+}
+
+void tevent_loop_allow_nesting(struct tevent_context *ev)
+{
+       ev->nesting.allowed = true;
+}
+
+void tevent_loop_set_nesting_hook(struct tevent_context *ev,
+                                 tevent_nesting_hook hook,
+                                 void *private_data)
+{
+       if (ev->nesting.hook_fn &&
+           (ev->nesting.hook_fn != hook ||
+            ev->nesting.hook_private != private_data)) {
+               /* the way the nesting hook code is currently written
+                  we cannot support two different nesting hooks at the
+                  same time. */
+               tevent_abort(ev, "tevent: Violation of nesting hook rules\n");
+       }
+       ev->nesting.hook_fn = hook;
+       ev->nesting.hook_private = private_data;
+}
+
+static void tevent_abort_nesting(struct tevent_context *ev, const char *location)
+{
+       const char *reason;
+
+       reason = talloc_asprintf(NULL, "tevent_loop_once() nesting at %s",
+                                location);
+       if (!reason) {
+               reason = "tevent_loop_once() nesting";
+       }
+
+       tevent_abort(ev, reason);
+}
+
+/*
+  do a single event loop using the events defined in ev
+*/
+int _tevent_loop_once(struct tevent_context *ev, const char *location)
+{
+       int ret;
+       void *nesting_stack_ptr = NULL;
+
+       ev->nesting.level++;
+
+       if (ev->nesting.level > 1) {
+               if (!ev->nesting.allowed) {
+                       tevent_abort_nesting(ev, location);
+                       errno = ELOOP;
+                       return -1;
+               }
+       }
+       if (ev->nesting.level > 0) {
+               if (ev->nesting.hook_fn) {
+                       int ret2;
+                       ret2 = ev->nesting.hook_fn(ev,
+                                                  ev->nesting.hook_private,
+                                                  ev->nesting.level,
+                                                  true,
+                                                  (void *)&nesting_stack_ptr,
+                                                  location);
+                       if (ret2 != 0) {
+                               ret = ret2;
+                               goto done;
+                       }
+               }
+       }
+
+       ret = ev->ops->loop_once(ev, location);
+
+       if (ev->nesting.level > 0) {
+               if (ev->nesting.hook_fn) {
+                       int ret2;
+                       ret2 = ev->nesting.hook_fn(ev,
+                                                  ev->nesting.hook_private,
+                                                  ev->nesting.level,
+                                                  false,
+                                                  (void *)&nesting_stack_ptr,
+                                                  location);
+                       if (ret2 != 0) {
+                               ret = ret2;
+                               goto done;
+                       }
+               }
+       }
+
+done:
+       ev->nesting.level--;
+       return ret;
+}
+
+/*
+  this is a performance optimization for the samba4 nested event loop problems
+*/
+int _tevent_loop_until(struct tevent_context *ev,
+                      bool (*finished)(void *private_data),
+                      void *private_data,
+                      const char *location)
+{
+       int ret = 0;
+       void *nesting_stack_ptr = NULL;
+
+       ev->nesting.level++;
+
+       if (ev->nesting.level > 1) {
+               if (!ev->nesting.allowed) {
+                       tevent_abort_nesting(ev, location);
+                       errno = ELOOP;
+                       return -1;
+               }
+       }
+       if (ev->nesting.level > 0) {
+               if (ev->nesting.hook_fn) {
+                       int ret2;
+                       ret2 = ev->nesting.hook_fn(ev,
+                                                  ev->nesting.hook_private,
+                                                  ev->nesting.level,
+                                                  true,
+                                                  (void *)&nesting_stack_ptr,
+                                                  location);
+                       if (ret2 != 0) {
+                               ret = ret2;
+                               goto done;
+                       }
+               }
+       }
+
+       while (!finished(private_data)) {
+               ret = ev->ops->loop_once(ev, location);
+               if (ret != 0) {
+                       break;
+               }
+       }
+
+       if (ev->nesting.level > 0) {
+               if (ev->nesting.hook_fn) {
+                       int ret2;
+                       ret2 = ev->nesting.hook_fn(ev,
+                                                  ev->nesting.hook_private,
+                                                  ev->nesting.level,
+                                                  false,
+                                                  (void *)&nesting_stack_ptr,
+                                                  location);
+                       if (ret2 != 0) {
+                               ret = ret2;
+                               goto done;
+                       }
+               }
+       }
+
+done:
+       ev->nesting.level--;
+       return ret;
+}
+
+/*
+  return on failure or (with 0) if all fd events are removed
+*/
+int tevent_common_loop_wait(struct tevent_context *ev,
+                           const char *location)
+{
+       /*
+        * loop as long as we have events pending
+        */
+       while (ev->fd_events ||
+              ev->timer_events ||
+              ev->immediate_events ||
+              ev->signal_events) {
+               int ret;
+               ret = _tevent_loop_once(ev, location);
+               if (ret != 0) {
+                       tevent_debug(ev, TEVENT_DEBUG_FATAL,
+                                    "_tevent_loop_once() failed: %d - %s\n",
+                                    ret, strerror(errno));
+                       return ret;
+               }
+       }
+
+       tevent_debug(ev, TEVENT_DEBUG_WARNING,
+                    "tevent_common_loop_wait() out of events\n");
+       return 0;
+}
+
+/*
+  return on failure or (with 0) if all fd events are removed
+*/
+int _tevent_loop_wait(struct tevent_context *ev, const char *location)
+{
+       return ev->ops->loop_wait(ev, location);
+}
+
+
+/*
+  re-initialise a tevent context. This leaves you with the same
+  event context, but all events are wiped and the structure is
+  re-initialised. This is most useful after a fork()
+
+  zero is returned on success, non-zero on failure
+*/
+int tevent_re_initialise(struct tevent_context *ev)
+{
+       tevent_common_context_destructor(ev);
+
+       return ev->ops->context_init(ev);
+}
diff --git a/ctdb/lib/tevent/tevent.exports b/ctdb/lib/tevent/tevent.exports
new file mode 100644 (file)
index 0000000..01d547a
--- /dev/null
@@ -0,0 +1,62 @@
+{
+    global:
+           _tevent_add_fd;
+           _tevent_add_signal;
+           _tevent_add_timer;
+           tevent_backend_list;
+           tevent_context_init;
+           tevent_context_init_byname;
+           _tevent_create_immediate;
+           tevent_fd_get_flags;
+           tevent_fd_set_auto_close;
+           tevent_fd_set_close_fn;
+           tevent_fd_set_flags;
+           tevent_loop_allow_nesting;
+           _tevent_loop_once;
+           tevent_loop_set_nesting_hook;
+           _tevent_loop_until;
+           _tevent_loop_wait;
+           tevent_queue_add;
+           _tevent_queue_create;
+           tevent_queue_length;
+           tevent_queue_start;
+           tevent_queue_stop;
+           tevent_register_backend;
+           _tevent_req_callback_data;
+           _tevent_req_create;
+           _tevent_req_data;
+           tevent_req_default_print;
+           _tevent_req_done;
+           _tevent_req_error;
+           tevent_req_is_error;
+           tevent_req_is_in_progress;
+           _tevent_req_nomem;
+           _tevent_req_notify_callback;
+           tevent_req_poll;
+           tevent_req_post;
+           tevent_req_print;
+           tevent_req_received;
+           tevent_req_set_callback;
+           tevent_req_set_endtime;
+           tevent_req_set_print_fn;
+           _tevent_schedule_immediate;
+           tevent_set_abort_fn;
+           tevent_set_debug;
+           tevent_set_debug_stderr;
+           tevent_set_default_backend;
+           tevent_signal_support;
+           tevent_timeval_add;
+           tevent_timeval_compare;
+           tevent_timeval_current;
+           tevent_timeval_current_ofs;
+           tevent_timeval_is_zero;
+           tevent_timeval_set;
+           tevent_timeval_until;
+           tevent_timeval_zero;
+           tevent_wakeup_recv;
+           tevent_wakeup_send;
+           _tevent_req_cancel;
+           tevent_req_set_cancel_fn;
+
+    local: *;
+};
diff --git a/ctdb/lib/tevent/tevent.h b/ctdb/lib/tevent/tevent.h
new file mode 100644 (file)
index 0000000..c2aead2
--- /dev/null
@@ -0,0 +1,1439 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   generalised event loop handling
+
+   Copyright (C) Andrew Tridgell 2005
+   Copyright (C) Stefan Metzmacher 2005-2009
+   Copyright (C) Volker Lendecke 2008
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __TEVENT_H__
+#define __TEVENT_H__
+
+#include <stdint.h>
+#include <talloc.h>
+#include <sys/time.h>
+#include <stdbool.h>
+
+struct tevent_context;
+struct tevent_ops;
+struct tevent_fd;
+struct tevent_timer;
+struct tevent_immediate;
+struct tevent_signal;
+
+/**
+ * @defgroup tevent The tevent API
+ *
+ * The tevent low-level API
+ *
+ * This API provides the public interface to manage events in the tevent
+ * mainloop. Functions are provided for managing low-level events such
+ * as timer events, fd events and signal handling.
+ *
+ * @{
+ */
+
+/* event handler types */
+/**
+ * Called when a file descriptor monitored by tevent has
+ * data to be read or written on it.
+ */
+typedef void (*tevent_fd_handler_t)(struct tevent_context *ev,
+                                   struct tevent_fd *fde,
+                                   uint16_t flags,
+                                   void *private_data);
+
+/**
+ * Called when tevent is ceasing the monitoring of a file descriptor.
+ */
+typedef void (*tevent_fd_close_fn_t)(struct tevent_context *ev,
+                                    struct tevent_fd *fde,
+                                    int fd,
+                                    void *private_data);
+
+/**
+ * Called when a tevent timer has fired.
+ */
+typedef void (*tevent_timer_handler_t)(struct tevent_context *ev,
+                                      struct tevent_timer *te,
+                                      struct timeval current_time,
+                                      void *private_data);
+
+/**
+ * Called when a tevent immediate event is invoked.
+ */
+typedef void (*tevent_immediate_handler_t)(struct tevent_context *ctx,
+                                          struct tevent_immediate *im,
+                                          void *private_data);
+
+/**
+ * Called after tevent detects the specified signal.
+ */
+typedef void (*tevent_signal_handler_t)(struct tevent_context *ev,
+                                       struct tevent_signal *se,
+                                       int signum,
+                                       int count,
+                                       void *siginfo,
+                                       void *private_data);
+
+/**
+ * @brief Create a event_context structure.
+ *
+ * This must be the first events call, and all subsequent calls pass this
+ * event_context as the first element. Event handlers also receive this as
+ * their first argument.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @return              An allocated tevent context, NULL on error.
+ *
+ * @see tevent_context_init()
+ */
+struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
+
+/**
+ * @brief Create a event_context structure and name it.
+ *
+ * This must be the first events call, and all subsequent calls pass this
+ * event_context as the first element. Event handlers also receive this as
+ * their first argument.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @param[in]  name     The name for the tevent context.
+ *
+ * @return              An allocated tevent context, NULL on error.
+ */
+struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
+
+/**
+ * @brief List available backends.
+ *
+ * @param[in]  mem_ctx  The memory context to use.
+ *
+ * @return              A string vector with a terminating NULL element, NULL
+ *                      on error.
+ */
+const char **tevent_backend_list(TALLOC_CTX *mem_ctx);
+
+/**
+ * @brief Set the default tevent backent.
+ *
+ * @param[in]  backend  The name of the backend to set.
+ */
+void tevent_set_default_backend(const char *backend);
+
+#ifdef DOXYGEN
+/**
+ * @brief Add a file descriptor based event.
+ *
+ * @param[in]  ev       The event context to work on.
+ *
+ * @param[in]  mem_ctx  The talloc memory context to use.
+ *
+ * @param[in]  fd       The file descriptor to base the event on.
+ *
+ * @param[in]  flags    #TEVENT_FD_READ or #TEVENT_FD_WRITE
+ *
+ * @param[in]  handler  The callback handler for the event.
+ *
+ * @param[in]  private_data  The private data passed to the callback handler.
+ *
+ * @return              The file descriptor based event, NULL on error.
+ *
+ * @note To cancel the monitoring of a file descriptor, call talloc_free()
+ * on the object returned by this function.
+ */
+struct tevent_fd *tevent_add_fd(struct tevent_context *ev,
+                               TALLOC_CTX *mem_ctx,
+                               int fd,
+                               uint16_t flags,
+                               tevent_fd_handler_t handler,
+                               void *private_data);
+#else
+struct tevent_fd *_tevent_add_fd(struct tevent_context *ev,
+                                TALLOC_CTX *mem_ctx,
+                                int fd,
+                                uint16_t flags,
+                                tevent_fd_handler_t handler,
+                                void *private_data,
+                                const char *handler_name,
+                                const char *location);
+#define tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data) \
+       _tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data, \
+                      #handler, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Add a timed event
+ *
+ * @param[in]  ev       The event context to work on.
+ *
+ * @param[in]  mem_ctx  The talloc memory context to use.
+ *
+ * @param[in]  next_event  Timeval specifying the absolute time to fire this
+ * event. This is not an offset.
+ *
+ * @param[in]  handler  The callback handler for the event.
+ *
+ * @param[in]  private_data  The private data passed to the callback handler.
+ *
+ * @return The newly-created timer event, or NULL on error.
+ *
+ * @note To cancel a timer event before it fires, call talloc_free() on the
+ * event returned from this function. This event is automatically
+ * talloc_free()-ed after its event handler files, if it hasn't been freed yet.
+ *
+ * @note Unlike some mainloops, tevent timers are one-time events. To set up
+ * a recurring event, it is necessary to call tevent_add_timer() again during
+ * the handler processing.
+ *
+ * @note Due to the internal mainloop processing, a timer set to run
+ * immediately will do so after any other pending timers fire, but before
+ * any further file descriptor or signal handling events fire. Callers should
+ * not rely on this behavior!
+ */
+struct tevent_timer *tevent_add_timer(struct tevent_context *ev,
+                                      TALLOC_CTX *mem_ctx,
+                                      struct timeval next_event,
+                                      tevent_timer_handler_t handler,
+                                      void *private_data);
+#else
+struct tevent_timer *_tevent_add_timer(struct tevent_context *ev,
+                                      TALLOC_CTX *mem_ctx,
+                                      struct timeval next_event,
+                                      tevent_timer_handler_t handler,
+                                      void *private_data,
+                                      const char *handler_name,
+                                      const char *location);
+#define tevent_add_timer(ev, mem_ctx, next_event, handler, private_data) \
+       _tevent_add_timer(ev, mem_ctx, next_event, handler, private_data, \
+                         #handler, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * Initialize an immediate event object
+ *
+ * This object can be used to trigger an event to occur immediately after
+ * returning from the current event (before any other event occurs)
+ *
+ * @param[in] mem_ctx  The talloc memory context to use as the parent
+ *
+ * @return An empty tevent_immediate object. Use tevent_schedule_immediate
+ * to populate and use it.
+ *
+ * @note Available as of tevent 0.9.8
+ */
+struct tevent_immediate *tevent_create_immediate(TALLOC_CTX *mem_ctx);
+#else
+struct tevent_immediate *_tevent_create_immediate(TALLOC_CTX *mem_ctx,
+                                                 const char *location);
+#define tevent_create_immediate(mem_ctx) \
+       _tevent_create_immediate(mem_ctx, __location__)
+#endif
+
+#ifdef DOXYGEN
+
+/**
+ * Schedule an event for immediate execution. This event will occur
+ * immediately after returning from the current event (before any other
+ * event occurs)
+ *
+ * @param[in] im       The tevent_immediate object to populate and use
+ * @param[in] ctx      The tevent_context to run this event
+ * @param[in] handler  The event handler to run when this event fires
+ * @param[in] private_data  Data to pass to the event handler
+ */
+void tevent_schedule_immediate(struct tevent_immediate *im,
+                struct tevent_context *ctx,
+                tevent_immediate_handler_t handler,
+                void *private_data);
+#else
+void _tevent_schedule_immediate(struct tevent_immediate *im,
+                               struct tevent_context *ctx,
+                               tevent_immediate_handler_t handler,
+                               void *private_data,
+                               const char *handler_name,
+                               const char *location);
+#define tevent_schedule_immediate(im, ctx, handler, private_data) \
+       _tevent_schedule_immediate(im, ctx, handler, private_data, \
+                                  #handler, __location__);
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Add a tevent signal handler
+ *
+ * tevent_add_signal() creates a new event for handling a signal the next
+ * time through the mainloop. It implements a very simple traditional signal
+ * handler whose only purpose is to add the handler event into the mainloop.
+ *
+ * @param[in]  ev       The event context to work on.
+ *
+ * @param[in]  mem_ctx  The talloc memory context to use.
+ *
+ * @param[in]  signum   The signal to trap
+ *
+ * @param[in]  handler  The callback handler for the signal.
+ *
+ * @param[in]  sa_flags sigaction flags for this signal handler.
+ *
+ * @param[in]  private_data  The private data passed to the callback handler.
+ *
+ * @return The newly-created signal handler event, or NULL on error.
+ *
+ * @note To cancel a signal handler, call talloc_free() on the event returned
+ * from this function.
+ */
+struct tevent_signal *tevent_add_signal(struct tevent_context *ev,
+                     TALLOC_CTX *mem_ctx,
+                     int signum,
+                     int sa_flags,
+                     tevent_signal_handler_t handler,
+                     void *private_data);
+#else
+struct tevent_signal *_tevent_add_signal(struct tevent_context *ev,
+                                        TALLOC_CTX *mem_ctx,
+                                        int signum,
+                                        int sa_flags,
+                                        tevent_signal_handler_t handler,
+                                        void *private_data,
+                                        const char *handler_name,
+                                        const char *location);
+#define tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data) \
+       _tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data, \
+                          #handler, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Pass a single time through the mainloop
+ *
+ * This will process any appropriate signal, immediate, fd and timer events
+ *
+ * @param[in]  ev The event context to process
+ *
+ * @return Zero on success, nonzero if an internal error occurred
+ */
+int tevent_loop_once(struct tevent_context *ev);
+#else
+int _tevent_loop_once(struct tevent_context *ev, const char *location);
+#define tevent_loop_once(ev) \
+       _tevent_loop_once(ev, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Run the mainloop
+ *
+ * The mainloop will run until there are no events remaining to be processed
+ *
+ * @param[in]  ev The event context to process
+ *
+ * @return Zero if all events have been processed. Nonzero if an internal
+ * error occurred.
+ */
+int tevent_loop_wait(struct tevent_context *ev);
+#else
+int _tevent_loop_wait(struct tevent_context *ev, const char *location);
+#define tevent_loop_wait(ev) \
+       _tevent_loop_wait(ev, __location__)
+#endif
+
+
+/**
+ * Assign a function to run when a tevent_fd is freed
+ *
+ * This function is a destructor for the tevent_fd. It does not automatically
+ * close the file descriptor. If this is the desired behavior, then it must be
+ * performed by the close_fn.
+ *
+ * @param[in] fde       File descriptor event on which to set the destructor
+ * @param[in] close_fn  Destructor to execute when fde is freed
+ */
+void tevent_fd_set_close_fn(struct tevent_fd *fde,
+                           tevent_fd_close_fn_t close_fn);
+
+/**
+ * Automatically close the file descriptor when the tevent_fd is freed
+ *
+ * This function calls close(fd) internally.
+ *
+ * @param[in] fde  File descriptor event to auto-close
+ */
+void tevent_fd_set_auto_close(struct tevent_fd *fde);
+
+/**
+ * Return the flags set on this file descriptor event
+ *
+ * @param[in] fde  File descriptor event to query
+ *
+ * @return The flags set on the event. See #TEVENT_FD_READ and
+ * #TEVENT_FD_WRITE
+ */
+uint16_t tevent_fd_get_flags(struct tevent_fd *fde);
+
+/**
+ * Set flags on a file descriptor event
+ *
+ * @param[in] fde    File descriptor event to set
+ * @param[in] flags  Flags to set on the event. See #TEVENT_FD_READ and
+ * #TEVENT_FD_WRITE
+ */
+void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
+
+/**
+ * Query whether tevent supports signal handling
+ *
+ * @param[in] ev  An initialized tevent context
+ *
+ * @return True if this platform and tevent context support signal handling
+ */
+bool tevent_signal_support(struct tevent_context *ev);
+
+void tevent_set_abort_fn(void (*abort_fn)(const char *reason));
+
+/* bits for file descriptor event flags */
+
+/**
+ * Monitor a file descriptor for write availability
+ */
+#define TEVENT_FD_READ 1
+/**
+ * Monitor a file descriptor for data to be read
+ */
+#define TEVENT_FD_WRITE 2
+
+/**
+ * Convenience function for declaring a tevent_fd writable
+ */
+#define TEVENT_FD_WRITEABLE(fde) \
+       tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_WRITE)
+
+/**
+ * Convenience function for declaring a tevent_fd readable
+ */
+#define TEVENT_FD_READABLE(fde) \
+       tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_READ)
+
+/**
+ * Convenience function for declaring a tevent_fd non-writable
+ */
+#define TEVENT_FD_NOT_WRITEABLE(fde) \
+       tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_WRITE)
+
+/**
+ * Convenience function for declaring a tevent_fd non-readable
+ */
+#define TEVENT_FD_NOT_READABLE(fde) \
+       tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_READ)
+
+/**
+ * Debug level of tevent
+ */
+enum tevent_debug_level {
+       TEVENT_DEBUG_FATAL,
+       TEVENT_DEBUG_ERROR,
+       TEVENT_DEBUG_WARNING,
+       TEVENT_DEBUG_TRACE
+};
+
+/**
+ * @brief The tevent debug callbac.
+ *
+ * @param[in]  context  The memory context to use.
+ *
+ * @param[in]  level    The debug level.
+ *
+ * @param[in]  fmt      The format string.
+ *
+ * @param[in]  ap       The arguments for the format string.
+ */
+typedef void (*tevent_debug_fn)(void *context,
+                               enum tevent_debug_level level,
+                               const char *fmt,
+                               va_list ap) PRINTF_ATTRIBUTE(3,0);
+
+/**
+ * Set destination for tevent debug messages
+ *
+ * @param[in] ev        Event context to debug
+ * @param[in] debug     Function to handle output printing
+ * @param[in] context   The context to pass to the debug function.
+ *
+ * @return Always returns 0 as of version 0.9.8
+ *
+ * @note Default is to emit no debug messages
+ */
+int tevent_set_debug(struct tevent_context *ev,
+                    tevent_debug_fn debug,
+                    void *context);
+
+/**
+ * Designate stderr for debug message output
+ *
+ * @param[in] ev     Event context to debug
+ *
+ * @note This function will only output TEVENT_DEBUG_FATAL, TEVENT_DEBUG_ERROR
+ * and TEVENT_DEBUG_WARNING messages. For TEVENT_DEBUG_TRACE, please define a
+ * function for tevent_set_debug()
+ */
+int tevent_set_debug_stderr(struct tevent_context *ev);
+
+/**
+ * @}
+ */
+
+/**
+ * @defgroup tevent_request The tevent request functions.
+ * @ingroup tevent
+ *
+ * This represents an async request being processed by callbacks via an event
+ * context. A user can issue for example a write request to a socket, giving
+ * an implementation function the fd, the buffer and the number of bytes to
+ * transfer. The function issuing the request will immediately return without
+ * blocking most likely without having sent anything. The API user then fills
+ * in req->async.fn and req->async.private_data, functions that are called
+ * when the request is finished.
+ *
+ * It is up to the user of the async request to talloc_free it after it has
+ * finished. This can happen while the completion function is called.
+ *
+ * @{
+ */
+
+/**
+ * An async request moves between the following 4 states:
+ */
+enum tevent_req_state {
+       /**
+        * we are creating the request
+        */
+       TEVENT_REQ_INIT,
+       /**
+        * we are waiting the request to complete
+        */
+       TEVENT_REQ_IN_PROGRESS,
+       /**
+        * the request is finished
+        */
+       TEVENT_REQ_DONE,
+       /**
+        * A user error has occurred
+        */
+       TEVENT_REQ_USER_ERROR,
+       /**
+        * Request timed out
+        */
+       TEVENT_REQ_TIMED_OUT,
+       /**
+        * No memory in between
+        */
+       TEVENT_REQ_NO_MEMORY,
+       /**
+        * the request is already received by the caller
+        */
+       TEVENT_REQ_RECEIVED
+};
+
+/**
+ * @brief An async request
+ */
+struct tevent_req;
+
+/**
+ * @brief A tevent request callback function.
+ *
+ * @param[in]  req      The tevent async request which executed this callback.
+ */
+typedef void (*tevent_req_fn)(struct tevent_req *req);
+
+/**
+ * @brief Set an async request callback.
+ *
+ * @param[in]  req      The async request to set the callback.
+ *
+ * @param[in]  fn       The callback function to set.
+ *
+ * @param[in]  pvt      A pointer to private data to pass to the async request
+ *                      callback.
+ */
+void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt);
+
+#ifdef DOXYGEN
+/**
+ * @brief Get the private data casted to the given type for a callback from
+ *        a tevent request structure.
+ *
+ * @param[in]  req      The structure to get the callback data from.
+ *
+ * @param[in]  type     The type of the private callback data to get.
+ *
+ * @return              The type casted private data set NULL if not set.
+ */
+void *tevent_req_callback_data(struct tevent_req *req, #type);
+#else
+void *_tevent_req_callback_data(struct tevent_req *req);
+#define tevent_req_callback_data(_req, _type) \
+       talloc_get_type_abort(_tevent_req_callback_data(_req), _type)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Get the private data for a callback from a tevent request structure.
+ *
+ * @param[in]  req      The structure to get the callback data from.
+ *
+ * @param[in]  req      The structure to get the data from.
+ *
+ * @return              The private data or NULL if not set.
+ */
+void *tevent_req_callback_data_void(struct tevent_req *req);
+#else
+#define tevent_req_callback_data_void(_req) \
+       _tevent_req_callback_data(_req)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Get the private data from a tevent request structure.
+ *
+ * @param[in]  req      The structure to get the private data from.
+ *
+ * @return              The private data or NULL if not set.
+ */
+void *tevent_req_data(struct tevent_req *req);
+#else
+void *_tevent_req_data(struct tevent_req *req);
+#define tevent_req_data(_req, _type) \
+       talloc_get_type_abort(_tevent_req_data(_req), _type)
+#endif
+
+/**
+ * @brief The print function which can be set for a tevent async request.
+ *
+ * @param[in]  req      The tevent async request.
+ *
+ * @param[in]  ctx      A talloc memory context which can be uses to allocate
+ *                      memory.
+ *
+ * @return              An allocated string buffer to print.
+ *
+ * Example:
+ * @code
+ *   static char *my_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
+ *   {
+ *     struct my_data *data = tevent_req_data(req, struct my_data);
+ *     char *result;
+ *
+ *     result = tevent_req_default_print(mem_ctx, req);
+ *     if (result == NULL) {
+ *       return NULL;
+ *     }
+ *
+ *     return talloc_asprintf_append_buffer(result, "foo=%d, bar=%d",
+ *       data->foo, data->bar);
+ *   }
+ * @endcode
+ */
+typedef char *(*tevent_req_print_fn)(struct tevent_req *req, TALLOC_CTX *ctx);
+
+/**
+ * @brief This function sets a print function for the given request.
+ *
+ * This function can be used to setup a print function for the given request.
+ * This will be triggered if the tevent_req_print() function was
+ * called on the given request.
+ *
+ * @param[in]  req      The request to use.
+ *
+ * @param[in]  fn       A pointer to the print function
+ *
+ * @note This function should only be used for debugging.
+ */
+void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn);
+
+/**
+ * @brief The default print function for creating debug messages.
+ *
+ * The function should not be used by users of the async API,
+ * but custom print function can use it and append custom text
+ * to the string.
+ *
+ * @param[in]  req      The request to be printed.
+ *
+ * @param[in]  mem_ctx  The memory context for the result.
+ *
+ * @return              Text representation of request.
+ *
+ */
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx);
+
+/**
+ * @brief Print an tevent_req structure in debug messages.
+ *
+ * This function should be used by callers of the async API.
+ *
+ * @param[in]  mem_ctx  The memory context for the result.
+ *
+ * @param[in] req       The request to be printed.
+ *
+ * @return              Text representation of request.
+ */
+char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req);
+
+/**
+ * @brief A typedef for a cancel function for a tevent request.
+ *
+ * @param[in]  req      The tevent request calling this function.
+ *
+ * @return              True if the request could be canceled, false if not.
+ */
+typedef bool (*tevent_req_cancel_fn)(struct tevent_req *req);
+
+/**
+ * @brief This function sets a cancel function for the given tevent request.
+ *
+ * This function can be used to setup a cancel function for the given request.
+ * This will be triggered if the tevent_req_cancel() function was
+ * called on the given request.
+ *
+ * @param[in]  req      The request to use.
+ *
+ * @param[in]  fn       A pointer to the cancel function.
+ */
+void tevent_req_set_cancel_fn(struct tevent_req *req, tevent_req_cancel_fn fn);
+
+#ifdef DOXYGEN
+/**
+ * @brief Try to cancel the given tevent request.
+ *
+ * This function can be used to cancel the given request.
+ *
+ * It is only possible to cancel a request when the implementation
+ * has registered a cancel function via the tevent_req_set_cancel_fn().
+ *
+ * @param[in]  req      The request to use.
+ *
+ * @return              This function returns true is the request is cancelable,
+ *                      othererwise false is returned.
+ *
+ * @note Even if the function returns true, the caller need to wait
+ *       for the function to complete normally.
+ *       Only the _recv() function of the given request indicates
+ *       if the request was really canceled.
+ */
+bool tevent_req_cancel(struct tevent_req *req);
+#else
+bool _tevent_req_cancel(struct tevent_req *req, const char *location);
+#define tevent_req_cancel(req) \
+       _tevent_req_cancel(req, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Create an async tevent request.
+ *
+ * The new async request will be initialized in state ASYNC_REQ_IN_PROGRESS.
+ *
+ * @param[in] mem_ctx   The memory context for the result.
+ *
+ * @param[in] pstate    The private state of the request.
+ *
+ * @param[in] state_size  The size of the private state of the request.
+ *
+ * @param[in] type      The name of the request.
+ *
+ * @return              A new async request. NULL on error.
+ */
+struct tevent_req *tevent_req_create(TALLOC_CTX *mem_ctx,
+                                     void *pstate,
+                                     size_t state_size,
+                                     const char *type);
+#else
+struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
+                                     void *pstate,
+                                     size_t state_size,
+                                     const char *type,
+                                     const char *location);
+
+#define tevent_req_create(_mem_ctx, _pstate, _type) \
+       _tevent_req_create((_mem_ctx), (_pstate), sizeof(_type), \
+                          #_type, __location__)
+#endif
+
+/**
+ * @brief Set a timeout for an async request.
+ *
+ * @param[in]  req      The request to set the timeout for.
+ *
+ * @param[in]  ev       The event context to use for the timer.
+ *
+ * @param[in]  endtime  The endtime of the request.
+ *
+ * @return              True if succeeded, false if not.
+ */
+bool tevent_req_set_endtime(struct tevent_req *req,
+                           struct tevent_context *ev,
+                           struct timeval endtime);
+
+#ifdef DOXYGEN
+/**
+ * @brief Call the notify callback of the given tevent request manually.
+ *
+ * @param[in]  req      The tevent request to call the notify function from.
+ *
+ * @see tevent_req_set_callback()
+ */
+void tevent_req_notify_callback(struct tevent_req *req);
+#else
+void _tevent_req_notify_callback(struct tevent_req *req, const char *location);
+#define tevent_req_notify_callback(req)                \
+       _tevent_req_notify_callback(req, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief An async request has successfully finished.
+ *
+ * This function is to be used by implementors of async requests. When a
+ * request is successfully finished, this function calls the user's completion
+ * function.
+ *
+ * @param[in]  req       The finished request.
+ */
+void tevent_req_done(struct tevent_req *req);
+#else
+void _tevent_req_done(struct tevent_req *req,
+                     const char *location);
+#define tevent_req_done(req) \
+       _tevent_req_done(req, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief An async request has seen an error.
+ *
+ * This function is to be used by implementors of async requests. When a
+ * request can not successfully completed, the implementation should call this
+ * function with the appropriate status code.
+ *
+ * If error is 0 the function returns false and does nothing more.
+ *
+ * @param[in]  req      The request with an error.
+ *
+ * @param[in]  error    The error code.
+ *
+ * @return              On success true is returned, false if error is 0.
+ *
+ * @code
+ * int error = first_function();
+ * if (tevent_req_error(req, error)) {
+ *      return;
+ * }
+ *
+ * error = second_function();
+ * if (tevent_req_error(req, error)) {
+ *      return;
+ * }
+ *
+ * tevent_req_done(req);
+ * return;
+ * @endcode
+ */
+bool tevent_req_error(struct tevent_req *req,
+                     uint64_t error);
+#else
+bool _tevent_req_error(struct tevent_req *req,
+                      uint64_t error,
+                      const char *location);
+#define tevent_req_error(req, error) \
+       _tevent_req_error(req, error, __location__)
+#endif
+
+#ifdef DOXYGEN
+/**
+ * @brief Helper function for nomem check.
+ *
+ * Convenience helper to easily check alloc failure within a callback
+ * implementing the next step of an async request.
+ *
+ * @param[in]  p        The pointer to be checked.
+ *
+ * @param[in]  req      The request being processed.
+ *
+ * @code
+ * p = talloc(mem_ctx, bla);
+ * if (tevent_req_nomem(p, req)) {
+ *      return;
+ * }
+ * @endcode
+ */
+bool tevent_req_nomem(const void *p,
+                     struct tevent_req *req);
+#else
+bool _tevent_req_nomem(const void *p,
+                      struct tevent_req *req,
+                      const char *location);
+#define tevent_req_nomem(p, req) \
+       _tevent_req_nomem(p, req, __location__)
+#endif
+
+/**
+ * @brief Finish a request before the caller had the change to set the callback.
+ *
+ * An implementation of an async request might find that it can either finish
+ * the request without waiting for an external event, or it can't even start
+ * the engine. To present the illusion of a callback to the user of the API,
+ * the implementation can call this helper function which triggers an
+ * immediate timed event. This way the caller can use the same calling
+ * conventions, independent of whether the request was actually deferred.
+ *
+ * @param[in]  req      The finished request.
+ *
+ * @param[in]  ev       The tevent_context for the timed event.
+ *
+ * @return              The given request will be returned.
+ */
+struct tevent_req *tevent_req_post(struct tevent_req *req,
+                                  struct tevent_context *ev);
+
+/**
+ * @brief Check if the given request is still in progress.
+ *
+ * It is typically used by sync wrapper functions.
+ *
+ * This function destroys the attached private data.
+ *
+ * @param[in]  req      The request to poll.
+ *
+ * @return              The boolean form of "is in progress".
+ */
+bool tevent_req_is_in_progress(struct tevent_req *req);
+
+/**
+ * @brief Actively poll for the given request to finish.
+ *
+ * This function is typically used by sync wrapper functions.
+ *
+ * @param[in]  req      The request to poll.
+ *
+ * @param[in]  ev       The tevent_context to be used.
+ *
+ * @return              On success true is returned. If a critical error has
+ *                      happened in the tevent loop layer false is returned.
+ *                      This is not the return value of the given request!
+ *
+ * @note This should only be used if the given tevent context was created by the
+ * caller, to avoid event loop nesting.
+ *
+ * @code
+ * req = tstream_writev_queue_send(mem_ctx,
+ *                                 ev_ctx,
+ *                                 tstream,
+ *                                 send_queue,
+ *                                 iov, 2);
+ * ok = tevent_req_poll(req, tctx->ev);
+ * rc = tstream_writev_queue_recv(req, &sys_errno);
+ * TALLOC_FREE(req);
+ * @endcode
+ */
+bool tevent_req_poll(struct tevent_req *req,
+                    struct tevent_context *ev);
+
+/**
+ * @brief Get the tevent request and the actual error code you've set.
+ *
+ * @param[in]  req      The tevent request to get the error from.
+ *
+ * @param[out] state    A pointer to store the tevent request error state.
+ *
+ * @param[out] error    A pointer to store the error set by tevent_req_error().
+ *
+ * @return              True if the function could set error and state, false
+ *                      otherwise.
+ *
+ * @see tevent_req_error()
+ */
+bool tevent_req_is_error(struct tevent_req *req,
+                        enum tevent_req_state *state,
+                        uint64_t *error);
+
+/**
+ * @brief Use as the last action of a _recv() function.
+ *
+ * This function destroys the attached private data.
+ *
+ * @param[in]  req      The finished request.
+ */
+void tevent_req_received(struct tevent_req *req);
+
+/**
+ * @brief Create a tevent subrequest at a given time.
+ *
+ * The idea is that always the same syntax for tevent requests.
+ *
+ * @param[in]  mem_ctx  The talloc memory context to use.
+ *
+ * @param[in]  ev       The event handle to setup the request.
+ *
+ * @param[in]  wakeup_time The time to wakeup and execute the request.
+ *
+ * @return              The new subrequest, NULL on error.
+ *
+ * Example:
+ * @code
+ *   static my_callback_wakeup_done(tevent_req *req)
+ *   {
+ *     struct tevent_req *req = tevent_req_callback_data(subreq,
+ *                              struct tevent_req);
+ *     bool ok;
+ *
+ *     ok = tevent_wakeup_recv(subreq);
+ *     TALLOC_FREE(subreq);
+ *     if (!ok) {
+ *         tevent_req_error(req, -1);
+ *         return;
+ *     }
+ *     ...
+ *   }
+ * @endcode
+ *
+ * @code
+ *   subreq = tevent_wakeup_send(mem_ctx, ev, wakeup_time);
+ *   if (tevent_req_nomem(subreq, req)) {
+ *     return false;
+ *   }
+ *   tevent_set_callback(subreq, my_callback_wakeup_done, req);
+ * @endcode
+ *
+ * @see tevent_wakeup_recv()
+ */
+struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
+                                     struct tevent_context *ev,
+                                     struct timeval wakeup_time);
+
+/**
+ * @brief Check if the wakeup has been correctly executed.
+ *
+ * This function needs to be called in the callback function set after calling
+ * tevent_wakeup_send().
+ *
+ * @param[in]  req      The tevent request to check.
+ *
+ * @return              True on success, false otherwise.
+ *
+ * @see tevent_wakeup_recv()
+ */
+bool tevent_wakeup_recv(struct tevent_req *req);
+
+/* @} */
+
+/**
+ * @defgroup tevent_helpers The tevent helper functiions
+ * @ingroup tevent
+ *
+ * @todo description
+ *
+ * @{
+ */
+
+/**
+ * @brief Compare two timeval values.
+ *
+ * @param[in]  tv1      The first timeval value to compare.
+ *
+ * @param[in]  tv2      The second timeval value to compare.
+ *
+ * @return              0 if they are equal.
+ *                      1 if the first time is greater than the second.
+ *                      -1 if the first time is smaller than the second.
+ */
+int tevent_timeval_compare(const struct timeval *tv1,
+                          const struct timeval *tv2);
+
+/**
+ * @brief Get a zero timval value.
+ *
+ * @return              A zero timval value.
+ */
+struct timeval tevent_timeval_zero(void);
+
+/**
+ * @brief Get a timeval value for the current time.
+ *
+ * @return              A timval value with the current time.
+ */
+struct timeval tevent_timeval_current(void);
+
+/**
+ * @brief Get a timeval structure with the given values.
+ *
+ * @param[in]  secs     The seconds to set.
+ *
+ * @param[in]  usecs    The milliseconds to set.
+ *
+ * @return              A timeval structure with the given values.
+ */
+struct timeval tevent_timeval_set(uint32_t secs, uint32_t usecs);
+
+/**
+ * @brief Get the difference between two timeval values.
+ *
+ * @param[in]  tv1      The first timeval.
+ *
+ * @param[in]  tv2      The second timeval.
+ *
+ * @return              A timeval structure with the difference between the
+ *                      first and the second value.
+ */
+struct timeval tevent_timeval_until(const struct timeval *tv1,
+                                   const struct timeval *tv2);
+
+/**
+ * @brief Check if a given timeval structure is zero.
+ *
+ * @param[in]  tv       The timeval to check if it is zero.
+ *
+ * @return              True if it is zero, false otherwise.
+ */
+bool tevent_timeval_is_zero(const struct timeval *tv);
+
+/**
+ * @brief Add the given amount of time to a timeval structure.
+ *
+ * @param[in]  tv        The timeval structure to add the time.
+ *
+ * @param[in]  secs      The seconds to add to the timeval.
+ *
+ * @param[in]  usecs     The milliseconds to add to the timeval.
+ *
+ * @return               The timeval structure with the new time.
+ */
+struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
+                                 uint32_t usecs);
+
+/**
+ * @brief Get a timeval in the future with a specified offset from now.
+ *
+ * @param[in]  secs     The seconds of the offset from now.
+ *
+ * @param[in]  usecs    The milliseconds of the offset from now.
+ *
+ * @return              A timval with the given offset in the future.
+ */
+struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs);
+
+/* @} */
+
+
+/**
+ * @defgroup tevent_queue The tevent queue functions
+ * @ingroup tevent
+ *
+ * A tevent_queue is used to queue up async requests that must be
+ * serialized. For example writing buffers into a socket must be
+ * serialized. Writing a large lump of data into a socket can require
+ * multiple write(2) or send(2) system calls. If more than one async
+ * request is outstanding to write large buffers into a socket, every
+ * request must individually be completed before the next one begins,
+ * even if multiple syscalls are required.
+ *
+ * Take a look at @ref tevent_queue_tutorial for more details.
+ * @{
+ */
+
+struct tevent_queue;
+
+#ifdef DOXYGEN
+/**
+ * @brief Create and start a tevent queue.
+ *
+ * @param[in]  mem_ctx  The talloc memory context to allocate the queue.
+ *
+ * @param[in]  name     The name to use to identify the queue.
+ *
+ * @return              An allocated tevent queue on success, NULL on error.
+ *
+ * @see tevent_start()
+ * @see tevent_stop()
+ */
+struct tevent_queue *tevent_queue_create(TALLOC_CTX *mem_ctx,
+                                        const char *name);
+#else
+struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
+                                         const char *name,
+                                         const char *location);
+
+#define tevent_queue_create(_mem_ctx, _name) \
+       _tevent_queue_create((_mem_ctx), (_name), __location__)
+#endif
+
+/**
+ * @brief A callback trigger function run by the queue.
+ *
+ * @param[in]  req      The tevent request the trigger function is executed on.
+ *
+ * @param[in]  private_data The private data pointer specified by
+ *                          tevent_queue_add().
+ *
+ * @see tevent_queue_add()
+ */
+typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
+                                         void *private_data);
+
+/**
+ * @brief Add a tevent request to the queue.
+ *
+ * @param[in]  queue    The queue to add the request.
+ *
+ * @param[in]  ev       The event handle to use for the request.
+ *
+ * @param[in]  req      The tevent request to add to the queue.
+ *
+ * @param[in]  trigger  The function triggered by the queue when the request
+ *                      is called.
+ *
+ * @param[in]  private_data The private data passed to the trigger function.
+ *
+ * @return              True if the request has been successfully added, false
+ *                      otherwise.
+ */
+bool tevent_queue_add(struct tevent_queue *queue,
+                     struct tevent_context *ev,
+                     struct tevent_req *req,
+                     tevent_queue_trigger_fn_t trigger,
+                     void *private_data);
+
+/**
+ * @brief Start a tevent queue.
+ *
+ * The queue is started by default.
+ *
+ * @param[in]  queue    The queue to start.
+ */
+void tevent_queue_start(struct tevent_queue *queue);
+
+/**
+ * @brief Stop a tevent queue.
+ *
+ * The queue is started by default.
+ *
+ * @param[in]  queue    The queue to stop.
+ */
+void tevent_queue_stop(struct tevent_queue *queue);
+
+/**
+ * @brief Get the length of the queue.
+ *
+ * @param[in]  queue    The queue to get the length from.
+ *
+ * @return              The number of elements.
+ */
+size_t tevent_queue_length(struct tevent_queue *queue);
+
+typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
+                                  void *private_data,
+                                  uint32_t level,
+                                  bool begin,
+                                  void *stack_ptr,
+                                  const char *location);
+#ifdef TEVENT_DEPRECATED
+#ifndef _DEPRECATED_
+#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
+#define _DEPRECATED_ __attribute__ ((deprecated))
+#else
+#define _DEPRECATED_
+#endif
+#endif
+void tevent_loop_allow_nesting(struct tevent_context *ev) _DEPRECATED_;
+void tevent_loop_set_nesting_hook(struct tevent_context *ev,
+                                 tevent_nesting_hook hook,
+                                 void *private_data) _DEPRECATED_;
+int _tevent_loop_until(struct tevent_context *ev,
+                      bool (*finished)(void *private_data),
+                      void *private_data,
+                      const char *location) _DEPRECATED_;
+#define tevent_loop_until(ev, finished, private_data) \
+       _tevent_loop_until(ev, finished, private_data, __location__)
+#endif
+
+int tevent_re_initialise(struct tevent_context *ev);
+
+/* @} */
+
+/**
+ * @defgroup tevent_ops The tevent operation functions
+ * @ingroup tevent
+ *
+ * The following structure and registration functions are exclusively
+ * needed for people writing and pluggin a different event engine.
+ * There is nothing useful for normal tevent user in here.
+ * @{
+ */
+
+struct tevent_ops {
+       /* context init */
+       int (*context_init)(struct tevent_context *ev);
+
+       /* fd_event functions */
+       struct tevent_fd *(*add_fd)(struct tevent_context *ev,
+                                   TALLOC_CTX *mem_ctx,
+                                   int fd, uint16_t flags,
+                                   tevent_fd_handler_t handler,
+                                   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);
+
+       /* timed_event functions */
+       struct tevent_timer *(*add_timer)(struct tevent_context *ev,
+                                         TALLOC_CTX *mem_ctx,
+                                         struct timeval next_event,
+                                         tevent_timer_handler_t handler,
+                                         void *private_data,
+                                         const char *handler_name,
+                                         const char *location);
+
+       /* immediate event functions */
+       void (*schedule_immediate)(struct tevent_immediate *im,
+                                  struct tevent_context *ev,
+                                  tevent_immediate_handler_t handler,
+                                  void *private_data,
+                                  const char *handler_name,
+                                  const char *location);
+
+       /* signal functions */
+       struct tevent_signal *(*add_signal)(struct tevent_context *ev,
+                                           TALLOC_CTX *mem_ctx,
+                                           int signum, int sa_flags,
+                                           tevent_signal_handler_t handler,
+                                           void *private_data,
+                                           const char *handler_name,
+                                           const char *location);
+
+       /* loop functions */
+       int (*loop_once)(struct tevent_context *ev, const char *location);
+       int (*loop_wait)(struct tevent_context *ev, const char *location);
+};
+
+bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
+
+/* @} */
+
+/**
+ * @defgroup tevent_compat The tevent compatibility functions
+ * @ingroup tevent
+ *
+ * The following definitions are usueful only for compatibility with the
+ * implementation originally developed within the samba4 code and will be
+ * soon removed. Please NEVER use in new code.
+ *
+ * @todo Ignore it?
+ *
+ * @{
+ */
+
+/* Saves ctdb from massive churn. */
+#define TEVENT_COMPAT_DEFINES 1
+#ifdef TEVENT_COMPAT_DEFINES
+
+#define event_context  tevent_context
+#define event_ops      tevent_ops
+#define fd_event       tevent_fd
+#define timed_event    tevent_timer
+#define signal_event   tevent_signal
+
+#define event_fd_handler_t     tevent_fd_handler_t
+#define event_timed_handler_t  tevent_timer_handler_t
+#define event_signal_handler_t tevent_signal_handler_t
+
+#define event_context_init(mem_ctx) \
+       tevent_context_init(mem_ctx)
+
+#define event_context_init_byname(mem_ctx, name) \
+       tevent_context_init_byname(mem_ctx, name)
+
+#define event_backend_list(mem_ctx) \
+       tevent_backend_list(mem_ctx)
+
+#define event_set_default_backend(backend) \
+       tevent_set_default_backend(backend)
+
+#define event_add_fd(ev, mem_ctx, fd, flags, handler, private_data) \
+       tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data)
+
+#define event_add_timed(ev, mem_ctx, next_event, handler, private_data) \
+       tevent_add_timer(ev, mem_ctx, next_event, handler, private_data)
+
+#define event_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data) \
+       tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data)
+
+#define event_loop_once(ev) \
+       tevent_loop_once(ev)
+
+#define event_loop_wait(ev) \
+       tevent_loop_wait(ev)
+
+#define event_get_fd_flags(fde) \
+       tevent_fd_get_flags(fde)
+
+#define event_set_fd_flags(fde, flags) \
+       tevent_fd_set_flags(fde, flags)
+
+#define EVENT_FD_READ          TEVENT_FD_READ
+#define EVENT_FD_WRITE         TEVENT_FD_WRITE
+
+#define EVENT_FD_WRITEABLE(fde) \
+       TEVENT_FD_WRITEABLE(fde)
+
+#define EVENT_FD_READABLE(fde) \
+       TEVENT_FD_READABLE(fde)
+
+#define EVENT_FD_NOT_WRITEABLE(fde) \
+       TEVENT_FD_NOT_WRITEABLE(fde)
+
+#define EVENT_FD_NOT_READABLE(fde) \
+       TEVENT_FD_NOT_READABLE(fde)
+
+#define ev_debug_level         tevent_debug_level
+
+#define EV_DEBUG_FATAL         TEVENT_DEBUG_FATAL
+#define EV_DEBUG_ERROR         TEVENT_DEBUG_ERROR
+#define EV_DEBUG_WARNING       TEVENT_DEBUG_WARNING
+#define EV_DEBUG_TRACE         TEVENT_DEBUG_TRACE
+
+#define ev_set_debug(ev, debug, context) \
+       tevent_set_debug(ev, debug, context)
+
+#define ev_set_debug_stderr(_ev) tevent_set_debug_stderr(ev)
+
+#endif /* TEVENT_COMPAT_DEFINES */
+
+/* @} */
+
+#endif /* __TEVENT_H__ */
diff --git a/ctdb/lib/tevent/tevent.mk b/ctdb/lib/tevent/tevent.mk
new file mode 100644 (file)
index 0000000..57bfd81
--- /dev/null
@@ -0,0 +1,46 @@
+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)
+
+$(TEVENT_SOBASE): $(TEVENT_SOLIB)
+       ln -fs $< $@
+
+$(TEVENT_SONAME): $(TEVENT_SOLIB)
+       ln -fs $< $@
+
+dirs::
+       @mkdir -p lib
+
+installdirs::
+       mkdir -p $(DESTDIR)$(includedir)
+       mkdir -p $(DESTDIR)$(libdir)
+       mkdir -p $(DESTDIR)$(libdir)/pkgconfig
+
+installheaders:: installdirs
+       cp $(srcdir)/tevent.h $(DESTDIR)$(includedir)
+
+installlibs:: installdirs
+       cp tevent.pc $(DESTDIR)$(libdir)/pkgconfig
+       cp $(TEVENT_STLIB) $(TEVENT_SOLIB) $(DESTDIR)$(libdir)
+       rm -f $(DESTDIR)$(libdir)/$(TEVENT_SONAME)
+       ln -s $(TEVENT_SOLIB) $(DESTDIR)$(libdir)/$(TEVENT_SONAME)
+       rm -f $(DESTDIR)$(libdir)/$(TEVENT_SOBASE)
+       ln -s $(TEVENT_SOLIB) $(DESTDIR)$(libdir)/$(TEVENT_SOBASE)
+
+install:: all installdirs installheaders installlibs $(PYTHON_INSTALL_TARGET)
+
+abi_checks::
+       @echo ABI checks:
+       @./script/abi_checks.sh tevent tevent.h
+
+test:: abi_checks
+
+clean::
+       rm -f $(TEVENT_SOBASE) $(TEVENT_SONAME) $(TEVENT_SOLIB) $(TEVENT_STLIB)
+       rm -f tevent.pc
+       rm -f tevent.exports.sort tevent.exports.check tevent.exports.check.sort
+       rm -f tevent.signatures.sort tevent.signatures.check tevent.signatures.check.sort
diff --git a/ctdb/lib/tevent/tevent.pc.in b/ctdb/lib/tevent/tevent.pc.in
new file mode 100644 (file)
index 0000000..9adcffb
--- /dev/null
@@ -0,0 +1,12 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: tevent
+Description: An event system library
+Version: @PACKAGE_VERSION@
+Requires: talloc
+Libs: -L${libdir} -ltevent
+Cflags: -I${includedir}
+URL: http://samba.org/
diff --git a/ctdb/lib/tevent/tevent.signatures b/ctdb/lib/tevent/tevent.signatures
new file mode 100644 (file)
index 0000000..c752b9e
--- /dev/null
@@ -0,0 +1,57 @@
+_Bool tevent_queue_add (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *);
+_Bool tevent_register_backend (const char *, const struct tevent_ops *);
+_Bool _tevent_req_error (struct tevent_req *, uint64_t, const char *);
+_Bool tevent_req_is_error (struct tevent_req *, enum tevent_req_state *, uint64_t *);
+_Bool tevent_req_is_in_progress (struct tevent_req *);
+_Bool _tevent_req_nomem (const void *, struct tevent_req *, const char *);
+_Bool tevent_req_poll (struct tevent_req *, struct tevent_context *);
+_Bool tevent_req_set_endtime (struct tevent_req *, struct tevent_context *, struct timeval);
+_Bool tevent_signal_support (struct tevent_context *);
+_Bool tevent_timeval_is_zero (const struct timeval *);
+_Bool tevent_wakeup_recv (struct tevent_req *);
+char *tevent_req_default_print (struct tevent_req *, TALLOC_CTX *);
+char *tevent_req_print (TALLOC_CTX *, struct tevent_req *);
+const char **tevent_backend_list (TALLOC_CTX *);
+int _tevent_loop_once (struct tevent_context *, const char *);
+int _tevent_loop_until (struct tevent_context *, _Bool (*) (void *), void *, const char *);
+int _tevent_loop_wait (struct tevent_context *, const char *);
+int tevent_set_debug_stderr (struct tevent_context *);
+int tevent_set_debug (struct tevent_context *, void (*) (void *, enum tevent_debug_level, const char *, va_list), void *);
+int tevent_timeval_compare (const struct timeval *, const struct timeval *);
+size_t tevent_queue_length (struct tevent_queue *);
+struct tevent_context *tevent_context_init_byname (TALLOC_CTX *, const char *);
+struct tevent_context *tevent_context_init (TALLOC_CTX *);
+struct tevent_fd *_tevent_add_fd (struct tevent_context *, TALLOC_CTX *, int, uint16_t, tevent_fd_handler_t, void *, const char *, const char *);
+struct tevent_immediate *_tevent_create_immediate (TALLOC_CTX *, const char *);
+struct tevent_queue *_tevent_queue_create (TALLOC_CTX *, const char *, const char *);
+struct tevent_req *_tevent_req_create (TALLOC_CTX *, void *, size_t, const char *, const char *);
+struct tevent_req *tevent_req_post (struct tevent_req *, struct tevent_context *);
+struct tevent_req *tevent_wakeup_send (TALLOC_CTX *, struct tevent_context *, struct timeval);
+struct tevent_signal *_tevent_add_signal (struct tevent_context *, TALLOC_CTX *, int, int, tevent_signal_handler_t, void *, const char *, const char *);
+struct tevent_timer *_tevent_add_timer (struct tevent_context *, TALLOC_CTX *, struct timeval, tevent_timer_handler_t, void *, const char *, const char *);
+struct timeval tevent_timeval_add (const struct timeval *, uint32_t, uint32_t);
+struct timeval tevent_timeval_current_ofs (uint32_t, uint32_t);
+struct timeval tevent_timeval_current (void);
+struct timeval tevent_timeval_set (uint32_t, uint32_t);
+struct timeval tevent_timeval_until (const struct timeval *, const struct timeval *);
+struct timeval tevent_timeval_zero (void);
+uint16_t tevent_fd_get_flags (struct tevent_fd *);
+void tevent_fd_set_auto_close (struct tevent_fd *);
+void tevent_fd_set_close_fn (struct tevent_fd *, tevent_fd_close_fn_t);
+void tevent_fd_set_flags (struct tevent_fd *, uint16_t);
+void tevent_loop_allow_nesting (struct tevent_context *);
+void tevent_loop_set_nesting_hook (struct tevent_context *, tevent_nesting_hook, void *);
+void tevent_queue_start (struct tevent_queue *);
+void tevent_queue_stop (struct tevent_queue *);
+void *_tevent_req_callback_data (struct tevent_req *);
+void *_tevent_req_data (struct tevent_req *);
+void _tevent_req_done (struct tevent_req *, const char *);
+void _tevent_req_notify_callback (struct tevent_req *, const char *);
+void tevent_req_received (struct tevent_req *);
+void tevent_req_set_callback (struct tevent_req *, tevent_req_fn, void *);
+void tevent_req_set_print_fn (struct tevent_req *, tevent_req_print_fn);
+void _tevent_schedule_immediate (struct tevent_immediate *, struct tevent_context *, tevent_immediate_handler_t, void *, const char *, const char *);
+void tevent_set_abort_fn (void (*) (const char *));
+void tevent_set_default_backend (const char *);
+_Bool _tevent_req_cancel (struct tevent_req *, const char *);
+void tevent_req_set_cancel_fn (struct tevent_req *, tevent_req_cancel_fn);
diff --git a/ctdb/lib/tevent/tevent_debug.c b/ctdb/lib/tevent/tevent_debug.c
new file mode 100644 (file)
index 0000000..62dfc8d
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 2005
+   Copyright (C) Jelmer Vernooij 2005
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+
+/********************************************************************
+ * Debug wrapper functions, modeled (with lot's of code copied as is)
+ * after the ev debug wrapper functions
+ ********************************************************************/
+
+/*
+  this allows the user to choose their own debug function
+*/
+int tevent_set_debug(struct tevent_context *ev,
+                    void (*debug)(void *context,
+                                  enum tevent_debug_level level,
+                                  const char *fmt,
+                                  va_list ap) PRINTF_ATTRIBUTE(3,0),
+                    void *context)
+{
+       ev->debug_ops.debug = debug;
+       ev->debug_ops.context = context;
+       return 0;
+}
+
+/*
+  debug function for ev_set_debug_stderr
+*/
+static void tevent_debug_stderr(void *private_data,
+                               enum tevent_debug_level level,
+                               const char *fmt,
+                               va_list ap) PRINTF_ATTRIBUTE(3,0);
+static void tevent_debug_stderr(void *private_data,
+                               enum tevent_debug_level level,
+                               const char *fmt, va_list ap)
+{
+       if (level <= TEVENT_DEBUG_WARNING) {
+               vfprintf(stderr, fmt, ap);
+       }
+}
+
+/*
+  convenience function to setup debug messages on stderr
+  messages of level TEVENT_DEBUG_WARNING and higher are printed
+*/
+int tevent_set_debug_stderr(struct tevent_context *ev)
+{
+       return tevent_set_debug(ev, tevent_debug_stderr, ev);
+}
+
+/*
+ * log a message
+ *
+ * The default debug action is to ignore debugging messages.
+ * This is the most appropriate action for a library.
+ * Applications using the library must decide where to
+ * redirect debugging messages
+*/
+void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level,
+                 const char *fmt, ...)
+{
+       va_list ap;
+       if (!ev) {
+               return;
+       }
+       if (ev->debug_ops.debug == NULL) {
+               return;
+       }
+       va_start(ap, fmt);
+       ev->debug_ops.debug(ev->debug_ops.context, level, fmt, ap);
+       va_end(ap);
+}
similarity index 53%
rename from ctdb/lib/events/events_epoll.c
rename to ctdb/lib/tevent/tevent_epoll.c
index 053ae6117c13f36d3c4a4c9747989cb3edec1c18..3abb0e63e59410bfb22e8220017db737c92daf79 100644 (file)
@@ -1,45 +1,39 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
 
    main select loop and event handling - epoll implementation
 
    Copyright (C) Andrew Tridgell       2003-2005
-   Copyright (C) Stefan Metzmacher     2005
-   
-   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,
+   Copyright (C) Stefan Metzmacher     2005-2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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/>.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "system/time.h"
+#include "replace.h"
 #include "system/filesys.h"
-#include "system/network.h"
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-#include <sys/epoll.h>
-
-extern pid_t ctdbd_pid;
+#include "system/select.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
 
 struct epoll_event_context {
        /* a pointer back to the generic event_context */
-       struct event_context *ev;
-
-       /* list of filedescriptor events */
-       struct fd_event *fd_events;
-
-       /* number of registered fd event handlers */
-       int num_fd_events;
+       struct tevent_context *ev;
 
        /* when using epoll this is the handle from epoll_create */
        int epoll_fd;
@@ -51,22 +45,21 @@ struct epoll_event_context {
   called when a epoll call fails, and we should fallback
   to using select
 */
-static void epoll_fallback_to_select(struct epoll_event_context *epoll_ev, const char *reason)
+static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
 {
-       DEBUG(0,("%s (%s) - falling back to select()\n", reason, strerror(errno)));
-       close(epoll_ev->epoll_fd);
-       epoll_ev->epoll_fd = -1;
-       talloc_set_destructor(epoll_ev, NULL);
+       tevent_debug(epoll_ev->ev, TEVENT_DEBUG_FATAL,
+                "%s (%s) - calling abort()\n", reason, strerror(errno));
+       abort();
 }
 
 /*
-  map from EVENT_FD_* to EPOLLIN/EPOLLOUT
+  map from TEVENT_FD_* to EPOLLIN/EPOLLOUT
 */
 static uint32_t epoll_map_flags(uint16_t flags)
 {
        uint32_t ret = 0;
-       if (flags & EVENT_FD_READ) ret |= (EPOLLIN | EPOLLERR | EPOLLHUP);
-       if (flags & EVENT_FD_WRITE) ret |= (EPOLLOUT | EPOLLERR | EPOLLHUP);
+       if (flags & TEVENT_FD_READ) ret |= (EPOLLIN | EPOLLERR | EPOLLHUP);
+       if (flags & TEVENT_FD_WRITE) ret |= (EPOLLOUT | EPOLLERR | EPOLLHUP);
        return ret;
 }
 
@@ -83,31 +76,27 @@ static int epoll_ctx_destructor(struct epoll_event_context *epoll_ev)
 /*
  init the epoll fd
 */
-static void epoll_init_ctx(struct epoll_event_context *epoll_ev)
+static int epoll_init_ctx(struct epoll_event_context *epoll_ev)
 {
-       unsigned v;
-
        epoll_ev->epoll_fd = epoll_create(64);
-
-       /* on exec, don't inherit the fd */
-       v = fcntl(epoll_ev->epoll_fd, F_GETFD, 0);
-        fcntl(epoll_ev->epoll_fd, F_SETFD, v | FD_CLOEXEC);
-
        epoll_ev->pid = getpid();
        talloc_set_destructor(epoll_ev, epoll_ctx_destructor);
+       if (epoll_ev->epoll_fd == -1) {
+               return -1;
+       }
+       return 0;
 }
 
-static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_event *fde);
+static void epoll_add_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde);
 
 /*
   reopen the epoll handle when our pid changes
-  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an 
+  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
   demonstration of why this is needed
  */
 static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
 {
-       struct fd_event *fde;
-       unsigned v;
+       struct tevent_fd *fde;
 
        if (epoll_ev->pid == getpid()) {
                return;
@@ -116,16 +105,12 @@ static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
        close(epoll_ev->epoll_fd);
        epoll_ev->epoll_fd = epoll_create(64);
        if (epoll_ev->epoll_fd == -1) {
-               DEBUG(0,("Failed to recreate epoll handle after fork\n"));
+               tevent_debug(epoll_ev->ev, TEVENT_DEBUG_FATAL,
+                            "Failed to recreate epoll handle after fork\n");
                return;
        }
-
-       /* on exec, don't inherit the fd */
-       v = fcntl(epoll_ev->epoll_fd, F_GETFD, 0);
-        fcntl(epoll_ev->epoll_fd, F_SETFD, v | FD_CLOEXEC);
-
        epoll_ev->pid = getpid();
-       for (fde=epoll_ev->fd_events;fde;fde=fde->next) {
+       for (fde=epoll_ev->ev->fd_events;fde;fde=fde->next) {
                epoll_add_event(epoll_ev, fde);
        }
 }
@@ -137,7 +122,7 @@ static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
 /*
  add the epoll event to the given fd_event
 */
-static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_event *fde)
+static void epoll_add_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde)
 {
        struct epoll_event event;
 
@@ -152,12 +137,12 @@ static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_even
        event.events = epoll_map_flags(fde->flags);
        event.data.ptr = fde;
        if (epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_ADD, fde->fd, &event) != 0) {
-               epoll_fallback_to_select(epoll_ev, "EPOLL_CTL_ADD failed");
+               epoll_panic(epoll_ev, "EPOLL_CTL_ADD failed");
        }
        fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT;
 
        /* only if we want to read we want to tell the event handler about errors */
-       if (fde->flags & EVENT_FD_READ) {
+       if (fde->flags & TEVENT_FD_READ) {
                fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
        }
 }
@@ -165,12 +150,10 @@ static void epoll_add_event(struct epoll_event_context *epoll_ev, struct fd_even
 /*
  delete the epoll event for given fd_event
 */
-static void epoll_del_event(struct epoll_event_context *epoll_ev, struct fd_event *fde)
+static void epoll_del_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde)
 {
        struct epoll_event event;
 
-       DLIST_REMOVE(epoll_ev->fd_events, fde);
-               
        if (epoll_ev->epoll_fd == -1) return;
 
        fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
@@ -182,7 +165,9 @@ static void epoll_del_event(struct epoll_event_context *epoll_ev, struct fd_even
        event.events = epoll_map_flags(fde->flags);
        event.data.ptr = fde;
        if (epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_DEL, fde->fd, &event) != 0) {
-               DEBUG(0,("epoll_del_event failed! probable early close bug (%s)\n", strerror(errno)));
+               tevent_debug(epoll_ev->ev, TEVENT_DEBUG_FATAL,
+                            "epoll_del_event failed! probable early close bug (%s)\n",
+                            strerror(errno));
        }
        fde->additional_flags &= ~EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT;
 }
@@ -190,7 +175,7 @@ static void epoll_del_event(struct epoll_event_context *epoll_ev, struct fd_even
 /*
  change the epoll event to the given fd_event
 */
-static void epoll_mod_event(struct epoll_event_context *epoll_ev, struct fd_event *fde)
+static void epoll_mod_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde)
 {
        struct epoll_event event;
        if (epoll_ev->epoll_fd == -1) return;
@@ -201,20 +186,20 @@ static void epoll_mod_event(struct epoll_event_context *epoll_ev, struct fd_even
        event.events = epoll_map_flags(fde->flags);
        event.data.ptr = fde;
        if (epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_MOD, fde->fd, &event) != 0) {
-               epoll_fallback_to_select(epoll_ev, "EPOLL_CTL_MOD failed");
+               epoll_panic(epoll_ev, "EPOLL_CTL_MOD failed");
        }
 
        /* only if we want to read we want to tell the event handler about errors */
-       if (fde->flags & EVENT_FD_READ) {
+       if (fde->flags & TEVENT_FD_READ) {
                fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
        }
 }
 
-static void epoll_change_event(struct epoll_event_context *epoll_ev, struct fd_event *fde)
+static void epoll_change_event(struct epoll_event_context *epoll_ev, struct tevent_fd *fde)
 {
        bool got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
-       bool want_read = (fde->flags & EVENT_FD_READ);
-       bool want_write= (fde->flags & EVENT_FD_WRITE);
+       bool want_read = (fde->flags & TEVENT_FD_READ);
+       bool want_write= (fde->flags & TEVENT_FD_WRITE);
 
        if (epoll_ev->epoll_fd == -1) return;
 
@@ -226,7 +211,7 @@ static void epoll_change_event(struct epoll_event_context *epoll_ev, struct fd_e
                        epoll_mod_event(epoll_ev, fde);
                        return;
                }
-               /* 
+               /*
                 * if we want to match the select behavior, we need to remove the epoll_event
                 * when the caller isn't interested in events.
                 *
@@ -238,7 +223,6 @@ static void epoll_change_event(struct epoll_event_context *epoll_ev, struct fd_e
 
        /* there's no epoll_event attached to the fde */
        if (want_read || (want_write && !got_error)) {
-               DLIST_ADD(epoll_ev->fd_events, fde);
                epoll_add_event(epoll_ev, fde);
                return;
        }
@@ -250,7 +234,7 @@ static void epoll_change_event(struct epoll_event_context *epoll_ev, struct fd_e
 static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval *tvalp)
 {
        int ret, i;
-#define MAXEVENTS 32
+#define MAXEVENTS 1
        struct epoll_event events[MAXEVENTS];
        int timeout = -1;
 
@@ -261,43 +245,43 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
                timeout = ((tvalp->tv_usec+999) / 1000) + (tvalp->tv_sec*1000);
        }
 
-       if (epoll_ev->ev->num_signal_handlers && 
-           common_event_check_signal(epoll_ev->ev)) {
+       if (epoll_ev->ev->signal_events &&
+           tevent_common_check_signal(epoll_ev->ev)) {
                return 0;
        }
 
        ret = epoll_wait(epoll_ev->epoll_fd, events, MAXEVENTS, timeout);
 
-       if (ret == -1 && errno == EINTR && epoll_ev->ev->num_signal_handlers) {
-               if (common_event_check_signal(epoll_ev->ev)) {
+       if (ret == -1 && errno == EINTR && epoll_ev->ev->signal_events) {
+               if (tevent_common_check_signal(epoll_ev->ev)) {
                        return 0;
                }
        }
 
        if (ret == -1 && errno != EINTR) {
-               epoll_fallback_to_select(epoll_ev, "epoll_wait() failed");
+               epoll_panic(epoll_ev, "epoll_wait() failed");
                return -1;
        }
 
        if (ret == 0 && tvalp) {
                /* we don't care about a possible delay here */
-               common_event_loop_timer_delay(epoll_ev->ev);
+               tevent_common_loop_timer_delay(epoll_ev->ev);
                return 0;
        }
 
        for (i=0;i<ret;i++) {
-               struct fd_event *fde = talloc_get_type(events[i].data.ptr, 
-                                                      struct fd_event);
+               struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
+                                                      struct tevent_fd);
                uint16_t flags = 0;
 
                if (fde == NULL) {
-                       epoll_fallback_to_select(epoll_ev, "epoll_wait() gave bad data");
+                       epoll_panic(epoll_ev, "epoll_wait() gave bad data");
                        return -1;
                }
                if (events[i].events & (EPOLLHUP|EPOLLERR)) {
                        fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR;
                        /*
-                        * if we only wait for EVENT_FD_WRITE, we should not tell the
+                        * if we only wait for TEVENT_FD_WRITE, we should not tell the
                         * event handler about it, and remove the epoll_event,
                         * as we only report errors when waiting for read events,
                         * to match the select() behavior
@@ -306,10 +290,10 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
                                epoll_del_event(epoll_ev, fde);
                                continue;
                        }
-                       flags |= EVENT_FD_READ;
+                       flags |= TEVENT_FD_READ;
                }
-               if (events[i].events & EPOLLIN) flags |= EVENT_FD_READ;
-               if (events[i].events & EPOLLOUT) flags |= EVENT_FD_WRITE;
+               if (events[i].events & EPOLLIN) flags |= TEVENT_FD_READ;
+               if (events[i].events & EPOLLOUT) flags |= TEVENT_FD_WRITE;
                if (flags) {
                        fde->handler(epoll_ev->ev, fde, flags, fde->private_data);
                        break;
@@ -322,8 +306,9 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
 /*
   create a epoll_event_context structure.
 */
-static int epoll_event_context_init(struct event_context *ev)
+static int epoll_event_context_init(struct tevent_context *ev)
 {
+       int ret;
        struct epoll_event_context *epoll_ev;
 
        epoll_ev = talloc_zero(ev, struct epoll_event_context);
@@ -331,7 +316,11 @@ static int epoll_event_context_init(struct event_context *ev)
        epoll_ev->ev = ev;
        epoll_ev->epoll_fd = -1;
 
-       epoll_init_ctx(epoll_ev);
+       ret = epoll_init_ctx(epoll_ev);
+       if (ret != 0) {
+               talloc_free(epoll_ev);
+               return ret;
+       }
 
        ev->additional_data = epoll_ev;
        return 0;
@@ -340,76 +329,58 @@ static int epoll_event_context_init(struct event_context *ev)
 /*
   destroy an fd_event
 */
-static int epoll_event_fd_destructor(struct fd_event *fde)
+static int epoll_event_fd_destructor(struct tevent_fd *fde)
 {
-       struct event_context *ev = fde->event_ctx;
-       struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
-                                                          struct epoll_event_context);
+       struct tevent_context *ev = fde->event_ctx;
+       struct epoll_event_context *epoll_ev = NULL;
 
-       epoll_check_reopen(epoll_ev);
-
-       epoll_ev->num_fd_events--;
+       if (ev) {
+               epoll_ev = talloc_get_type(ev->additional_data,
+                                          struct epoll_event_context);
 
-       epoll_del_event(epoll_ev, fde);
+               epoll_check_reopen(epoll_ev);
 
-       if (fde->flags & EVENT_FD_AUTOCLOSE) {
-               close(fde->fd);
-               fde->fd = -1;
+               epoll_del_event(epoll_ev, fde);
        }
 
-       return 0;
+       return tevent_common_fd_destructor(fde);
 }
 
 /*
   add a fd based event
   return NULL on failure (memory allocation error)
 */
-static struct fd_event *epoll_event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                        int fd, uint16_t flags,
-                                        event_fd_handler_t handler,
-                                        void *private_data)
+static struct tevent_fd *epoll_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+                                           int fd, uint16_t flags,
+                                           tevent_fd_handler_t handler,
+                                           void *private_data,
+                                           const char *handler_name,
+                                           const char *location)
 {
        struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
                                                           struct epoll_event_context);
-       struct fd_event *fde;
+       struct tevent_fd *fde;
 
        epoll_check_reopen(epoll_ev);
 
-       fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event);
+       fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
+                                  handler, private_data,
+                                  handler_name, location);
        if (!fde) return NULL;
 
-       fde->event_ctx          = ev;
-       fde->fd                 = fd;
-       fde->flags              = flags;
-       fde->handler            = handler;
-       fde->private_data       = private_data;
-       fde->additional_flags   = 0;
-       fde->additional_data    = NULL;
-
-       epoll_ev->num_fd_events++;
        talloc_set_destructor(fde, epoll_event_fd_destructor);
 
-       DLIST_ADD(epoll_ev->fd_events, fde);
        epoll_add_event(epoll_ev, fde);
 
        return fde;
 }
 
-
-/*
-  return the fd event flags
-*/
-static uint16_t epoll_event_get_fd_flags(struct fd_event *fde)
-{
-       return fde->flags;
-}
-
 /*
   set the fd event flags
 */
-static void epoll_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
+static void epoll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 {
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct epoll_event_context *epoll_ev;
 
        if (fde->flags == flags) return;
@@ -425,77 +396,48 @@ static void epoll_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
 }
 
 /*
-  do a single event loop using the events defined in ev 
+  do a single event loop using the events defined in ev
 */
-static int epoll_event_loop_once(struct event_context *ev)
+static int epoll_event_loop_once(struct tevent_context *ev, const char *location)
 {
        struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
-                                                          struct epoll_event_context);
+                                                          struct epoll_event_context);
        struct timeval tval;
 
-       tval = common_event_loop_timer_delay(ev);
-       if (timeval_is_zero(&tval)) {
+       if (ev->signal_events &&
+           tevent_common_check_signal(ev)) {
                return 0;
        }
 
-       epoll_check_reopen(epoll_ev);
-
-       return epoll_event_loop(epoll_ev, &tval);
-}
+       if (ev->immediate_events &&
+           tevent_common_loop_immediate(ev)) {
+               return 0;
+       }
 
-/*
-  return on failure or (with 0) if all fd events are removed
-*/
-static int epoll_event_loop_wait(struct event_context *ev)
-{
-       static time_t t=0;
-       time_t new_t;
-       struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
-                                                          struct epoll_event_context);
-       while (epoll_ev->num_fd_events) {
-               if (epoll_event_loop_once(ev) != 0) {
-                       break;
-               }
-               if (getpid() == ctdbd_pid) {
-                       new_t=time(NULL);
-                       if (t != 0) {
-                               if (t > new_t) {
-                                       DEBUG(0,(__location__ " ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
-                               }
-                               /* We assume here that we get at least one event every 5 seconds */
-                               if (new_t > (t+5)) {
-                                       DEBUG(0,(__location__ " ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
-                               }
-                       }
-                       t=new_t;
-               }
+       tval = tevent_common_loop_timer_delay(ev);
+       if (tevent_timeval_is_zero(&tval)) {
+               return 0;
        }
 
-       return 0;
+       epoll_check_reopen(epoll_ev);
+
+       return epoll_event_loop(epoll_ev, &tval);
 }
 
-static const struct event_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_flags   = epoll_event_set_fd_flags,
-       .add_timed      = common_event_add_timed,
-       .add_signal     = common_event_add_signal,
-       .loop_once      = epoll_event_loop_once,
-       .loop_wait      = epoll_event_loop_wait,
+static const struct tevent_ops epoll_event_ops = {
+       .context_init           = epoll_event_context_init,
+       .add_fd                 = epoll_event_add_fd,
+       .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,
+       .schedule_immediate     = tevent_common_schedule_immediate,
+       .add_signal             = tevent_common_add_signal,
+       .loop_once              = epoll_event_loop_once,
+       .loop_wait              = tevent_common_loop_wait,
 };
 
-bool events_epoll_init(void)
+_PRIVATE_ bool tevent_epoll_init(void)
 {
-       return event_register_backend("epoll", &epoll_event_ops);
-}
-
-#if _SAMBA_BUILD_
-NTSTATUS s4_events_epoll_init(void)
-{
-       if (!events_epoll_init()) {
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-       return NT_STATUS_OK;
+       return tevent_register_backend("epoll", &epoll_event_ops);
 }
-#endif
diff --git a/ctdb/lib/tevent/tevent_fd.c b/ctdb/lib/tevent/tevent_fd.c
new file mode 100644 (file)
index 0000000..c58e8e1
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   common events code for fd events
+
+   Copyright (C) Stefan Metzmacher 2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+int tevent_common_fd_destructor(struct tevent_fd *fde)
+{
+       if (fde->event_ctx) {
+               DLIST_REMOVE(fde->event_ctx->fd_events, fde);
+       }
+
+       if (fde->close_fn) {
+               fde->close_fn(fde->event_ctx, fde, fde->fd, fde->private_data);
+               fde->fd = -1;
+       }
+
+       return 0;
+}
+
+struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+                                      int fd, uint16_t flags,
+                                      tevent_fd_handler_t handler,
+                                      void *private_data,
+                                      const char *handler_name,
+                                      const char *location)
+{
+       struct tevent_fd *fde;
+
+       fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd);
+       if (!fde) return NULL;
+
+       fde->event_ctx          = ev;
+       fde->fd                 = fd;
+       fde->flags              = flags;
+       fde->handler            = handler;
+       fde->close_fn           = NULL;
+       fde->private_data       = private_data;
+       fde->handler_name       = handler_name;
+       fde->location           = location;
+       fde->additional_flags   = 0;
+       fde->additional_data    = NULL;
+
+       DLIST_ADD(ev->fd_events, fde);
+
+       talloc_set_destructor(fde, tevent_common_fd_destructor);
+
+       return fde;
+}
+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;
+}
+
+void tevent_common_fd_set_close_fn(struct tevent_fd *fde,
+                                  tevent_fd_close_fn_t close_fn)
+{
+       fde->close_fn = close_fn;
+}
diff --git a/ctdb/lib/tevent/tevent_immediate.c b/ctdb/lib/tevent/tevent_immediate.c
new file mode 100644 (file)
index 0000000..d5e7688
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   common events code for immediate events
+
+   Copyright (C) Stefan Metzmacher 2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+static void tevent_common_immediate_cancel(struct tevent_immediate *im)
+{
+       if (!im->event_ctx) {
+               return;
+       }
+
+       tevent_debug(im->event_ctx, TEVENT_DEBUG_TRACE,
+                    "Cancel immediate event %p \"%s\"\n",
+                    im, im->handler_name);
+
+       /* let the backend free im->additional_data */
+       if (im->cancel_fn) {
+               im->cancel_fn(im);
+       }
+
+       DLIST_REMOVE(im->event_ctx->immediate_events, im);
+       im->event_ctx           = NULL;
+       im->handler             = NULL;
+       im->private_data        = NULL;
+       im->handler_name        = NULL;
+       im->schedule_location   = NULL;
+       im->cancel_fn           = NULL;
+       im->additional_data     = NULL;
+
+       talloc_set_destructor(im, NULL);
+}
+
+/*
+  destroy an immediate event
+*/
+static int tevent_common_immediate_destructor(struct tevent_immediate *im)
+{
+       tevent_common_immediate_cancel(im);
+       return 0;
+}
+
+/*
+ * schedule an immediate event on
+ */
+void tevent_common_schedule_immediate(struct tevent_immediate *im,
+                                     struct tevent_context *ev,
+                                     tevent_immediate_handler_t handler,
+                                     void *private_data,
+                                     const char *handler_name,
+                                     const char *location)
+{
+       tevent_common_immediate_cancel(im);
+
+       if (!handler) {
+               return;
+       }
+
+       im->event_ctx           = ev;
+       im->handler             = handler;
+       im->private_data        = private_data;
+       im->handler_name        = handler_name;
+       im->schedule_location   = location;
+       im->cancel_fn           = NULL;
+       im->additional_data     = NULL;
+
+       DLIST_ADD_END(ev->immediate_events, im, struct tevent_immediate *);
+       talloc_set_destructor(im, tevent_common_immediate_destructor);
+
+       tevent_debug(ev, TEVENT_DEBUG_TRACE,
+                    "Schedule immediate event \"%s\": %p\n",
+                    handler_name, im);
+}
+
+/*
+  trigger the first immediate event and return true
+  if no event was triggered return false
+*/
+bool tevent_common_loop_immediate(struct tevent_context *ev)
+{
+       struct tevent_immediate *im = ev->immediate_events;
+       tevent_immediate_handler_t handler;
+       void *private_data;
+
+       if (!im) {
+               return false;
+       }
+
+       tevent_debug(ev, TEVENT_DEBUG_TRACE,
+                    "Run immediate event \"%s\": %p\n",
+                    im->handler_name, im);
+
+       /*
+        * remember the handler and then clear the event
+        * the handler might reschedule the event
+        */
+       handler = im->handler;
+       private_data = im->private_data;
+
+       DLIST_REMOVE(im->event_ctx->immediate_events, im);
+       im->event_ctx           = NULL;
+       im->handler             = NULL;
+       im->private_data        = NULL;
+       im->handler_name        = NULL;
+       im->schedule_location   = NULL;
+       im->cancel_fn           = NULL;
+       im->additional_data     = NULL;
+
+       talloc_set_destructor(im, NULL);
+
+       handler(ev, im, private_data);
+
+       return true;
+}
diff --git a/ctdb/lib/tevent/tevent_internal.h b/ctdb/lib/tevent/tevent_internal.h
new file mode 100644 (file)
index 0000000..ba03bc5
--- /dev/null
@@ -0,0 +1,308 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   generalised event loop handling
+
+   INTERNAL STRUCTS. THERE ARE NO API GUARANTEES.
+   External users should only ever have to include this header when
+   implementing new tevent backends.
+
+   Copyright (C) Stefan Metzmacher 2005-2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+struct tevent_req {
+       /**
+        * @brief What to do on completion
+        *
+        * This is used for the user of an async request, fn is called when
+        * the request completes, either successfully or with an error.
+        */
+       struct {
+               /**
+                * @brief Completion function
+                * Completion function, to be filled by the API user
+                */
+               tevent_req_fn fn;
+               /**
+                * @brief Private data for the completion function
+                */
+               void *private_data;
+       } async;
+
+       /**
+        * @brief Private state pointer for the actual implementation
+        *
+        * The implementation doing the work for the async request needs to
+        * keep around current data like for example a fd event. The user of
+        * an async request should not touch this.
+        */
+       void *data;
+
+       /**
+        * @brief A function to overwrite the default print function
+        *
+        * The implementation doing the work may want to implement a
+        * custom function to print the text representation of the async
+        * request.
+        */
+       tevent_req_print_fn private_print;
+
+       /**
+        * @brief A function to cancel the request
+        *
+        * The implementation might want to set a function
+        * that is called when the tevent_req_cancel() function
+        * was called.
+        */
+       tevent_req_cancel_fn private_cancel;
+
+       /**
+        * @brief Internal state of the request
+        *
+        * Callers should only access this via functions and never directly.
+        */
+       struct {
+               /**
+                * @brief The talloc type of the data pointer
+                *
+                * This is filled by the tevent_req_create() macro.
+                *
+                * This for debugging only.
+                */
+               const char *private_type;
+
+               /**
+                * @brief The location where the request was created
+                *
+                * This uses the __location__ macro via the tevent_req_create()
+                * macro.
+                *
+                * This for debugging only.
+                */
+               const char *create_location;
+
+               /**
+                * @brief The location where the request was finished
+                *
+                * This uses the __location__ macro via the tevent_req_done(),
+                * tevent_req_error() or tevent_req_nomem() macro.
+                *
+                * This for debugging only.
+                */
+               const char *finish_location;
+
+               /**
+                * @brief The location where the request was canceled
+                *
+                * This uses the __location__ macro via the
+                * tevent_req_cancel() macro.
+                *
+                * This for debugging only.
+                */
+               const char *cancel_location;
+
+               /**
+                * @brief The external state - will be queried by the caller
+                *
+                * While the async request is being processed, state will remain in
+                * TEVENT_REQ_IN_PROGRESS. A request is finished if
+                * req->state>=TEVENT_REQ_DONE.
+                */
+               enum tevent_req_state state;
+
+               /**
+                * @brief status code when finished
+                *
+                * This status can be queried in the async completion function. It
+                * will be set to 0 when everything went fine.
+                */
+               uint64_t error;
+
+               /**
+                * @brief the immediate event used by tevent_req_post
+                *
+                */
+               struct tevent_immediate *trigger;
+
+               /**
+                * @brief the timer event if tevent_req_set_endtime was used
+                *
+                */
+               struct tevent_timer *timer;
+       } internal;
+};
+
+struct tevent_fd {
+       struct tevent_fd *prev, *next;
+       struct tevent_context *event_ctx;
+       int fd;
+       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! */
+       const char *handler_name;
+       const char *location;
+       /* this is private for the events_ops implementation */
+       uint16_t additional_flags;
+       void *additional_data;
+};
+
+struct tevent_timer {
+       struct tevent_timer *prev, *next;
+       struct tevent_context *event_ctx;
+       struct timeval next_event;
+       tevent_timer_handler_t handler;
+       /* this is private for the specific handler */
+       void *private_data;
+       /* this is for debugging only! */
+       const char *handler_name;
+       const char *location;
+       /* this is private for the events_ops implementation */
+       void *additional_data;
+};
+
+struct tevent_immediate {
+       struct tevent_immediate *prev, *next;
+       struct tevent_context *event_ctx;
+       tevent_immediate_handler_t handler;
+       /* this is private for the specific handler */
+       void *private_data;
+       /* this is for debugging only! */
+       const char *handler_name;
+       const char *create_location;
+       const char *schedule_location;
+       /* this is private for the events_ops implementation */
+       void (*cancel_fn)(struct tevent_immediate *im);
+       void *additional_data;
+};
+
+struct tevent_signal {
+       struct tevent_signal *prev, *next;
+       struct tevent_context *event_ctx;
+       int signum;
+       int sa_flags;
+       tevent_signal_handler_t handler;
+       /* this is private for the specific handler */
+       void *private_data;
+       /* this is for debugging only! */
+       const char *handler_name;
+       const char *location;
+       /* this is private for the events_ops implementation */
+       void *additional_data;
+};
+
+struct tevent_debug_ops {
+       void (*debug)(void *context, enum tevent_debug_level level,
+                     const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0);
+       void *context;
+};
+
+void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level,
+                 const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
+
+struct tevent_context {
+       /* the specific events implementation */
+       const struct tevent_ops *ops;
+
+       /* list of fd events - used by common code */
+       struct tevent_fd *fd_events;
+
+       /* list of timed events - used by common code */
+       struct tevent_timer *timer_events;
+
+       /* list of immediate events - used by common code */
+       struct tevent_immediate *immediate_events;
+
+       /* list of signal events - used by common code */
+       struct tevent_signal *signal_events;
+
+       /* this is private for the events_ops implementation */
+       void *additional_data;
+
+       /* pipe hack used with signal handlers */
+       struct tevent_fd *pipe_fde;
+       int pipe_fds[2];
+
+       /* debugging operations */
+       struct tevent_debug_ops debug_ops;
+
+       /* info about the nesting status */
+       struct {
+               bool allowed;
+               uint32_t level;
+               tevent_nesting_hook hook_fn;
+               void *hook_private;
+       } nesting;
+};
+
+
+int tevent_common_context_destructor(struct tevent_context *ev);
+int tevent_common_loop_wait(struct tevent_context *ev,
+                           const char *location);
+
+int tevent_common_fd_destructor(struct tevent_fd *fde);
+struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev,
+                                      TALLOC_CTX *mem_ctx,
+                                      int fd,
+                                      uint16_t flags,
+                                      tevent_fd_handler_t handler,
+                                      void *private_data,
+                                      const char *handler_name,
+                                      const char *location);
+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);
+
+struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
+                                            TALLOC_CTX *mem_ctx,
+                                            struct timeval next_event,
+                                            tevent_timer_handler_t handler,
+                                            void *private_data,
+                                            const char *handler_name,
+                                            const char *location);
+struct timeval tevent_common_loop_timer_delay(struct tevent_context *);
+
+void tevent_common_schedule_immediate(struct tevent_immediate *im,
+                                     struct tevent_context *ev,
+                                     tevent_immediate_handler_t handler,
+                                     void *private_data,
+                                     const char *handler_name,
+                                     const char *location);
+bool tevent_common_loop_immediate(struct tevent_context *ev);
+
+struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
+                                              TALLOC_CTX *mem_ctx,
+                                              int signum,
+                                              int sa_flags,
+                                              tevent_signal_handler_t handler,
+                                              void *private_data,
+                                              const char *handler_name,
+                                              const char *location);
+int tevent_common_check_signal(struct tevent_context *ev);
+void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se);
+
+bool tevent_standard_init(void);
+bool tevent_select_init(void);
+#ifdef HAVE_EPOLL
+bool tevent_epoll_init(void);
+#endif
similarity index 67%
rename from ctdb/lib/events/events_liboop.c
rename to ctdb/lib/tevent/tevent_liboop.c
index 946c3888c165ac0cb3e677d8cfcb6df1b90599cc..c8af5ab07626c6d1d95cfb209cdf3dccd20b99ab 100644 (file)
@@ -1,40 +1,43 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    main select loop and event handling
    wrapper for http://liboop.org/
 
    Copyright (C) Stefan Metzmacher 2005
-   
-   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,
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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/>.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "includes.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
+#include "events.h"
+#include "events_internal.h"
 
 #include <oop.h>
 
 /*
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 
- NOTE: this code compiles fine, but is completly *UNTESTED*
-       and is only commited as example
+ NOTE: this code compiles fine, but is completely *UNTESTED*
+       and is only committed as an example
 
- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 */
 
-static int oop_event_context_destructor(struct event_context *ev)
+static int oop_event_context_destructor(struct tevent_context *ev)
 {
        oop_source_sys *oop_sys = ev->additional_data;
 
@@ -46,7 +49,7 @@ static int oop_event_context_destructor(struct event_context *ev)
 /*
   create a oop_event_context structure.
 */
-static int oop_event_context_init(struct event_context *ev, void *private_data)
+static int oop_event_context_init(struct tevent_context *ev, void *private_data)
 {
        oop_source_sys *oop_sys = private_data;
 
@@ -66,7 +69,7 @@ static int oop_event_context_init(struct event_context *ev, void *private_data)
 
 static void *oop_event_fd_handler(oop_source *oop, int fd, oop_event oop_type, void *ptr)
 {
-       struct fd_event *fde = ptr;
+       struct tevent_fd *fde = ptr;
 
        if (fd != fde->fd) return OOP_ERROR;
 
@@ -76,7 +79,7 @@ static void *oop_event_fd_handler(oop_source *oop, int fd, oop_event oop_type, v
                        return OOP_CONTINUE;
                case OOP_WRITE:
                        fde->handler(fde->event_ctx, fde, EVENT_FD_WRITE, fde->private_data);
-                       return OOP_CONTINUE;                    
+                       return OOP_CONTINUE;
                case OOP_EXCEPTION:
                        return OOP_ERROR;
                case OOP_NUM_EVENTS:
@@ -89,9 +92,9 @@ static void *oop_event_fd_handler(oop_source *oop, int fd, oop_event oop_type, v
 /*
   destroy an fd_event
 */
-static int oop_event_fd_destructor(struct fd_event *fde)
+static int oop_event_fd_destructor(struct tevent_fd *fde)
 {
-       struct event_context *ev = fde->event_ctx;
+       struct tevent_context *ev = fde->event_ctx;
        oop_source_sys *oop_sys = ev->additional_data;
        oop_source *oop = oop_sys_source(oop_sys);
 
@@ -112,16 +115,16 @@ static int oop_event_fd_destructor(struct fd_event *fde)
   add a fd based event
   return NULL on failure (memory allocation error)
 */
-static struct fd_event *oop_event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
+static struct tevent_fd *oop_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
                                         int fd, uint16_t flags,
                                         event_fd_handler_t handler,
                                         void *private_data)
 {
-       struct fd_event *fde;
+       struct tevent_fd *fde;
        oop_source_sys *oop_sys = ev->additional_data;
        oop_source *oop = oop_sys_source(oop_sys);
-       
-       fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event);
+
+       fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd);
        if (!fde) return NULL;
 
        fde->event_ctx          = ev;
@@ -145,7 +148,7 @@ static struct fd_event *oop_event_add_fd(struct event_context *ev, TALLOC_CTX *m
 /*
   return the fd event flags
 */
-static uint16_t oop_event_get_fd_flags(struct fd_event *fde)
+static uint16_t oop_event_get_fd_flags(struct tevent_fd *fde)
 {
        return fde->flags;
 }
@@ -153,7 +156,7 @@ static uint16_t oop_event_get_fd_flags(struct fd_event *fde)
 /*
   set the fd event flags
 */
-static void oop_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
+static void oop_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 {
        oop_source_sys *oop_sys;
        oop_source *oop;
@@ -176,16 +179,16 @@ static void oop_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
        fde->flags = flags;
 }
 
-static int oop_event_timed_destructor(struct timed_event *te);
+static int oop_event_timed_destructor(struct tevent_timer *te);
 
-static int oop_event_timed_deny_destructor(struct timed_event *te)
+static int oop_event_timed_deny_destructor(struct tevent_timer *te)
 {
        return -1;
 }
 
 static void *oop_event_timed_handler(oop_source *oop, struct timeval t, void *ptr)
 {
-       struct timed_event *te = ptr;
+       struct tevent_timer *te = ptr;
 
        /* deny the handler to free the event */
        talloc_set_destructor(te, oop_event_timed_deny_destructor);
@@ -200,9 +203,9 @@ static void *oop_event_timed_handler(oop_source *oop, struct timeval t, void *pt
 /*
   destroy a timed event
 */
-static int oop_event_timed_destructor(struct timed_event *te)
+static int oop_event_timed_destructor(struct tevent_timer *te)
 {
-       struct event_context *ev = te->event_ctx;
+       struct tevent_context *ev = te->event_ctx;
        oop_source_sys *oop_sys = ev->additional_data;
        oop_source *oop = oop_sys_source(oop_sys);
 
@@ -215,16 +218,16 @@ static int oop_event_timed_destructor(struct timed_event *te)
   add a timed event
   return NULL on failure (memory allocation error)
 */
-static struct timed_event *oop_event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                              struct timeval next_event, 
-                                              event_timed_handler_t handler, 
-                                              void *private_data) 
+static struct tevent_timer *oop_event_add_timed(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+                                              struct timeval next_event,
+                                              event_timed_handler_t handler,
+                                              void *private_data)
 {
        oop_source_sys *oop_sys = ev->additional_data;
        oop_source *oop = oop_sys_source(oop_sys);
-       struct timed_event *te;
+       struct tevent_timer *te;
 
-       te = talloc(mem_ctx?mem_ctx:ev, struct timed_event);
+       te = talloc(mem_ctx?mem_ctx:ev, struct tevent_timer);
        if (te == NULL) return NULL;
 
        te->event_ctx           = ev;
@@ -241,9 +244,9 @@ static struct timed_event *oop_event_add_timed(struct event_context *ev, TALLOC_
 }
 
 /*
-  do a single event loop using the events defined in ev 
+  do a single event loop using the events defined in ev
 */
-static int oop_event_loop_once(struct event_context *ev)
+static int oop_event_loop_once(struct tevent_context *ev)
 {
        void *oop_ret;
        oop_source_sys *oop_sys = ev->additional_data;
@@ -259,7 +262,7 @@ static int oop_event_loop_once(struct event_context *ev)
 /*
   return on failure or (with 0) if all fd events are removed
 */
-static int oop_event_loop_wait(struct event_context *ev)
+static int oop_event_loop_wait(struct tevent_context *ev)
 {
        void *oop_ret;
        oop_source_sys *oop_sys = ev->additional_data;
@@ -277,7 +280,7 @@ static const struct event_ops event_oop_ops = {
        .add_fd         = oop_event_add_fd,
        .get_fd_flags   = oop_event_get_fd_flags,
        .set_fd_flags   = oop_event_set_fd_flags,
-       .add_timed      = oop_event_add_timed,
+       .add_timer      = oop_event_add_timed,
        .add_signal     = common_event_add_signal,
        .loop_once      = oop_event_loop_once,
        .loop_wait      = oop_event_loop_wait,
diff --git a/ctdb/lib/tevent/tevent_queue.c b/ctdb/lib/tevent/tevent_queue.c
new file mode 100644 (file)
index 0000000..3715c35
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+   Unix SMB/CIFS implementation.
+   Infrastructure for async requests
+   Copyright (C) Volker Lendecke 2008
+   Copyright (C) Stefan Metzmacher 2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+struct tevent_queue_entry {
+       struct tevent_queue_entry *prev, *next;
+       struct tevent_queue *queue;
+
+       bool triggered;
+
+       struct tevent_req *req;
+       struct tevent_context *ev;
+
+       tevent_queue_trigger_fn_t trigger;
+       void *private_data;
+};
+
+struct tevent_queue {
+       const char *name;
+       const char *location;
+
+       bool running;
+       struct tevent_immediate *immediate;
+
+       size_t length;
+       struct tevent_queue_entry *list;
+};
+
+static void tevent_queue_immediate_trigger(struct tevent_context *ev,
+                                          struct tevent_immediate *im,
+                                          void *private_data);
+
+static int tevent_queue_entry_destructor(struct tevent_queue_entry *e)
+{
+       struct tevent_queue *q = e->queue;
+
+       if (!q) {
+               return 0;
+       }
+
+       DLIST_REMOVE(q->list, e);
+       q->length--;
+
+       if (!q->running) {
+               return 0;
+       }
+
+       if (!q->list) {
+               return 0;
+       }
+
+       if (q->list->triggered) {
+               return 0;
+       }
+
+       tevent_schedule_immediate(q->immediate,
+                                 q->list->ev,
+                                 tevent_queue_immediate_trigger,
+                                 q);
+
+       return 0;
+}
+
+static int tevent_queue_destructor(struct tevent_queue *q)
+{
+       q->running = false;
+
+       while (q->list) {
+               struct tevent_queue_entry *e = q->list;
+               talloc_free(e);
+       }
+
+       return 0;
+}
+
+struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
+                                         const char *name,
+                                         const char *location)
+{
+       struct tevent_queue *queue;
+
+       queue = talloc_zero(mem_ctx, struct tevent_queue);
+       if (!queue) {
+               return NULL;
+       }
+
+       queue->name = talloc_strdup(queue, name);
+       if (!queue->name) {
+               talloc_free(queue);
+               return NULL;
+       }
+       queue->immediate = tevent_create_immediate(queue);
+       if (!queue->immediate) {
+               talloc_free(queue);
+               return NULL;
+       }
+
+       queue->location = location;
+
+       /* queue is running by default */
+       queue->running = true;
+
+       talloc_set_destructor(queue, tevent_queue_destructor);
+       return queue;
+}
+
+static void tevent_queue_immediate_trigger(struct tevent_context *ev,
+                                          struct tevent_immediate *im,
+                                          void *private_data)
+{
+       struct tevent_queue *q = talloc_get_type(private_data,
+                                 struct tevent_queue);
+
+       if (!q->running) {
+               return;
+       }
+
+       q->list->triggered = true;
+       q->list->trigger(q->list->req, q->list->private_data);
+}
+
+bool tevent_queue_add(struct tevent_queue *queue,
+                     struct tevent_context *ev,
+                     struct tevent_req *req,
+                     tevent_queue_trigger_fn_t trigger,
+                     void *private_data)
+{
+       struct tevent_queue_entry *e;
+
+       e = talloc_zero(req, struct tevent_queue_entry);
+       if (e == NULL) {
+               return false;
+       }
+
+       e->queue = queue;
+       e->req = req;
+       e->ev = ev;
+       e->trigger = trigger;
+       e->private_data = private_data;
+
+       DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
+       queue->length++;
+       talloc_set_destructor(e, tevent_queue_entry_destructor);
+
+       if (!queue->running) {
+               return true;
+       }
+
+       if (queue->list->triggered) {
+               return true;
+       }
+
+       tevent_schedule_immediate(queue->immediate,
+                                 queue->list->ev,
+                                 tevent_queue_immediate_trigger,
+                                 queue);
+
+       return true;
+}
+
+void tevent_queue_start(struct tevent_queue *queue)
+{
+       if (queue->running) {
+               /* already started */
+               return;
+       }
+
+       queue->running = true;
+
+       if (!queue->list) {
+               return;
+       }
+
+       if (queue->list->triggered) {
+               return;
+       }
+
+       tevent_schedule_immediate(queue->immediate,
+                                 queue->list->ev,
+                                 tevent_queue_immediate_trigger,
+                                 queue);
+}
+
+void tevent_queue_stop(struct tevent_queue *queue)
+{
+       queue->running = false;
+}
+
+size_t tevent_queue_length(struct tevent_queue *queue)
+{
+       return queue->length;
+}
diff --git a/ctdb/lib/tevent/tevent_req.c b/ctdb/lib/tevent/tevent_req.c
new file mode 100644 (file)
index 0000000..b0c9c57
--- /dev/null
@@ -0,0 +1,277 @@
+/*
+   Unix SMB/CIFS implementation.
+   Infrastructure for async requests
+   Copyright (C) Volker Lendecke 2008
+   Copyright (C) Stefan Metzmacher 2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+char *tevent_req_default_print(struct tevent_req *req, TALLOC_CTX *mem_ctx)
+{
+       return talloc_asprintf(mem_ctx,
+                              "tevent_req[%p/%s]: state[%d] error[%lld (0x%llX)] "
+                              " state[%s (%p)] timer[%p]",
+                              req, req->internal.create_location,
+                              req->internal.state,
+                              (unsigned long long)req->internal.error,
+                              (unsigned long long)req->internal.error,
+                              talloc_get_name(req->data),
+                              req->data,
+                              req->internal.timer
+                              );
+}
+
+char *tevent_req_print(TALLOC_CTX *mem_ctx, struct tevent_req *req)
+{
+       if (!req->private_print) {
+               return tevent_req_default_print(req, mem_ctx);
+       }
+
+       return req->private_print(req, mem_ctx);
+}
+
+struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
+                                   void *pdata,
+                                   size_t data_size,
+                                   const char *type,
+                                   const char *location)
+{
+       struct tevent_req *req;
+       void **ppdata = (void **)pdata;
+       void *data;
+
+       req = talloc_zero(mem_ctx, struct tevent_req);
+       if (req == NULL) {
+               return NULL;
+       }
+       req->internal.private_type      = type;
+       req->internal.create_location   = location;
+       req->internal.finish_location   = NULL;
+       req->internal.state             = TEVENT_REQ_IN_PROGRESS;
+       req->internal.trigger           = tevent_create_immediate(req);
+       if (!req->internal.trigger) {
+               talloc_free(req);
+               return NULL;
+       }
+
+       data = talloc_zero_size(req, data_size);
+       if (data == NULL) {
+               talloc_free(req);
+               return NULL;
+       }
+       talloc_set_name_const(data, type);
+
+       req->data = data;
+
+       *ppdata = data;
+       return req;
+}
+
+void _tevent_req_notify_callback(struct tevent_req *req, const char *location)
+{
+       req->internal.finish_location = location;
+       if (req->async.fn != NULL) {
+               req->async.fn(req);
+       }
+}
+
+static void tevent_req_finish(struct tevent_req *req,
+                             enum tevent_req_state state,
+                             const char *location)
+{
+       req->internal.state = state;
+       _tevent_req_notify_callback(req, location);
+}
+
+void _tevent_req_done(struct tevent_req *req,
+                     const char *location)
+{
+       tevent_req_finish(req, TEVENT_REQ_DONE, location);
+}
+
+bool _tevent_req_error(struct tevent_req *req,
+                      uint64_t error,
+                      const char *location)
+{
+       if (error == 0) {
+               return false;
+       }
+
+       req->internal.error = error;
+       tevent_req_finish(req, TEVENT_REQ_USER_ERROR, location);
+       return true;
+}
+
+bool _tevent_req_nomem(const void *p,
+                      struct tevent_req *req,
+                      const char *location)
+{
+       if (p != NULL) {
+               return false;
+       }
+       tevent_req_finish(req, TEVENT_REQ_NO_MEMORY, location);
+       return true;
+}
+
+/**
+ * @internal
+ *
+ * @brief Immediate event callback.
+ *
+ * @param[in]  ev       The event context to use.
+ *
+ * @param[in]  im       The immediate event.
+ *
+ * @param[in]  priv     The async request to be finished.
+ */
+static void tevent_req_trigger(struct tevent_context *ev,
+                              struct tevent_immediate *im,
+                              void *private_data)
+{
+       struct tevent_req *req = talloc_get_type(private_data,
+                                struct tevent_req);
+
+       tevent_req_finish(req, req->internal.state,
+                         req->internal.finish_location);
+}
+
+struct tevent_req *tevent_req_post(struct tevent_req *req,
+                                  struct tevent_context *ev)
+{
+       tevent_schedule_immediate(req->internal.trigger,
+                                 ev, tevent_req_trigger, req);
+       return req;
+}
+
+bool tevent_req_is_in_progress(struct tevent_req *req)
+{
+       if (req->internal.state == TEVENT_REQ_IN_PROGRESS) {
+               return true;
+       }
+
+       return false;
+}
+
+void tevent_req_received(struct tevent_req *req)
+{
+       TALLOC_FREE(req->data);
+       req->private_print = NULL;
+
+       TALLOC_FREE(req->internal.trigger);
+       TALLOC_FREE(req->internal.timer);
+
+       req->internal.state = TEVENT_REQ_RECEIVED;
+}
+
+bool tevent_req_poll(struct tevent_req *req,
+                    struct tevent_context *ev)
+{
+       while (tevent_req_is_in_progress(req)) {
+               int ret;
+
+               ret = tevent_loop_once(ev);
+               if (ret != 0) {
+                       return false;
+               }
+       }
+
+       return true;
+}
+
+bool tevent_req_is_error(struct tevent_req *req, enum tevent_req_state *state,
+                       uint64_t *error)
+{
+       if (req->internal.state == TEVENT_REQ_DONE) {
+               return false;
+       }
+       if (req->internal.state == TEVENT_REQ_USER_ERROR) {
+               *error = req->internal.error;
+       }
+       *state = req->internal.state;
+       return true;
+}
+
+static void tevent_req_timedout(struct tevent_context *ev,
+                              struct tevent_timer *te,
+                              struct timeval now,
+                              void *private_data)
+{
+       struct tevent_req *req = talloc_get_type(private_data,
+                                struct tevent_req);
+
+       TALLOC_FREE(req->internal.timer);
+
+       tevent_req_finish(req, TEVENT_REQ_TIMED_OUT, __FUNCTION__);
+}
+
+bool tevent_req_set_endtime(struct tevent_req *req,
+                           struct tevent_context *ev,
+                           struct timeval endtime)
+{
+       TALLOC_FREE(req->internal.timer);
+
+       req->internal.timer = tevent_add_timer(ev, req, endtime,
+                                              tevent_req_timedout,
+                                              req);
+       if (tevent_req_nomem(req->internal.timer, req)) {
+               return false;
+       }
+
+       return true;
+}
+
+void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt)
+{
+       req->async.fn = fn;
+       req->async.private_data = pvt;
+}
+
+void *_tevent_req_callback_data(struct tevent_req *req)
+{
+       return req->async.private_data;
+}
+
+void *_tevent_req_data(struct tevent_req *req)
+{
+       return req->data;
+}
+
+void tevent_req_set_print_fn(struct tevent_req *req, tevent_req_print_fn fn)
+{
+       req->private_print = fn;
+}
+
+void tevent_req_set_cancel_fn(struct tevent_req *req, tevent_req_cancel_fn fn)
+{
+       req->private_cancel = fn;
+}
+
+bool _tevent_req_cancel(struct tevent_req *req, const char *location)
+{
+       if (req->private_cancel == NULL) {
+               return false;
+       }
+
+       return req->private_cancel(req);
+}
diff --git a/ctdb/lib/tevent/tevent_select.c b/ctdb/lib/tevent/tevent_select.c
new file mode 100644 (file)
index 0000000..128a7d6
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+   Unix SMB/CIFS implementation.
+   main select loop and event handling
+   Copyright (C) Andrew Tridgell       2003-2005
+   Copyright (C) Stefan Metzmacher     2005-2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/select.h"
+#include "tevent.h"
+#include "tevent_util.h"
+#include "tevent_internal.h"
+
+struct select_event_context {
+       /* a pointer back to the generic event_context */
+       struct tevent_context *ev;
+
+       /* the maximum file descriptor number in fd_events */
+       int maxfd;
+
+       /* information for exiting from the event loop */
+       int exit_code;
+};
+
+/*
+  create a select_event_context structure.
+*/
+static int select_event_context_init(struct tevent_context *ev)
+{
+       struct select_event_context *select_ev;
+
+       select_ev = talloc_zero(ev, struct select_event_context);
+       if (!select_ev) return -1;
+       select_ev->ev = ev;
+
+       ev->additional_data = select_ev;
+       return 0;
+}
+
+/*
+  recalculate the maxfd
+*/
+static void calc_maxfd(struct select_event_context *select_ev)
+{
+       struct tevent_fd *fde;
+
+       select_ev->maxfd = 0;
+       for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
+               if (fde->fd > select_ev->maxfd) {
+                       select_ev->maxfd = fde->fd;
+               }
+       }
+}
+
+
+/* to mark the ev->maxfd invalid
+ * this means we need to recalculate it
+ */
+#define EVENT_INVALID_MAXFD (-1)
+
+/*
+  destroy an fd_event
+*/
+static int select_event_fd_destructor(struct tevent_fd *fde)
+{
+       struct tevent_context *ev = fde->event_ctx;
+       struct select_event_context *select_ev = NULL;
+
+       if (ev) {
+               select_ev = talloc_get_type(ev->additional_data,
+                                           struct select_event_context);
+
+               if (select_ev->maxfd == fde->fd) {
+                       select_ev->maxfd = EVENT_INVALID_MAXFD;
+               }
+       }
+
+       return tevent_common_fd_destructor(fde);
+}
+
+/*
+  add a fd based event
+  return NULL on failure (memory allocation error)
+*/
+static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+                                            int fd, uint16_t flags,
+                                            tevent_fd_handler_t handler,
+                                            void *private_data,
+                                            const char *handler_name,
+                                            const char *location)
+{
+       struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
+                                                          struct select_event_context);
+       struct tevent_fd *fde;
+
+       fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
+                                  handler, private_data,
+                                  handler_name, location);
+       if (!fde) return NULL;
+
+       if ((select_ev->maxfd != EVENT_INVALID_MAXFD)
+           && (fde->fd > select_ev->maxfd)) {
+               select_ev->maxfd = fde->fd;
+       }
+       talloc_set_destructor(fde, select_event_fd_destructor);
+
+       return fde;
+}
+
+/*
+  event loop handling using select()
+*/
+static int select_event_loop_select(struct select_event_context *select_ev, struct timeval *tvalp)
+{
+       fd_set r_fds, w_fds;
+       struct tevent_fd *fde;
+       int selrtn;
+
+       /* we maybe need to recalculate the maxfd */
+       if (select_ev->maxfd == EVENT_INVALID_MAXFD) {
+               calc_maxfd(select_ev);
+       }
+
+       FD_ZERO(&r_fds);
+       FD_ZERO(&w_fds);
+
+       /* setup any fd events */
+       for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
+               if (fde->flags & TEVENT_FD_READ) {
+                       FD_SET(fde->fd, &r_fds);
+               }
+               if (fde->flags & TEVENT_FD_WRITE) {
+                       FD_SET(fde->fd, &w_fds);
+               }
+       }
+
+       if (select_ev->ev->signal_events &&
+           tevent_common_check_signal(select_ev->ev)) {
+               return 0;
+       }
+
+       selrtn = select(select_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp);
+
+       if (selrtn == -1 && errno == EINTR &&
+           select_ev->ev->signal_events) {
+               tevent_common_check_signal(select_ev->ev);
+               return 0;
+       }
+
+       if (selrtn == -1 && errno == EBADF) {
+               /* the socket is dead! this should never
+                  happen as the socket should have first been
+                  made readable and that should have removed
+                  the event, so this must be a bug. This is a
+                  fatal error. */
+               tevent_debug(select_ev->ev, TEVENT_DEBUG_FATAL,
+                            "ERROR: EBADF on select_event_loop_once\n");
+               select_ev->exit_code = EBADF;
+               return -1;
+       }
+
+       if (selrtn == 0 && tvalp) {
+               /* we don't care about a possible delay here */
+               tevent_common_loop_timer_delay(select_ev->ev);
+               return 0;
+       }
+
+       if (selrtn > 0) {
+               /* at least one file descriptor is ready - check
+                  which ones and call the handler, being careful to allow
+                  the handler to remove itself when called */
+               for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
+                       uint16_t flags = 0;
+
+                       if (FD_ISSET(fde->fd, &r_fds)) flags |= TEVENT_FD_READ;
+                       if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE;
+                       if (flags) {
+                               fde->handler(select_ev->ev, fde, flags, fde->private_data);
+                               break;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+/*
+  do a single event loop using the events defined in ev
+*/
+static int select_event_loop_once(struct tevent_context *ev, const char *location)
+{
+       struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
+                                                          struct select_event_context);
+       struct timeval tval;
+
+       if (ev->signal_events &&
+           tevent_common_check_signal(ev)) {
+               return 0;
+       }
+
+       if (ev->immediate_events &&
+           tevent_common_loop_immediate(ev)) {
+               return 0;
+       }
+
+       tval = tevent_common_loop_timer_delay(ev);
+       if (tevent_timeval_is_zero(&tval)) {
+               return 0;
+       }
+
+       return select_event_loop_select(select_ev, &tval);
+}
+
+static const struct tevent_ops select_event_ops = {
+       .context_init           = select_event_context_init,
+       .add_fd                 = select_event_add_fd,
+       .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,
+       .schedule_immediate     = tevent_common_schedule_immediate,
+       .add_signal             = tevent_common_add_signal,
+       .loop_once              = select_event_loop_once,
+       .loop_wait              = tevent_common_loop_wait,
+};
+
+_PRIVATE_ bool tevent_select_init(void)
+{
+       return tevent_register_backend("select", &select_event_ops);
+}
diff --git a/ctdb/lib/tevent/tevent_signal.c b/ctdb/lib/tevent/tevent_signal.c
new file mode 100644 (file)
index 0000000..e157374
--- /dev/null
@@ -0,0 +1,423 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   common events code for signal events
+
+   Copyright (C) Andrew Tridgell       2007
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/filesys.h"
+#include "system/wait.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+#define TEVENT_NUM_SIGNALS 64
+
+/* maximum number of SA_SIGINFO signals to hold in the queue.
+  NB. This *MUST* be a power of 2, in order for the ring buffer
+  wrap to work correctly. Thanks to Petr Vandrovec <petr@vandrovec.name>
+  for this. */
+
+#define TEVENT_SA_INFO_QUEUE_COUNT 64
+
+struct tevent_sigcounter {
+       uint32_t count;
+       uint32_t seen;
+};
+
+#define TEVENT_SIG_INCREMENT(s) (s).count++
+#define TEVENT_SIG_SEEN(s, n) (s).seen += (n)
+#define TEVENT_SIG_PENDING(s) ((s).seen != (s).count)
+
+struct tevent_common_signal_list {
+       struct tevent_common_signal_list *prev, *next;
+       struct tevent_signal *se;
+};
+
+/*
+  the poor design of signals means that this table must be static global
+*/
+static struct tevent_sig_state {
+       struct tevent_common_signal_list *sig_handlers[TEVENT_NUM_SIGNALS+1];
+       struct sigaction *oldact[TEVENT_NUM_SIGNALS+1];
+       struct tevent_sigcounter signal_count[TEVENT_NUM_SIGNALS+1];
+       struct tevent_sigcounter got_signal;
+#ifdef SA_SIGINFO
+       /* with SA_SIGINFO we get quite a lot of info per signal */
+       siginfo_t *sig_info[TEVENT_NUM_SIGNALS+1];
+       struct tevent_sigcounter sig_blocked[TEVENT_NUM_SIGNALS+1];
+#endif
+} *sig_state;
+
+/*
+  return number of sigcounter events not processed yet
+*/
+static uint32_t tevent_sig_count(struct tevent_sigcounter s)
+{
+       return s.count - s.seen;
+}
+
+/*
+  signal handler - redirects to registered signals
+*/
+static void tevent_common_signal_handler(int signum)
+{
+       char c = 0;
+       ssize_t res;
+       struct tevent_common_signal_list *sl;
+       struct tevent_context *ev = NULL;
+       int saved_errno = errno;
+
+       TEVENT_SIG_INCREMENT(sig_state->signal_count[signum]);
+       TEVENT_SIG_INCREMENT(sig_state->got_signal);
+
+       /* Write to each unique event context. */
+       for (sl = sig_state->sig_handlers[signum]; sl; sl = sl->next) {
+               if (sl->se->event_ctx && sl->se->event_ctx != ev) {
+                       ev = sl->se->event_ctx;
+                       /* doesn't matter if this pipe overflows */
+                       res = write(ev->pipe_fds[1], &c, 1);
+               }
+       }
+
+       errno = saved_errno;
+}
+
+#ifdef SA_SIGINFO
+/*
+  signal handler with SA_SIGINFO - redirects to registered signals
+*/
+static void tevent_common_signal_handler_info(int signum, siginfo_t *info,
+                                             void *uctx)
+{
+       uint32_t count = tevent_sig_count(sig_state->signal_count[signum]);
+       /* sig_state->signal_count[signum].seen % TEVENT_SA_INFO_QUEUE_COUNT
+        * is the base of the unprocessed signals in the ringbuffer. */
+       uint32_t ofs = (sig_state->signal_count[signum].seen + count) %
+                               TEVENT_SA_INFO_QUEUE_COUNT;
+       sig_state->sig_info[signum][ofs] = *info;
+
+       tevent_common_signal_handler(signum);
+
+       /* handle SA_SIGINFO */
+       if (count+1 == TEVENT_SA_INFO_QUEUE_COUNT) {
+               /* we've filled the info array - block this signal until
+                  these ones are delivered */
+               sigset_t set;
+               sigemptyset(&set);
+               sigaddset(&set, signum);
+               sigprocmask(SIG_BLOCK, &set, NULL);
+               TEVENT_SIG_INCREMENT(sig_state->sig_blocked[signum]);
+       }
+}
+#endif
+
+static int tevent_common_signal_list_destructor(struct tevent_common_signal_list *sl)
+{
+       if (sig_state->sig_handlers[sl->se->signum]) {
+               DLIST_REMOVE(sig_state->sig_handlers[sl->se->signum], sl);
+       }
+       return 0;
+}
+
+/*
+  destroy a signal event
+*/
+static int tevent_signal_destructor(struct tevent_signal *se)
+{
+       struct tevent_common_signal_list *sl;
+       sl = talloc_get_type(se->additional_data,
+                            struct tevent_common_signal_list);
+
+       if (se->event_ctx) {
+               DLIST_REMOVE(se->event_ctx->signal_events, se);
+       }
+
+       talloc_free(sl);
+
+       if (sig_state->sig_handlers[se->signum] == NULL) {
+               /* restore old handler, if any */
+               if (sig_state->oldact[se->signum]) {
+                       sigaction(se->signum, sig_state->oldact[se->signum], NULL);
+                       sig_state->oldact[se->signum] = NULL;
+               }
+#ifdef SA_SIGINFO
+               if (se->sa_flags & SA_SIGINFO) {
+                       if (sig_state->sig_info[se->signum]) {
+                               talloc_free(sig_state->sig_info[se->signum]);
+                               sig_state->sig_info[se->signum] = NULL;
+                       }
+               }
+#endif
+       }
+
+       return 0;
+}
+
+/*
+  this is part of the pipe hack needed to avoid the signal race condition
+*/
+static void signal_pipe_handler(struct tevent_context *ev, struct tevent_fd *fde,
+                               uint16_t flags, void *_private)
+{
+       char c[16];
+       ssize_t res;
+       /* its non-blocking, doesn't matter if we read too much */
+       res = read(fde->fd, c, sizeof(c));
+}
+
+/*
+  add a signal event
+  return NULL on failure (memory allocation error)
+*/
+struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
+                                              TALLOC_CTX *mem_ctx,
+                                              int signum,
+                                              int sa_flags,
+                                              tevent_signal_handler_t handler,
+                                              void *private_data,
+                                              const char *handler_name,
+                                              const char *location)
+{
+       struct tevent_signal *se;
+       struct tevent_common_signal_list *sl;
+       sigset_t set, oldset;
+
+       if (signum >= TEVENT_NUM_SIGNALS) {
+               errno = EINVAL;
+               return NULL;
+       }
+
+       /* the sig_state needs to be on a global context as it can last across
+          multiple event contexts */
+       if (sig_state == NULL) {
+               sig_state = talloc_zero(talloc_autofree_context(), struct tevent_sig_state);
+               if (sig_state == NULL) {
+                       return NULL;
+               }
+       }
+
+       se = talloc(mem_ctx?mem_ctx:ev, struct tevent_signal);
+       if (se == NULL) return NULL;
+
+       se->event_ctx           = ev;
+       se->signum              = signum;
+       se->sa_flags            = sa_flags;
+       se->handler             = handler;
+       se->private_data        = private_data;
+       se->handler_name        = handler_name;
+       se->location            = location;
+       se->additional_data     = NULL;
+
+       sl = talloc(se, struct tevent_common_signal_list);
+       if (!sl) {
+               talloc_free(se);
+               return NULL;
+       }
+       sl->se = se;
+       se->additional_data     = sl;
+
+       /* Ensure, no matter the destruction order, that we always have a handle on the global sig_state */
+       if (!talloc_reference(se, sig_state)) {
+               talloc_free(se);
+               return NULL;
+       }
+
+       /* we need to setup the pipe hack handler if not already
+          setup */
+       if (ev->pipe_fde == NULL) {
+               if (pipe(ev->pipe_fds) == -1) {
+                       talloc_free(se);
+                       return NULL;
+               }
+               ev_set_blocking(ev->pipe_fds[0], false);
+               ev_set_blocking(ev->pipe_fds[1], false);
+               ev->pipe_fde = tevent_add_fd(ev, ev, ev->pipe_fds[0],
+                                            TEVENT_FD_READ,
+                                            signal_pipe_handler, NULL);
+               if (!ev->pipe_fde) {
+                       close(ev->pipe_fds[0]);
+                       close(ev->pipe_fds[1]);
+                       talloc_free(se);
+                       return NULL;
+               }
+       }
+
+       /* only install a signal handler if not already installed */
+       if (sig_state->sig_handlers[signum] == NULL) {
+               struct sigaction act;
+               ZERO_STRUCT(act);
+               act.sa_handler = tevent_common_signal_handler;
+               act.sa_flags = sa_flags;
+#ifdef SA_SIGINFO
+               if (sa_flags & SA_SIGINFO) {
+                       act.sa_handler   = NULL;
+                       act.sa_sigaction = tevent_common_signal_handler_info;
+                       if (sig_state->sig_info[signum] == NULL) {
+                               sig_state->sig_info[signum] =
+                                       talloc_zero_array(sig_state, siginfo_t,
+                                                         TEVENT_SA_INFO_QUEUE_COUNT);
+                               if (sig_state->sig_info[signum] == NULL) {
+                                       talloc_free(se);
+                                       return NULL;
+                               }
+                       }
+               }
+#endif
+               sig_state->oldact[signum] = talloc(sig_state, struct sigaction);
+               if (sig_state->oldact[signum] == NULL) {
+                       talloc_free(se);
+                       return NULL;
+               }
+               if (sigaction(signum, &act, sig_state->oldact[signum]) == -1) {
+                       talloc_free(se);
+                       return NULL;
+               }
+       }
+
+       DLIST_ADD(se->event_ctx->signal_events, se);
+
+       /* Make sure the signal doesn't come in while we're mangling list. */
+       sigemptyset(&set);
+       sigaddset(&set, signum);
+       sigprocmask(SIG_BLOCK, &set, &oldset);
+       DLIST_ADD(sig_state->sig_handlers[signum], sl);
+       sigprocmask(SIG_SETMASK, &oldset, NULL);
+
+       talloc_set_destructor(se, tevent_signal_destructor);
+       talloc_set_destructor(sl, tevent_common_signal_list_destructor);
+
+       return se;
+}
+
+
+/*
+  check if a signal is pending
+  return != 0 if a signal was pending
+*/
+int tevent_common_check_signal(struct tevent_context *ev)
+{
+       int i;
+
+       if (!sig_state || !TEVENT_SIG_PENDING(sig_state->got_signal)) {
+               return 0;
+       }
+
+       for (i=0;i<TEVENT_NUM_SIGNALS+1;i++) {
+               struct tevent_common_signal_list *sl, *next;
+               struct tevent_sigcounter counter = sig_state->signal_count[i];
+               uint32_t count = tevent_sig_count(counter);
+#ifdef SA_SIGINFO
+               /* Ensure we null out any stored siginfo_t entries
+                * after processing for debugging purposes. */
+               bool clear_processed_siginfo = false;
+#endif
+
+               if (count == 0) {
+                       continue;
+               }
+               for (sl=sig_state->sig_handlers[i];sl;sl=next) {
+                       struct tevent_signal *se = sl->se;
+                       next = sl->next;
+#ifdef SA_SIGINFO
+                       if (se->sa_flags & SA_SIGINFO) {
+                               uint32_t j;
+
+                               clear_processed_siginfo = true;
+
+                               for (j=0;j<count;j++) {
+                                       /* sig_state->signal_count[i].seen
+                                        * % TEVENT_SA_INFO_QUEUE_COUNT is
+                                        * the base position of the unprocessed
+                                        * signals in the ringbuffer. */
+                                       uint32_t ofs = (counter.seen + j)
+                                               % TEVENT_SA_INFO_QUEUE_COUNT;
+                                       se->handler(ev, se, i, 1,
+                                                   (void*)&sig_state->sig_info[i][ofs],
+                                                   se->private_data);
+                               }
+                               if (se->sa_flags & SA_RESETHAND) {
+                                       talloc_free(se);
+                               }
+                               continue;
+                       }
+#endif
+                       se->handler(ev, se, i, count, NULL, se->private_data);
+                       if (se->sa_flags & SA_RESETHAND) {
+                               talloc_free(se);
+                       }
+               }
+
+#ifdef SA_SIGINFO
+               if (clear_processed_siginfo) {
+                       uint32_t j;
+                       for (j=0;j<count;j++) {
+                               uint32_t ofs = (counter.seen + j)
+                                       % TEVENT_SA_INFO_QUEUE_COUNT;
+                               memset((void*)&sig_state->sig_info[i][ofs],
+                                       '\0',
+                                       sizeof(siginfo_t));
+                       }
+               }
+#endif
+
+               TEVENT_SIG_SEEN(sig_state->signal_count[i], count);
+               TEVENT_SIG_SEEN(sig_state->got_signal, count);
+
+#ifdef SA_SIGINFO
+               if (TEVENT_SIG_PENDING(sig_state->sig_blocked[i])) {
+                       /* We'd filled the queue, unblock the
+                          signal now the queue is empty again.
+                          Note we MUST do this after the
+                          TEVENT_SIG_SEEN(sig_state->signal_count[i], count)
+                          call to prevent a new signal running
+                          out of room in the sig_state->sig_info[i][]
+                          ring buffer. */
+                       sigset_t set;
+                       sigemptyset(&set);
+                       sigaddset(&set, i);
+                       TEVENT_SIG_SEEN(sig_state->sig_blocked[i],
+                                tevent_sig_count(sig_state->sig_blocked[i]));
+                       sigprocmask(SIG_UNBLOCK, &set, NULL);
+               }
+#endif
+       }
+
+       return 1;
+}
+
+void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se)
+{
+       struct tevent_common_signal_list *sl;
+       sl = talloc_get_type(se->additional_data,
+                            struct tevent_common_signal_list);
+
+       tevent_common_signal_list_destructor(sl);
+
+       if (sig_state->sig_handlers[se->signum] == NULL) {
+               if (sig_state->oldact[se->signum]) {
+                       sigaction(se->signum, sig_state->oldact[se->signum], NULL);
+                       sig_state->oldact[se->signum] = NULL;
+               }
+       }
+       return;
+}
similarity index 62%
rename from ctdb/lib/events/events_standard.c
rename to ctdb/lib/tevent/tevent_standard.c
index 6537d271d88199f80c57196ad2df8bf8705031fc..3f2d6d5b280f0aef2048996029f0f3fc9f22afa3 100644 (file)
@@ -1,21 +1,25 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    main select loop and event handling
    Copyright (C) Andrew Tridgell       2003-2005
-   Copyright (C) Stefan Metzmacher     2005
-   
-   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,
+   Copyright (C) Stefan Metzmacher     2005-2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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/>.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
 */
 
 /*
     at runtime we fallback to select()
 */
 
-#include "includes.h"
-#include "system/time.h"
+#include "replace.h"
 #include "system/filesys.h"
-#include "system/network.h"
-#include "system/select.h" /* needed for HAVE_EVENTS_EPOLL */
-#include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
-#include "lib/events/events_internal.h"
-
-extern pid_t ctdbd_pid;
+#include "system/select.h"
+#include "tevent.h"
+#include "tevent_util.h"
+#include "tevent_internal.h"
 
 struct std_event_context {
        /* a pointer back to the generic event_context */
-       struct event_context *ev;
-
-       /* list of filedescriptor events */
-       struct fd_event *fd_events;
+       struct tevent_context *ev;
 
        /* the maximum file descriptor number in fd_events */
        int maxfd;
@@ -59,27 +56,29 @@ struct std_event_context {
 };
 
 /* use epoll if it is available */
-#if HAVE_EVENTS_EPOLL
+#if HAVE_EPOLL
 /*
   called when a epoll call fails, and we should fallback
   to using select
 */
 static void epoll_fallback_to_select(struct std_event_context *std_ev, const char *reason)
 {
-       DEBUG(0,("%s (%s) - falling back to select()\n", reason, strerror(errno)));
+       tevent_debug(std_ev->ev, TEVENT_DEBUG_FATAL,
+                    "%s (%s) - falling back to select()\n",
+                    reason, strerror(errno));
        close(std_ev->epoll_fd);
        std_ev->epoll_fd = -1;
        talloc_set_destructor(std_ev, NULL);
 }
 
 /*
-  map from EVENT_FD_* to EPOLLIN/EPOLLOUT
+  map from TEVENT_FD_* to EPOLLIN/EPOLLOUT
 */
 static uint32_t epoll_map_flags(uint16_t flags)
 {
        uint32_t ret = 0;
-       if (flags & EVENT_FD_READ) ret |= (EPOLLIN | EPOLLERR | EPOLLHUP);
-       if (flags & EVENT_FD_WRITE) ret |= (EPOLLOUT | EPOLLERR | EPOLLHUP);
+       if (flags & TEVENT_FD_READ) ret |= (EPOLLIN | EPOLLERR | EPOLLHUP);
+       if (flags & TEVENT_FD_WRITE) ret |= (EPOLLOUT | EPOLLERR | EPOLLHUP);
        return ret;
 }
 
@@ -105,16 +104,16 @@ static void epoll_init_ctx(struct std_event_context *std_ev)
        talloc_set_destructor(std_ev, epoll_ctx_destructor);
 }
 
-static void epoll_add_event(struct std_event_context *std_ev, struct fd_event *fde);
+static void epoll_add_event(struct std_event_context *std_ev, struct tevent_fd *fde);
 
 /*
   reopen the epoll handle when our pid changes
-  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an 
+  see http://junkcode.samba.org/ftp/unpacked/junkcode/epoll_fork.c for an
   demonstration of why this is needed
  */
 static void epoll_check_reopen(struct std_event_context *std_ev)
 {
-       struct fd_event *fde;
+       struct tevent_fd *fde;
 
        if (std_ev->pid == getpid()) {
                return;
@@ -123,11 +122,12 @@ static void epoll_check_reopen(struct std_event_context *std_ev)
        close(std_ev->epoll_fd);
        std_ev->epoll_fd = epoll_create(64);
        if (std_ev->epoll_fd == -1) {
-               DEBUG(0,("Failed to recreate epoll handle after fork\n"));
+               tevent_debug(std_ev->ev, TEVENT_DEBUG_FATAL,
+                            "Failed to recreate epoll handle after fork\n");
                return;
        }
        std_ev->pid = getpid();
-       for (fde=std_ev->fd_events;fde;fde=fde->next) {
+       for (fde=std_ev->ev->fd_events;fde;fde=fde->next) {
                epoll_add_event(std_ev, fde);
        }
 }
@@ -139,7 +139,7 @@ static void epoll_check_reopen(struct std_event_context *std_ev)
 /*
  add the epoll event to the given fd_event
 */
-static void epoll_add_event(struct std_event_context *std_ev, struct fd_event *fde)
+static void epoll_add_event(struct std_event_context *std_ev, struct tevent_fd *fde)
 {
        struct epoll_event event;
        if (std_ev->epoll_fd == -1) return;
@@ -158,7 +158,7 @@ static void epoll_add_event(struct std_event_context *std_ev, struct fd_event *f
        fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_HAS_EVENT;
 
        /* only if we want to read we want to tell the event handler about errors */
-       if (fde->flags & EVENT_FD_READ) {
+       if (fde->flags & TEVENT_FD_READ) {
                fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
        }
 }
@@ -166,7 +166,7 @@ static void epoll_add_event(struct std_event_context *std_ev, struct fd_event *f
 /*
  delete the epoll event for given fd_event
 */
-static void epoll_del_event(struct std_event_context *std_ev, struct fd_event *fde)
+static void epoll_del_event(struct std_event_context *std_ev, struct tevent_fd *fde)
 {
        struct epoll_event event;
        if (std_ev->epoll_fd == -1) return;
@@ -186,7 +186,7 @@ static void epoll_del_event(struct std_event_context *std_ev, struct fd_event *f
 /*
  change the epoll event to the given fd_event
 */
-static void epoll_mod_event(struct std_event_context *std_ev, struct fd_event *fde)
+static void epoll_mod_event(struct std_event_context *std_ev, struct tevent_fd *fde)
 {
        struct epoll_event event;
        if (std_ev->epoll_fd == -1) return;
@@ -201,16 +201,16 @@ static void epoll_mod_event(struct std_event_context *std_ev, struct fd_event *f
        }
 
        /* only if we want to read we want to tell the event handler about errors */
-       if (fde->flags & EVENT_FD_READ) {
+       if (fde->flags & TEVENT_FD_READ) {
                fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_REPORT_ERROR;
        }
 }
 
-static void epoll_change_event(struct std_event_context *std_ev, struct fd_event *fde)
+static void epoll_change_event(struct std_event_context *std_ev, struct tevent_fd *fde)
 {
        bool got_error = (fde->additional_flags & EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR);
-       bool want_read = (fde->flags & EVENT_FD_READ);
-       bool want_write= (fde->flags & EVENT_FD_WRITE);
+       bool want_read = (fde->flags & TEVENT_FD_READ);
+       bool want_write= (fde->flags & TEVENT_FD_WRITE);
 
        if (std_ev->epoll_fd == -1) return;
 
@@ -222,7 +222,7 @@ static void epoll_change_event(struct std_event_context *std_ev, struct fd_event
                        epoll_mod_event(std_ev, fde);
                        return;
                }
-               /* 
+               /*
                 * if we want to match the select behavior, we need to remove the epoll_event
                 * when the caller isn't interested in events.
                 *
@@ -245,7 +245,7 @@ static void epoll_change_event(struct std_event_context *std_ev, struct fd_event
 static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tvalp)
 {
        int ret, i;
-#define MAXEVENTS 8
+#define MAXEVENTS 1
        struct epoll_event events[MAXEVENTS];
        int timeout = -1;
 
@@ -256,15 +256,15 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
                timeout = ((tvalp->tv_usec+999) / 1000) + (tvalp->tv_sec*1000);
        }
 
-       if (std_ev->ev->num_signal_handlers && 
-           common_event_check_signal(std_ev->ev)) {
+       if (std_ev->ev->signal_events &&
+           tevent_common_check_signal(std_ev->ev)) {
                return 0;
        }
 
        ret = epoll_wait(std_ev->epoll_fd, events, MAXEVENTS, timeout);
 
-       if (ret == -1 && errno == EINTR && std_ev->ev->num_signal_handlers) {
-               if (common_event_check_signal(std_ev->ev)) {
+       if (ret == -1 && errno == EINTR && std_ev->ev->signal_events) {
+               if (tevent_common_check_signal(std_ev->ev)) {
                        return 0;
                }
        }
@@ -276,13 +276,13 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
 
        if (ret == 0 && tvalp) {
                /* we don't care about a possible delay here */
-               common_event_loop_timer_delay(std_ev->ev);
+               tevent_common_loop_timer_delay(std_ev->ev);
                return 0;
        }
 
        for (i=0;i<ret;i++) {
-               struct fd_event *fde = talloc_get_type(events[i].data.ptr, 
-                                                      struct fd_event);
+               struct tevent_fd *fde = talloc_get_type(events[i].data.ptr,
+                                                      struct tevent_fd);
                uint16_t flags = 0;
 
                if (fde == NULL) {
@@ -292,7 +292,7 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
                if (events[i].events & (EPOLLHUP|EPOLLERR)) {
                        fde->additional_flags |= EPOLL_ADDITIONAL_FD_FLAG_GOT_ERROR;
                        /*
-                        * if we only wait for EVENT_FD_WRITE, we should not tell the
+                        * if we only wait for TEVENT_FD_WRITE, we should not tell the
                         * event handler about it, and remove the epoll_event,
                         * as we only report errors when waiting for read events,
                         * to match the select() behavior
@@ -301,10 +301,10 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
                                epoll_del_event(std_ev, fde);
                                continue;
                        }
-                       flags |= EVENT_FD_READ;
+                       flags |= TEVENT_FD_READ;
                }
-               if (events[i].events & EPOLLIN) flags |= EVENT_FD_READ;
-               if (events[i].events & EPOLLOUT) flags |= EVENT_FD_WRITE;
+               if (events[i].events & EPOLLIN) flags |= TEVENT_FD_READ;
+               if (events[i].events & EPOLLOUT) flags |= TEVENT_FD_WRITE;
                if (flags) {
                        fde->handler(std_ev->ev, fde, flags, fde->private_data);
                        break;
@@ -314,7 +314,7 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
        return 0;
 }
 #else
-#define epoll_init_ctx(std_ev) 
+#define epoll_init_ctx(std_ev)
 #define epoll_add_event(std_ev,fde)
 #define epoll_del_event(std_ev,fde)
 #define epoll_change_event(std_ev,fde)
@@ -325,7 +325,7 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
 /*
   create a std_event_context structure.
 */
-static int std_event_context_init(struct event_context *ev)
+static int std_event_context_init(struct tevent_context *ev)
 {
        struct std_event_context *std_ev;
 
@@ -345,10 +345,10 @@ static int std_event_context_init(struct event_context *ev)
 */
 static void calc_maxfd(struct std_event_context *std_ev)
 {
-       struct fd_event *fde;
+       struct tevent_fd *fde;
 
        std_ev->maxfd = 0;
-       for (fde = std_ev->fd_events; fde; fde = fde->next) {
+       for (fde = std_ev->ev->fd_events; fde; fde = fde->next) {
                if (fde->fd > std_ev->maxfd) {
                        std_ev->maxfd = fde->fd;
                }
@@ -364,57 +364,49 @@ static void calc_maxfd(struct std_event_context *std_ev)
 /*
   destroy an fd_event
 */
-static int std_event_fd_destructor(struct fd_event *fde)
+static int std_event_fd_destructor(struct tevent_fd *fde)
 {
-       struct event_context *ev = fde->event_ctx;
-       struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
-                                                          struct std_event_context);
-
-       epoll_check_reopen(std_ev);
+       struct tevent_context *ev = fde->event_ctx;
+       struct std_event_context *std_ev = NULL;
 
-       if (std_ev->maxfd == fde->fd) {
-               std_ev->maxfd = EVENT_INVALID_MAXFD;
-       }
+       if (ev) {
+               std_ev = talloc_get_type(ev->additional_data,
+                                        struct std_event_context);
 
-       DLIST_REMOVE(std_ev->fd_events, fde);
+               epoll_check_reopen(std_ev);
 
-       epoll_del_event(std_ev, fde);
+               if (std_ev->maxfd == fde->fd) {
+                       std_ev->maxfd = EVENT_INVALID_MAXFD;
+               }
 
-       if (fde->flags & EVENT_FD_AUTOCLOSE) {
-               close(fde->fd);
-               fde->fd = -1;
+               epoll_del_event(std_ev, fde);
        }
 
-       return 0;
+       return tevent_common_fd_destructor(fde);
 }
 
 /*
   add a fd based event
   return NULL on failure (memory allocation error)
 */
-static struct fd_event *std_event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
-                                        int fd, uint16_t flags,
-                                        event_fd_handler_t handler,
-                                        void *private_data)
+static struct tevent_fd *std_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+                                         int fd, uint16_t flags,
+                                         tevent_fd_handler_t handler,
+                                         void *private_data,
+                                         const char *handler_name,
+                                         const char *location)
 {
        struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
                                                           struct std_event_context);
-       struct fd_event *fde;
+       struct tevent_fd *fde;
 
        epoll_check_reopen(std_ev);
 
-       fde = talloc(mem_ctx?mem_ctx:ev, struct fd_event);
+       fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
+                                  handler, private_data,
+                                  handler_name, location);
        if (!fde) return NULL;
 
-       fde->event_ctx          = ev;
-       fde->fd                 = fd;
-       fde->flags              = flags;
-       fde->handler            = handler;
-       fde->private_data       = private_data;
-       fde->additional_flags   = 0;
-       fde->additional_data    = NULL;
-
-       DLIST_ADD(std_ev->fd_events, fde);
        if ((std_ev->maxfd != EVENT_INVALID_MAXFD)
            && (fde->fd > std_ev->maxfd)) {
                std_ev->maxfd = fde->fd;
@@ -426,21 +418,12 @@ static struct fd_event *std_event_add_fd(struct event_context *ev, TALLOC_CTX *m
        return fde;
 }
 
-
-/*
-  return the fd event flags
-*/
-static uint16_t std_event_get_fd_flags(struct fd_event *fde)
-{
-       return fde->flags;
-}
-
 /*
   set the fd event flags
 */
-static void std_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
+static void std_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 {
-       struct event_context *ev;
+       struct tevent_context *ev;
        struct std_event_context *std_ev;
 
        if (fde->flags == flags) return;
@@ -461,7 +444,7 @@ static void std_event_set_fd_flags(struct fd_event *fde, uint16_t flags)
 static int std_event_loop_select(struct std_event_context *std_ev, struct timeval *tvalp)
 {
        fd_set r_fds, w_fds;
-       struct fd_event *fde;
+       struct tevent_fd *fde;
        int selrtn;
 
        /* we maybe need to recalculate the maxfd */
@@ -473,25 +456,25 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
        FD_ZERO(&w_fds);
 
        /* setup any fd events */
-       for (fde = std_ev->fd_events; fde; fde = fde->next) {
-               if (fde->flags & EVENT_FD_READ) {
+       for (fde = std_ev->ev->fd_events; fde; fde = fde->next) {
+               if (fde->flags & TEVENT_FD_READ) {
                        FD_SET(fde->fd, &r_fds);
                }
-               if (fde->flags & EVENT_FD_WRITE) {
+               if (fde->flags & TEVENT_FD_WRITE) {
                        FD_SET(fde->fd, &w_fds);
                }
        }
 
-       if (std_ev->ev->num_signal_handlers && 
-           common_event_check_signal(std_ev->ev)) {
+       if (std_ev->ev->signal_events &&
+           tevent_common_check_signal(std_ev->ev)) {
                return 0;
        }
 
        selrtn = select(std_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp);
 
-       if (selrtn == -1 && errno == EINTR && 
-           std_ev->ev->num_signal_handlers) {
-               common_event_check_signal(std_ev->ev);
+       if (selrtn == -1 && errno == EINTR &&
+           std_ev->ev->signal_events) {
+               tevent_common_check_signal(std_ev->ev);
                return 0;
        }
 
@@ -501,14 +484,15 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
                   made readable and that should have removed
                   the event, so this must be a bug. This is a
                   fatal error. */
-               DEBUG(0,("ERROR: EBADF on std_event_loop_once\n"));
+               tevent_debug(std_ev->ev, TEVENT_DEBUG_FATAL,
+                            "ERROR: EBADF on std_event_loop_once\n");
                std_ev->exit_code = EBADF;
                return -1;
        }
 
        if (selrtn == 0 && tvalp) {
                /* we don't care about a possible delay here */
-               common_event_loop_timer_delay(std_ev->ev);
+               tevent_common_loop_timer_delay(std_ev->ev);
                return 0;
        }
 
@@ -516,11 +500,11 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
                /* at least one file descriptor is ready - check
                   which ones and call the handler, being careful to allow
                   the handler to remove itself when called */
-               for (fde = std_ev->fd_events; fde; fde = fde->next) {
+               for (fde = std_ev->ev->fd_events; fde; fde = fde->next) {
                        uint16_t flags = 0;
 
-                       if (FD_ISSET(fde->fd, &r_fds)) flags |= EVENT_FD_READ;
-                       if (FD_ISSET(fde->fd, &w_fds)) flags |= EVENT_FD_WRITE;
+                       if (FD_ISSET(fde->fd, &r_fds)) flags |= TEVENT_FD_READ;
+                       if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE;
                        if (flags) {
                                fde->handler(std_ev->ev, fde, flags, fde->private_data);
                                break;
@@ -529,87 +513,56 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
        }
 
        return 0;
-}              
+}
 
 /*
-  do a single event loop using the events defined in ev 
+  do a single event loop using the events defined in ev
 */
-static int std_event_loop_once(struct event_context *ev)
+static int std_event_loop_once(struct tevent_context *ev, const char *location)
 {
        struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
-                                                          struct std_event_context);
+                                                          struct std_event_context);
        struct timeval tval;
 
-       tval = common_event_loop_timer_delay(ev);
-       if (timeval_is_zero(&tval)) {
+       if (ev->signal_events &&
+           tevent_common_check_signal(ev)) {
                return 0;
        }
 
-       epoll_check_reopen(std_ev);
-
-       if (epoll_event_loop(std_ev, &tval) == 0) {
+       if (ev->immediate_events &&
+           tevent_common_loop_immediate(ev)) {
                return 0;
        }
 
-       return std_event_loop_select(std_ev, &tval);
-}
+       tval = tevent_common_loop_timer_delay(ev);
+       if (tevent_timeval_is_zero(&tval)) {
+               return 0;
+       }
 
-/*
-  return on failure or (with 0) if all fd events are removed
-*/
-static int std_event_loop_wait(struct event_context *ev)
-{
-       static time_t t=0;
-       time_t new_t;
-       struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
-                                                          struct std_event_context);
-       std_ev->exit_code = 0;
+       epoll_check_reopen(std_ev);
 
-       while (std_ev->fd_events && std_ev->exit_code == 0) {
-               if (std_event_loop_once(ev) != 0) {
-                       break;
-               }
-               if (getpid() == ctdbd_pid) {
-                       new_t=time(NULL);
-                       if (t != 0) {
-                               if (t > new_t) {
-                                       DEBUG(0,(__location__ " ERROR Time skipped backward by %d seconds\n", (int)(t-new_t)));
-                               }
-                               /* We assume here that we get at least one event every 5 seconds */
-                               if (new_t > (t+5)) {
-                                       DEBUG(0,(__location__ " ERROR Time jumped forward by %d seconds\n", (int)(new_t-t)));
-                               }
-                       }
-                       t=new_t;
-               }
+       if (epoll_event_loop(std_ev, &tval) == 0) {
+               return 0;
        }
 
-       return std_ev->exit_code;
+       return std_event_loop_select(std_ev, &tval);
 }
 
-static const struct event_ops std_event_ops = {
-       .context_init   = std_event_context_init,
-       .add_fd         = std_event_add_fd,
-       .get_fd_flags   = std_event_get_fd_flags,
-       .set_fd_flags   = std_event_set_fd_flags,
-       .add_timed      = common_event_add_timed,
-       .add_signal     = common_event_add_signal,
-       .loop_once      = std_event_loop_once,
-       .loop_wait      = std_event_loop_wait,
+static const struct tevent_ops std_event_ops = {
+       .context_init           = std_event_context_init,
+       .add_fd                 = std_event_add_fd,
+       .set_fd_close_fn        = tevent_common_fd_set_close_fn,
+       .get_fd_flags           = tevent_common_fd_get_flags,
+       .set_fd_flags           = std_event_set_fd_flags,
+       .add_timer              = tevent_common_add_timer,
+       .schedule_immediate     = tevent_common_schedule_immediate,
+       .add_signal             = tevent_common_add_signal,
+       .loop_once              = std_event_loop_once,
+       .loop_wait              = tevent_common_loop_wait,
 };
 
 
-bool events_standard_init(void)
-{
-       return event_register_backend("standard", &std_event_ops);
-}
-
-#if _SAMBA_BUILD_
-NTSTATUS s4_events_standard_init(void)
+_PRIVATE_ bool tevent_standard_init(void)
 {
-       if (!events_standard_init()) {
-               return NT_STATUS_INTERNAL_ERROR;
-       }
-       return NT_STATUS_OK;
+       return tevent_register_backend("standard", &std_event_ops);
 }
-#endif
diff --git a/ctdb/lib/tevent/tevent_timed.c b/ctdb/lib/tevent/tevent_timed.c
new file mode 100644 (file)
index 0000000..457ef1c
--- /dev/null
@@ -0,0 +1,267 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   common events code for timed events
+
+   Copyright (C) Andrew Tridgell       2003-2006
+   Copyright (C) Stefan Metzmacher     2005-2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "system/time.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+/**
+  compare two timeval structures.
+  Return -1 if tv1 < tv2
+  Return 0 if tv1 == tv2
+  Return 1 if tv1 > tv2
+*/
+int tevent_timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
+{
+       if (tv1->tv_sec  > tv2->tv_sec)  return 1;
+       if (tv1->tv_sec  < tv2->tv_sec)  return -1;
+       if (tv1->tv_usec > tv2->tv_usec) return 1;
+       if (tv1->tv_usec < tv2->tv_usec) return -1;
+       return 0;
+}
+
+/**
+  return a zero timeval
+*/
+struct timeval tevent_timeval_zero(void)
+{
+       struct timeval tv;
+       tv.tv_sec = 0;
+       tv.tv_usec = 0;
+       return tv;
+}
+
+/**
+  return a timeval for the current time
+*/
+struct timeval tevent_timeval_current(void)
+{
+       struct timeval tv;
+       gettimeofday(&tv, NULL);
+       return tv;
+}
+
+/**
+  return a timeval struct with the given elements
+*/
+struct timeval tevent_timeval_set(uint32_t secs, uint32_t usecs)
+{
+       struct timeval tv;
+       tv.tv_sec = secs;
+       tv.tv_usec = usecs;
+       return tv;
+}
+
+/**
+  return the difference between two timevals as a timeval
+  if tv1 comes after tv2, then return a zero timeval
+  (this is *tv2 - *tv1)
+*/
+struct timeval tevent_timeval_until(const struct timeval *tv1,
+                                   const struct timeval *tv2)
+{
+       struct timeval t;
+       if (tevent_timeval_compare(tv1, tv2) >= 0) {
+               return tevent_timeval_zero();
+       }
+       t.tv_sec = tv2->tv_sec - tv1->tv_sec;
+       if (tv1->tv_usec > tv2->tv_usec) {
+               t.tv_sec--;
+               t.tv_usec = 1000000 - (tv1->tv_usec - tv2->tv_usec);
+       } else {
+               t.tv_usec = tv2->tv_usec - tv1->tv_usec;
+       }
+       return t;
+}
+
+/**
+  return true if a timeval is zero
+*/
+bool tevent_timeval_is_zero(const struct timeval *tv)
+{
+       return tv->tv_sec == 0 && tv->tv_usec == 0;
+}
+
+struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
+                                 uint32_t usecs)
+{
+       struct timeval tv2 = *tv;
+       tv2.tv_sec += secs;
+       tv2.tv_usec += usecs;
+       tv2.tv_sec += tv2.tv_usec / 1000000;
+       tv2.tv_usec = tv2.tv_usec % 1000000;
+
+       return tv2;
+}
+
+/**
+  return a timeval in the future with a specified offset
+*/
+struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs)
+{
+       struct timeval tv = tevent_timeval_current();
+       return tevent_timeval_add(&tv, secs, usecs);
+}
+
+/*
+  destroy a timed event
+*/
+static int tevent_common_timed_destructor(struct tevent_timer *te)
+{
+       tevent_debug(te->event_ctx, TEVENT_DEBUG_TRACE,
+                    "Destroying timer event %p \"%s\"\n",
+                    te, te->handler_name);
+
+       if (te->event_ctx) {
+               DLIST_REMOVE(te->event_ctx->timer_events, te);
+       }
+
+       return 0;
+}
+
+static int tevent_common_timed_deny_destructor(struct tevent_timer *te)
+{
+       return -1;
+}
+
+/*
+  add a timed event
+  return NULL on failure (memory allocation error)
+*/
+struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+                                            struct timeval next_event,
+                                            tevent_timer_handler_t handler,
+                                            void *private_data,
+                                            const char *handler_name,
+                                            const char *location)
+{
+       struct tevent_timer *te, *last_te, *cur_te;
+
+       te = talloc(mem_ctx?mem_ctx:ev, struct tevent_timer);
+       if (te == NULL) return NULL;
+
+       te->event_ctx           = ev;
+       te->next_event          = next_event;
+       te->handler             = handler;
+       te->private_data        = private_data;
+       te->handler_name        = handler_name;
+       te->location            = location;
+       te->additional_data     = NULL;
+
+       /* keep the list ordered */
+       last_te = NULL;
+       for (cur_te = ev->timer_events; cur_te; cur_te = cur_te->next) {
+               /* if the new event comes before the current one break */
+               if (tevent_timeval_compare(&te->next_event, &cur_te->next_event) < 0) {
+                       break;
+               }
+
+               last_te = cur_te;
+       }
+
+       DLIST_ADD_AFTER(ev->timer_events, te, last_te);
+
+       talloc_set_destructor(te, tevent_common_timed_destructor);
+
+       tevent_debug(ev, TEVENT_DEBUG_TRACE,
+                    "Added timed event \"%s\": %p\n",
+                    handler_name, te);
+       return te;
+}
+
+/*
+  do a single event loop using the events defined in ev
+
+  return the delay untill the next timed event,
+  or zero if a timed event was triggered
+*/
+struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
+{
+       struct timeval current_time = tevent_timeval_zero();
+       struct tevent_timer *te = ev->timer_events;
+
+       if (!te) {
+               /* have a default tick time of 30 seconds. This guarantees
+                  that code that uses its own timeout checking will be
+                  able to proceeed eventually */
+               return tevent_timeval_set(30, 0);
+       }
+
+       /*
+        * work out the right timeout for the next timed event
+        *
+        * avoid the syscall to gettimeofday() if the timed event should
+        * be triggered directly
+        *
+        * if there's a delay till the next timed event, we're done
+        * with just returning the delay
+        */
+       if (!tevent_timeval_is_zero(&te->next_event)) {
+               struct timeval delay;
+
+               current_time = tevent_timeval_current();
+
+               delay = tevent_timeval_until(&current_time, &te->next_event);
+               if (!tevent_timeval_is_zero(&delay)) {
+                       return delay;
+               }
+       }
+
+       /*
+        * ok, we have a timed event that we'll process ...
+        */
+
+       /* deny the handler to free the event */
+       talloc_set_destructor(te, tevent_common_timed_deny_destructor);
+
+       /* We need to remove the timer from the list before calling the
+        * handler because in a semi-async inner event loop called from the
+        * handler we don't want to come across this event again -- vl */
+       DLIST_REMOVE(ev->timer_events, te);
+
+       /*
+        * If the timed event was registered for a zero current_time,
+        * then we pass a zero timeval here too! To avoid the
+        * overhead of gettimeofday() calls.
+        *
+        * otherwise we pass the current time
+        */
+       te->handler(ev, te, current_time, te->private_data);
+
+       /* The destructor isn't necessary anymore, we've already removed the
+        * event from the list. */
+       talloc_set_destructor(te, NULL);
+
+       tevent_debug(te->event_ctx, TEVENT_DEBUG_TRACE,
+                    "Ending timer event %p \"%s\"\n",
+                    te, te->handler_name);
+
+       talloc_free(te);
+
+       return tevent_timeval_zero();
+}
diff --git a/ctdb/lib/tevent/tevent_util.c b/ctdb/lib/tevent/tevent_util.c
new file mode 100644 (file)
index 0000000..f78cd8f
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 2005
+   Copyright (C) Jelmer Vernooij 2005
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "talloc.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+#include <fcntl.h>
+
+/**
+  return the number of elements in a string list
+*/
+size_t ev_str_list_length(const char **list)
+{
+       size_t ret;
+       for (ret=0;list && list[ret];ret++) /* noop */ ;
+       return ret;
+}
+
+/**
+  add an entry to a string list
+*/
+const char **ev_str_list_add(const char **list, const char *s)
+{
+       size_t len = ev_str_list_length(list);
+       const char **ret;
+
+       ret = talloc_realloc(NULL, list, const char *, len+2);
+       if (ret == NULL) return NULL;
+
+       ret[len] = talloc_strdup(ret, s);
+       if (ret[len] == NULL) return NULL;
+
+       ret[len+1] = NULL;
+
+       return ret;
+}
+
+
+/**
+ Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
+ else
+  if SYSV use O_NDELAY
+  if BSD use FNDELAY
+**/
+
+int ev_set_blocking(int fd, bool set)
+{
+       int val;
+#ifdef O_NONBLOCK
+#define FLAG_TO_SET O_NONBLOCK
+#else
+#ifdef SYSV
+#define FLAG_TO_SET O_NDELAY
+#else /* BSD */
+#define FLAG_TO_SET FNDELAY
+#endif
+#endif
+
+       if((val = fcntl(fd, F_GETFL, 0)) == -1)
+               return -1;
+       if(set) /* Turn blocking on - ie. clear nonblock flag */
+               val &= ~FLAG_TO_SET;
+       else
+               val |= FLAG_TO_SET;
+       return fcntl( fd, F_SETFL, val);
+#undef FLAG_TO_SET
+}
diff --git a/ctdb/lib/tevent/tevent_util.h b/ctdb/lib/tevent/tevent_util.h
new file mode 100644 (file)
index 0000000..46a4506
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Copyright (C) Andrew Tridgell 1998-2010
+   Copyright (C) Jelmer Vernooij 2005
+
+   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/>.
+*/
+
+/* To use these macros you must have a structure containing a next and
+   prev pointer */
+
+#ifndef _DLINKLIST_H
+#define _DLINKLIST_H
+
+/*
+  February 2010 - changed list format to have a prev pointer from the
+  list head. This makes DLIST_ADD_END() O(1) even though we only have
+  one list pointer.
+
+  The scheme is as follows:
+
+     1) with no entries in the list:
+          list_head == NULL
+
+     2) with 1 entry in the list:
+          list_head->next == NULL
+          list_head->prev == list_head
+
+     3) with 2 entries in the list:
+          list_head->next == element2
+          list_head->prev == element2
+         element2->prev == list_head
+         element2->next == NULL
+
+     4) with N entries in the list:
+          list_head->next == element2
+          list_head->prev == elementN
+         elementN->prev == element{N-1}
+         elementN->next == NULL
+
+  This allows us to find the tail of the list by using
+  list_head->prev, which means we can add to the end of the list in
+  O(1) time
+
+
+  Note that the 'type' arguments below are no longer needed, but
+  are kept for now to prevent an incompatible argument change
+ */
+
+
+/*
+   add an element at the front of a list
+*/
+#define DLIST_ADD(list, p) \
+do { \
+        if (!(list)) { \
+               (p)->prev = (list) = (p);  \
+               (p)->next = NULL; \
+       } else { \
+               (p)->prev = (list)->prev; \
+               (list)->prev = (p); \
+               (p)->next = (list); \
+               (list) = (p); \
+       } \
+} while (0)
+
+/*
+   remove an element from a list
+   Note that the element doesn't have to be in the list. If it
+   isn't then this is a no-op
+*/
+#define DLIST_REMOVE(list, p) \
+do { \
+       if ((p) == (list)) { \
+               if ((p)->next) (p)->next->prev = (p)->prev; \
+               (list) = (p)->next; \
+       } else if ((list) && (p) == (list)->prev) {     \
+               (p)->prev->next = NULL; \
+               (list)->prev = (p)->prev; \
+       } else { \
+               if ((p)->prev) (p)->prev->next = (p)->next; \
+               if ((p)->next) (p)->next->prev = (p)->prev; \
+       } \
+       if ((p) != (list)) (p)->next = (p)->prev = NULL;        \
+} while (0)
+
+/*
+   find the head of the list given any element in it.
+   Note that this costs O(N), so you should avoid this macro
+   if at all possible!
+*/
+#define DLIST_HEAD(p, result_head) \
+do { \
+       (result_head) = (p); \
+       while (DLIST_PREV(result_head)) (result_head) = (result_head)->prev; \
+} while(0)
+
+/* return the last element in the list */
+#define DLIST_TAIL(list) ((list)?(list)->prev:NULL)
+
+/* return the previous element in the list. */
+#define DLIST_PREV(p) (((p)->prev && (p)->prev->next != NULL)?(p)->prev:NULL)
+
+/* insert 'p' after the given element 'el' in a list. If el is NULL then
+   this is the same as a DLIST_ADD() */
+#define DLIST_ADD_AFTER(list, p, el) \
+do { \
+        if (!(list) || !(el)) { \
+               DLIST_ADD(list, p); \
+       } else { \
+               (p)->prev = (el);   \
+               (p)->next = (el)->next;         \
+               (el)->next = (p);               \
+               if ((p)->next) (p)->next->prev = (p);   \
+               if ((list)->prev == (el)) (list)->prev = (p); \
+       }\
+} while (0)
+
+
+/*
+   add to the end of a list.
+   Note that 'type' is ignored
+*/
+#define DLIST_ADD_END(list, p, type)                   \
+do { \
+       if (!(list)) { \
+               DLIST_ADD(list, p); \
+       } else { \
+               DLIST_ADD_AFTER(list, p, (list)->prev); \
+       } \
+} while (0)
+
+/* promote an element to the from of a list */
+#define DLIST_PROMOTE(list, p) \
+do { \
+          DLIST_REMOVE(list, p); \
+          DLIST_ADD(list, p); \
+} while (0)
+
+/*
+   demote an element to the end of a list.
+   Note that 'type' is ignored
+*/
+#define DLIST_DEMOTE(list, p, type)                    \
+do { \
+       DLIST_REMOVE(list, p); \
+       DLIST_ADD_END(list, p, NULL);           \
+} while (0)
+
+/*
+   concatenate two lists - putting all elements of the 2nd list at the
+   end of the first list.
+   Note that 'type' is ignored
+*/
+#define DLIST_CONCATENATE(list1, list2, type)  \
+do { \
+       if (!(list1)) { \
+               (list1) = (list2); \
+       } else { \
+               (list1)->prev->next = (list2); \
+               if (list2) { \
+                       void *_tmplist = (void *)(list1)->prev; \
+                       (list1)->prev = (list2)->prev; \
+                       (list2)->prev = _tmplist; \
+               } \
+       } \
+} while (0)
+
+#endif /* _DLINKLIST_H */
+
+const char **ev_str_list_add(const char **list, const char *s);
+int ev_set_blocking(int fd, bool set);
+size_t ev_str_list_length(const char **list);
+
+/* Defined here so we can build against older talloc versions that don't
+ * have this define yet. */
+#ifndef TALLOC_FREE
+#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
+#endif
diff --git a/ctdb/lib/tevent/tevent_wakeup.c b/ctdb/lib/tevent/tevent_wakeup.c
new file mode 100644 (file)
index 0000000..d7cac06
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+   Unix SMB/CIFS implementation.
+   Infrastructure for async requests
+   Copyright (C) Volker Lendecke 2008
+   Copyright (C) Stefan Metzmacher 2009
+
+     ** NOTE! The following LGPL license applies to the tevent
+     ** library. This does NOT imply that all of Samba is released
+     ** under the LGPL
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "replace.h"
+#include "tevent.h"
+#include "tevent_internal.h"
+#include "tevent_util.h"
+
+struct tevent_wakeup_state {
+       struct timeval wakeup_time;
+};
+
+struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
+                                     struct tevent_context *ev,
+                                     struct timeval wakeup_time)
+{
+       struct tevent_req *req;
+       struct tevent_wakeup_state *state;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct tevent_wakeup_state);
+       if (!req) {
+               return NULL;
+       }
+       state->wakeup_time = wakeup_time;
+
+       if (!tevent_req_set_endtime(req, ev, wakeup_time)) {
+               goto post;
+       }
+
+       return req;
+post:
+       return tevent_req_post(req, ev);
+}
+
+bool tevent_wakeup_recv(struct tevent_req *req)
+{
+       enum tevent_req_state state;
+       uint64_t error;
+
+       if (tevent_req_is_error(req, &state, &error)) {
+               if (state == TEVENT_REQ_TIMED_OUT) {
+                       return true;
+               }
+       }
+
+       return false;
+}
diff --git a/ctdb/lib/tevent/wscript b/ctdb/lib/tevent/wscript
new file mode 100644 (file)
index 0000000..114db31
--- /dev/null
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+APPNAME = 'tevent'
+VERSION = '0.9.9'
+
+blddir = 'bin'
+
+import sys, os
+
+# find the buildtools directory
+srcdir = '.'
+while not os.path.exists(srcdir+'/buildtools') and len(srcdir.split('/')) < 5:
+    srcdir = '../' + srcdir
+sys.path.insert(0, srcdir + '/buildtools/wafsamba')
+
+import wafsamba, samba_dist
+
+samba_dist.DIST_DIRS('lib/tevent:. lib/replace:lib/replace lib/talloc:lib/talloc buildtools:buildtools')
+
+def set_options(opt):
+    opt.BUILTIN_DEFAULT('replace')
+    opt.BUNDLED_EXTENSION_DEFAULT('tevent', noextension='tevent')
+    opt.RECURSE('lib/replace')
+    opt.RECURSE('lib/talloc')
+
+def configure(conf):
+    conf.RECURSE('lib/replace')
+    conf.RECURSE('lib/talloc')
+
+    conf.env.standalone_tevent = conf.IN_LAUNCH_DIR()
+
+    if not conf.env.standalone_tevent:
+        if conf.CHECK_BUNDLED_SYSTEM('tevent', minversion=VERSION,
+                                     onlyif='talloc', implied_deps='replace talloc'):
+            conf.define('USING_SYSTEM_TEVENT', 1)
+
+    if conf.CHECK_FUNCS('epoll_create', headers='sys/epoll.h'):
+        conf.DEFINE('HAVE_EPOLL', 1)
+
+    conf.SAMBA_CONFIG_H()
+
+def build(bld):
+    bld.RECURSE('lib/replace')
+    bld.RECURSE('lib/talloc')
+
+    SRC = '''tevent.c tevent_debug.c tevent_fd.c tevent_immediate.c
+             tevent_queue.c tevent_req.c tevent_select.c
+             tevent_signal.c tevent_standard.c tevent_timed.c tevent_util.c tevent_wakeup.c'''
+
+    if bld.CONFIG_SET('HAVE_EPOLL'):
+        SRC += ' tevent_epoll.c'
+
+    if not bld.CONFIG_SET('USING_SYSTEM_TEVENT'):
+        bld.SAMBA_LIBRARY('tevent',
+                          SRC,
+                          deps='replace talloc',
+                          enabled= not bld.CONFIG_SET('USING_SYSTEM_TEVENT'),
+                          abi_file='ABI/tevent-%s.sigs' % VERSION,
+                          abi_match='tevent_* _tevent_*',
+                          vnum=VERSION,
+                                                 is_bundled=not bld.env.standalone_tevent)
+
+    if bld.env.standalone_tevent:
+        bld.env.PKGCONFIGDIR = '${LIBDIR}/pkgconfig'
+        bld.PKG_CONFIG_FILES('tevent.pc', vnum=VERSION)
+        bld.INSTALL_FILES('${INCLUDEDIR}', 'tevent.h')
+
+def test(ctx):
+    '''test tevent'''
+    print("The tevent testsuite is part of smbtorture in samba4")
+
+
+def dist():
+    '''makes a tarball for distribution'''
+    samba_dist.dist()
index 9c4f6dd4d7198c35e89f19030aa6eaebba2afeb5..30474b121122ee048f698d4a2d5a913a52099005 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "includes.h"
 #include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "db_wrap.h"
 
index bb8abc8b6736803efc432fb21b09d9c5da4bce88..3d5f2165d5c7dbec15a1bd7bd4dbcfaf2dfb9e86 100644 (file)
@@ -17,7 +17,7 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/time.h"
 #include "system/network.h"
index 7cb35cd57a8f380f19fe1fa29e8e87545b62aea7..84a8c78e64b761d513f7caeddaceda2e4d1185b8 100644 (file)
@@ -21,7 +21,7 @@
   protocol design and packet details
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
index 0dbc0d9d0d4773e971bcd7dfc1971b390e21f0d6..cbacd17bedd04eee24f58c9aec3164271fbd9633 100644 (file)
@@ -17,7 +17,7 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
index 7a31a13491e53c05400e945bceaff9991035f0a1..517ad9ba12c36dfb5a0360e150b57f3746d6bbef 100644 (file)
@@ -20,7 +20,7 @@
 #include "includes.h"
 #include "db_wrap.h"
 #include "lib/tdb/include/tdb.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -822,8 +822,9 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
 
        /* now start accepting clients, only can do this once frozen */
        fde = event_add_fd(ctdb->ev, ctdb, ctdb->daemon.sd, 
-                          EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+                          EVENT_FD_READ,
                           ctdb_accept_client, ctdb);
+       tevent_fd_set_auto_close(fde);
 
        /* release any IPs we hold from previous runs of the daemon */
        ctdb_release_all_ips(ctdb);
index e641ef3ae68c5e756250416441630e8b153b1b6d..924a7131e853d60d7ef0c2777b58b4cc09b7f489 100644 (file)
@@ -17,7 +17,7 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -231,7 +231,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
        h->fd = fd[0];
 
 
-       fde = event_add_fd(ctdb->ev, h, h->fd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+       fde = event_add_fd(ctdb->ev, h, h->fd, EVENT_FD_READ,
                           ctdb_freeze_lock_handler, h);
        if (fde == NULL) {
                DEBUG(DEBUG_ERR,("Failed to setup fd event for ctdb_freeze_lock\n"));
@@ -239,6 +239,7 @@ static struct ctdb_freeze_handle *ctdb_freeze_lock(struct ctdb_context *ctdb, ui
                talloc_free(h);
                return NULL;
        }
+       tevent_fd_set_auto_close(fde);
 
        return h;
 }
index dfe7cfc622147e069feec96df782b57c476452fa..b4899b746f471ce3f4cde40faa22455b98f6178f 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "../include/ctdb_private.h"
index afbb921439e3fd51bf822568cd5dc2bbf503a6a1..de802187cf19c4212392229ce90c86b022875f97 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "db_wrap.h"
@@ -153,13 +153,14 @@ struct lockwait_handle *ctdb_lockwait(struct ctdb_db_context *ctdb_db,
        talloc_set_destructor(result, lockwait_destructor);
 
        result->fde = event_add_fd(ctdb_db->ctdb->ev, result, result->fd[0],
-                                  EVENT_FD_READ|EVENT_FD_AUTOCLOSE, lockwait_handler,
+                                  EVENT_FD_READ, lockwait_handler,
                                   (void *)result);
        if (result->fde == NULL) {
                talloc_free(result);
                ctdb_db->ctdb->statistics.pending_lockwait_calls--;
                return NULL;
        }
+       tevent_fd_set_auto_close(result->fde);
 
        result->start_time = timeval_current();
 
index 807bb179e0b152353a2c329354c7504616a21060..4680c32b076d0fc098323eaa206d5c99c027f705 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "../include/ctdb_client.h"
 #include "../include/ctdb_private.h"
 #include "system/syslog.h"
@@ -85,6 +85,7 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 {
        struct sockaddr_in syslog_sin;
        struct ctdb_syslog_state *state;
+       struct tevent_fd *fde;
 
        state = talloc(ctdb, struct ctdb_syslog_state);
        CTDB_NO_MEMORY(ctdb, state);
@@ -122,8 +123,9 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
 
        close(state->fd[0]);
        set_close_on_exec(state->fd[1]);
-       event_add_fd(ctdb->ev, state, state->fd[1], EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
+       fde = event_add_fd(ctdb->ev, state, state->fd[1], EVENT_FD_READ,
                     ctdb_syslog_terminate_handler, state);
+       tevent_fd_set_auto_close(fde);
 
        state->syslog_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
        if (state->syslog_fd == -1) {
@@ -147,8 +149,9 @@ int start_syslog_daemon(struct ctdb_context *ctdb)
        }
 
 
-       event_add_fd(ctdb->ev, state, state->syslog_fd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
+       fde = event_add_fd(ctdb->ev, state, state->syslog_fd, EVENT_FD_READ,
                     ctdb_syslog_handler, state);
+       tevent_fd_set_auto_close(fde);
 
        event_loop_wait(ctdb->ev);
 
@@ -434,6 +437,7 @@ struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx,
 {
        int p[2];
        struct ctdb_log_state *log;
+       struct tevent_fd *fde;
 
        log = talloc_zero(mem_ctx, struct ctdb_log_state);
        CTDB_NO_MEMORY_NULL(ctdb, log);
@@ -470,9 +474,10 @@ struct ctdb_log_state *ctdb_fork_with_logging(TALLOC_CTX *mem_ctx,
        log->pfd = p[0];
        set_close_on_exec(log->pfd);
        talloc_set_destructor(log, log_context_destructor);
-       event_add_fd(ctdb->ev, log, log->pfd,
-                    EVENT_FD_READ | EVENT_FD_AUTOCLOSE,
-                    ctdb_log_handler, log);
+       fde = event_add_fd(ctdb->ev, log, log->pfd,
+                          EVENT_FD_READ, ctdb_log_handler, log);
+       tevent_fd_set_auto_close(fde);
+
        return log;
 
 free_log:
@@ -487,6 +492,7 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
 {
        int p[2];
        int old_stdout, old_stderr;
+       struct tevent_fd *fde;
 
        if (ctdb->log->fd == STDOUT_FILENO) {
                /* not needed for stdout logging */
@@ -525,9 +531,10 @@ int ctdb_set_child_logging(struct ctdb_context *ctdb)
        set_close_on_exec(STDERR_FILENO);
        set_close_on_exec(p[0]);
 
-       event_add_fd(ctdb->ev, ctdb->log, p[0],
-                    EVENT_FD_READ | EVENT_FD_AUTOCLOSE,
-                    ctdb_log_handler, ctdb->log);
+       fde = event_add_fd(ctdb->ev, ctdb->log, p[0],
+                          EVENT_FD_READ, ctdb_log_handler, ctdb->log);
+       tevent_fd_set_auto_close(fde);
+
        ctdb->log->pfd = p[0];
 
        DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d for logging\n", p[0]));
index 03c62ac50abbcb0dd74fa3a9e82ccc393903b3d1..b1a032f8cf66d9ec71b8eba130bbabd4220b0d83 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
index 3343501624571d1e8f90076350a9701cda078ba7..d025706adacfcf0ceb003a1965574cc0bb3bbdc4 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "../include/ctdb_private.h"
index d38aa8d9e775539522ba610cfc8c4eadd1ca5863..1d5ab351c6b842d5cfc910038498dbcb365a2d9b 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "db_wrap.h"
@@ -566,13 +566,14 @@ struct childwrite_handle *ctdb_childwrite(struct ctdb_db_context *ctdb_db,
        DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d for ctdb_childwrite\n", result->fd[0]));
 
        result->fde = event_add_fd(ctdb_db->ctdb->ev, result, result->fd[0],
-                                  EVENT_FD_READ|EVENT_FD_AUTOCLOSE, childwrite_handler,
+                                  EVENT_FD_READ, childwrite_handler,
                                   (void *)result);
        if (result->fde == NULL) {
                talloc_free(result);
                ctdb_db->ctdb->statistics.pending_childwrite_calls--;
                return NULL;
        }
+       tevent_fd_set_auto_close(result->fde);
 
        result->start_time = timeval_current();
 
index 22e48986f41d4a1828b397dd1fce13edb582dfe8..33a543e06fca82b66c5a9e5bee351b323381f03c 100644 (file)
@@ -18,7 +18,7 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/time.h"
 #include "system/network.h"
@@ -754,7 +754,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                                    ctdb_set_recmode_timeout, state);
 
        state->fde = event_add_fd(ctdb->ev, state, state->fd[0],
-                               EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
+                               EVENT_FD_READ,
                                set_recmode_handler,
                                (void *)state);
 
@@ -762,6 +762,7 @@ int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
                talloc_free(state);
                return -1;
        }
+       tevent_fd_set_auto_close(state->fde);
 
        state->ctdb    = ctdb;
        state->recmode = recmode;
index 82fe62ea2db93fe8714e5668a25b86842fdc2ece..dc1a59d06792fd4e076bad754498dac41c08fd23 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/time.h"
 #include "system/network.h"
@@ -2804,7 +2804,7 @@ static int check_recovery_lock(struct ctdb_context *ctdb)
        }
 
        state->fde = event_add_fd(ctdb->ev, state, state->fd[0],
-                               EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
+                               EVENT_FD_READ,
                                reclock_child_handler,
                                (void *)state);
 
@@ -2813,6 +2813,7 @@ static int check_recovery_lock(struct ctdb_context *ctdb)
                talloc_free(state);
                return -1;
        }
+       tevent_fd_set_auto_close(state->fde);
 
        while (state->status == RECLOCK_CHECKING) {
                event_loop_once(ctdb->ev);
@@ -3558,6 +3559,7 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 {
        int fd[2];
        struct signal_event *se;
+       struct tevent_fd *fde;
 
        if (pipe(fd) != 0) {
                return -1;
@@ -3589,8 +3591,9 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb)
 
        DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d to recovery daemon\n", fd[0]));
 
-       event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+       fde = event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ,
                     ctdb_recoverd_parent, &fd[0]);     
+       tevent_fd_set_auto_close(fde);
 
        /* set up a handler to pick up sigchld */
        se = event_add_signal(ctdb->ev, ctdb,
index 6563aa1e7be49c908166e6faefe367c928cc0026..e4708eb41d26c1e97e0822e6c64c17e49724acf8 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 #include "lib/tdb/include/tdb.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
 #include "system/filesys.h"
index 52db386d7fe8913bf74062a73227e0c20325ba44..89e9cef221b2d9aa1677c3c784ee69b7d8a8fcf9 100644 (file)
@@ -18,7 +18,7 @@
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
@@ -2408,8 +2408,9 @@ static int ctdb_killtcp_add_connection(struct ctdb_context *ctdb,
 
        if (killtcp->fde == NULL) {
                killtcp->fde = event_add_fd(ctdb->ev, killtcp, killtcp->capture_fd, 
-                                           EVENT_FD_READ | EVENT_FD_AUTOCLOSE, 
+                                           EVENT_FD_READ,
                                            capture_tcp_handler, killtcp);
+               tevent_fd_set_auto_close(killtcp->fde);
 
                /* We also need to set up some events to tickle all these connections
                   until they are all reset
index 3549007cfa91c51b015d4e98bb38a08f53baebb1..e4e10501eb4ea8fbba6b1644c7e01b4d1f427779 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/wait.h"
 #include "db_wrap.h"
index 6bc8158efe9f41749af645d7a582daab0b7edb6f..6720e0da824acf44c6370cd4df0d76642334d7a5 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "../include/ctdb_private.h"
 #include "system/syslog.h"
 #include "system/time.h"
index f1e61dbf115483f1540a23db57578514d5b7d4a0..9ec8b31d968934c6cb54101a4b3b469c578a4f33 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -26,7 +26,7 @@
 #include "../include/ctdb_private.h"
 #include "db_wrap.h"
 #include "lib/util/dlinklist.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "../include/ctdb_private.h"
 #include "../common/rb_tree.h"
 
@@ -801,6 +801,7 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
        struct ctdb_db_context *ctdb_db = vacuum_handle->ctdb_db;
        struct ctdb_context *ctdb = ctdb_db->ctdb;
        struct ctdb_vacuum_child_context *child_ctx;
+       struct tevent_fd *fde;
        int ret;
 
        /* we dont vacuum if we are in recovery mode */
@@ -869,10 +870,9 @@ ctdb_vacuum_event(struct event_context *ev, struct timed_event *te,
 
        DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d to child vacuum process\n", child_ctx->fd[0]));
 
-       event_add_fd(ctdb->ev, child_ctx, child_ctx->fd[0],
-               EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
-               vacuum_child_handler,
-               child_ctx);
+       fde = event_add_fd(ctdb->ev, child_ctx, child_ctx->fd[0],
+                          EVENT_FD_READ, vacuum_child_handler, child_ctx);
+       tevent_fd_set_auto_close(fde);
 
        vacuum_handle->child_ctx = child_ctx;
        child_ctx->vacuum_handle = vacuum_handle;
index e20a742f56ab1cf3a59fef67e9086cbc45c21f19..b0b075c4f31931de8f57028bd8fda5d08a9b9470 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "system/time.h"
index 8011269e26f625595841a5eae5302fa91e70bf57..aa8556d499ac9528f4650c8a239708f33a7298dd 100644 (file)
@@ -24,7 +24,7 @@
 #include "system/dir.h"
 #include "system/locale.h"
 #include "../include/ctdb_private.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "../common/rb_tree.h"
 
 static void ctdb_event_script_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *p);
@@ -363,6 +363,7 @@ static int fork_child_for_script(struct ctdb_context *ctdb,
                                 struct ctdb_event_script_state *state)
 {
        int r;
+       struct tevent_fd *fde;
        struct ctdb_script_wire *current = get_current_script(state);
 
        current->start = timeval_current();
@@ -402,8 +403,10 @@ static int fork_child_for_script(struct ctdb_context *ctdb,
        DEBUG(DEBUG_DEBUG, (__location__ " Created PIPE FD:%d to child eventscript process\n", state->fd[0]));
 
        /* Set ourselves up to be called when that's done. */
-       event_add_fd(ctdb->ev, state, state->fd[0], EVENT_FD_READ|EVENT_FD_AUTOCLOSE,
-                    ctdb_event_script_handler, state);
+       fde = event_add_fd(ctdb->ev, state, state->fd[0], EVENT_FD_READ,
+                          ctdb_event_script_handler, state);
+       tevent_fd_set_auto_close(fde);
+
        return 0;
 }
 
index 2430764e6cd88b33ef59dda321dbbf2555968cfd..d7a0b3368773ff05d7dc5f1ed8b8c4dff5cd087b 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
 #include "system/filesys.h"
@@ -280,6 +280,7 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
        struct flock lock;
        int one = 1;
        int sock_size;
+       struct tevent_fd *fde;
 
        /* in order to ensure that we don't get two nodes with the
           same adddress, we must make the bind() and listen() calls
@@ -395,8 +396,9 @@ static int ctdb_tcp_listen_automatic(struct ctdb_context *ctdb)
                goto failed;
        }
 
-       event_add_fd(ctdb->ev, ctcp, ctcp->listen_fd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
-                    ctdb_listen_event, ctdb);  
+       fde = event_add_fd(ctdb->ev, ctcp, ctcp->listen_fd, EVENT_FD_READ,
+                          ctdb_listen_event, ctdb);
+       tevent_fd_set_auto_close(fde);
 
        close(lock_fd);
        return 0;
@@ -419,6 +421,7 @@ int ctdb_tcp_listen(struct ctdb_context *ctdb)
         ctdb_sock_addr sock;
        int sock_size;
        int one = 1;
+       struct tevent_fd *fde;
 
        /* we can either auto-bind to the first available address, or we can
           use a specified address */
@@ -469,8 +472,9 @@ int ctdb_tcp_listen(struct ctdb_context *ctdb)
                goto failed;
        }
 
-       event_add_fd(ctdb->ev, ctcp, ctcp->listen_fd, EVENT_FD_READ|EVENT_FD_AUTOCLOSE, 
+       fde = event_add_fd(ctdb->ev, ctcp, ctcp->listen_fd, EVENT_FD_READ,
                     ctdb_listen_event, ctdb);  
+       tevent_fd_set_auto_close(fde);
 
        return 0;
 
index edc10f8ac962c3f0481616255135374e289e2280..95141d5610d8b283d84412c4208b9413f7d1d250 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "includes.h"
 #include "lib/tdb/include/tdb.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/network.h"
 #include "system/filesys.h"
 #include "../include/ctdb_private.h"
index 10711d1ea188422e8609a7d88cc13dd62c787be8..bba35decf51ed458e0bc970d0223bfc9442f4afc 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/util/dlinklist.h"
 #include "lib/tdb/include/tdb.h"
 #include "system/network.h"
index 17153f5aa42c6da01017290626ba4506399f1676..6d812237ec2605692be902ae96f36f5f50434ef5 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index 0ab45aaa8d430f4f731689aa528e9185ec762b93..c08494c7a5e34b692dc10061456fa84fff075455 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index 648aa183056a6a201b00a5102bf09397e71d0313..15be3cabdc75388485056b70209e697eddda2901 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index 4a50aa798f78008b5b31ff04c8e878efaf5cf2fc..6074b6a1e361e5a3f86dace78eb374b52aeb3fc0 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index 4b9b2bc93efe593dd73d15fa32558f0d47f41c52..e350f08c1564e4d37ca7ebd724fb2b0aa4eb5b3b 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index ce4195c65ff456c30a505b133ce945a102213949..e4c4052412ebdad6c6bd1344a038f50daf544cc2 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index b70621f2f673ad28557f1af27f490c0fcec65680..39e40dd16bb7f552c15ecd7d97754a2de70cea8f 100644 (file)
@@ -20,7 +20,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index 1726b235d430222cf651f665789fc1ff21dc3385..c4510e43c93a41cb44238c9cd5446a77b930ae15 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "popt.h"
 #include "cmdline.h"
index 553a0f6c4882d3245510a864eff33a09d8ce620a..707f7d71dec966527f97a16805cc813a08676e67 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "lib/util/dlinklist.h"
 #include "system/filesys.h"
 #include "popt.h"
index 4b81df7a2ad20d5734970b9cbd679e32bd1b6089..deb99a54f3573ff8597c3f3df967b06cee9b5a10 100644 (file)
@@ -19,7 +19,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/time.h"
 #include "system/filesys.h"
 #include "system/network.h"
index c761583049511d400863102c48d1e37a16cbc7a9..bd75a69e2564763b69e3f5ffbb467d8570e7df50 100644 (file)
@@ -18,7 +18,7 @@
 */
 
 #include "includes.h"
-#include "lib/events/events.h"
+#include "lib/tevent/tevent.h"
 #include "system/filesys.h"
 #include "system/network.h"
 #include "../include/ctdb_client.h"