From 880d9d6d8c209c770185b9b1c9a3019cb56be763 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 12 Mar 2009 09:22:41 +0100 Subject: tevent: add tevent_set_abort_fn() metze --- lib/tevent/tevent.c | 19 +++++++++++++++++++ lib/tevent/tevent.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c index fd273afb66..943d4d6bc2 100644 --- a/lib/tevent/tevent.c +++ b/lib/tevent/tevent.c @@ -313,6 +313,25 @@ bool tevent_signal_support(struct tevent_context *ev) return false; } +static void (*tevent_abort_fn)(const char *reason); + +void tevent_set_abort_fn(void (*abort_fn)(const char *reason)) +{ + tevent_abort_fn = abort_fn; +} + +static void tevent_abort(struct tevent_context *ev, const char *reason) +{ + tevent_debug(ev, TEVENT_DEBUG_FATAL, + "abort: %s\n", reason); + + if (!tevent_abort_fn) { + abort(); + } + + tevent_abort_fn(reason); +} + /* add a timer event return NULL on failure diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h index 1f4cf2d329..90d0767f87 100644 --- a/lib/tevent/tevent.h +++ b/lib/tevent/tevent.h @@ -110,6 +110,8 @@ void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags); bool tevent_signal_support(struct tevent_context *ev); +void tevent_set_abort_fn(void (*abort_fn)(const char *reason)); + /* bits for file descriptor event flags */ #define TEVENT_FD_READ 1 #define TEVENT_FD_WRITE 2 -- cgit