]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
call fr_network_listen_read() on Linux
authorAlan T. DeKok <aland@freeradius.org>
Thu, 16 Nov 2017 00:04:02 +0000 (19:04 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 16 Nov 2017 00:04:02 +0000 (19:04 -0500)
because libkqueue is broken

src/modules/proto_detail/proto_detail.h
src/modules/proto_detail/proto_detail_file.c
src/modules/proto_detail/proto_detail_work.c

index eba2e981b364ea6918da6e7f289de5d8b9c6fad6..8b0f695f6512da9143442bc5bd1c0510a7746075 100644 (file)
@@ -122,6 +122,8 @@ typedef struct proto_detail_work_t {
 
        fr_event_timer_t const          *ev;                    //!< for detail file timers.
        RADCLIENT                       *client;                //!< so the rest of the server doesn't complain
+
+       fr_network_t                    *nr;                    //!< for Linux-specific callbacks
 } proto_detail_work_t;
 
 typedef struct proto_detail_process_t {
index 954694f0916745f5f678a1c61bb914d9d63d98bc..1c3fefe2ea3c25ce2d067feb6650e9519d5c48b6 100644 (file)
@@ -275,12 +275,15 @@ static void work_exists(proto_detail_file_t *inst, int fd)
        DEBUG3("proto_detail (%s): Obtained lock and starting to process file %s",
               inst->name, inst->filename_work);
 
+       MEM(listen = talloc_zero(NULL, fr_listen_t));
+
        /*
         *      The worker may be in a different thread, so avoid
         *      talloc threading issues by using a NULL TALLOC_CTX.
         */
-       work = talloc(NULL, proto_detail_work_t);
+       work = talloc(listen, proto_detail_work_t);
        if (!work) {
+               talloc_free(listen);
                DEBUG("Failed allocating memory");
                return;
        }
@@ -300,7 +303,7 @@ static void work_exists(proto_detail_file_t *inst, int fd)
                      inst->name, inst->filename_work, fr_syserror(errno));
 
                close(fd);
-               talloc_free(work);
+               talloc_free(listen);
 
                when.tv_sec = 0;
                when.tv_usec = 10; /* hard-code! */
@@ -338,8 +341,6 @@ static void work_exists(proto_detail_file_t *inst, int fd)
         *      This listener is parented from the worker.  So that
         *      when the worker goes away, so does the listener.
         */
-       listen = talloc_zero(work, fr_listen_t);
-
        listen->app_io = inst->parent->work_io;
        listen->app_io_instance = work;
 
@@ -390,7 +391,7 @@ static void work_exists(proto_detail_file_t *inst, int fd)
                (void) fr_event_fd_delete(inst->el, work->fd, FR_EVENT_FILTER_VNODE);
                (void) fr_event_fd_delete(inst->el, work->fd, FR_EVENT_FILTER_IO);
                if (listen) (void) listen->app_io->detach(listen->app_io_instance);
-               talloc_free(work);
+               talloc_free(listen);
                return;
        }
 
index 266dc2391ffb374d337b8ed15103edb320013e05..38da95ec0ab010d3e118c45bc7559ec4c2c49ead 100644 (file)
@@ -88,10 +88,10 @@ static const CONF_PARSER file_listen_config[] = {
 /*
  *     All of the decoding is done by proto_detail.c
  */
-static int mod_decode(UNUSED void const *instance, REQUEST *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
+static int mod_decode(void const *instance, REQUEST *request, UNUSED uint8_t *const data, UNUSED size_t data_len)
 {
 
-       proto_detail_work_t const       *inst = talloc_get_type_abort_const(instance, proto_detail_work_t);
+       proto_detail_work_t const       *inst = talloc_get_type_abort_const(instance, proto_detail_work_t);
        fr_detail_entry_t const         *track = request->async->packet_ctx;
        VALUE_PAIR *vp;
 
@@ -459,7 +459,7 @@ done:
 }
 
 
-static void work_retransmit(UNUSED fr_event_list_t *el, UNUSED struct timeval *now, UNUSED void *uctx)
+static void work_retransmit(UNUSED fr_event_list_t *el, UNUSED struct timeval *now, void *uctx)
 {
        fr_detail_entry_t               *track = talloc_get_type_abort(uctx, fr_detail_entry_t);
        proto_detail_work_t             *inst = talloc_parent(track);
@@ -484,6 +484,10 @@ static void work_retransmit(UNUSED fr_event_list_t *el, UNUSED struct timeval *n
         *      the correct read offset.
         */
        (void) lseek(inst->fd, 0, SEEK_SET);
+
+#ifdef __linux__
+       fr_network_listen_read(inst->nr, talloc_parent(inst));
+#endif
 }
 
 static ssize_t mod_write(void *instance, void *packet_ctx,
@@ -684,7 +688,7 @@ static int mod_close(void *instance)
        inst->fd = -1;
 
        if (inst->free_on_close) {
-               talloc_free(inst);
+               talloc_free(talloc_parent(inst));
        }
 
        return 0;
@@ -725,6 +729,7 @@ static void mod_event_list_set(void *instance, fr_event_list_t *el, void *nr)
 #endif
 
        inst->el = el;
+       inst->nr = nr;
 }