diff options
Diffstat (limited to 'lib/tevent')
-rw-r--r-- | lib/tevent/tevent.c | 19 | ||||
-rw-r--r-- | lib/tevent/tevent.h | 2 |
2 files changed, 21 insertions, 0 deletions
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 |