fixed a wrong check when setting a log target

This commit is contained in:
hyung-hwan 2017-09-29 00:32:31 +00:00
parent 3478885962
commit 88e67887b7
3 changed files with 18 additions and 12 deletions

View File

@ -42,6 +42,9 @@ public:
int daemonize (bool chdir_to_root = true, int fork_count = 1) QSE_CPP_NOEXCEPT; int daemonize (bool chdir_to_root = true, int fork_count = 1) QSE_CPP_NOEXCEPT;
int chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT;
int chroot (const qse_mchar_t* mpath) QSE_CPP_NOEXCEPT;
protected: protected:
bool _root_only; bool _root_only;

View File

@ -49,14 +49,7 @@ int AppRoot::daemonize (bool chdir_to_root, int fork_count) QSE_CPP_NOEXCEPT
} }
int n = QSE_FORK(); int n = QSE_FORK();
if (n == -1) if (n == -1) return -1;
{
//throw DaemonError ("can't xp_fork");
//if (err_code) *err_code = ERR_FORK;
return -1;
}
// the parent exits
if (n != 0) QSE_EXIT(0); // TODO: should i call exit() in stdlib.h? if (n != 0) QSE_EXIT(0); // TODO: should i call exit() in stdlib.h?
} }
@ -128,6 +121,16 @@ int AppRoot::switchUser () QSE_CPP_NOEXCEPT
} }
#endif #endif
int AppRoot::chroot (const qse_mchar_t* mpath) QSE_CPP_NOEXCEPT
{
QSE_CHROOT (mpath);
}
int AppRoot::chroot (const qse_wchar_t* mpath) QSE_CPP_NOEXCEPT
{
}
void AppRoot::on_signal () QSE_CPP_NOEXCEPT void AppRoot::on_signal () QSE_CPP_NOEXCEPT
{ {
} }

View File

@ -229,7 +229,7 @@ int qse_log_init (qse_log_t* log, qse_mmgr_t* mmgr, const qse_char_t* ident, int
log->t.syslog_remote.sock = -1; log->t.syslog_remote.sock = -1;
if (potflags & QSE_LOG_FILE) log->flags |= QSE_LOG_FILE; if (potflags & QSE_LOG_FILE) log->flags |= QSE_LOG_FILE;
if (target->file) if (target && target->file)
{ {
if (qse_strlen(target->file) >= QSE_COUNTOF(log->t.file.pathbuf)) if (qse_strlen(target->file) >= QSE_COUNTOF(log->t.file.pathbuf))
{ {
@ -247,7 +247,7 @@ int qse_log_init (qse_log_t* log, qse_mmgr_t* mmgr, const qse_char_t* ident, int
if (potflags & QSE_LOG_SYSLOG) log->flags |= QSE_LOG_SYSLOG; if (potflags & QSE_LOG_SYSLOG) log->flags |= QSE_LOG_SYSLOG;
if (potflags & QSE_LOG_SYSLOG_REMOTE) log->flags |= QSE_LOG_SYSLOG_REMOTE; if (potflags & QSE_LOG_SYSLOG_REMOTE) log->flags |= QSE_LOG_SYSLOG_REMOTE;
if (qse_skadfamily(&target->syslog_remote) >= 0) log->t.syslog_remote.addr = target->syslog_remote; if (target && qse_skadfamily(&target->syslog_remote) >= 0) log->t.syslog_remote.addr = target->syslog_remote;
if (ident) qse_strxcpy (log->ident, QSE_COUNTOF(log->ident), ident); if (ident) qse_strxcpy (log->ident, QSE_COUNTOF(log->ident), ident);
if (qse_mtx_init(&log->mtx, mmgr) <= -1) if (qse_mtx_init(&log->mtx, mmgr) <= -1)
@ -381,7 +381,7 @@ int qse_log_settarget (qse_log_t* log, int flags, const qse_log_target_t* target
/* If you just want to set the target file path without enable QSE_LOG_FILE, /* If you just want to set the target file path without enable QSE_LOG_FILE,
* just set target->file without QSE_LOG_FILE in the flags. * just set target->file without QSE_LOG_FILE in the flags.
* later, you can call this function with QSE_LOG_FILE set but with target->file or QSE_NULL */ * later, you can call this function with QSE_LOG_FILE set but with target->file or QSE_NULL */
if (target->file) if (target && target->file)
{ {
if (log->t.file.path && log->t.file.path != log->t.file.pathbuf) QSE_MMGR_FREE (log->mmgr, log->t.file.path); if (log->t.file.path && log->t.file.path != log->t.file.pathbuf) QSE_MMGR_FREE (log->mmgr, log->t.file.path);
@ -400,7 +400,7 @@ int qse_log_settarget (qse_log_t* log, int flags, const qse_log_target_t* target
if (flags & QSE_LOG_SYSLOG) log->flags |= QSE_LOG_SYSLOG; if (flags & QSE_LOG_SYSLOG) log->flags |= QSE_LOG_SYSLOG;
if (flags & QSE_LOG_SYSLOG_REMOTE) log->flags |= QSE_LOG_SYSLOG_REMOTE; if (flags & QSE_LOG_SYSLOG_REMOTE) log->flags |= QSE_LOG_SYSLOG_REMOTE;
if (qse_skadfamily(&target->syslog_remote) >= 0) log->t.syslog_remote.addr = target->syslog_remote; if (target && qse_skadfamily(&target->syslog_remote) >= 0) log->t.syslog_remote.addr = target->syslog_remote;
return 0; return 0;
} }