summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--minecproxy/main.c12
-rw-r--r--minecproxy/server-config.c8
-rw-r--r--minecproxy/uring.c5
-rw-r--r--minecproxy/uring.h3
-rw-r--r--shared/config-parser.c1
5 files changed, 21 insertions, 8 deletions
diff --git a/minecproxy/main.c b/minecproxy/main.c
index 48bb1fa..7e17369 100644
--- a/minecproxy/main.c
+++ b/minecproxy/main.c
@@ -179,9 +179,19 @@ static void cfg_free(struct uring_task *task)
debug(DBG_SIG, "called");
systemd_delete();
xfree(cfg->igmp_iface);
+ cfg->igmp_iface = NULL;
xfree(cfg->data_real_path);
+ cfg->data_real_path = NULL;
xfree(cfg->cfg_real_path);
- cfg->igmp_iface = NULL;
+ cfg->cfg_real_path = NULL;
+ if (cfg->data_dir) {
+ closedir(cfg->data_dir);
+ cfg->data_dir = NULL;
+ }
+ if (cfg->cfg_dir) {
+ closedir(cfg->cfg_dir);
+ cfg->cfg_dir = NULL;
+ }
exiting = true;
/* The cfg struct is free:d in main() */
}
diff --git a/minecproxy/server-config.c b/minecproxy/server-config.c
index 2e7f277..81df970 100644
--- a/minecproxy/server-config.c
+++ b/minecproxy/server-config.c
@@ -185,8 +185,8 @@ static void inotify_cb(struct uring_task *task, int res)
server = server_new(event->name);
verbose("New server config file detected: %s",
event->name);
- uring_openat(&server->task, event->name,
- server_cfg_open_cb);
+ uring_openat(&server->task, dirfd(cfg->cfg_dir),
+ event->name, server_cfg_open_cb);
} else
error("inotify: unknown event: 0x%08x", event->mask);
}
@@ -249,7 +249,7 @@ void server_cfg_monitor_init()
server = server_new(dent->d_name);
if (server)
- uring_openat(&server->task, server->scfg.filename,
- server_cfg_open_cb);
+ uring_openat(&server->task, dirfd(cfg->cfg_dir),
+ server->scfg.filename, server_cfg_open_cb);
}
}
diff --git a/minecproxy/uring.c b/minecproxy/uring.c
index 0e90914..ead566d 100644
--- a/minecproxy/uring.c
+++ b/minecproxy/uring.c
@@ -423,7 +423,8 @@ void uring_read_offset(struct uring_task *task, void *buf, size_t len,
io_uring_sqe_set_data(sqe, task);
}
-void uring_openat(struct uring_task *task, const char *path, utask_cb_t cb)
+void uring_openat(struct uring_task *task, int dfd, const char *path,
+ utask_cb_t cb)
{
struct io_uring_sqe *sqe;
@@ -434,7 +435,7 @@ void uring_openat(struct uring_task *task, const char *path, utask_cb_t cb)
sqe = get_sqe(task);
task->cb = cb;
- io_uring_prep_openat(sqe, AT_FDCWD, path, O_RDONLY | O_CLOEXEC, 0);
+ io_uring_prep_openat(sqe, dfd, path, O_RDONLY | O_CLOEXEC, 0);
io_uring_sqe_set_data(sqe, task);
}
diff --git a/minecproxy/uring.h b/minecproxy/uring.h
index d5db725..7ec5f16 100644
--- a/minecproxy/uring.h
+++ b/minecproxy/uring.h
@@ -47,7 +47,8 @@ static inline void uring_read(struct uring_task *task, void *buf, size_t len,
uring_read_offset(task, buf, len, 0, cb);
}
-void uring_openat(struct uring_task *task, const char *path, utask_cb_t cb);
+void uring_openat(struct uring_task *task, int dfd, const char *path,
+ utask_cb_t cb);
void uring_tbuf_recvmsg(struct uring_task *task, utask_cb_t cb);
diff --git a/shared/config-parser.c b/shared/config-parser.c
index 909c558..8b43ada 100644
--- a/shared/config-parser.c
+++ b/shared/config-parser.c
@@ -574,6 +574,7 @@ void scfg_delete(struct server_config *scfg)
struct saddr *saddr, *tmp;
struct dns_async *dns;
+ xfree(scfg->name);
xfree(scfg->filename);
xfree(scfg->pretty_name);
xfree(scfg->stop_exec);