From: Alan T. DeKok Date: Thu, 16 Nov 2017 00:04:02 +0000 (-0500) Subject: call fr_network_listen_read() on Linux X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d916df3dfbae25dd5285351a4e01153477ddaba;p=thirdparty%2Ffreeradius-server.git call fr_network_listen_read() on Linux because libkqueue is broken --- diff --git a/src/modules/proto_detail/proto_detail.h b/src/modules/proto_detail/proto_detail.h index eba2e981b36..8b0f695f651 100644 --- a/src/modules/proto_detail/proto_detail.h +++ b/src/modules/proto_detail/proto_detail.h @@ -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 { diff --git a/src/modules/proto_detail/proto_detail_file.c b/src/modules/proto_detail/proto_detail_file.c index 954694f0916..1c3fefe2ea3 100644 --- a/src/modules/proto_detail/proto_detail_file.c +++ b/src/modules/proto_detail/proto_detail_file.c @@ -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; } diff --git a/src/modules/proto_detail/proto_detail_work.c b/src/modules/proto_detail/proto_detail_work.c index 266dc2391ff..38da95ec0ab 100644 --- a/src/modules/proto_detail/proto_detail_work.c +++ b/src/modules/proto_detail/proto_detail_work.c @@ -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; }