]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
If poll_interval is set don't open a dummy file
authorNick Porter <nick@portercomputing.co.uk>
Tue, 17 Oct 2023 10:20:47 +0000 (11:20 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Wed, 18 Oct 2023 10:19:13 +0000 (11:19 +0100)
Avoids a libkqueue issue which caused a crash on exit.

src/listen/detail/proto_detail.c
src/listen/detail/proto_detail_file.c

index 15d7f1370356e5424e0e7c9b410020b6feb2a97d..7c872d0020d976e5345549d9635ef26ee17b8142 100644 (file)
@@ -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",
index 530ffa6058ee646bd58c35f6833457ae40f2ff43..8d7b2bce70111a00500ad19f426c34336531b1ea 100644 (file)
@@ -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) {