From 193eba85a9a6eff7c314f6afaaeff6bf3cff1399 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 3 Jan 2009 12:39:11 +0100 Subject: tevent: add tevent_fd_set_auto_close() tevent_fd_set_auto_close() is a simple wrapper arround tevent_fd_set_close_fn() with a callback that uses plain close(2). metze --- lib/tevent/tevent.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/tevent/tevent.c') diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c index 93918cc14d..5582b583e7 100644 --- a/lib/tevent/tevent.c +++ b/lib/tevent/tevent.c @@ -53,6 +53,7 @@ */ #include "replace.h" +#include "system/filesys.h" #include "tevent.h" #include "tevent_internal.h" #include "tevent_util.h" @@ -250,6 +251,19 @@ void tevent_fd_set_close_fn(struct tevent_fd *fde, fde->event_ctx->ops->set_fd_close_fn(fde, close_fn); } +static void tevent_fd_auto_close_fn(struct tevent_context *ev, + struct tevent_fd *fde, + int fd, + void *private_data) +{ + close(fd); +} + +void tevent_fd_set_auto_close(struct tevent_fd *fde) +{ + tevent_fd_set_close_fn(fde, tevent_fd_auto_close_fn); +} + /* return the fd event flags */ -- cgit