1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-08 04:58:40 +03:00

Merge remote branch 'amitay/tevent-sync'

(This used to be ctdb commit 17ff3f240b0d72c72ed28d70fb9aeb3b20c80670)
This commit is contained in:
Ronnie Sahlberg 2012-04-26 08:09:23 +10:00
commit db411aaada
100 changed files with 885 additions and 4752 deletions

View File

@ -22,7 +22,6 @@
#include "db_wrap.h" #include "db_wrap.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "lib/tevent/tevent.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/locale.h" #include "system/locale.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "../include/ctdb_client.h" #include "../include/ctdb_client.h"

View File

@ -22,7 +22,6 @@
#include "includes.h" #include "includes.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/tevent/tevent.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/time.h" #include "system/time.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -21,7 +21,6 @@
protocol design and packet details protocol design and packet details
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -29,7 +29,6 @@
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "lib/tevent/tevent.h"
#include <net/ethernet.h> #include <net/ethernet.h>
#include <netinet/ip6.h> #include <netinet/ip6.h>
#include <net/if_arp.h> #include <net/if_arp.h>

View File

@ -28,7 +28,6 @@
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "lib/tevent/tevent.h"
#include <net/ethernet.h> #include <net/ethernet.h>
#include <netinet/ip6.h> #include <netinet/ip6.h>
#include <net/if_arp.h> #include <net/if_arp.h>

View File

@ -28,7 +28,6 @@
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "lib/tevent/tevent.h"
#include <net/ethernet.h> #include <net/ethernet.h>
#include <netinet/ip6.h> #include <netinet/ip6.h>
#include <net/if_arp.h> #include <net/if_arp.h>

View File

@ -23,7 +23,6 @@
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "lib/tevent/tevent.h"
#include <netinet/if_ether.h> #include <netinet/if_ether.h>
#include <netinet/ip6.h> #include <netinet/ip6.h>
#include <netinet/icmp6.h> #include <netinet/icmp6.h>

View File

@ -21,7 +21,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include <system/network.h> #include <system/network.h>
#include <assert.h> #include <assert.h>
#include "ctdb_private.h" #include "ctdb_private.h"

View File

@ -21,7 +21,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include <system/network.h> #include <system/network.h>
#include <assert.h> #include <assert.h>
#include "ctdb_private.h" #include "ctdb_private.h"

View File

@ -37,7 +37,6 @@
#include <time.h> #include <time.h>
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "ib/ibwrapper.h" #include "ib/ibwrapper.h"
struct ibwtest_ctx { struct ibwtest_ctx {

View File

@ -11,6 +11,13 @@
#include "idtree.h" #include "idtree.h"
#include "ctdb_client.h" #include "ctdb_client.h"
/* Allow use of deprecated function tevent_loop_allow_nesting() */
#define TEVENT_DEPRECATED
/* Saves ctdb from massive churn. */
#define TEVENT_COMPAT_DEFINES 1
#include "tevent.h"
typedef bool BOOL; typedef bool BOOL;
#define True 1 #define True 1

View File

@ -14,6 +14,7 @@ _tevent_req_done: void (struct tevent_req *, const char *)
_tevent_req_error: bool (struct tevent_req *, uint64_t, 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_nomem: bool (const void *, struct tevent_req *, const char *)
_tevent_req_notify_callback: void (struct tevent_req *, const char *) _tevent_req_notify_callback: void (struct tevent_req *, const char *)
_tevent_req_oom: 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_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_backend_list: const char **(TALLOC_CTX *)
tevent_cleanup_pending_signal_handlers: void (struct tevent_signal *) tevent_cleanup_pending_signal_handlers: void (struct tevent_signal *)
@ -40,12 +41,16 @@ tevent_fd_set_flags: void (struct tevent_fd *, uint16_t)
tevent_loop_allow_nesting: void (struct tevent_context *) tevent_loop_allow_nesting: void (struct tevent_context *)
tevent_loop_set_nesting_hook: void (struct tevent_context *, tevent_nesting_hook, void *) 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_add: bool (struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
tevent_queue_add_entry: struct tevent_queue_entry *(struct tevent_queue *, struct tevent_context *, struct tevent_req *, tevent_queue_trigger_fn_t, void *)
tevent_queue_add_optimize_empty: struct tevent_queue_entry *(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_length: size_t (struct tevent_queue *)
tevent_queue_running: bool (struct tevent_queue *)
tevent_queue_start: void (struct tevent_queue *) tevent_queue_start: void (struct tevent_queue *)
tevent_queue_stop: void (struct tevent_queue *) tevent_queue_stop: void (struct tevent_queue *)
tevent_re_initialise: int (struct tevent_context *) tevent_re_initialise: int (struct tevent_context *)
tevent_register_backend: bool (const char *, const struct tevent_ops *) tevent_register_backend: bool (const char *, const struct tevent_ops *)
tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *) tevent_req_default_print: char *(struct tevent_req *, TALLOC_CTX *)
tevent_req_defer_callback: void (struct tevent_req *, struct tevent_context *)
tevent_req_is_error: bool (struct tevent_req *, enum tevent_req_state *, uint64_t *) 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_is_in_progress: bool (struct tevent_req *)
tevent_req_poll: bool (struct tevent_req *, struct tevent_context *) tevent_req_poll: bool (struct tevent_req *, struct tevent_context *)

View File

@ -1,79 +0,0 @@
#!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

View File

@ -1 +0,0 @@
../../buildtools/scripts/autogen-waf.sh

View File

@ -1,13 +0,0 @@
#!/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

View File

@ -1,14 +0,0 @@
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)
])

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
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)

View File

@ -8,7 +8,7 @@
* signals, and the classic file descriptor events. * signals, and the classic file descriptor events.
* *
* Tevent also provide helpers to deal with asynchronous code providing the * Tevent also provide helpers to deal with asynchronous code providing the
* tevent_req (tevent tequest) functions. * tevent_req (tevent request) functions.
* *
* @section tevent_download Download * @section tevent_download Download
* *

View File

@ -1,238 +0,0 @@
#! /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

View File

@ -1,7 +0,0 @@
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)])

View File

@ -39,7 +39,7 @@ if test x"$INCLUDED_TEVENT" != x"no" ; then
TEVENT_OBJ="tevent.o tevent_debug.o tevent_util.o" 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_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_req.o tevent_wakeup.o tevent_queue.o"
TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o" TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o tevent_poll.o"
AC_SUBST(TEVENT_OBJ) AC_SUBST(TEVENT_OBJ)
TEVENT_CFLAGS="-I$teventdir" TEVENT_CFLAGS="-I$teventdir"
@ -55,8 +55,3 @@ if test x"$INCLUDED_TEVENT" != x"no" ; then
AC_DEFINE(HAVE_EPOLL, 1, [Whether epoll available]) AC_DEFINE(HAVE_EPOLL, 1, [Whether epoll available])
fi fi
fi fi
if test x"$VERSIONSCRIPT" != "x"; then
EXPORTSFILE=tevent.exports
AC_SUBST(EXPORTSFILE)
fi

View File

@ -1,156 +0,0 @@
# 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

View File

@ -1,48 +0,0 @@
#!/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}

View File

