From d97cb915c5314e1cd9ffab3cc4ca65e8bb978013 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 14 Sep 2020 17:49:29 +0000 Subject: [PATCH] removed MAIN*CHROOT from the sample app code --- qse/lib/si/nwad.c | 3 ++- qse/samples/app/MainApp.cpp | 17 ++--------------- qse/samples/app/MainApp.hpp | 2 -- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/qse/lib/si/nwad.c b/qse/lib/si/nwad.c index 0f5a14a5..e127ebb1 100644 --- a/qse/lib/si/nwad.c +++ b/qse/lib/si/nwad.c @@ -151,7 +151,8 @@ int qse_mbsntonwad (const qse_mchar_t* str, qse_size_t len, qse_nwad_t* nwad) if (p >= end) return -1; - if ((*p == '@' && len >= 2) || *p == '/') // with @, you can specify a relative path + // with @, you can specify a relative path as well as an absolute path + if ((*p == '@' && len >= 2) || *p == '/') { /* the string begins with @. it's a local name excluding @. * if it begins with /, it's also a local name */ diff --git a/qse/samples/app/MainApp.cpp b/qse/samples/app/MainApp.cpp index 23f731f0..6f018cdb 100644 --- a/qse/samples/app/MainApp.cpp +++ b/qse/samples/app/MainApp.cpp @@ -18,11 +18,6 @@ MainApp::Env::Env (MainApp* app, QSE::Mmgr* mmgr): SkvEnv(mmgr), app(app), log_t QSE_T("info+"), (ProbeProc)&MainApp::Env::probe_log_level); - this->addItem ( - APP_ENV_CHROOT, - QSE_T(""), - (ProbeProc)&MainApp::Env::probe_chroot); - this->addItem ( APP_ENV_GATE_ADDRESSES, APP_GATE_ADDRESSES, @@ -76,14 +71,6 @@ int MainApp::Env::probe_log_level (const qse_char_t* v) return 0; } -int MainApp::Env::probe_chroot (const qse_char_t* v) -{ - // nothing to inspect - if (v[0] != '\0' && qse_stristype(v, QSE_CTYPE_SPACE)) return -1; - this->chroot.update (v); - return 0; -} - int MainApp::Env::probe_gate_addresses (const qse_char_t* v) { if (v[0] == '\0' || qse_stristype(v, QSE_CTYPE_SPACE)) return -1; @@ -155,6 +142,8 @@ int MainApp::run (bool foreground) try { + this->chroot_if_needed (); + int x = this->load_config(); QSE_APP_LOG1 (this, QSE_LOG_INFO, QSE_T("starting application %d\n"), (int)getpid()); @@ -162,8 +151,6 @@ int MainApp::run (bool foreground) if (x <= -1) QSE_APP_LOG1 (this, QSE_LOG_WARNING, QSE_T("unable to load configuration from %js\n"), this->conffile.getData()); else QSE_APP_LOG1 (this, QSE_LOG_INFO, QSE_T("loaded configuration from %js\n"), this->conffile.getData()); - this->chroot_if_needed (); - this->tcp_gate.setBindAddress (this->gate_addresses.isEmpty()? this->env.getGateAddresses(): this->gate_addresses.getData()); if (this->tcp_gate.start() <= -1) { diff --git a/qse/samples/app/MainApp.hpp b/qse/samples/app/MainApp.hpp index c1128a67..1ed30c75 100644 --- a/qse/samples/app/MainApp.hpp +++ b/qse/samples/app/MainApp.hpp @@ -40,7 +40,6 @@ #define APP_ENV_LOG_TYPE QSE_T("MAIN*LOG_TYPE") #define APP_ENV_LOG_LEVEL QSE_T("MAIN*LOG_LEVEL") -#define APP_ENV_CHROOT QSE_T("MAIN*CHROOT") #define APP_ENV_GATE_ADDRESSES QSE_T("GATE*ADDRESSES") #define APP_ENV_GATE_MAX_CONNECTIONS QSE_T("GATE*MAX_CONNECTIONS") @@ -76,7 +75,6 @@ public: int probe_log_type (const qse_char_t* v); int probe_log_level (const qse_char_t* v); - int probe_chroot (const char_t* v); int probe_gate_addresses (const qse_char_t* v); int probe_gate_max_connections (const qse_char_t* v);