]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add 'nr' to event_list_set()
authorAlan T. DeKok <aland@freeradius.org>
Wed, 15 Nov 2017 23:55:10 +0000 (18:55 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 15 Nov 2017 23:55:10 +0000 (18:55 -0500)
so that if a reader needs to poke the network, it can do so

src/lib/io/application.h
src/lib/io/network.c
src/lib/io/network.h
src/modules/proto_detail/proto_detail_file.c
src/modules/proto_detail/proto_detail_work.c
src/modules/proto_radius/proto_radius_udp.c

index a25340058fc2b824b244d3f63c31edab21765dca..b8047ddf88230e1f008cec79886ef1b7290333f9 100644 (file)
@@ -47,7 +47,7 @@ typedef void (*fr_app_process_set_t)(void const *instance, REQUEST *request);
 
 /** Called by the network thread to pass an event list for the module to use for timer events
  */
-typedef void (*fr_app_event_list_set_t)(void *instance, fr_event_list_t *el);
+typedef void (*fr_app_event_list_set_t)(void *instance, fr_event_list_t *el, void *nr);
 
 /** Describes a new application (protocol)
  *
index 4f3bcc6160a1ed716cb9884a5e6e60bb152c5b16..77402e341e07024b24f6d7133fd46e94bef3e801 100644 (file)
@@ -657,7 +657,7 @@ static void fr_network_socket_callback(void *ctx, void const *data, size_t data_
 
        app_io = s->listen->app_io;
 
-       if (app_io->event_list_set) app_io->event_list_set(s->listen->app_io_instance, nr->el);
+       if (app_io->event_list_set) app_io->event_list_set(s->listen->app_io_instance, nr->el, nr);
 
        rad_assert(app_io->fd);
        s->fd = app_io->fd(s->listen->app_io_instance);
@@ -718,7 +718,7 @@ static void fr_network_directory_callback(void *ctx, void const *data, size_t da
 
        app_io = s->listen->app_io;
 
-       if (app_io->event_list_set) app_io->event_list_set(s->listen->app_io_instance, nr->el);
+       if (app_io->event_list_set) app_io->event_list_set(s->listen->app_io_instance, nr->el, nr);
 
        rad_assert(app_io->fd);
        s->fd = app_io->fd(s->listen->app_io_instance);
@@ -1221,3 +1221,25 @@ int fr_network_worker_add(fr_network_t *nr, fr_worker_t *worker)
 
        return rcode;
 }
+
+/** Signal the network to read from a listener
+ *
+ * @param nr the network
+ * @param worker the worker
+ */
+void fr_network_listen_read(fr_network_t *nr, fr_listen_t const *listen)
+{
+       fr_network_socket_t my_socket, *s;
+
+       (void) talloc_get_type_abort(nr, fr_network_t);
+       (void) talloc_get_type_abort(listen, fr_listen_t);
+
+       my_socket.listen = listen;
+       s = rbtree_finddata(nr->sockets, &my_socket);
+       if (!s) return;
+
+       /*
+        *      Go read the socket.
+        */
+       fr_network_read(nr->el, s->fd, 0, s);
+}
index 9abe90392a1984584ba711e3b08024fa2cf37aa6..29d6413ed8949c3577348c1cb5ad8cdce190de02 100644 (file)
@@ -41,6 +41,7 @@ void fr_network(fr_network_t *nr) CC_HINT(nonnull);
 int fr_network_socket_add(fr_network_t *nr, fr_listen_t const *io) CC_HINT(nonnull);
 int fr_network_directory_add(fr_network_t *nr, fr_listen_t const *listen) CC_HINT(nonnull);
 int fr_network_worker_add(fr_network_t *nr, fr_worker_t *worker) CC_HINT(nonnull);
+void fr_network_listen_read(fr_network_t *nr, fr_listen_t const *listen) CC_HINT(nonnull);
 
 #ifdef __cplusplus
 }
index 50d38c51079d37a2d88a058e3a1f0f62da6e3f08..954694f0916745f5f678a1c61bb914d9d63d98bc 100644 (file)
@@ -492,8 +492,9 @@ static void work_init(proto_detail_file_t *inst)
  *
  * @param[in] instance of the detail worker
  * @param[in] el the event list
+ * @param[in] nr context from the network side
  */
-static void mod_event_list_set(void *instance, fr_event_list_t *el)
+static void mod_event_list_set(void *instance, fr_event_list_t *el, UNUSED void *nr)
 {
        proto_detail_file_t     *inst = talloc_get_type_abort(instance, proto_detail_file_t);
 #ifdef __linux__
index 1e0781b112bf937a6c21a4d16ce1b064fce77c37..266dc2391ffb374d337b8ed15103edb320013e05 100644 (file)
@@ -707,8 +707,9 @@ static int mod_fd(void const *instance)
  *
  * @param[in] instance of the detail worker
  * @param[in] el the event list
+ * @param[in] nr context from the network side
  */
-static void mod_event_list_set(void *instance, fr_event_list_t *el)
+static void mod_event_list_set(void *instance, fr_event_list_t *el, void *nr)
 {
        proto_detail_work_t *inst = talloc_get_type_abort(instance, proto_detail_work_t);
 
index 7490272d2e4ea3d944f1c28fa7ad77e55375df2a..824f48c75bf85e4cde2aaf2ae5709e32f4fbc615 100644 (file)
@@ -578,8 +578,9 @@ static int mod_fd(void const *instance)
  *
  * @param[in] instance of the RADIUS UDP I/O path.
  * @param[in] el the event list
+ * @param[in] nr_ctx context from the network side
  */
-static void mod_event_list_set(void *instance, fr_event_list_t *el)
+static void mod_event_list_set(void *instance, fr_event_list_t *el, UNUSED void *nr_ctx)
 {
        proto_radius_udp_t *inst;