]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add callback to set event list in app_io
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 20 Jun 2017 20:55:09 +0000 (16:55 -0400)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 20 Jun 2017 20:55:09 +0000 (16:55 -0400)
src/lib/io/application.h
src/lib/io/network.c

index 262233357648ac6c00a92ab200158a580083b910..94ffa2f5518d715f088b6dbd93ccf5649d711e56 100644 (file)
@@ -37,6 +37,7 @@ typedef struct fr_schedule_t fr_schedule_t;
 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.
@@ -44,12 +45,9 @@ typedef int (*fr_app_bootstrap_t)( void *instance, CONF_SECTION *cs);
  */
 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)
  *
@@ -73,7 +71,6 @@ typedef struct 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_io_process_t                 process;        //!< Entry point into the protocol subtype's state machine.
 } fr_app_process_t;
 
@@ -86,7 +83,8 @@ typedef struct fr_app_io_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
 
index 56559c7ca3d8f1e538a9a05c0cc2756dcbcd8ff1..9cbdafb9fc2e4df6f3ac6e86348c4c75cecf6530 100644 (file)
@@ -455,10 +455,10 @@ static int _network_socket_free(fr_network_socket_t *s)
  */
 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));
 
@@ -487,15 +487,18 @@ static void fr_network_socket_callback(void *ctx, void const *data, size_t data_
                _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;