summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tevent/tevent.c2
-rw-r--r--lib/tevent/tevent.h176
-rw-r--r--lib/tevent/tevent_aio.c2
-rw-r--r--lib/tevent/tevent_epoll.c2
-rw-r--r--lib/tevent/tevent_internal.h117
-rw-r--r--lib/tevent/tevent_liboop.c2
-rw-r--r--lib/tevent/tevent_select.c2
-rw-r--r--lib/tevent/tevent_standard.c2
-rw-r--r--lib/tevent/tevent_timed.c10
-rw-r--r--source4/lib/events/events.h6
-rw-r--r--source4/lib/events/events_internal.h4
11 files changed, 208 insertions, 117 deletions
diff --git a/lib/tevent/tevent.c b/lib/tevent/tevent.c
index cd470c93ae..2ea5ad33e0 100644
--- a/lib/tevent/tevent.c
+++ b/lib/tevent/tevent.c
@@ -256,7 +256,7 @@ struct timed_event *event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ct
event_timed_handler_t handler,
void *private_data)
{
- return ev->ops->add_timed(ev, mem_ctx, next_event, handler, private_data);
+ return ev->ops->add_timer(ev, mem_ctx, next_event, handler, private_data);
}
/*
diff --git a/lib/tevent/tevent.h b/lib/tevent/tevent.h
index 1857f9bb10..002edd1836 100644
--- a/lib/tevent/tevent.h
+++ b/lib/tevent/tevent.h
@@ -26,73 +26,151 @@
#include <talloc.h>
struct event_context;
-struct event_ops;
+struct tevent_ops;
struct fd_event;
-struct timed_event;
-struct aio_event;
-struct signal_event;
+struct tevent_timer;
+struct tevent_aio;
+struct tevent_signal;
+
+#define tevent_context event_context
+#define tevent_fd fd_event
/* event handler types */
-typedef void (*event_fd_handler_t)(struct event_context *, struct fd_event *,
- uint16_t , void *);
-typedef void (*event_timed_handler_t)(struct event_context *, struct timed_event *,
- struct timeval , void *);
-typedef void (*event_signal_handler_t)(struct event_context *, struct signal_event *,
- int , int, void *, void *);
-typedef void (*event_aio_handler_t)(struct event_context *, struct aio_event *,
- int, void *);
-
-#ifdef _SAMBA_BUILD_
-struct event_context *s4_event_context_init(TALLOC_CTX *mem_ctx);
+typedef void (*tevent_fd_handler_t)(struct tevent_context *,
+ struct tevent_fd *,
+ uint16_t , void *);
+typedef void (*tevent_timer_handler_t)(struct tevent_context *,
+ struct tevent_timer *,
+ struct timeval , void *);
+typedef void (*tevent_signal_handler_t)(struct tevent_context *,
+ struct tevent_signal *,
+ int , int, void *, void *);
+typedef void (*tevent_aio_handler_t)(struct tevent_context *,
+ struct tevent_aio *,
+ int, void *);
+
+struct tevent_context *tevent_context_init(TALLOC_CTX *mem_ctx);
+struct tevent_context *tevent_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
+const char **tevent_backend_list(TALLOC_CTX *mem_ctx);
+void tevent_set_default_backend(const char *backend);
+
+struct tevent_fd *tevent_add_fd(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int fd, uint16_t flags,
+ tevent_fd_handler_t handler,
+ void *private_data);
+
+struct tevent_timer *tevent_add_timer(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ struct timeval next_event,
+ tevent_timer_handler_t handler,
+ void *private_data);
+
+struct tevent_signal *tevent_add_signal(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int signum, int sa_flags,
+ tevent_signal_handler_t handler,
+ void *private_data);
+
+struct iocb;
+struct tevent_aio *tevent_add_aio(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ struct iocb *iocb,
+ tevent_aio_handler_t handler,
+ void *private_data);
+
+int tevent_loop_once(struct tevent_context *ev);
+int tevent_loop_wait(struct tevent_context *ev);
+
+uint16_t tevent_fd_get_flags(struct tevent_fd *fde);
+void tevent_fd_set_flags(struct tevent_fd *fde, uint16_t flags);
+
+/* bits for file descriptor event flags */
+#define TEVENT_FD_READ 1
+#define TEVENT_FD_WRITE 2
+#define TEVENT_FD_AUTOCLOSE 4
+
+#define TEVENT_FD_WRITEABLE(fde) \
+ tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_WRITE)
+#define TEVENT_FD_READABLE(fde) \
+ tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_READ)
+
+#define TEVENT_FD_NOT_WRITEABLE(fde) \
+ tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_WRITE)
+#define TEVENT_FD_NOT_READABLE(fde) \
+ tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_READ)
+
+/* for now always define the compat symbols */
+#ifndef TEVENT_COMPAT_DEFINES
+#define TEVENT_COMPAT_DEFINES 1
#endif
-struct event_context *event_context_init(TALLOC_CTX *mem_ctx);
-struct event_context *event_context_init_byname(TALLOC_CTX *mem_ctx, const char *name);
-const char **event_backend_list(TALLOC_CTX *mem_ctx);
-void event_set_default_backend(const char *backend);
+#ifdef TEVENT_COMPAT_DEFINES
-struct fd_event *event_add_fd(struct event_context *ev, TALLOC_CTX *mem_ctx,
- int fd, uint16_t flags, event_fd_handler_t handler,
- void *private_data);
+/*TODO:#define event_context tevent_context*/
+#define event_ops tevent_ops
+/*TODO:#define fd_event tevent_fd*/
+#define timed_event tevent_timer
+#define aio_event tevent_aio
+#define signal_event tevent_signal
-struct timed_event *event_add_timed(struct event_context *ev, TALLOC_CTX *mem_ctx,
- struct timeval next_event,
- event_timed_handler_t handler,
- void *private_data);
+#define event_fd_handler_t tevent_fd_handler_t
+#define event_timed_handler_t tevent_timer_handler_t
+#define event_aio_handler_t tevent_aio_handler_t
+#define event_signal_handler_t tevent_signal_handler_t
-struct signal_event *event_add_signal(struct event_context *ev, TALLOC_CTX *mem_ctx,
- int signum, int sa_flags,
- event_signal_handler_t handler,
- void *private_data);
+#define event_context_init(mem_ctx) \
+ tevent_context_init(mem_ctx)
-struct iocb;
-struct aio_event *event_add_aio(struct event_context *ev,
- TALLOC_CTX *mem_ctx,
- struct iocb *iocb,
- event_aio_handler_t handler,
- void *private_data);
+#define event_context_init_byname(mem_ctx, name) \
+ tevent_context_init_byname(mem_ctx, name)
-int event_loop_once(struct event_context *ev);
-int event_loop_wait(struct event_context *ev);
+#define event_backend_list(mem_ctx) \
+ tevent_backend_list(mem_ctx)
-uint16_t event_get_fd_flags(struct fd_event *fde);
-void event_set_fd_flags(struct fd_event *fde, uint16_t flags);
+#define event_set_default_backend(backend) \
+ tevent_set_default_backend(backend)
-struct event_context *event_context_find(TALLOC_CTX *mem_ctx);
+#define event_add_fd(ev, mem_ctx, fd, flags, handler, private_data) \
+ tevent_add_fd(ev, mem_ctx, fd, flags, handler, private_data)
-/* bits for file descriptor event flags */
-#define EVENT_FD_READ 1
-#define EVENT_FD_WRITE 2
-#define EVENT_FD_AUTOCLOSE 4
+#define event_add_timed(ev, mem_ctx, next_event, handler, private_data) \
+ tevent_add_timer(ev, mem_ctx, next_event, handler, private_data)
+
+#define event_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data) \
+ tevent_add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data)
+
+#define event_add_aio(ev, mem_ctx, iocb, handler, private_data) \
+ tevent_add_aio(ev, mem_ctx, iocb, handler, private_data)
+
+#define event_loop_once(ev) \
+ tevent_loop_once(ev)
+
+#define event_loop_wait(ev) \
+ tevent_loop_wait(ev)
+
+#define event_get_fd_flags(fde) \
+ tevent_fd_get_flags(fde)
+
+#define event_set_fd_flags(fde, flags) \
+ tevent_fd_set_flags(fde, flags)
+
+#define EVENT_FD_READ TEVENT_FD_READ
+#define EVENT_FD_WRITE TEVENT_FD_WRITE
+#define EVENT_FD_AUTOCLOSE TEVENT_FD_AUTOCLOSE
#define EVENT_FD_WRITEABLE(fde) \
- event_set_fd_flags(fde, event_get_fd_flags(fde) | EVENT_FD_WRITE)
+ TEVENT_FD_WRITEABLE(fde)
+
#define EVENT_FD_READABLE(fde) \
- event_set_fd_flags(fde, event_get_fd_flags(fde) | EVENT_FD_READ)
+ TEVENT_FD_READABLE(fde)
#define EVENT_FD_NOT_WRITEABLE(fde) \
- event_set_fd_flags(fde, event_get_fd_flags(fde) & ~EVENT_FD_WRITE)
+ TEVENT_FD_NOT_WRITEABLE(fde)
+
#define EVENT_FD_NOT_READABLE(fde) \
- event_set_fd_flags(fde, event_get_fd_flags(fde) & ~EVENT_FD_READ)
+ TEVENT_FD_NOT_READABLE(fde)
+
+#endif /* TEVENT_COMPAT_DEFINES */
#endif /* __TEVENT_H__ */
diff --git a/lib/tevent/tevent_aio.c b/lib/tevent/tevent_aio.c
index 7c3473b9a7..b3cd126a34 100644
--- a/lib/tevent/tevent_aio.c
+++ b/lib/tevent/tevent_aio.c
@@ -554,7 +554,7 @@ static const struct event_ops aio_event_ops = {
.add_aio = aio_event_add_aio,
.get_fd_flags = aio_event_get_fd_flags,
.set_fd_flags = aio_event_set_fd_flags,
- .add_timed = common_event_add_timed,
+ .add_timer = common_event_add_timed,
.add_signal = common_event_add_signal,
.loop_once = aio_event_loop_once,
.loop_wait = aio_event_loop_wait,
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c
index 1d03b7dbf0..cff6e46e2c 100644
--- a/lib/tevent/tevent_epoll.c
+++ b/lib/tevent/tevent_epoll.c
@@ -470,7 +470,7 @@ static const struct event_ops epoll_event_ops = {
.add_fd = epoll_event_add_fd,
.get_fd_flags = epoll_event_get_fd_flags,
.set_fd_flags = epoll_event_set_fd_flags,
- .add_timed = common_event_add_timed,
+ .add_timer = common_event_add_timed,
.add_signal = common_event_add_signal,
.loop_once = epoll_event_loop_once,
.loop_wait = epoll_event_loop_wait,
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 9606fadd55..42c860756d 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -21,49 +21,49 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-struct event_ops {
+struct tevent_ops {
/* conntext init */
- int (*context_init)(struct event_context *ev);
+ int (*context_init)(struct tevent_context *ev);
/* fd_event functions */
- struct fd_event *(*add_fd)(struct event_context *ev,
- TALLOC_CTX *mem_ctx,
- int fd, uint16_t flags,
- event_fd_handler_t handler,
- void *private_data);
- uint16_t (*get_fd_flags)(struct fd_event *fde);
- void (*set_fd_flags)(struct fd_event *fde, uint16_t flags);
+ struct tevent_fd *(*add_fd)(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int fd, uint16_t flags,
+ tevent_fd_handler_t handler,
+ void *private_data);
+ uint16_t (*get_fd_flags)(struct tevent_fd *fde);
+ void (*set_fd_flags)(struct tevent_fd *fde, uint16_t flags);
/* timed_event functions */
- struct timed_event *(*add_timed)(struct event_context *ev,
- TALLOC_CTX *mem_ctx,
- struct timeval next_event,
- event_timed_handler_t handler,
- void *private_data);
+ struct tevent_timer *(*add_timer)(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ struct timeval next_event,
+ tevent_timer_handler_t handler,
+ void *private_data);
/* disk aio event functions */
- struct aio_event *(*add_aio)(struct event_context *ev,
- TALLOC_CTX *mem_ctx,
- struct iocb *iocb,
- event_aio_handler_t handler,
- void *private_data);
+ struct tevent_aio *(*add_aio)(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ struct iocb *iocb,
+ tevent_aio_handler_t handler,
+ void *private_data);
/* signal functions */
- struct signal_event *(*add_signal)(struct event_context *ev,
- TALLOC_CTX *mem_ctx,
- int signum, int sa_flags,
- event_signal_handler_t handler,
- void *private_data);
+ struct tevent_signal *(*add_signal)(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int signum, int sa_flags,
+ tevent_signal_handler_t handler,
+ void *private_data);
/* loop functions */
- int (*loop_once)(struct event_context *ev);
- int (*loop_wait)(struct event_context *ev);
+ int (*loop_once)(struct tevent_context *ev);
+ int (*loop_wait)(struct tevent_context *ev);
};
-struct fd_event {
- struct fd_event *prev, *next;
- struct event_context *event_ctx;
+struct tevent_fd {
+ struct tevent_fd *prev, *next;
+ struct tevent_context *event_ctx;
int fd;
uint16_t flags; /* see EVENT_FD_* flags */
- event_fd_handler_t handler;
+ tevent_fd_handler_t handler;
/* this is private for the specific handler */
void *private_data;
/* this is private for the events_ops implementation */
@@ -71,21 +71,21 @@ struct fd_event {
void *additional_data;
};
-struct timed_event {
- struct timed_event *prev, *next;
- struct event_context *event_ctx;
+struct tevent_timer {
+ struct tevent_timer *prev, *next;
+ struct tevent_context *event_ctx;
struct timeval next_event;
- event_timed_handler_t handler;
+ tevent_timer_handler_t handler;
/* this is private for the specific handler */
void *private_data;
/* this is private for the events_ops implementation */
void *additional_data;
};
-struct signal_event {
- struct signal_event *prev, *next;
- struct event_context *event_ctx;
- event_signal_handler_t handler;
+struct tevent_signal {
+ struct tevent_signal *prev, *next;
+ struct tevent_context *event_ctx;
+ tevent_signal_handler_t handler;
void *private_data;
int signum;
int sa_flags;
@@ -101,22 +101,22 @@ struct ev_debug_ops {
void *context;
};
-int ev_set_debug(struct event_context *ev,
+int ev_set_debug(struct tevent_context *ev,
void (*debug)(void *context, enum ev_debug_level level,
const char *fmt, va_list ap) PRINTF_ATTRIBUTE(3,0),
void *context);
-int ev_set_debug_stderr(struct event_context *ev);
+int ev_set_debug_stderr(struct tevent_context *ev);
void ev_debug(struct event_context *ev, enum ev_debug_level level, const char *fmt, ...);
/* aio event is private to the aio backend */
-struct aio_event;
+struct tevent_aio;
-struct event_context {
+struct tevent_context {
/* the specific events implementation */
- const struct event_ops *ops;
+ const struct tevent_ops *ops;
/* list of timed events - used by common code */
- struct timed_event *timed_events;
+ struct tevent_timer *timer_events;
/* this is private for the events_ops implementation */
void *additional_data;
@@ -125,27 +125,30 @@ struct event_context {
int num_signal_handlers;
/* pipe hack used with signal handlers */
- struct fd_event *pipe_fde;
+ struct tevent_fd *pipe_fde;
/* debugging operations */
struct ev_debug_ops debug_ops;
};
-bool event_register_backend(const char *name, const struct event_ops *ops);
+bool event_register_backend(const char *name, const struct tevent_ops *ops);
bool ev_timeval_is_zero(const struct timeval *tv);
-struct timed_event *common_event_add_timed(struct event_context *, TALLOC_CTX *,
- struct timeval, event_timed_handler_t, void *);
-struct timeval common_event_loop_timer_delay(struct event_context *);
-
-struct signal_event *common_event_add_signal(struct event_context *ev,
- TALLOC_CTX *mem_ctx,
- int signum,
- int sa_flags,
- event_signal_handler_t handler,
- void *private_data);
-int common_event_check_signal(struct event_context *ev);
+struct tevent_timer *common_event_add_timed(struct tevent_context *,
+ TALLOC_CTX *,
+ struct timeval,
+ tevent_timer_handler_t,
+ void *);
+struct timeval common_event_loop_timer_delay(struct tevent_context *);
+
+struct tevent_signal *common_event_add_signal(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int signum,
+ int sa_flags,
+ tevent_signal_handler_t handler,
+ void *private_data);
+int common_event_check_signal(struct tevent_context *ev);
bool events_standard_init(void);
diff --git a/lib/tevent/tevent_liboop.c b/lib/tevent/tevent_liboop.c
index 339297a3cf..520bc5a996 100644
--- a/lib/tevent/tevent_liboop.c
+++ b/lib/tevent/tevent_liboop.c
@@ -276,7 +276,7 @@ static const struct event_ops event_oop_ops = {
.add_fd = oop_event_add_fd,
.get_fd_flags = oop_event_get_fd_flags,
.set_fd_flags = oop_event_set_fd_flags,
- .add_timed = oop_event_add_timed,
+ .add_timer = oop_event_add_timed,
.add_signal = common_event_add_signal,
.loop_once = oop_event_loop_once,
.loop_wait = oop_event_loop_wait,
diff --git a/lib/tevent/tevent_select.c b/lib/tevent/tevent_select.c
index 35c6f78599..efb3ff564c 100644
--- a/lib/tevent/tevent_select.c
+++ b/lib/tevent/tevent_select.c
@@ -289,7 +289,7 @@ static const struct event_ops select_event_ops = {
.add_fd = select_event_add_fd,
.get_fd_flags = select_event_get_fd_flags,
.set_fd_flags = select_event_set_fd_flags,
- .add_timed = common_event_add_timed,
+ .add_timer = common_event_add_timed,
.add_signal = common_event_add_signal,
.loop_once = select_event_loop_once,
.loop_wait = select_event_loop_wait,
diff --git a/lib/tevent/tevent_standard.c b/lib/tevent/tevent_standard.c
index c63d092173..ba474dbd26 100644
--- a/lib/tevent/tevent_standard.c
+++ b/lib/tevent/tevent_standard.c
@@ -593,7 +593,7 @@ static const struct event_ops std_event_ops = {
.add_fd = std_event_add_fd,
.get_fd_flags = std_event_get_fd_flags,
.set_fd_flags = std_event_set_fd_flags,
- .add_timed = common_event_add_timed,
+ .add_timer = common_event_add_timed,
.add_signal = common_event_add_signal,
.loop_once = std_event_loop_once,
.loop_wait = std_event_loop_wait,
diff --git a/lib/tevent/tevent_timed.c b/lib/tevent/tevent_timed.c
index ba8213710e..a9b80948a1 100644
--- a/lib/tevent/tevent_timed.c
+++ b/lib/tevent/tevent_timed.c
@@ -113,7 +113,7 @@ static int common_event_timed_destructor(struct timed_event *te)
{
struct event_context *ev = talloc_get_type(te->event_ctx,
struct event_context);
- DLIST_REMOVE(ev->timed_events, te);
+ DLIST_REMOVE(ev->timer_events, te);
return 0;
}
@@ -144,7 +144,7 @@ struct timed_event *common_event_add_timed(struct event_context *ev, TALLOC_CTX
/* keep the list ordered */
last_te = NULL;
- for (cur_te = ev->timed_events; cur_te; cur_te = cur_te->next) {
+ for (cur_te = ev->timer_events; cur_te; cur_te = cur_te->next) {
/* if the new event comes before the current one break */
if (ev_timeval_compare(&te->next_event, &cur_te->next_event) < 0) {
break;
@@ -153,7 +153,7 @@ struct timed_event *common_event_add_timed(struct event_context *ev, TALLOC_CTX
last_te = cur_te;
}
- DLIST_ADD_AFTER(ev->timed_events, te, last_te);
+ DLIST_ADD_AFTER(ev->timer_events, te, last_te);
talloc_set_destructor(te, common_event_timed_destructor);
@@ -169,7 +169,7 @@ struct timed_event *common_event_add_timed(struct event_context *ev, TALLOC_CTX
struct timeval common_event_loop_timer_delay(struct event_context *ev)
{
struct timeval current_time = ev_timeval_zero();
- struct timed_event *te = ev->timed_events;
+ struct timed_event *te = ev->timer_events;
if (!te) {
/* have a default tick time of 30 seconds. This guarantees
@@ -208,7 +208,7 @@ struct timeval common_event_loop_timer_delay(struct event_context *ev)
/* We need to remove the timer from the list before calling the
* handler because in a semi-async inner event loop called from the
* handler we don't want to come across this event again -- vl */
- DLIST_REMOVE(ev->timed_events, te);
+ DLIST_REMOVE(ev->timer_events, te);
/*
* If the timed event was registered for a zero current_time,
diff --git a/source4/lib/events/events.h b/source4/lib/events/events.h
index 9c6e8252e1..803cba8456 100644
--- a/source4/lib/events/events.h
+++ b/source4/lib/events/events.h
@@ -1 +1,7 @@
+#ifndef __LIB_EVENTS_H__
+#define __LIB_EVENTS_H__
+#define TEVENT_COMPAT_DEFINES 1
#include <../lib/tevent/tevent.h>
+struct event_context *s4_event_context_init(TALLOC_CTX *mem_ctx);
+struct event_context *event_context_find(TALLOC_CTX *mem_ctx);
+#endif /* __LIB_EVENTS_H__ */
diff --git a/source4/lib/events/events_internal.h b/source4/lib/events/events_internal.h
index e0928310f9..055bfe1a92 100644
--- a/source4/lib/events/events_internal.h
+++ b/source4/lib/events/events_internal.h
@@ -1 +1,5 @@
+#ifndef __LIB_EVENTS_INTERNAL_H__
+#define __LIB_EVENTS_INTERNAL_H__
+#define TEVENT_COMPAT_DEFINES 1
#include <../lib/tevent/tevent_internal.h>
+#endif /* __LIB_EVENTS_INTERNAL_H__ */