From: Nick Porter Date: Tue, 17 Oct 2023 10:20:47 +0000 (+0100) Subject: If poll_interval is set don't open a dummy file X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4d4a14ac2381dd9d60359ec1fb37dc51110a215;p=thirdparty%2Ffreeradius-server.git If poll_interval is set don't open a dummy file Avoids a libkqueue issue which caused a crash on exit. --- diff --git a/src/listen/detail/proto_detail.c b/src/listen/detail/proto_detail.c index 15d7f137035..7c872d0020d 100644 --- a/src/listen/detail/proto_detail.c +++ b/src/listen/detail/proto_detail.c @@ -421,12 +421,22 @@ static int mod_open(void *instance, fr_schedule_t *sc, CONF_SECTION *conf) return 0; } - /* - * Watch the directory for changes. - */ - if (!fr_schedule_directory_add(sc, li)) { - talloc_free(li); - return -1; + if (li->non_socket_listener) { + /* + * Add listener. Will insert polling timer. + */ + if (!fr_schedule_listen_add(sc, li)) { + talloc_free(li); + return -1; + } + } else { + /* + * Watch the directory for changes. + */ + if (!fr_schedule_directory_add(sc, li)) { + talloc_free(li); + return -1; + } } DEBUG("Listening on %s bound to virtual server %s", diff --git a/src/listen/detail/proto_detail_file.c b/src/listen/detail/proto_detail_file.c index 530ffa6058e..8d7b2bce701 100644 --- a/src/listen/detail/proto_detail_file.c +++ b/src/listen/detail/proto_detail_file.c @@ -144,14 +144,14 @@ static int mod_open(fr_listen_t *li) oflag = O_RDONLY; #endif li->fd = thread->fd = open(inst->directory, oflag); + if (thread->fd < 0) { + cf_log_err(inst->cs, "Failed opening %s: %s", inst->directory, fr_syserror(errno)); + return -1; + } } else { - li->fd = thread->fd = open("/dev/null", O_RDONLY); + li->fd = thread->fd = -1; + li->non_socket_listener = true; } - if (thread->fd < 0) { - cf_log_err(inst->cs, "Failed opening %s: %s", inst->directory, fr_syserror(errno)); - return -1; - } - thread->inst = inst; thread->name = talloc_typed_asprintf(thread, "detail_file which will read files matching %s", inst->filename); thread->vnode_fd = -1; @@ -759,7 +759,7 @@ static int mod_close(fr_listen_t *li) * "copy timer from -> to, which means we only have to * delete our child event loop from the parent on close. */ - close(thread->fd); + if (thread->fd >= 0) close(thread->fd); if (thread->vnode_fd >= 0) { if (thread->nr) {