typedef int (*fr_app_open_t)(void *instance, fr_schedule_t *sc, CONF_SECTION *cs);
typedef int (*fr_app_instantiate_t)(void *instance, CONF_SECTION *cs);
typedef int (*fr_app_bootstrap_t)( void *instance, CONF_SECTION *cs);
+
/** Set the next state executed by the request to be one of the application subtype's entry points
*
* @param[in] instance of the #fr_app_t.
*/
typedef void (*fr_app_process_set_t)(void const *instance, REQUEST *request);
-/** Allows submodules to receive uctx data (a structure provided by their parent)
- *
- * @param[in] instance of #fr_app_process_t or #fr_app_io_t.
- * @param[in] uctx provided by caller.
+/** Called by the network thread to pass an event list for the module to use for timer events
*/
-typedef void (*fr_app_set_parent_inst_t)(void *instance, void *uctx);
+typedef void (*fr_app_event_list_set_t)(fr_event_list_t *el);
/** Describes a new application (protocol)
*
fr_app_bootstrap_t bootstrap;
fr_app_instantiate_t instantiate;
- fr_app_set_parent_inst_t set_parent_inst;//!< Allow the submodule to receive data from the main module.
fr_io_process_t process; //!< Entry point into the protocol subtype's state machine.
} fr_app_process_t;
fr_app_bootstrap_t bootstrap;
fr_app_instantiate_t instantiate;
- fr_app_set_parent_inst_t set_parent_inst; //!< Allow the submodule to receive data from the main module.
+ fr_app_event_list_set_t event_list_set; //!< Called by the network thread to pass an event list
+ //!< for use by the app_io_t.
size_t default_message_size; // Usually minimum message size
*/
static void fr_network_socket_callback(void *ctx, void const *data, size_t data_size, UNUSED fr_time_t now)
{
- int fd;
- fr_network_t *nr = ctx;
- fr_network_socket_t *s;
- fr_event_fd_handler_t write_fn, error_fn;
+ int fd;
+ fr_network_t *nr = ctx;
+ fr_network_socket_t *s;
+ fr_app_io_t const *app_io;
rad_assert(data_size == sizeof(*s));
_exit(1);
}
- write_fn = error_fn = NULL;
-
- if (s->listen->app_io->flush) write_fn = fr_network_write;
+ app_io = s->listen->app_io;
- if (s->listen->app_io->error) error_fn = fr_network_error;
+ if (app_io->event_list_set) app_io->event_list_set(nr->el);
- fd = s->listen->app_io->fd(s->listen->app_io_instance);
+ rad_assert(app_io->fd);
+ fd = app_io->fd(s->listen->app_io_instance);
- if (fr_event_fd_insert(nr->el, fd, fr_network_read, write_fn, error_fn, s) < 0) {
+ if (fr_event_fd_insert(nr->el, fd,
+ fr_network_read,
+ app_io->write ? fr_network_write : NULL,
+ app_io->error ? fr_network_error : NULL,
+ s) < 0) {
fr_log(nr->log, L_ERR, "Failed adding new socket to event loop: %s", fr_strerror());
talloc_free(s);
return;