- The tevent low-level API.
The tevent request functions.
A tevent_req represents an asynchronous computation.
#define TEVENT_FD_READ 1
Monitor a file descriptor for data to be read.
#define TEVENT_FD_WRITE 2
Monitor a file descriptor for writeability.
#define TEVENT_FD_WRITEABLE(fde) tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_WRITE)
Convenience function for declaring a tevent_fd writable.
#define TEVENT_FD_READABLE(fde) tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) | TEVENT_FD_READ)
Convenience function for declaring a tevent_fd readable.
#define TEVENT_FD_NOT_WRITEABLE(fde) tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_WRITE)
Convenience function for declaring a tevent_fd non-writable.
#define TEVENT_FD_NOT_READABLE(fde) tevent_fd_set_flags(fde, tevent_fd_get_flags(fde) & ~TEVENT_FD_READ)
Convenience function for declaring a tevent_fd non-readable.
typedef void(* tevent_fd_handler_t) (struct tevent_context *ev, struct tevent_fd *fde, uint16_t flags, void *private_data)
Called when a file descriptor monitored by tevent has data to be read or written on it.
typedef void(* tevent_fd_close_fn_t) (struct tevent_context *ev, struct tevent_fd *fde, int fd, void *private_data)
Called when tevent is ceasing the monitoring of a file descriptor.
typedef void(* tevent_timer_handler_t) (struct tevent_context *ev, struct tevent_timer *te, struct timeval current_time, void *private_data)
Called when a tevent timer has fired.
typedef void(* tevent_immediate_handler_t) (struct tevent_context *ctx, struct tevent_immediate *im, void *private_data)
Called when a tevent immediate event is invoked.
typedef void(* tevent_signal_handler_t) (struct tevent_context *ev, struct tevent_signal *se, int signum, int count, void *siginfo, void *private_data)
Called after tevent detects the specified signal.
typedef void(* tevent_debug_fn) (void *context, enum tevent_debug_level level, const char *fmt, va_list ap)
The tevent debug callbac.
enum tevent_debug_level
Debug level of tevent.
enum tevent_trace_point { TEVENT_TRACE_BEFORE_WAIT, TEVENT_TRACE_AFTER_WAIT, TEVENT_TRACE_BEFORE_LOOP_ONCE, TEVENT_TRACE_AFTER_LOOP_ONCE }
struct tevent_context * tevent_context_init (TALLOC_CTX *mem_ctx)
Create a event_context structure.
struct tevent_context * tevent_context_init_byname (TALLOC_CTX *mem_ctx, const char *name)
Create a event_context structure and select a specific backend.
struct tevent_context * tevent_context_init_ops (TALLOC_CTX *mem_ctx, const struct tevent_ops *ops, void *additional_data)
Create a custom event context.
const char ** tevent_backend_list (TALLOC_CTX *mem_ctx)
List available backends.
void tevent_set_default_backend (const char *backend)
Set the default tevent 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)
Add a file descriptor based event.
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)
Add a timed event.
void tevent_update_timer (struct tevent_timer *te, struct timeval next_event)
Set the time a tevent_timer fires.
struct tevent_immediate * tevent_create_immediate (TALLOC_CTX *mem_ctx)
Initialize an immediate event object.
void tevent_schedule_immediate (struct tevent_immediate *im, struct tevent_context *ctx, tevent_immediate_handler_t handler, void *private_data)
Schedule an event for immediate execution.
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)
Add a tevent signal handler.
size_t tevent_num_signals (void)
the number of supported signals
size_t tevent_sa_info_queue_count (void)
the number of pending realtime signals
int tevent_loop_once (struct tevent_context *ev)
Pass a single time through the mainloop.
int tevent_loop_wait (struct tevent_context *ev)
Run the mainloop.
void tevent_fd_set_close_fn (struct tevent_fd *fde, tevent_fd_close_fn_t close_fn)
Assign a function to run when a tevent_fd is freed.
void tevent_fd_set_auto_close (struct tevent_fd *fde)
Automatically close the file descriptor when the tevent_fd is freed.
uint16_t tevent_fd_get_flags (struct tevent_fd *fde)
Return the flags set on this file descriptor event.
void tevent_fd_set_flags (struct tevent_fd *fde, uint16_t flags)
Set flags on a file descriptor event.
bool tevent_signal_support (struct tevent_context *ev)
Query whether tevent supports signal handling.
int tevent_set_debug (struct tevent_context *ev, tevent_debug_fn debug, void *context)
Set destination for tevent debug messages.
int tevent_set_debug_stderr (struct tevent_context *ev)
Designate stderr for debug message output.
void tevent_set_trace_callback (struct tevent_context *ev, tevent_trace_callback_t cb, void *private_data)
Register a callback to be called at certain trace points.
void tevent_get_trace_callback (struct tevent_context *ev, tevent_trace_callback_t *cb, void *private_data)
Retrieve the current trace callback.
The tevent low-level API.
This API provides the public interface to manage events in the tevent mainloop. Functions are provided for managing low-level events such as timer events, fd events and signal handling.
The tevent debug callbac.
Parameters
Enumerator
Add a file descriptor based event.
Parameters
Returns
Note
The caller should avoid closing the file descriptor before calling talloc_free()! Otherwise the behaviour is undefined which might result in crashes. See https://bugzilla.samba.org/show_bug.cgi?id=11141 for an example.
Add a tevent signal handler. tevent_add_signal() creates a new event for handling a signal the next time through the mainloop. It implements a very simple traditional signal handler whose only purpose is to add the handler event into the mainloop.
Parameters
Returns
Note
See also
Add a timed event.
Parameters
Returns
Note
Unlike some mainloops, tevent timers are one-time events. To set up a recurring event, it is necessary to call tevent_add_timer() again during the handler processing.
Due to the internal mainloop processing, a timer set to run immediately will do so after any other pending timers fire, but before any further file descriptor or signal handling events fire. Callers should not rely on this behavior!
List available backends.
Parameters
Returns
Create a event_context structure. This must be the first events call, and all subsequent calls pass this event_context as the first element. Event handlers also receive this as their first argument.
Parameters
Returns
See also
Create a event_context structure and select a specific backend. This must be the first events call, and all subsequent calls pass this event_context as the first element. Event handlers also receive this as their first argument.
Parameters
Returns
Create a custom event context.
Parameters
Returns
Initialize an immediate event object. This object can be used to trigger an event to occur immediately after returning from the current event (before any other event occurs)
Parameters
Returns
Note
Return the flags set on this file descriptor event.
Parameters
Returns
Automatically close the file descriptor when the tevent_fd is freed. This function calls close(fd) internally.
Parameters
See also
Assign a function to run when a tevent_fd is freed. This function is a destructor for the tevent_fd. It does not automatically close the file descriptor. If this is the desired behavior, then it must be performed by the close_fn.
Parameters
Note
See also
tevent_context_wrapper_create
Set flags on a file descriptor event.
Parameters
Retrieve the current trace callback.
Parameters
Note
Pass a single time through the mainloop. This will process any appropriate signal, immediate, fd and timer events
Parameters
Returns
Run the mainloop. The mainloop will run until there are no events remaining to be processed
Parameters
Returns
the number of supported signals This returns value of the configure time TEVENT_NUM_SIGNALS constant.
The 'signum' argument of tevent_add_signal() must be less than TEVENT_NUM_SIGNALS.
See also
the number of pending realtime signals This returns value of TEVENT_SA_INFO_QUEUE_COUNT.
The tevent internals remember the last TEVENT_SA_INFO_QUEUE_COUNT siginfo_t structures for SA_SIGINFO signals. If the system generates more some signals get lost.
See also
Schedule an event for immediate execution. This event will occur immediately after returning from the current event (before any other event occurs)
Parameters
Set destination for tevent debug messages.
Parameters
Returns
Note
Designate stderr for debug message output.
Parameters
Note
Set the default tevent backend.
Parameters
Register a callback to be called at certain trace points.
Parameters
Note
Query whether tevent supports signal handling.
Parameters
Returns
Set the time a tevent_timer fires.
Parameters
Generated automatically by Doxygen for tevent from the source code.