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",
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;
* "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) {