@ -1,18 +0,0 @@
.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 *~ */*~

View File

@ -1,11 +0,0 @@
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}])

View File

@ -1,91 +0,0 @@
#!/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

View File

@ -1,31 +0,0 @@
#!/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

View File

@ -1,183 +0,0 @@
#!/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";
}

View File

@ -1,75 +0,0 @@
#
# 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;
}

View File

@ -1,45 +0,0 @@
#! /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

View File

@ -101,7 +101,9 @@ static bool test_event_context(struct torture_context *test,
#ifdef SA_RESTART #ifdef SA_RESTART
se1 = event_add_signal(ev_ctx, ev_ctx, SIGALRM, SA_RESTART, count_handler, &alarm_count); se1 = event_add_signal(ev_ctx, ev_ctx, SIGALRM, SA_RESTART, count_handler, &alarm_count);
#endif #endif
#ifdef SA_RESETHAND
se2 = event_add_signal(ev_ctx, ev_ctx, SIGALRM, SA_RESETHAND, count_handler, &alarm_count); se2 = event_add_signal(ev_ctx, ev_ctx, SIGALRM, SA_RESETHAND, count_handler, &alarm_count);
#endif
#ifdef SA_SIGINFO #ifdef SA_SIGINFO
se3 = event_add_signal(ev_ctx, ev_ctx, SIGUSR1, SA_SIGINFO, count_handler, &info_count); se3 = event_add_signal(ev_ctx, ev_ctx, SIGUSR1, SA_SIGINFO, count_handler, &info_count);
#endif #endif
@ -146,7 +148,7 @@ static bool test_event_context(struct torture_context *test,
struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx) struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx)
{ {
struct torture_suite *suite = torture_suite_create(mem_ctx, "EVENT"); struct torture_suite *suite = torture_suite_create(mem_ctx, "event");
const char **list = event_backend_list(suite); const char **list = event_backend_list(suite);
int i; int i;

View File

@ -64,9 +64,6 @@
#include "tevent_internal.h" #include "tevent_internal.h"
#include "tevent_util.h" #include "tevent_util.h"
/* needed for the special ctdbd "track if time jumps unexpectedly */
#include <time.h>
struct tevent_ops_list { struct tevent_ops_list {
struct tevent_ops_list *next, *prev; struct tevent_ops_list *next, *prev;
const char *name; const char *name;
@ -91,7 +88,7 @@ bool tevent_register_backend(const char *name, const struct tevent_ops *ops)
} }
} }
e = talloc(talloc_autofree_context(), struct tevent_ops_list); e = talloc(NULL, struct tevent_ops_list);
if (e == NULL) return false; if (e == NULL) return false;
e->name = name; e->name = name;
@ -107,8 +104,7 @@ bool tevent_register_backend(const char *name, const struct tevent_ops *ops)
void tevent_set_default_backend(const char *backend) void tevent_set_default_backend(const char *backend)
{ {
talloc_free(tevent_default_backend); talloc_free(tevent_default_backend);
tevent_default_backend = talloc_strdup(talloc_autofree_context(), tevent_default_backend = talloc_strdup(NULL, backend);
backend);
} }
/* /*
@ -117,6 +113,7 @@ void tevent_set_default_backend(const char *backend)
static void tevent_backend_init(void) static void tevent_backend_init(void)
{ {
tevent_select_init(); tevent_select_init();
tevent_poll_init();
tevent_standard_init(); tevent_standard_init();
#ifdef HAVE_EPOLL #ifdef HAVE_EPOLL
tevent_epoll_init(); tevent_epoll_init();
@ -188,6 +185,17 @@ int tevent_common_context_destructor(struct tevent_context *ev)
tevent_cleanup_pending_signal_handlers(se); tevent_cleanup_pending_signal_handlers(se);
} }
/* removing nesting hook or we get an abort when nesting is
* not allowed. -- SSS
* Note that we need to leave the allowed flag at its current
* value, otherwise the use in tevent_re_initialise() will
* leave the event context with allowed forced to false, which
* will break users that expect nesting to be allowed
*/
ev->nesting.level = 0;
ev->nesting.hook_fn = NULL;
ev->nesting.hook_private = NULL;
return 0; return 0;
} }
@ -394,7 +402,6 @@ struct tevent_immediate *_tevent_create_immediate(TALLOC_CTX *mem_ctx,
/* /*
schedule an immediate event schedule an immediate event
return NULL on failure
*/ */
void _tevent_schedule_immediate(struct tevent_immediate *im, void _tevent_schedule_immediate(struct tevent_immediate *im,
struct tevent_context *ev, struct tevent_context *ev,
@ -581,14 +588,12 @@ done:
return ret; return ret;
} }
/* /*
return on failure or (with 0) if all fd events are removed return on failure or (with 0) if all fd events are removed
*/ */
int tevent_common_loop_wait(struct tevent_context *ev, int tevent_common_loop_wait(struct tevent_context *ev,
const char *location) const char *location)
{ {
/* /*
* loop as long as we have events pending * loop as long as we have events pending
*/ */

View File

@ -1,62 +0,0 @@
{
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: *;
};

View File

@ -28,10 +28,6 @@
#ifndef __TEVENT_H__ #ifndef __TEVENT_H__
#define __TEVENT_H__ #define __TEVENT_H__
#ifndef TEVENT_DEPRECATED
#define TEVENT_DEPRECATED
#endif
#include <stdint.h> #include <stdint.h>
#include <talloc.h> #include <talloc.h>
#include <sys/time.h> #include <sys/time.h>
@ -115,7 +111,7 @@ typedef void (*tevent_signal_handler_t)(struct tevent_context *ev,
struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx); struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
/** /**
* @brief Create a event_context structure and name it. * @brief Create a event_context structure and select a specific backend.
* *
* This must be the first events call, and all subsequent calls pass this * 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 * event_context as the first element. Event handlers also receive this as
@ -123,7 +119,7 @@ struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
* *
* @param[in] mem_ctx The memory context to use. * @param[in] mem_ctx The memory context to use.
* *
* @param[in] name The name for the tevent context. * @param[in] name The name of the backend to use.
* *
* @return An allocated tevent context, NULL on error. * @return An allocated tevent context, NULL on error.
*/ */
@ -140,7 +136,7 @@ struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const cha
const char **tevent_backend_list(TALLOC_CTX *mem_ctx); const char **tevent_backend_list(TALLOC_CTX *mem_ctx);
/** /**
* @brief Set the default tevent backent. * @brief Set the default tevent backend.
* *
* @param[in] backend The name of the backend to set. * @param[in] backend The name of the backend to set.
*/ */
@ -513,50 +509,121 @@ int tevent_set_debug_stderr(struct tevent_context *ev);
* @defgroup tevent_request The tevent request functions. * @defgroup tevent_request The tevent request functions.
* @ingroup tevent * @ingroup tevent
* *
* This represents an async request being processed by callbacks via an event * A tevent_req represents an asynchronous computation.
* 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 * The tevent_req group of API calls is the recommended way of
* finished. This can happen while the completion function is called. * programming async computations within tevent. In particular the
* file descriptor (tevent_add_fd) and timer (tevent_add_timed) events
* are considered too low-level to be used in larger computations. To
* read and write from and to sockets, Samba provides two calls on top
* of tevent_add_fd: read_packet_send/recv and writev_send/recv. These
* requests are much easier to compose than the low-level event
* handlers called from tevent_add_fd.
*
* A lot of the simplicity tevent_req has brought to the notoriously
* hairy async programming came via a set of conventions that every
* async computation programmed should follow. One central piece of
* these conventions is the naming of routines and variables.
*
* Every async computation needs a name (sensibly called "computation"
* down from here). From this name quite a few naming conventions are
* derived.
*
* Every computation that requires local state needs a
* @code
* struct computation_state {
* int local_var;
* };
* @endcode
* Even if no local variables are required, such a state struct should
* be created containing a dummy variable. Quite a few helper
* functions and macros (for example tevent_req_create()) assume such
* a state struct.
*
* An async computation is started by a computation_send
* function. When it is finished, its result can be received by a
* computation_recv function. For an example how to set up an async
* computation, see the code example in the documentation for
* tevent_req_create() and tevent_req_post(). The prototypes for _send
* and _recv functions should follow some conventions:
*
* @code
* struct tevent_req *computation_send(TALLOC_CTX *mem_ctx,
* struct tevent_req *ev,
* ... further args);
* int computation_recv(struct tevent_req *req, ... further output args);
* @endcode
*
* The "int" result of computation_recv() depends on the result the
* sync version of the function would have, "int" is just an example
* here.
*
* Another important piece of the conventions is that the program flow
* is interrupted as little as possible. Because a blocking
* sub-computation requires that the flow needs to continue in a
* separate function that is the logical sequel of some computation,
* it should lexically follow sending off the blocking
* sub-computation. Setting the callback function via
* tevent_req_set_callback() requires referencing a function lexically
* below the call to tevent_req_set_callback(), forward declarations
* are required. A lot of the async computations thus begin with a
* sequence of declarations such as
*
* @code
* static void computation_step1_done(struct tevent_req *subreq);
* static void computation_step2_done(struct tevent_req *subreq);
* static void computation_step3_done(struct tevent_req *subreq);
* @endcode
*
* It really helps readability a lot to do these forward declarations,
* because the lexically sequential program flow makes the async
* computations almost as clear to read as a normal, sync program
* flow.
*
* It is up to the user of the async computation to talloc_free it
* after it has finished. If an async computation should be aborted,
* the tevent_req structure can be talloc_free'ed. After it has
* finished, it should talloc_free'ed by the API user.
* *
* @{ * @{
*/ */
/** /**
* An async request moves between the following 4 states: * An async request moves from TEVENT_REQ_INIT to
* TEVENT_REQ_IN_PROGRESS. All other states are valid after a request
* has finished.
*/ */
enum tevent_req_state { enum tevent_req_state {
/** /**
* we are creating the request * We are creating the request
*/ */
TEVENT_REQ_INIT, TEVENT_REQ_INIT,
/** /**
* we are waiting the request to complete * We are waiting the request to complete
*/ */
TEVENT_REQ_IN_PROGRESS, TEVENT_REQ_IN_PROGRESS,
/** /**
* the request is finished * The request is finished successfully
*/ */
TEVENT_REQ_DONE, TEVENT_REQ_DONE,
/** /**
* A user error has occurred * A user error has occurred. The user error has been
* indicated by tevent_req_error(), it can be retrieved via
* tevent_req_is_error().
*/ */
TEVENT_REQ_USER_ERROR, TEVENT_REQ_USER_ERROR,
/** /**
* Request timed out * Request timed out after the timeout set by tevent_req_set_endtime.
*/ */
TEVENT_REQ_TIMED_OUT, TEVENT_REQ_TIMED_OUT,
/** /**
* No memory in between * An internal allocation has failed, or tevent_req_nomem has
* been given a NULL pointer as the first argument.
*/ */
TEVENT_REQ_NO_MEMORY, TEVENT_REQ_NO_MEMORY,
/** /**
* the request is already received by the caller * The request has been received by the caller. No further
* action is valid.
*/ */
TEVENT_REQ_RECEIVED TEVENT_REQ_RECEIVED
}; };
@ -576,6 +643,9 @@ typedef void (*tevent_req_fn)(struct tevent_req *req);
/** /**
* @brief Set an async request callback. * @brief Set an async request callback.
* *
* See the documentation of tevent_req_post() for an example how this
* is supposed to be used.
*
* @param[in] req The async request to set the callback. * @param[in] req The async request to set the callback.
* *
* @param[in] fn The callback function to set. * @param[in] fn The callback function to set.
@ -587,9 +657,17 @@ void tevent_req_set_callback(struct tevent_req *req, tevent_req_fn fn, void *pvt
#ifdef DOXYGEN #ifdef DOXYGEN
/** /**
* @brief Get the private data casted to the given type for a callback from * @brief Get the private data cast to the given type for a callback from
* a tevent request structure. * a tevent request structure.
* *
* @code
* static void computation_done(struct tevent_req *subreq) {
* struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req);
* struct computation_state *state = tevent_req_data(req, struct computation_state);
* .... more things, eventually maybe call tevent_req_done(req);
* }
* @endcode
*
* @param[in] req The structure to get the callback data from. * @param[in] req The structure to get the callback data from.
* *
* @param[in] type The type of the private callback data to get. * @param[in] type The type of the private callback data to get.
@ -623,11 +701,17 @@ void *tevent_req_callback_data_void(struct tevent_req *req);
/** /**
* @brief Get the private data from a tevent request structure. * @brief Get the private data from a tevent request structure.
* *
* When the tevent_req has been created by tevent_req_create, the
* result of tevent_req_data() is the state variable created by
* tevent_req_create() as a child of the req.
*
* @param[in] req The structure to get the private data from. * @param[in] req The structure to get the private data from.
* *
* @param[in] type The type of the private data
*
* @return The private data or NULL if not set. * @return The private data or NULL if not set.
*/ */
void *tevent_req_data(struct tevent_req *req); void *tevent_req_data(struct tevent_req *req, #type);
#else #else
void *_tevent_req_data(struct tevent_req *req); void *_tevent_req_data(struct tevent_req *req);
#define tevent_req_data(_req, _type) \ #define tevent_req_data(_req, _type) \
@ -759,22 +843,29 @@ bool _tevent_req_cancel(struct tevent_req *req, const char *location);
/** /**
* @brief Create an async tevent request. * @brief Create an async tevent request.
* *
* The new async request will be initialized in state ASYNC_REQ_IN_PROGRESS. * The new async request will be initialized in state TEVENT_REQ_IN_PROGRESS.
*
* @code
* struct tevent_req *req;
* struct computation_state *state;
* req = tevent_req_create(mem_ctx, &state, struct computation_state);
* @endcode
*
* Tevent_req_create() creates the state variable as a talloc child of
* its result. The state variable should be used as the talloc parent
* for all temporary variables that are allocated during the async
* computation. This way, when the user of the async computation frees
* the request, the state as a talloc child will be free'd along with
* all the temporary variables hanging off the state.
* *
* @param[in] mem_ctx The memory context for the result. * @param[in] mem_ctx The memory context for the result.
* * @param[in] pstate Pointer to the private request state.
* @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. * @param[in] type The name of the request.
* *
* @return A new async request. NULL on error. * @return A new async request. NULL on error.
*/ */
struct tevent_req *tevent_req_create(TALLOC_CTX *mem_ctx, struct tevent_req *tevent_req_create(TALLOC_CTX *mem_ctx,
void *pstate, void **pstate, #type);
size_t state_size,
const char *type);
#else #else
struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx, struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
void *pstate, void *pstate,
@ -904,32 +995,105 @@ bool _tevent_req_nomem(const void *p,
_tevent_req_nomem(p, req, __location__) _tevent_req_nomem(p, req, __location__)
#endif #endif
#ifdef DOXYGEN
/**
* @brief Indicate out of memory to a request
*
* @param[in] req The request being processed.
*/
void tevent_req_oom(struct tevent_req *req);
#else
void _tevent_req_oom(struct tevent_req *req,
const char *location);
#define tevent_req_oom(req) \
_tevent_req_oom(req, __location__)
#endif
/** /**
* @brief Finish a request before the caller had the change to set the callback. * @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 * 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 request without waiting for an external event, or it can not even start
* the engine. To present the illusion of a callback to the user of the API, * 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 * the implementation can call this helper function which triggers an
* immediate timed event. This way the caller can use the same calling * immediate event. This way the caller can use the same calling
* conventions, independent of whether the request was actually deferred. * conventions, independent of whether the request was actually deferred.
* *
* @code
* struct tevent_req *computation_send(TALLOC_CTX *mem_ctx,
* struct tevent_context *ev)
* {
* struct tevent_req *req, *subreq;
* struct computation_state *state;
* req = tevent_req_create(mem_ctx, &state, struct computation_state);
* if (req == NULL) {
* return NULL;
* }
* subreq = subcomputation_send(state, ev);
* if (tevent_req_nomem(subreq, req)) {
* return tevent_req_post(req, ev);
* }
* tevent_req_set_callback(subreq, computation_done, req);
* return req;
* }
* @endcode
*
* @param[in] req The finished request. * @param[in] req The finished request.
* *
* @param[in] ev The tevent_context for the timed event. * @param[in] ev The tevent_context for the immediate event.
* *
* @return The given request will be returned. * @return The given request will be returned.
*/ */
struct tevent_req *tevent_req_post(struct tevent_req *req, struct tevent_req *tevent_req_post(struct tevent_req *req,
struct tevent_context *ev); struct tevent_context *ev);
/**
* @brief Finish multiple requests within one function
*
* Normally tevent_req_notify_callback() and all wrappers
* (e.g. tevent_req_done() and tevent_req_error())
* need to be the last thing an event handler should call.
* This is because the callback is likely to destroy the
* context of the current function.
*
* If a function wants to notify more than one caller,
* it is dangerous if it just triggers multiple callbacks
* in a row. With tevent_req_defer_callback() it is possible
* to set an event context that will be used to defer the callback
* via an immediate event (similar to tevent_req_post()).
*
* @code
* struct complete_state {
* struct tevent_context *ev;
*
* struct tevent_req **reqs;
* };
*
* void complete(struct complete_state *state)
* {
* size_t i, c = talloc_array_length(state->reqs);
*
* for (i=0; i < c; i++) {
* tevent_req_defer_callback(state->reqs[i], state->ev);
* tevent_req_done(state->reqs[i]);
* }
* }
* @endcode
*
* @param[in] req The finished request.
*
* @param[in] ev The tevent_context for the immediate event.
*
* @return The given request will be returned.
*/
void tevent_req_defer_callback(struct tevent_req *req,
struct tevent_context *ev);
/** /**
* @brief Check if the given request is still in progress. * @brief Check if the given request is still in progress.
* *
* It is typically used by sync wrapper functions. * It is typically used by sync wrapper functions.
* *
* This function destroys the attached private data.
*
* @param[in] req The request to poll. * @param[in] req The request to poll.
* *
* @return The boolean form of "is in progress". * @return The boolean form of "is in progress".
@ -967,7 +1131,21 @@ bool tevent_req_poll(struct tevent_req *req,
struct tevent_context *ev); struct tevent_context *ev);
/** /**
* @brief Get the tevent request and the actual error code you've set. * @brief Get the tevent request state and the actual error set by
* tevent_req_error.
*
* @code
* int computation_recv(struct tevent_req *req, uint64_t *perr)
* {
* enum tevent_req_state state;
* uint64_t err;
* if (tevent_req_is_error(req, &state, &err)) {
* *perr = err;
* return -1;
* }
* return 0;
* }
* @endcode
* *
* @param[in] req The tevent request to get the error from. * @param[in] req The tevent request to get the error from.
* *
@ -1008,7 +1186,7 @@ void tevent_req_received(struct tevent_req *req);
* *
* Example: * Example:
* @code * @code
* static my_callback_wakeup_done(tevent_req *req) * static void my_callback_wakeup_done(tevent_req *subreq)
* { * {
* struct tevent_req *req = tevent_req_callback_data(subreq, * struct tevent_req *req = tevent_req_callback_data(subreq,
* struct tevent_req); * struct tevent_req);
@ -1096,7 +1274,7 @@ struct timeval tevent_timeval_current(void);
* *
* @param[in] secs The seconds to set. * @param[in] secs The seconds to set.
* *
* @param[in] usecs The milliseconds to set. * @param[in] usecs The microseconds to set.
* *
* @return A timeval structure with the given values. * @return A timeval structure with the given values.
*/ */
@ -1131,7 +1309,7 @@ bool tevent_timeval_is_zero(const struct timeval *tv);
* *
* @param[in] secs The seconds to add to the timeval. * @param[in] secs The seconds to add to the timeval.
* *
* @param[in] usecs The milliseconds to add to the timeval. * @param[in] usecs The microseconds to add to the timeval.
* *
* @return The timeval structure with the new time. * @return The timeval structure with the new time.
*/ */
@ -1143,7 +1321,7 @@ struct timeval tevent_timeval_add(const struct timeval *tv, uint32_t secs,
* *
* @param[in] secs The seconds of the offset from now. * @param[in] secs The seconds of the offset from now.
* *
* @param[in] usecs The milliseconds of the offset from now. * @param[in] usecs The microseconds of the offset from now.
* *
* @return A timval with the given offset in the future. * @return A timval with the given offset in the future.
*/ */
@ -1169,6 +1347,7 @@ struct timeval tevent_timeval_current_ofs(uint32_t secs, uint32_t usecs);
*/ */
struct tevent_queue; struct tevent_queue;
struct tevent_queue_entry;
#ifdef DOXYGEN #ifdef DOXYGEN
/** /**
@ -1180,8 +1359,8 @@ struct tevent_queue;
* *
* @return An allocated tevent queue on success, NULL on error. * @return An allocated tevent queue on success, NULL on error.
* *
* @see tevent_start() * @see tevent_queue_start()
* @see tevent_stop() * @see tevent_queue_stop()
*/ */
struct tevent_queue *tevent_queue_create(TALLOC_CTX *mem_ctx, struct tevent_queue *tevent_queue_create(TALLOC_CTX *mem_ctx,
const char *name); const char *name);
@ -1203,6 +1382,8 @@ struct tevent_queue *_tevent_queue_create(TALLOC_CTX *mem_ctx,
* tevent_queue_add(). * tevent_queue_add().
* *
* @see tevent_queue_add() * @see tevent_queue_add()
* @see tevent_queue_add_entry()
* @see tevent_queue_add_optimize_empty()
*/ */
typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req, typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
void *private_data); void *private_data);
@ -1217,7 +1398,9 @@ typedef void (*tevent_queue_trigger_fn_t)(struct tevent_req *req,
* @param[in] req The tevent request to add to the queue. * @param[in] req The tevent request to add to the queue.
* *
* @param[in] trigger The function triggered by the queue when the request * @param[in] trigger The function triggered by the queue when the request
* is called. * is called. Since tevent 0.9.14 it's possible to
* pass NULL, in order to just add a "blocker" to the
* queue.
* *
* @param[in] private_data The private data passed to the trigger function. * @param[in] private_data The private data passed to the trigger function.
* *
@ -1230,6 +1413,79 @@ bool tevent_queue_add(struct tevent_queue *queue,
tevent_queue_trigger_fn_t trigger, tevent_queue_trigger_fn_t trigger,
void *private_data); void *private_data);
/**
* @brief Add a tevent request to the queue.
*
* The request can be removed from the queue by calling talloc_free()
* (or a similar function) on the returned queue entry. This
* is the only difference to tevent_queue_add().
*
* @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. Since tevent 0.9.14 it's possible to
* pass NULL, in order to just add a "blocker" to the
* queue.
*
* @param[in] private_data The private data passed to the trigger function.
*
* @return a pointer to the tevent_queue_entry if the request
* has been successfully added, NULL otherwise.
*
* @see tevent_queue_add()
* @see tevent_queue_add_optimize_empty()
*/
struct tevent_queue_entry *tevent_queue_add_entry(
struct tevent_queue *queue,
struct tevent_context *ev,
struct tevent_req *req,
tevent_queue_trigger_fn_t trigger,
void *private_data);
/**
* @brief Add a tevent request to the queue using a possible optimization.
*
* This tries to optimize for the empty queue case and may calls
* the trigger function directly. This is the only difference compared
* to tevent_queue_add_entry().
*
* The caller needs to be prepared that the trigger function has
* already called tevent_req_notify_callback(), tevent_req_error(),
* tevent_req_done() or a similar function.
*
* The request can be removed from the queue by calling talloc_free()
* (or a similar function) on the returned queue entry.
*
* @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. Since tevent 0.9.14 it's possible to
* pass NULL, in order to just add a "blocker" to the
* queue.
*
* @param[in] private_data The private data passed to the trigger function.
*
* @return a pointer to the tevent_queue_entry if the request
* has been successfully added, NULL otherwise.
*
* @see tevent_queue_add()
* @see tevent_queue_add_entry()
*/
struct tevent_queue_entry *tevent_queue_add_optimize_empty(
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. * @brief Start a tevent queue.
* *
@ -1257,6 +1513,17 @@ void tevent_queue_stop(struct tevent_queue *queue);
*/ */
size_t tevent_queue_length(struct tevent_queue *queue); size_t tevent_queue_length(struct tevent_queue *queue);
/**
* @brief Is the tevent queue running.
*
* The queue is started by default.
*
* @param[in] queue The queue.
*
* @return Wether the queue is running or not..
*/
bool tevent_queue_running(struct tevent_queue *queue);
typedef int (*tevent_nesting_hook)(struct tevent_context *ev, typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
void *private_data, void *private_data,
uint32_t level, uint32_t level,
@ -1264,7 +1531,6 @@ typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
void *stack_ptr, void *stack_ptr,
const char *location); const char *location);
#ifdef TEVENT_DEPRECATED #ifdef TEVENT_DEPRECATED
#if (TEVENT_DEPRECATED_QUIET != 1)
#ifndef _DEPRECATED_ #ifndef _DEPRECATED_
#if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 ) #if (__GNUC__ >= 3) && (__GNUC_MINOR__ >= 1 )
#define _DEPRECATED_ __attribute__ ((deprecated)) #define _DEPRECATED_ __attribute__ ((deprecated))
@ -1272,10 +1538,6 @@ typedef int (*tevent_nesting_hook)(struct tevent_context *ev,
#define _DEPRECATED_ #define _DEPRECATED_
#endif #endif
#endif #endif
#else
#undef _DEPRECATED_
#define _DEPRECATED_
#endif
void tevent_loop_allow_nesting(struct tevent_context *ev) _DEPRECATED_; void tevent_loop_allow_nesting(struct tevent_context *ev) _DEPRECATED_;
void tevent_loop_set_nesting_hook(struct tevent_context *ev, void tevent_loop_set_nesting_hook(struct tevent_context *ev,
tevent_nesting_hook hook, tevent_nesting_hook hook,
@ -1367,8 +1629,6 @@ bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
* @{ * @{
*/ */
/* Saves ctdb from massive churn. */
#define TEVENT_COMPAT_DEFINES 1
#ifdef TEVENT_COMPAT_DEFINES #ifdef TEVENT_COMPAT_DEFINES
#define event_context tevent_context #define event_context tevent_context

View File

@ -1,46 +0,0 @@
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

View File

@ -1,57 +0,0 @@
_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);

View File

@ -42,8 +42,7 @@ struct epoll_event_context {
}; };
/* /*
called when a epoll call fails, and we should fallback called when a epoll call fails
to using select
*/ */
static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason) static void epoll_panic(struct epoll_event_context *epoll_ev, const char *reason)
{ {
@ -79,11 +78,20 @@ static int epoll_ctx_destructor(struct epoll_event_context *epoll_ev)
static int epoll_init_ctx(struct epoll_event_context *epoll_ev) static int epoll_init_ctx(struct epoll_event_context *epoll_ev)
{ {
epoll_ev->epoll_fd = epoll_create(64); epoll_ev->epoll_fd = epoll_create(64);
epoll_ev->pid = getpid();
talloc_set_destructor(epoll_ev, epoll_ctx_destructor);
if (epoll_ev->epoll_fd == -1) { if (epoll_ev->epoll_fd == -1) {
tevent_debug(epoll_ev->ev, TEVENT_DEBUG_FATAL,
"Failed to create epoll handle.\n");
return -1; return -1;
} }
if (!ev_set_close_on_exec(epoll_ev->epoll_fd)) {
tevent_debug(epoll_ev->ev, TEVENT_DEBUG_WARNING,
"Failed to set close-on-exec, file descriptor may be leaked to children.\n");
}
epoll_ev->pid = getpid();
talloc_set_destructor(epoll_ev, epoll_ctx_destructor);
return 0; return 0;
} }
@ -109,6 +117,12 @@ static void epoll_check_reopen(struct epoll_event_context *epoll_ev)
"Failed to recreate epoll handle after fork\n"); "Failed to recreate epoll handle after fork\n");
return; return;
} }
if (!ev_set_close_on_exec(epoll_ev->epoll_fd)) {
tevent_debug(epoll_ev->ev, TEVENT_DEBUG_WARNING,
"Failed to set close-on-exec, file descriptor may be leaked to children.\n");
}
epoll_ev->pid = getpid(); epoll_ev->pid = getpid();
for (fde=epoll_ev->ev->fd_events;fde;fde=fde->next) { for (fde=epoll_ev->ev->fd_events;fde;fde=fde->next) {
epoll_add_event(epoll_ev, fde); epoll_add_event(epoll_ev, fde);
@ -228,8 +242,6 @@ static void epoll_change_event(struct epoll_event_context *epoll_ev, struct teve
} }
} }
extern pid_t ctdbd_pid;
/* /*
event loop handling using epoll event loop handling using epoll
*/ */
@ -252,9 +264,7 @@ static int epoll_event_loop(struct epoll_event_context *epoll_ev, struct timeval
return 0; return 0;
} }
if (getpid() == ctdbd_pid) tevent_before_wait(epoll_ev->ev);
ret = epoll_wait(epoll_ev->epoll_fd, events, MAXEVENTS, timeout); ret = epoll_wait(epoll_ev->epoll_fd, events, MAXEVENTS, timeout);
if (getpid() == ctdbd_pid) tevent_after_wait(epoll_ev->ev);
if (ret == -1 && errno == EINTR && epoll_ev->ev->signal_events) { if (ret == -1 && errno == EINTR && epoll_ev->ev->signal_events) {
if (tevent_common_check_signal(epoll_ev->ev)) { if (tevent_common_check_signal(epoll_ev->ev)) {

View File

@ -51,6 +51,12 @@ struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev, TALLOC_CTX *me
{ {
struct tevent_fd *fde; struct tevent_fd *fde;
/* tevent will crash later on select() if we save
* a negative file descriptor. Better to fail here
* so that consumers will be able to debug it
*/
if (fd < 0) return NULL;
fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd); fde = talloc(mem_ctx?mem_ctx:ev, struct tevent_fd);
if (!fde) return NULL; if (!fde) return NULL;

View File

@ -141,6 +141,12 @@ struct tevent_req {
*/ */
struct tevent_immediate *trigger; struct tevent_immediate *trigger;
/**
* @brief An event context which will be used to
* defer the _tevent_req_notify_callback().
*/
struct tevent_context *defer_callback_ev;
/** /**
* @brief the timer event if tevent_req_set_endtime was used * @brief the timer event if tevent_req_set_endtime was used
* *
@ -162,7 +168,7 @@ struct tevent_fd {
const char *handler_name; const char *handler_name;
const char *location; const char *location;
/* this is private for the events_ops implementation */ /* this is private for the events_ops implementation */
uint16_t additional_flags; uint64_t additional_flags;
void *additional_data; void *additional_data;
}; };
@ -303,6 +309,7 @@ void tevent_cleanup_pending_signal_handlers(struct tevent_signal *se);
bool tevent_standard_init(void); bool tevent_standard_init(void);
bool tevent_select_init(void); bool tevent_select_init(void);
bool tevent_poll_init(void);
#ifdef HAVE_EPOLL #ifdef HAVE_EPOLL
bool tevent_epoll_init(void); bool tevent_epoll_init(void);
#endif #endif

View File

@ -0,0 +1,312 @@
/*
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 poll_event_context {
/*
* These two arrays are maintained together.
*/
struct pollfd *fds;
struct tevent_fd **fd_events;
uint64_t num_fds;
/* information for exiting from the event loop */
int exit_code;
};
/*
create a select_event_context structure.
*/
static int poll_event_context_init(struct tevent_context *ev)
{
struct poll_event_context *poll_ev;
poll_ev = talloc_zero(ev, struct poll_event_context);
if (poll_ev == NULL) {
return -1;
}
ev->additional_data = poll_ev;
return 0;
}
/*
destroy an fd_event
*/
static int poll_event_fd_destructor(struct tevent_fd *fde)
{
struct tevent_context *ev = fde->event_ctx;
struct poll_event_context *poll_ev = NULL;
struct tevent_fd *moved_fde;
uint64_t del_idx = fde->additional_flags;
if (ev == NULL) {
goto done;
}
poll_ev = talloc_get_type_abort(
ev->additional_data, struct poll_event_context);
moved_fde = poll_ev->fd_events[poll_ev->num_fds-1];
poll_ev->fd_events[del_idx] = moved_fde;
poll_ev->fds[del_idx] = poll_ev->fds[poll_ev->num_fds-1];
moved_fde->additional_flags = del_idx;
poll_ev->num_fds -= 1;
done:
return tevent_common_fd_destructor(fde);
}
/*
add a fd based event
return NULL on failure (memory allocation error)
*/
static struct tevent_fd *poll_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 poll_event_context *poll_ev = talloc_get_type_abort(
ev->additional_data, struct poll_event_context);
struct pollfd *pfd;
struct tevent_fd *fde;
fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
handler, private_data,
handler_name, location);
if (fde == NULL) {
return NULL;
}
/* we allocate 16 slots to avoid a lot of reallocations */
if (talloc_array_length(poll_ev->fds) == poll_ev->num_fds) {
struct pollfd *tmp_fds;
struct tevent_fd **tmp_fd_events;
tmp_fds = talloc_realloc(
poll_ev, poll_ev->fds, struct pollfd,
poll_ev->num_fds + 16);
if (tmp_fds == NULL) {
TALLOC_FREE(fde);
return NULL;
}
poll_ev->fds = tmp_fds;
tmp_fd_events = talloc_realloc(
poll_ev, poll_ev->fd_events, struct tevent_fd *,
poll_ev->num_fds + 16);
if (tmp_fd_events == NULL) {
TALLOC_FREE(fde);
return NULL;
}
poll_ev->fd_events = tmp_fd_events;
}
pfd = &poll_ev->fds[poll_ev->num_fds];
pfd->fd = fd;
pfd->events = 0;
pfd->revents = 0;
if (flags & TEVENT_FD_READ) {
pfd->events |= (POLLIN|POLLHUP);
}
if (flags & TEVENT_FD_WRITE) {
pfd->events |= (POLLOUT);
}
fde->additional_flags = poll_ev->num_fds;
poll_ev->fd_events[poll_ev->num_fds] = fde;
poll_ev->num_fds += 1;
talloc_set_destructor(fde, poll_event_fd_destructor);
return fde;
}
/*
set the fd event flags
*/
static void poll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
{
struct poll_event_context *poll_ev = talloc_get_type_abort(
fde->event_ctx->additional_data, struct poll_event_context);
uint64_t idx = fde->additional_flags;
uint16_t pollflags = 0;
if (flags & TEVENT_FD_READ) {
pollflags |= (POLLIN|POLLHUP);
}
if (flags & TEVENT_FD_WRITE) {
pollflags |= (POLLOUT);
}
poll_ev->fds[idx].events = pollflags;
fde->flags = flags;
}
/*
event loop handling using poll()
*/
static int poll_event_loop_poll(struct tevent_context *ev,
struct timeval *tvalp)
{
struct poll_event_context *poll_ev = talloc_get_type_abort(
ev->additional_data, struct poll_event_context);
struct tevent_fd *fde;
int pollrtn;
int timeout = -1;
if (ev->signal_events && tevent_common_check_signal(ev)) {
return 0;
}
if (tvalp != NULL) {
timeout = tvalp->tv_sec * 1000;
timeout += (tvalp->tv_usec + 999) / 1000;
}
pollrtn = poll(poll_ev->fds, poll_ev->num_fds, timeout);
if (pollrtn == -1 && errno == EINTR && ev->signal_events) {
tevent_common_check_signal(ev);
return 0;
}
if (pollrtn == -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(ev, TEVENT_DEBUG_FATAL,
"ERROR: EBADF on poll_event_loop_once\n");
poll_ev->exit_code = EBADF;
return -1;
}
if (pollrtn == 0 && tvalp) {
/* we don't care about a possible delay here */
tevent_common_loop_timer_delay(ev);
return 0;
}
if (pollrtn <= 0) {
/*
* No fd's ready
*/
return 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 = ev->fd_events; fde; fde = fde->next) {
struct pollfd *pfd;
uint64_t pfd_idx = fde->additional_flags;
uint16_t flags = 0;
pfd = &poll_ev->fds[pfd_idx];
if (pfd->revents & (POLLHUP|POLLERR)) {
/* If we only wait for TEVENT_FD_WRITE, we
should not tell the event handler about it,
and remove the writable flag, as we only
report errors when waiting for read events
to match the select behavior. */
if (!(fde->flags & TEVENT_FD_READ)) {
TEVENT_FD_NOT_WRITEABLE(fde);
continue;
}
flags |= TEVENT_FD_READ;
}
if (pfd->revents & POLLIN) {
flags |= TEVENT_FD_READ;
}
if (pfd->revents & POLLOUT) {
flags |= TEVENT_FD_WRITE;
}
if (flags != 0) {
fde->handler(ev, fde, flags, fde->private_data);
break;
}
}
return 0;
}
/*
do a single event loop using the events defined in ev
*/
static int poll_event_loop_once(struct tevent_context *ev,
const char *location)
{
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 poll_event_loop_poll(ev, &tval);
}
static const struct tevent_ops poll_event_ops = {
.context_init = poll_event_context_init,
.add_fd = poll_event_add_fd,
.set_fd_close_fn = tevent_common_fd_set_close_fn,
.get_fd_flags = tevent_common_fd_get_flags,
.set_fd_flags = poll_event_set_fd_flags,
.add_timer = tevent_common_add_timer,
.schedule_immediate = tevent_common_schedule_immediate,
.add_signal = tevent_common_add_signal,
.loop_once = poll_event_loop_once,
.loop_wait = tevent_common_loop_wait,
};
_PRIVATE_ bool tevent_poll_init(void)
{
return tevent_register_backend("poll", &poll_event_ops);
}

View File

@ -144,17 +144,19 @@ static void tevent_queue_immediate_trigger(struct tevent_context *ev,
q->list->trigger(q->list->req, q->list->private_data); q->list->trigger(q->list->req, q->list->private_data);
} }
bool tevent_queue_add(struct tevent_queue *queue, static struct tevent_queue_entry *tevent_queue_add_internal(
struct tevent_context *ev, struct tevent_queue *queue,
struct tevent_req *req, struct tevent_context *ev,
tevent_queue_trigger_fn_t trigger, struct tevent_req *req,
void *private_data) tevent_queue_trigger_fn_t trigger,
void *private_data,
bool allow_direct)
{ {
struct tevent_queue_entry *e; struct tevent_queue_entry *e;
e = talloc_zero(req, struct tevent_queue_entry); e = talloc_zero(req, struct tevent_queue_entry);
if (e == NULL) { if (e == NULL) {
return false; return NULL;
} }
e->queue = queue; e->queue = queue;
@ -163,16 +165,53 @@ bool tevent_queue_add(struct tevent_queue *queue,
e->trigger = trigger; e->trigger = trigger;
e->private_data = private_data; e->private_data = private_data;
/*
* if there is no trigger, it is just a blocker
*/
if (trigger == NULL) {
e->triggered = true;
}
if (queue->length > 0) {
/*
* if there are already entries in the
* queue do not optimize.
*/
allow_direct = false;
}
if (req->async.fn != NULL) {
/*
* If the callers wants to optimize for the
* empty queue case, call the trigger only
* if there is no callback defined for the
* request yet.
*/
allow_direct = false;
}
DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *); DLIST_ADD_END(queue->list, e, struct tevent_queue_entry *);
queue->length++; queue->length++;
talloc_set_destructor(e, tevent_queue_entry_destructor); talloc_set_destructor(e, tevent_queue_entry_destructor);
if (!queue->running) { if (!queue->running) {
return true; return e;
} }
if (queue->list->triggered) { if (queue->list->triggered) {
return true; return e;
}
/*
* If allowed we directly call the trigger
* avoiding possible delays caused by
* an immediate event.
*/
if (allow_direct) {
queue->list->triggered = true;
queue->list->trigger(queue->list->req,
queue->list->private_data);
return e;
} }
tevent_schedule_immediate(queue->immediate, tevent_schedule_immediate(queue->immediate,
@ -180,9 +219,48 @@ bool tevent_queue_add(struct tevent_queue *queue,
tevent_queue_immediate_trigger, tevent_queue_immediate_trigger,
queue); queue);
return e;
}
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 = tevent_queue_add_internal(queue, ev, req,
trigger, private_data, false);
if (e == NULL) {
return false;
}
return true; return true;
} }
struct tevent_queue_entry *tevent_queue_add_entry(
struct tevent_queue *queue,
struct tevent_context *ev,
struct tevent_req *req,
tevent_queue_trigger_fn_t trigger,
void *private_data)
{
return tevent_queue_add_internal(queue, ev, req,
trigger, private_data, false);
}
struct tevent_queue_entry *tevent_queue_add_optimize_empty(
struct tevent_queue *queue,
struct tevent_context *ev,
struct tevent_req *req,
tevent_queue_trigger_fn_t trigger,
void *private_data)
{
return tevent_queue_add_internal(queue, ev, req,
trigger, private_data, true);
}
void tevent_queue_start(struct tevent_queue *queue) void tevent_queue_start(struct tevent_queue *queue)
{ {
if (queue->running) { if (queue->running) {
@ -215,3 +293,8 @@ size_t tevent_queue_length(struct tevent_queue *queue)
{ {
return queue->length; return queue->length;
} }
bool tevent_queue_running(struct tevent_queue *queue)
{
return queue->running;
}

View File

@ -74,6 +74,7 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
talloc_free(req); talloc_free(req);
return NULL; return NULL;
} }
req->internal.defer_callback_ev = NULL;
data = talloc_zero_size(req, data_size); data = talloc_zero_size(req, data_size);
if (data == NULL) { if (data == NULL) {
@ -91,6 +92,11 @@ struct tevent_req *_tevent_req_create(TALLOC_CTX *mem_ctx,
void _tevent_req_notify_callback(struct tevent_req *req, const char *location) void _tevent_req_notify_callback(struct tevent_req *req, const char *location)
{ {
req->internal.finish_location = location; req->internal.finish_location = location;
if (req->internal.defer_callback_ev) {
(void)tevent_req_post(req, req->internal.defer_callback_ev);
req->internal.defer_callback_ev = NULL;
return;
}
if (req->async.fn != NULL) { if (req->async.fn != NULL) {
req->async.fn(req); req->async.fn(req);
} }
@ -123,6 +129,11 @@ bool _tevent_req_error(struct tevent_req *req,
return true; return true;
} }
void _tevent_req_oom(struct tevent_req *req, const char *location)
{
tevent_req_finish(req, TEVENT_REQ_NO_MEMORY, location);
}
bool _tevent_req_nomem(const void *p, bool _tevent_req_nomem(const void *p,
struct tevent_req *req, struct tevent_req *req,
const char *location) const char *location)
@ -130,7 +141,7 @@ bool _tevent_req_nomem(const void *p,
if (p != NULL) { if (p != NULL) {
return false; return false;
} }
tevent_req_finish(req, TEVENT_REQ_NO_MEMORY, location); _tevent_req_oom(req, location);
return true; return true;
} }
@ -164,6 +175,12 @@ struct tevent_req *tevent_req_post(struct tevent_req *req,
return req; return req;
} }
void tevent_req_defer_callback(struct tevent_req *req,
struct tevent_context *ev)
{
req->internal.defer_callback_ev = ev;
}
bool tevent_req_is_in_progress(struct tevent_req *req) bool tevent_req_is_in_progress(struct tevent_req *req)
{ {
if (req->internal.state == TEVENT_REQ_IN_PROGRESS) { if (req->internal.state == TEVENT_REQ_IN_PROGRESS) {

View File

@ -111,6 +111,11 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
struct select_event_context); struct select_event_context);
struct tevent_fd *fde; struct tevent_fd *fde;
if (fd < 0 || fd >= FD_SETSIZE) {
errno = EBADF;
return NULL;
}
fde = tevent_common_add_fd(ev, mem_ctx, fd, flags, fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
handler, private_data, handler, private_data,
handler_name, location); handler_name, location);
@ -125,8 +130,6 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
return fde; return fde;
} }
extern pid_t ctdbd_pid;
/* /*
event loop handling using select() event loop handling using select()
*/ */
@ -146,6 +149,11 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
/* setup any fd events */ /* setup any fd events */
for (fde = select_ev->ev->fd_events; fde; fde = fde->next) { for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
errno = EBADF;
return -1;
}
if (fde->flags & TEVENT_FD_READ) { if (fde->flags & TEVENT_FD_READ) {
FD_SET(fde->fd, &r_fds); FD_SET(fde->fd, &r_fds);
} }
@ -159,9 +167,7 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
return 0; return 0;
} }
if (getpid() == ctdbd_pid) tevent_before_wait(select_ev->ev);
selrtn = select(select_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp); selrtn = select(select_ev->maxfd+1, &r_fds, &w_fds, NULL, tvalp);
if (getpid() == ctdbd_pid) tevent_after_wait(select_ev->ev);
if (selrtn == -1 && errno == EINTR && if (selrtn == -1 && errno == EINTR &&
select_ev->ev->signal_events) { select_ev->ev->signal_events) {

View File

@ -208,7 +208,7 @@ struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
/* the sig_state needs to be on a global context as it can last across /* the sig_state needs to be on a global context as it can last across
multiple event contexts */ multiple event contexts */
if (sig_state == NULL) { if (sig_state == NULL) {
sig_state = talloc_zero(talloc_autofree_context(), struct tevent_sig_state); sig_state = talloc_zero(NULL, struct tevent_sig_state);
if (sig_state == NULL) { if (sig_state == NULL) {
return NULL; return NULL;
} }
@ -307,6 +307,15 @@ struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
return se; return se;
} }
struct tevent_se_exists {
struct tevent_se_exists **myself;
};
static int tevent_se_exists_destructor(struct tevent_se_exists *s)
{
*s->myself = NULL;
return 0;
}
/* /*
check if a signal is pending check if a signal is pending
@ -335,7 +344,25 @@ int tevent_common_check_signal(struct tevent_context *ev)
} }
for (sl=sig_state->sig_handlers[i];sl;sl=next) { for (sl=sig_state->sig_handlers[i];sl;sl=next) {
struct tevent_signal *se = sl->se; struct tevent_signal *se = sl->se;
struct tevent_se_exists *exists;
next = sl->next; next = sl->next;
/*
* We have to be careful to not touch "se"
* after it was deleted in its handler. Thus
* we allocate a child whose destructor will
* tell by nulling out itself that its parent
* is gone.
*/
exists = talloc(se, struct tevent_se_exists);
if (exists == NULL) {
continue;
}
exists->myself = &exists;
talloc_set_destructor(
exists, tevent_se_exists_destructor);
#ifdef SA_SIGINFO #ifdef SA_SIGINFO
if (se->sa_flags & SA_SIGINFO) { if (se->sa_flags & SA_SIGINFO) {
uint32_t j; uint32_t j;
@ -352,17 +379,26 @@ int tevent_common_check_signal(struct tevent_context *ev)
se->handler(ev, se, i, 1, se->handler(ev, se, i, 1,
(void*)&sig_state->sig_info[i][ofs], (void*)&sig_state->sig_info[i][ofs],
se->private_data); se->private_data);
if (!exists) {
break;
}
} }
if (se->sa_flags & SA_RESETHAND) { #ifdef SA_RESETHAND
if (exists && (se->sa_flags & SA_RESETHAND)) {
talloc_free(se); talloc_free(se);
} }
#endif
talloc_free(exists);
continue; continue;
} }
#endif #endif
se->handler(ev, se, i, count, NULL, se->private_data); se->handler(ev, se, i, count, NULL, se->private_data);
if (se->sa_flags & SA_RESETHAND) { #ifdef SA_RESETHAND
if (exists && (se->sa_flags & SA_RESETHAND)) {
talloc_free(se); talloc_free(se);
} }
#endif
talloc_free(exists);
} }
#ifdef SA_SIGINFO #ifdef SA_SIGINFO

View File

@ -100,6 +100,17 @@ static int epoll_ctx_destructor(struct std_event_context *std_ev)
static void epoll_init_ctx(struct std_event_context *std_ev) static void epoll_init_ctx(struct std_event_context *std_ev)
{ {
std_ev->epoll_fd = epoll_create(64); std_ev->epoll_fd = epoll_create(64);
if (std_ev->epoll_fd == -1) {
tevent_debug(std_ev->ev, TEVENT_DEBUG_FATAL,
"Failed to create epoll handle.\n");
return;
}
if (!ev_set_close_on_exec(std_ev->epoll_fd)) {
tevent_debug(std_ev->ev, TEVENT_DEBUG_WARNING,
"Failed to set close-on-exec, file descriptor may be leaked to children.\n");
}
std_ev->pid = getpid(); std_ev->pid = getpid();
talloc_set_destructor(std_ev, epoll_ctx_destructor); talloc_set_destructor(std_ev, epoll_ctx_destructor);
} }
@ -126,6 +137,12 @@ static void epoll_check_reopen(struct std_event_context *std_ev)
"Failed to recreate epoll handle after fork\n"); "Failed to recreate epoll handle after fork\n");
return; return;
} }
if (!ev_set_close_on_exec(std_ev->epoll_fd)) {
tevent_debug(std_ev->ev, TEVENT_DEBUG_WARNING,
"Failed to set close-on-exec, file descriptor may be leaked to children.\n");
}
std_ev->pid = getpid(); std_ev->pid = getpid();
for (fde=std_ev->ev->fd_events;fde;fde=fde->next) { for (fde=std_ev->ev->fd_events;fde;fde=fde->next) {
epoll_add_event(std_ev, fde); epoll_add_event(std_ev, fde);
@ -239,8 +256,6 @@ static void epoll_change_event(struct std_event_context *std_ev, struct tevent_f
} }
} }
extern pid_t ctdbd_pid;
/* /*
event loop handling using epoll event loop handling using epoll
*/ */
@ -263,9 +278,7 @@ static int epoll_event_loop(struct std_event_context *std_ev, struct timeval *tv
return 0; return 0;
} }
if (getpid() == ctdbd_pid) tevent_before_wait(std_ev->ev);
ret = epoll_wait(std_ev->epoll_fd, events, MAXEVENTS, timeout); ret = epoll_wait(std_ev->epoll_fd, events, MAXEVENTS, timeout);
if (getpid() == ctdbd_pid) tevent_after_wait(std_ev->ev);
if (ret == -1 && errno == EINTR && std_ev->ev->signal_events) { if (ret == -1 && errno == EINTR && std_ev->ev->signal_events) {
if (tevent_common_check_signal(std_ev->ev)) { if (tevent_common_check_signal(std_ev->ev)) {
@ -461,6 +474,10 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
/* setup any fd events */ /* setup any fd events */
for (fde = std_ev->ev->fd_events; fde; fde = fde->next) { for (fde = std_ev->ev->fd_events; fde; fde = fde->next) {
if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
std_ev->exit_code = EBADF;
return -1;
}
if (fde->flags & TEVENT_FD_READ) { if (fde->flags & TEVENT_FD_READ) {
FD_SET(fde->fd, &r_fds); FD_SET(fde->fd, &r_fds);
} }
@ -509,7 +526,7 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
if (FD_ISSET(fde->fd, &r_fds)) flags |= TEVENT_FD_READ; if (FD_ISSET(fde->fd, &r_fds)) flags |= TEVENT_FD_READ;
if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE; if (FD_ISSET(fde->fd, &w_fds)) flags |= TEVENT_FD_WRITE;
if (flags) { if (flags & fde->flags) {
fde->handler(std_ev->ev, fde, flags, fde->private_data); fde->handler(std_ev->ev, fde, flags, fde->private_data);
break; break;
} }

View File

@ -197,7 +197,7 @@ struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev, TALLOC_C
/* /*
do a single event loop using the events defined in ev do a single event loop using the events defined in ev
return the delay untill the next timed event, return the delay until the next timed event,
or zero if a timed event was triggered or zero if a timed event was triggered
*/ */
struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev) struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
@ -208,7 +208,7 @@ struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
if (!te) { if (!te) {
/* have a default tick time of 30 seconds. This guarantees /* have a default tick time of 30 seconds. This guarantees
that code that uses its own timeout checking will be that code that uses its own timeout checking will be
able to proceeed eventually */ able to proceed eventually */
return tevent_timeval_set(30, 0); return tevent_timeval_set(30, 0);
} }

View File

@ -89,53 +89,19 @@ int ev_set_blocking(int fd, bool set)
#undef FLAG_TO_SET #undef FLAG_TO_SET
} }
static struct timeval tevent_before_wait_ts; bool ev_set_close_on_exec(int fd)
static struct timeval tevent_after_wait_ts; {
#ifdef FD_CLOEXEC
int val;
/* val = fcntl(fd, F_GETFD, 0);
* measure the time difference between multiple arrivals if (val >= 0) {
* to the point where we wait for new events to come in val |= FD_CLOEXEC;
* val = fcntl(fd, F_SETFD, val);
* allows to measure how long it takes to work on a if (val != -1) {
* event return true;
*/
void tevent_before_wait(struct event_context *ev) {
struct timeval diff;
struct timeval now = tevent_timeval_current();
if (!tevent_timeval_is_zero(&tevent_after_wait_ts)) {
diff = tevent_timeval_until(&tevent_after_wait_ts, &now);
if (diff.tv_sec > 3) {
tevent_debug(ev, TEVENT_DEBUG_ERROR, __location__
" Handling event took %d seconds!",
(int) diff.tv_sec);
} }
} }
#endif
tevent_before_wait_ts = tevent_timeval_current(); return false;
}
/*
* measure how long the select()/epoll() call took
*
* allows to measure how long we are waiting for new events
*/
void tevent_after_wait(struct event_context *ev) {
struct timeval diff;
struct timeval now = tevent_timeval_current();
if (!tevent_timeval_is_zero(&tevent_before_wait_ts)) {
diff = tevent_timeval_until(&tevent_before_wait_ts, &now);
if (diff.tv_sec > 3) {
tevent_debug(ev, TEVENT_DEBUG_FATAL, __location__
" No event for %d seconds!",
(int) diff.tv_sec);
}
}
tevent_after_wait_ts = tevent_timeval_current();
} }

