]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
call worker close, and don't just close the FD
authorAlan T. DeKok <aland@freeradius.org>
Thu, 16 Nov 2017 17:08:56 +0000 (12:08 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 16 Nov 2017 17:09:26 +0000 (12:09 -0500)
src/modules/proto_detail/proto_detail_file.c

index 684a1cd407e17e493243987cc0dca7429afb74c0..af25b4da522e7f5e028f55c9b794c638d754bf21 100644 (file)
@@ -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;