const char *handler_name,
const char *location)
{
- return ev->ops->add_fd(ev, mem_ctx, fd, flags, handler, private_data);
+ return ev->ops->add_fd(ev, mem_ctx, fd, flags, handler, private_data,
+ handler_name, location);
}
/*
const char *location)
{
if (ev->ops->add_aio == NULL) return NULL;
- return ev->ops->add_aio(ev, mem_ctx, iocb, handler, private_data);
+ return ev->ops->add_aio(ev, mem_ctx, iocb, handler, private_data,
+ handler_name, location);
}
/*
const char *handler_name,
const char *location)
{
- return ev->ops->add_timer(ev, mem_ctx, next_event, handler, private_data);
+ return ev->ops->add_timer(ev, mem_ctx, next_event, handler, private_data,
+ handler_name, location);
}
/*
const char *handler_name,
const char *location)
{
- return ev->ops->add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data);
+ return ev->ops->add_signal(ev, mem_ctx, signum, sa_flags, handler, private_data,
+ handler_name, location);
}
/*
pid_t pid;
};
-struct aio_event {
+struct tevent_aio {
struct tevent_context *event_ctx;
struct iocb iocb;
void *private_data;
- event_aio_handler_t handler;
+ tevent_aio_handler_t handler;
};
/*
if (aio_ev->epoll_fd == -1) return -1;
if (aio_ev->ev->num_signal_handlers &&
- common_event_check_signal(aio_ev->ev)) {
+ tevent_common_check_signal(aio_ev->ev)) {
return 0;
}
if (ret == -EINTR) {
if (aio_ev->ev->num_signal_handlers) {
- common_event_check_signal(aio_ev->ev);
+ tevent_common_check_signal(aio_ev->ev);
}
return 0;
}
if (ret == 0 && tvalp) {
/* we don't care about a possible delay here */
- common_event_loop_timer_delay(aio_ev->ev);
+ tevent_common_loop_timer_delay(aio_ev->ev);
return 0;
}
switch (finished->aio_lio_opcode) {
case IO_CMD_PWRITE:
case IO_CMD_PREAD: {
- struct aio_event *ae = talloc_get_type(finished->data,
- struct aio_event);
+ struct tevent_aio *ae = talloc_get_type(finished->data,
+ struct tevent_aio);
if (ae) {
talloc_set_destructor(ae, NULL);
ae->handler(ae->event_ctx, ae,
return NULL on failure (memory allocation error)
*/
static struct tevent_fd *aio_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
- int fd, uint16_t flags,
- event_fd_handler_t handler,
- void *private_data)
+ int fd, uint16_t flags,
+ tevent_fd_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
struct aio_event_context);
fde->flags = flags;
fde->handler = handler;
fde->private_data = private_data;
+ fde->handler_name = handler_name;
+ fde->location = location;
fde->additional_flags = 0;
fde->additional_data = NULL;
struct aio_event_context);
struct timeval tval;
- tval = common_event_loop_timer_delay(ev);
+ tval = tevent_common_loop_timer_delay(ev);
if (ev_timeval_is_zero(&tval)) {
return 0;
}
/*
called when a disk IO event needs to be cancelled
*/
-static int aio_destructor(struct aio_event *ae)
+static int aio_destructor(struct tevent_aio *ae)
{
struct tevent_context *ev = ae->event_ctx;
struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
}
/* submit an aio disk IO event */
-static struct aio_event *aio_event_add_aio(struct tevent_context *ev,
- TALLOC_CTX *mem_ctx,
- struct iocb *iocb,
- event_aio_handler_t handler,
- void *private_data)
+static struct tevent_aio *aio_event_add_aio(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ struct iocb *iocb,
+ tevent_aio_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
struct aio_event_context *aio_ev = talloc_get_type(ev->additional_data,
struct aio_event_context);
struct iocb *iocbp;
- struct aio_event *ae = talloc(mem_ctx?mem_ctx:ev, struct aio_event);
+ struct tevent_aio *ae = talloc(mem_ctx?mem_ctx:ev, struct tevent_aio);
if (ae == NULL) return NULL;
ae->event_ctx = ev;
.add_aio = aio_event_add_aio,
.get_fd_flags = aio_event_get_fd_flags,
.set_fd_flags = aio_event_set_fd_flags,
- .add_timer = common_event_add_timed,
- .add_signal = common_event_add_signal,
+ .add_timer = tevent_common_add_timer,
+ .add_signal = tevent_common_add_signal,
.loop_once = aio_event_loop_once,
.loop_wait = aio_event_loop_wait,
};
}
if (epoll_ev->ev->num_signal_handlers &&
- common_event_check_signal(epoll_ev->ev)) {
+ tevent_common_check_signal(epoll_ev->ev)) {
return 0;
}
ret = epoll_wait(epoll_ev->epoll_fd, events, MAXEVENTS, timeout);
if (ret == -1 && errno == EINTR && epoll_ev->ev->num_signal_handlers) {
- if (common_event_check_signal(epoll_ev->ev)) {
+ if (tevent_common_check_signal(epoll_ev->ev)) {
return 0;
}
}
if (ret == 0 && tvalp) {
/* we don't care about a possible delay here */
- common_event_loop_timer_delay(epoll_ev->ev);
+ tevent_common_loop_timer_delay(epoll_ev->ev);
return 0;
}
return NULL on failure (memory allocation error)
*/
static struct tevent_fd *epoll_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
- int fd, uint16_t flags,
- event_fd_handler_t handler,
- void *private_data)
+ int fd, uint16_t flags,
+ tevent_fd_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
struct epoll_event_context *epoll_ev = talloc_get_type(ev->additional_data,
struct epoll_event_context);
fde->flags = flags;
fde->handler = handler;
fde->private_data = private_data;
+ fde->handler_name = handler_name;
+ fde->location = location;
fde->additional_flags = 0;
fde->additional_data = NULL;
struct epoll_event_context);
struct timeval tval;
- tval = common_event_loop_timer_delay(ev);
+ tval = tevent_common_loop_timer_delay(ev);
if (ev_timeval_is_zero(&tval)) {
return 0;
}
.add_fd = epoll_event_add_fd,
.get_fd_flags = epoll_event_get_fd_flags,
.set_fd_flags = epoll_event_set_fd_flags,
- .add_timer = common_event_add_timed,
- .add_signal = common_event_add_signal,
+ .add_timer = tevent_common_add_timer,
+ .add_signal = tevent_common_add_signal,
.loop_once = epoll_event_loop_once,
.loop_wait = epoll_event_loop_wait,
};
TALLOC_CTX *mem_ctx,
int fd, uint16_t flags,
tevent_fd_handler_t handler,
- void *private_data);
+ void *private_data,
+ const char *handler_name,
+ const char *location);
uint16_t (*get_fd_flags)(struct tevent_fd *fde);
void (*set_fd_flags)(struct tevent_fd *fde, uint16_t flags);
TALLOC_CTX *mem_ctx,
struct timeval next_event,
tevent_timer_handler_t handler,
- void *private_data);
+ void *private_data,
+ const char *handler_name,
+ const char *location);
/* disk aio event functions */
struct tevent_aio *(*add_aio)(struct tevent_context *ev,
TALLOC_CTX *mem_ctx,
struct iocb *iocb,
tevent_aio_handler_t handler,
- void *private_data);
+ void *private_data,
+ const char *handler_name,
+ const char *location);
/* signal functions */
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);
+ void *private_data,
+ const char *handler_name,
+ const char *location);
/* loop functions */
int (*loop_once)(struct tevent_context *ev);
tevent_fd_handler_t handler;
/* this is private for the specific handler */
void *private_data;
+ /* this is for debugging only! */
+ const char *handler_name;
+ const char *location;
/* this is private for the events_ops implementation */
uint16_t additional_flags;
void *additional_data;
tevent_timer_handler_t handler;
/* this is private for the specific handler */
void *private_data;
+ /* this is for debugging only! */
+ const char *handler_name;
+ const char *location;
/* this is private for the events_ops implementation */
void *additional_data;
};
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;
+ tevent_signal_handler_t handler;
+ /* this is private for the specific handler */
+ void *private_data;
+ /* this is for debugging only! */
+ const char *handler_name;
+ const char *location;
+ /* this is private for the events_ops implementation */
+ void *additional_data;
};
/* DEBUG */
bool tevent_register_backend(const char *name, const struct tevent_ops *ops);
bool ev_timeval_is_zero(const struct timeval *tv);
-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);
-
+struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ struct timeval next_event,
+ tevent_timer_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location);
+struct timeval tevent_common_loop_timer_delay(struct tevent_context *);
+
+struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int signum,
+ int sa_flags,
+ tevent_signal_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location);
+int tevent_common_check_signal(struct tevent_context *ev);
bool tevent_standard_init(void);
bool tevent_select_init(void);
return NULL on failure (memory allocation error)
*/
static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
- int fd, uint16_t flags,
- event_fd_handler_t handler,
- void *private_data)
+ int fd, uint16_t flags,
+ tevent_fd_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
struct select_event_context *select_ev = talloc_get_type(ev->additional_data,
struct select_event_context);
fde->flags = flags;
fde->handler = handler;
fde->private_data = private_data;
+ fde->handler_name = handler_name;
+ fde->location = location;
fde->additional_flags = 0;
fde->additional_data = NULL;
}
if (select_ev->ev->num_signal_handlers &&
- common_event_check_signal(select_ev->ev)) {
+ tevent_common_check_signal(select_ev->ev)) {
return 0;
}
if (selrtn == -1 && errno == EINTR &&
select_ev->ev->num_signal_handlers) {
- common_event_check_signal(select_ev->ev);
+ tevent_common_check_signal(select_ev->ev);
return 0;
}
if (selrtn == 0 && tvalp) {
/* we don't care about a possible delay here */
- common_event_loop_timer_delay(select_ev->ev);
+ tevent_common_loop_timer_delay(select_ev->ev);
return 0;
}
struct select_event_context);
struct timeval tval;
- tval = common_event_loop_timer_delay(ev);
+ tval = tevent_common_loop_timer_delay(ev);
if (ev_timeval_is_zero(&tval)) {
return 0;
}
.add_fd = select_event_add_fd,
.get_fd_flags = select_event_get_fd_flags,
.set_fd_flags = select_event_set_fd_flags,
- .add_timer = common_event_add_timed,
- .add_signal = common_event_add_signal,
+ .add_timer = tevent_common_add_timer,
+ .add_signal = tevent_common_add_signal,
.loop_once = select_event_loop_once,
.loop_wait = select_event_loop_wait,
};
the poor design of signals means that this table must be static global
*/
static struct sig_state {
- struct signal_event *sig_handlers[NUM_SIGNALS+1];
+ struct tevent_signal *sig_handlers[NUM_SIGNALS+1];
struct sigaction *oldact[NUM_SIGNALS+1];
struct sigcounter signal_count[NUM_SIGNALS+1];
struct sigcounter got_signal;
/*
destroy a signal event
*/
-static int signal_event_destructor(struct signal_event *se)
+static int tevent_signal_destructor(struct tevent_signal *se)
{
se->event_ctx->num_signal_handlers--;
DLIST_REMOVE(sig_state->sig_handlers[se->signum], se);
add a signal event
return NULL on failure (memory allocation error)
*/
-struct signal_event *common_event_add_signal(struct tevent_context *ev,
- TALLOC_CTX *mem_ctx,
- int signum,
- int sa_flags,
- event_signal_handler_t handler,
- void *private_data)
+struct tevent_signal *tevent_common_add_signal(struct tevent_context *ev,
+ TALLOC_CTX *mem_ctx,
+ int signum,
+ int sa_flags,
+ tevent_signal_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
- struct signal_event *se;
+ struct tevent_signal *se;
if (signum >= NUM_SIGNALS) {
return NULL;
}
}
- se = talloc(mem_ctx?mem_ctx:ev, struct signal_event);
+ se = talloc(mem_ctx?mem_ctx:ev, struct tevent_signal);
if (se == NULL) return NULL;
se->event_ctx = ev;
- se->handler = handler;
- se->private_data = private_data;
se->signum = signum;
se->sa_flags = sa_flags;
-
+ se->handler = handler;
+ se->private_data = private_data;
+ se->handler_name = handler_name;
+ se->location = location;
+ se->additional_data = NULL;
+
/* Ensure, no matter the destruction order, that we always have a handle on the global sig_state */
if (!talloc_reference(se, sig_state)) {
return NULL;
DLIST_ADD(sig_state->sig_handlers[signum], se);
- talloc_set_destructor(se, signal_event_destructor);
+ talloc_set_destructor(se, tevent_signal_destructor);
/* we need to setup the pipe hack handler if not already
setup */
ev_set_blocking(sig_state->pipe_hack[0], false);
ev_set_blocking(sig_state->pipe_hack[1], false);
}
- ev->pipe_fde = event_add_fd(ev, ev, sig_state->pipe_hack[0],
- EVENT_FD_READ, signal_pipe_handler, NULL);
+ ev->pipe_fde = tevent_add_fd(ev, ev, sig_state->pipe_hack[0],
+ TEVENT_FD_READ, signal_pipe_handler, NULL);
}
ev->num_signal_handlers++;
check if a signal is pending
return != 0 if a signal was pending
*/
-int common_event_check_signal(struct tevent_context *ev)
+int tevent_common_check_signal(struct tevent_context *ev)
{
int i;
}
for (i=0;i<NUM_SIGNALS+1;i++) {
- struct signal_event *se, *next;
+ struct tevent_signal *se, *next;
struct sigcounter counter = sig_state->signal_count[i];
uint32_t count = sig_count(counter);
}
if (std_ev->ev->num_signal_handlers &&
- common_event_check_signal(std_ev->ev)) {
+ tevent_common_check_signal(std_ev->ev)) {
return 0;
}
ret = epoll_wait(std_ev->epoll_fd, events, MAXEVENTS, timeout);
if (ret == -1 && errno == EINTR && std_ev->ev->num_signal_handlers) {
- if (common_event_check_signal(std_ev->ev)) {
+ if (tevent_common_check_signal(std_ev->ev)) {
return 0;
}
}
if (ret == 0 && tvalp) {
/* we don't care about a possible delay here */
- common_event_loop_timer_delay(std_ev->ev);
+ tevent_common_loop_timer_delay(std_ev->ev);
return 0;
}
return NULL on failure (memory allocation error)
*/
static struct tevent_fd *std_event_add_fd(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
- int fd, uint16_t flags,
- event_fd_handler_t handler,
- void *private_data)
+ int fd, uint16_t flags,
+ tevent_fd_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
struct std_event_context *std_ev = talloc_get_type(ev->additional_data,
struct std_event_context);
}
if (std_ev->ev->num_signal_handlers &&
- common_event_check_signal(std_ev->ev)) {
+ tevent_common_check_signal(std_ev->ev)) {
return 0;
}
if (selrtn == -1 && errno == EINTR &&
std_ev->ev->num_signal_handlers) {
- common_event_check_signal(std_ev->ev);
+ tevent_common_check_signal(std_ev->ev);
return 0;
}
if (selrtn == 0 && tvalp) {
/* we don't care about a possible delay here */
- common_event_loop_timer_delay(std_ev->ev);
+ tevent_common_loop_timer_delay(std_ev->ev);
return 0;
}
struct std_event_context);
struct timeval tval;
- tval = common_event_loop_timer_delay(ev);
+ tval = tevent_common_loop_timer_delay(ev);
if (ev_timeval_is_zero(&tval)) {
return 0;
}
.add_fd = std_event_add_fd,
.get_fd_flags = std_event_get_fd_flags,
.set_fd_flags = std_event_set_fd_flags,
- .add_timer = common_event_add_timed,
- .add_signal = common_event_add_signal,
+ .add_timer = tevent_common_add_timer,
+ .add_signal = tevent_common_add_signal,
.loop_once = std_event_loop_once,
.loop_wait = std_event_loop_wait,
};
/*
destroy a timed event
*/
-static int common_event_timed_destructor(struct tevent_timer *te)
+static int tevent_common_timed_destructor(struct tevent_timer *te)
{
struct tevent_context *ev = talloc_get_type(te->event_ctx,
struct tevent_context);
return 0;
}
-static int common_event_timed_deny_destructor(struct tevent_timer *te)
+static int tevent_common_timed_deny_destructor(struct tevent_timer *te)
{
return -1;
}
add a timed event
return NULL on failure (memory allocation error)
*/
-struct tevent_timer *common_event_add_timed(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
- struct timeval next_event,
- event_timed_handler_t handler,
- void *private_data)
+struct tevent_timer *tevent_common_add_timer(struct tevent_context *ev, TALLOC_CTX *mem_ctx,
+ struct timeval next_event,
+ tevent_timer_handler_t handler,
+ void *private_data,
+ const char *handler_name,
+ const char *location)
{
struct tevent_timer *te, *last_te, *cur_te;
te->next_event = next_event;
te->handler = handler;
te->private_data = private_data;
+ te->handler_name = handler_name;
+ te->location = location;
te->additional_data = NULL;
/* keep the list ordered */
DLIST_ADD_AFTER(ev->timer_events, te, last_te);
- talloc_set_destructor(te, common_event_timed_destructor);
+ talloc_set_destructor(te, tevent_common_timed_destructor);
return te;
}
return the delay untill the next timed event,
or zero if a timed event was triggered
*/
-struct timeval common_event_loop_timer_delay(struct tevent_context *ev)
+struct timeval tevent_common_loop_timer_delay(struct tevent_context *ev)
{
struct timeval current_time = ev_timeval_zero();
struct tevent_timer *te = ev->timer_events;
*/
/* deny the handler to free the event */
- talloc_set_destructor(te, common_event_timed_deny_destructor);
+ talloc_set_destructor(te, tevent_common_timed_deny_destructor);
/* We need to remove the timer from the list before calling the
* handler because in a semi-async inner event loop called from the