View File

@ -183,10 +183,7 @@ do { \
const char **ev_str_list_add(const char **list, const char *s); const char **ev_str_list_add(const char **list, const char *s);
int ev_set_blocking(int fd, bool set); int ev_set_blocking(int fd, bool set);
size_t ev_str_list_length(const char **list); size_t ev_str_list_length(const char **list);
bool ev_set_close_on_exec(int fd);
void tevent_before_wait(struct event_context *ev);
void tevent_after_wait(struct event_context *ev);
/* Defined here so we can build against older talloc versions that don't /* Defined here so we can build against older talloc versions that don't
* have this define yet. */ * have this define yet. */

View File

@ -1,75 +0,0 @@
#!/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()

View File

@ -28,7 +28,6 @@
#include "includes.h" #include "includes.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "db_wrap.h" #include "db_wrap.h"

View File

@ -17,7 +17,6 @@
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/time.h" #include "system/time.h"
#include "system/network.h" #include "system/network.h"

View File

@ -21,7 +21,6 @@
protocol design and packet details protocol design and packet details
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "system/network.h" #include "system/network.h"

View File

@ -17,7 +17,6 @@
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -20,7 +20,6 @@
#include "includes.h" #include "includes.h"
#include "db_wrap.h" #include "db_wrap.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/tevent/tevent.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -17,7 +17,6 @@
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "db_wrap.h" #include "db_wrap.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "../include/ctdb_client.h" #include "../include/ctdb_client.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "system/syslog.h" #include "system/syslog.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "db_wrap.h" #include "db_wrap.h"

View File

@ -18,7 +18,6 @@
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/time.h" #include "system/time.h"
#include "system/network.h" #include "system/network.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/time.h" #include "system/time.h"
#include "system/network.h" #include "system/network.h"

View File

@ -19,7 +19,6 @@
#include "includes.h" #include "includes.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/tevent/tevent.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -19,7 +19,6 @@
#include "includes.h" #include "includes.h"
#include <string.h> #include <string.h>
#include "lib/tevent/tevent.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
static void ctdb_statistics_update(struct event_context *ev, struct timed_event *te, static void ctdb_statistics_update(struct event_context *ev, struct timed_event *te,

View File

@ -19,7 +19,6 @@
along with this program; if not, see <http://www.gnu.org/licenses/>. along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "system/network.h" #include "system/network.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/wait.h" #include "system/wait.h"
#include "db_wrap.h" #include "db_wrap.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "db_wrap.h" #include "db_wrap.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "ctdb_private.h" #include "ctdb_private.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "system/syslog.h" #include "system/syslog.h"
#include "system/time.h" #include "system/time.h"

View File

@ -20,7 +20,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"
@ -28,7 +27,6 @@
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "db_wrap.h" #include "db_wrap.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "lib/tevent/tevent.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "../common/rb_tree.h" #include "../common/rb_tree.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "system/time.h" #include "system/time.h"

View File

@ -24,7 +24,6 @@
#include "system/dir.h" #include "system/dir.h"
#include "system/locale.h" #include "system/locale.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"
#include "lib/tevent/tevent.h"
#include "../common/rb_tree.h" #include "../common/rb_tree.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"

View File

@ -19,7 +19,6 @@
#include "includes.h" #include "includes.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "lib/tevent/tevent.h"
#include "system/network.h" #include "system/network.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "../include/ctdb_private.h" #include "../include/ctdb_private.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "system/network.h" #include "system/network.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -20,7 +20,6 @@
#include <time.h> #include <time.h>
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -26,12 +26,7 @@
#define _GNU_SOURCE #define _GNU_SOURCE
#include <stdio.h> #include <stdio.h>
#include <sys/socket.h> #include <sys/socket.h>
#include "lib/tevent/tevent.h"
#define tevent_context_init(x) tevent_context_init_foobar(x)
struct tevent_context *tevent_context_init_foobar(TALLOC_CTX *mem_ctx);
#define tevent_loop_allow_nesting(x) tevent_loop_allow_nesting_foobar(x)
void tevent_loop_allow_nesting_foobar(struct tevent_context *ev);
#define ctdb_cmdline_client(x, y) ctdb_cmdline_client_foobar(x, y) #define ctdb_cmdline_client(x, y) ctdb_cmdline_client_foobar(x, y)
#define ctdb_get_socketname(x) ctdb_get_socketname_foobar(x) #define ctdb_get_socketname(x) ctdb_get_socketname_foobar(x)
@ -46,8 +41,6 @@ void tevent_loop_allow_nesting_foobar(struct tevent_context *ev);
#include "tools/ctdb.c" #include "tools/ctdb.c"
#ifdef CTDB_TEST_USE_MAIN #ifdef CTDB_TEST_USE_MAIN
#undef tevent_context_init
#undef tevent_loop_allow_nesting
#undef ctdb_cmdline_client #undef ctdb_cmdline_client
#undef ctdb_get_socketname #undef ctdb_get_socketname
#else #else

View File

@ -22,11 +22,6 @@
#include "libctdb_test.c" #include "libctdb_test.c"
void tevent_loop_allow_nesting_foobar(struct tevent_context *ev)
{
return;
}
struct ctdb_context *ctdb_cmdline_client_foobar(struct tevent_context *ev, struct ctdb_context *ctdb_cmdline_client_foobar(struct tevent_context *ev,
struct timeval req_timeout) struct timeval req_timeout)
{ {
@ -37,12 +32,6 @@ struct ctdb_context *ctdb_cmdline_client_foobar(struct tevent_context *ev,
return ret; return ret;
} }
struct tevent_context *tevent_context_init_foobar(TALLOC_CTX *mem_ctx)
{
/* This should obviously never be used... */
return (struct tevent_context *) 1;
}
const char *ctdb_get_socketname_foobar(struct ctdb_context *ctdb) const char *ctdb_get_socketname_foobar(struct ctdb_context *ctdb)
{ {
return LIBCTDB_TEST_FAKESTATE; return LIBCTDB_TEST_FAKESTATE;

View File

@ -25,7 +25,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -20,7 +20,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"
#include "cmdline.h" #include "cmdline.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/util/db_wrap.h" #include "lib/util/db_wrap.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"

View File

@ -21,7 +21,6 @@
#define _CTDBD_TEST_C #define _CTDBD_TEST_C
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/tdb/include/tdb.h" #include "lib/tdb/include/tdb.h"
#include "ctdb_private.h" #include "ctdb_private.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "lib/util/dlinklist.h" #include "lib/util/dlinklist.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "popt.h" #include "popt.h"

View File

@ -19,7 +19,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/time.h" #include "system/time.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/network.h" #include "system/network.h"

View File

@ -18,7 +18,6 @@
*/ */
#include "includes.h" #include "includes.h"
#include "lib/tevent/tevent.h"
#include "system/filesys.h" #include "system/filesys.h"
#include "system/network.h" #include "system/network.h"
#include "../include/ctdb_client.h" #include "../include/ctdb_client.h"

View File

@ -23,7 +23,6 @@
#include <pcp/impl.h> #include <pcp/impl.h>
#include <pcp/pmda.h> #include <pcp/pmda.h>
#include "../../include/includes.h" #include "../../include/includes.h"
#include "../../lib/tevent/tevent.h"
#include "../../include/ctdb.h" #include "../../include/ctdb.h"
#include "../../include/ctdb_private.h" #include "../../include/ctdb_private.h"
#include "../../include/ctdb_protocol.h" #include "../../include/ctdb_protocol.h"