From 6586ea650597ae0563c4234a7658499ce1e0117b Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Sun, 12 Jul 2020 14:04:40 +0200 Subject: Teach minecproxy to use same dirs as minecctl, step 1 --- minecproxy/server-config.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'minecproxy/server-config.c') diff --git a/minecproxy/server-config.c b/minecproxy/server-config.c index 959f1d0..2e7f277 100644 --- a/minecproxy/server-config.c +++ b/minecproxy/server-config.c @@ -215,11 +215,10 @@ void server_cfg_monitor_init() int ifd; int iwd; struct server_cfg_monitor *scfgm; - DIR *dir; struct dirent *dent; struct server *server; - assert_return(!cfg->server_cfg_monitor); + assert_return(!cfg->server_cfg_monitor && cfg->cfg_dir); scfgm = zmalloc(sizeof(*scfgm)); if (!scfgm) @@ -231,7 +230,7 @@ void server_cfg_monitor_init() /* ln = IN_CREATE, cp/vi/mv = IN_CREATE, IN_OPEN, IN_CLOSE_WRITE */ iwd = inotify_add_watch( - ifd, ".", + ifd, cfg->cfg_real_path, IN_CLOSE_WRITE | IN_DELETE | IN_CREATE | IN_DELETE_SELF | IN_MOVE_SELF | IN_MOVED_TO | IN_MOVED_FROM | IN_DONT_FOLLOW | IN_EXCL_UNLINK | IN_ONLYDIR); @@ -244,11 +243,7 @@ void server_cfg_monitor_init() cfg->server_cfg_monitor = scfgm; uring_read(&scfgm->task, scfgm->buf, sizeof(scfgm->buf), inotify_cb); - dir = opendir("."); - if (!dir) - die("opendir(%s): %m", cfg->cfg_dir); - - while ((dent = readdir(dir)) != NULL) { + while ((dent = readdir(cfg->cfg_dir)) != NULL) { if (!config_valid_server_filename(dent, NULL)) continue; @@ -257,6 +252,4 @@ void server_cfg_monitor_init() uring_openat(&server->task, server->scfg.filename, server_cfg_open_cb); } - - closedir(dir); } -- cgit v1.2.3