From: Alan T. DeKok Date: Fri, 24 Nov 2017 16:39:00 +0000 (-0500) Subject: close vnode_fd on detach, too X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6ccc662406f601abc0121f8f56f8e5cf253f9d2a;p=thirdparty%2Ffreeradius-server.git close vnode_fd on detach, too --- diff --git a/src/modules/proto_detail/proto_detail.h b/src/modules/proto_detail/proto_detail.h index 8b0f695f651..2431ce2c27c 100644 --- a/src/modules/proto_detail/proto_detail.h +++ b/src/modules/proto_detail/proto_detail.h @@ -79,6 +79,7 @@ typedef struct proto_detail_work_t { char const *name; //!< debug name for printing int fd; //!< file descriptor + int vnode_fd; //!< file descriptor for vnode_delete fr_event_list_t *el; //!< for various timers diff --git a/src/modules/proto_detail/proto_detail_file.c b/src/modules/proto_detail/proto_detail_file.c index 5f21c55c4db..f89443109db 100644 --- a/src/modules/proto_detail/proto_detail_file.c +++ b/src/modules/proto_detail/proto_detail_file.c @@ -423,6 +423,8 @@ static int work_exists(proto_detail_file_t *inst, int fd) return -1; } + inst->vnode_fd = fd; + return 0; } @@ -435,6 +437,7 @@ static void mod_vnode_delete(fr_event_list_t *el, int fd, UNUSED int fflags, voi (void) fr_event_fd_delete(el, fd, FR_EVENT_FILTER_VNODE); close(fd); + inst->vnode_fd = -1; /* * Re-initialize the state machine. @@ -674,8 +677,13 @@ static int mod_detach(void *instance) * "copy timer from -> to, which means we only have to * delete our child event loop from the parent on close. */ - close(inst->fd); + + if (inst->vnode_fd >= 0) { + (void) fr_event_fd_delete(inst->el, inst->vnode_fd, FR_EVENT_FILTER_VNODE); + close(inst->vnode_fd); + } + return 0; }