summaryrefslogtreecommitdiff
path: root/minecproxy
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-07-12 14:11:53 +0200
committerDavid Härdeman <david@hardeman.nu>2020-07-12 14:11:53 +0200
commit32858e669a79e0a053031fd65e2007d4b89e066b (patch)
treef9b43f625b30543b358c347579266072a197104a /minecproxy
parent6586ea650597ae0563c4234a7658499ce1e0117b (diff)
Teach minecproxy to use same dirs as minecctl, step 2
Diffstat (limited to 'minecproxy')
-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
4 files changed, 20 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);