From: Alan T. DeKok Date: Thu, 16 Nov 2017 17:08:56 +0000 (-0500) Subject: call worker close, and don't just close the FD X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c098efdc4c7817af8ca28bdddfd8928033ce2f5;p=thirdparty%2Ffreeradius-server.git call worker close, and don't just close the FD --- diff --git a/src/modules/proto_detail/proto_detail_file.c b/src/modules/proto_detail/proto_detail_file.c index 684a1cd407e..af25b4da522 100644 --- a/src/modules/proto_detail/proto_detail_file.c +++ b/src/modules/proto_detail/proto_detail_file.c @@ -231,6 +231,7 @@ static void work_retry_timer(UNUSED fr_event_list_t *el, UNUSED struct timeval * */ static void work_exists(proto_detail_file_t *inst, int fd) { + bool opened = false; proto_detail_work_t *work; fr_listen_t *listen = NULL; @@ -381,14 +382,20 @@ static void work_exists(proto_detail_file_t *inst, int fd) ERROR("Failed opening %s", listen->app_io->name); goto error; } + opened = true; if (!fr_schedule_socket_add(inst->parent->sc, listen)) { error: (void) fr_event_fd_delete(inst->el, fd, FR_EVENT_FILTER_VNODE); - close(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 (opened) { + (void) listen->app_io->close(listen->app_io_instance); + } else { + close(fd); + } + if (listen) (void) listen->app_io->detach(listen->app_io_instance); talloc_free(listen); return;