Skip to content

Commit

Permalink
[core] use log_warn(),log_notice(),log_info() (fixes #3239)
Browse files Browse the repository at this point in the history
use log_warn(),log_notice(),log_info() in server.c instead of log_error

(behavior change)

This is a behavior change *only* if using syslog() for error logging.
Previously all error log syslogging was sent to syslog() as LOG_ERR.

x-ref:
  "syslog level set to error for messages that are not errors"
  https://redmine.lighttpd.net/issues/3239
  • Loading branch information
gstrauss committed Jan 11, 2024
1 parent ac7dfe7 commit db37cbd
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ server_epoch_secs (server * const srv, unix_time64_t mono_ts_delta)
const unix_time64_t new_ts_adj = new_ts - mono_ts_delta;
/* attempt to detect large clock jump */
if (new_ts_adj < cur_ts || new_ts_adj - cur_ts > 300) { /*(5 mins)*/
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"warning: clock jumped %lld secs",
(long long)((int64_t)new_ts_adj - (int64_t)cur_ts));

Expand All @@ -476,6 +476,7 @@ server_epoch_secs (server * const srv, unix_time64_t mono_ts_delta)
? new_ts_adj-cur_ts
: cur_ts-new_ts_adj) > delta) {
log_error(srv->errh, __FILE__, __LINE__,
"clock jumped; "
"attempting graceful restart in < ~5 seconds, else hard restart");
srv->graceful_expire_ts = log_monotonic_secs + 5;
raise(SIGUSR1);
Expand Down Expand Up @@ -1125,7 +1126,7 @@ static int server_graceful_state_bg (server *srv) {
* future: fdevent kqueue and stat_cache kqueue would need to be closed,
* re-opened, and active fds re-registered. Not current done.
* Need to create some routines like fdevent_reinit_after_fork*/
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"server.graceful-restart-bg ignored on OpenBSD and NetBSD "
"due to limitation in kqueue inheritance and lacking rfork");
return 0;
Expand Down Expand Up @@ -1177,7 +1178,7 @@ static int server_graceful_state_bg (server *srv) {

/* (original process is backgrounded -- even if no active connections --
* to allow graceful shutdown tasks to be run by server and by modules) */
log_error(srv->errh, __FILE__, __LINE__,
log_notice(srv->errh, __FILE__, __LINE__,
"[note] pid %lld continuing to handle %u connection(s) in progress",
(long long)getpid(), srv->srvconf.max_conns - srv->lim_conns);

Expand Down Expand Up @@ -1226,7 +1227,7 @@ static void server_graceful_state (server *srv) {
return;
}

log_error(srv->errh,__FILE__,__LINE__,"[note] graceful shutdown started");
log_notice(srv->errh,__FILE__,__LINE__,"[note] graceful shutdown started");

/* no graceful restart if chroot()ed, if oneshot mode, or if idle timeout */
if (srv->srvconf.changeroot || oneshot_fd || 2 == graceful_shutdown)
Expand Down Expand Up @@ -1538,7 +1539,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
srv->srvconf.pid_file = NULL;
if (srv->srvconf.max_worker) {
srv->srvconf.max_worker = 0;
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"server one-shot command line option disables server.max-worker config file option.");
}

Expand Down Expand Up @@ -1676,7 +1677,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
plugin *p = ((plugin **)srv->plugins.ptr)[i];
if (0 == strcmp(p->name, "indexfile")) {
if (pname)
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"Warning: mod_indexfile should be listed in server.modules prior to mod_%s", pname);
break;
}
Expand Down Expand Up @@ -1893,7 +1894,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
#endif
/*(might perform similar checks on srv->srvconf.modules_dir)*/
) {
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"(warning) daemonizing without absolute path command line args"
" (graceful restart may fail)");
}
Expand Down Expand Up @@ -1935,7 +1936,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
return -1;
}
if (!oneshot_fd)
log_error(srv->errh, __FILE__, __LINE__, "server started (" PACKAGE_DESC ")");
log_notice(srv->errh, __FILE__, __LINE__, "server started (" PACKAGE_DESC ")");
}

if (HANDLER_GO_ON != plugins_call_set_defaults(srv)) {
Expand Down Expand Up @@ -1965,7 +1966,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {

if (idle_limit && srv->srvconf.max_worker) {
srv->srvconf.max_worker = 0;
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"server idle time limit command line option disables server.max-worker config file option.");
}

Expand All @@ -1992,7 +1993,7 @@ static int server_main_setup (server * const srv, int argc, char **argv) {
/* set max-conns */
if (srv->srvconf.max_conns > srv->max_fds/2) {
/* we can't have more connections than max-fds/2 */
log_error(srv->errh, __FILE__, __LINE__,
log_warn(srv->errh, __FILE__, __LINE__,
"can't have more connections than fds/2: %hu %d",
srv->srvconf.max_conns, srv->max_fds);
srv->lim_conns = srv->srvconf.max_conns = srv->max_fds/2;
Expand Down Expand Up @@ -2083,12 +2084,12 @@ static void server_handle_sighup (server * const srv) {
plugins_call_handle_sighup(srv);
fdlog_files_cycle(srv->errh); /* reopen log files, not pipes */
#ifdef HAVE_SIGACTION
log_error(srv->errh, __FILE__, __LINE__,
log_info(srv->errh, __FILE__, __LINE__,
"logfiles cycled UID = %d PID = %d",
(int)last_sighup_info.si_uid,
(int)last_sighup_info.si_pid);
#else
log_error(srv->errh, __FILE__, __LINE__,
log_info(srv->errh, __FILE__, __LINE__,
"logfiles cycled");
#endif
}
Expand All @@ -2103,7 +2104,7 @@ static void server_handle_sigalrm (server * const srv, unix_time64_t mono_ts, un

/* check idle time limit, if enabled */
if (idle_limit && idle_limit < mono_ts - last_active_ts && !graceful_shutdown) {
log_error(srv->errh, __FILE__, __LINE__,
log_notice(srv->errh, __FILE__, __LINE__,
"[note] idle timeout %ds exceeded, "
"initiating graceful shutdown", (int)idle_limit);
graceful_shutdown = 2; /* value 2 indicates idle timeout */
Expand Down Expand Up @@ -2330,16 +2331,16 @@ int server_main (int argc, char ** argv) {

if (NULL == srv->conns) rc = 0;
if (2 == graceful_shutdown) { /* value 2 indicates idle timeout */
log_error(srv->errh, __FILE__, __LINE__,
log_notice(srv->errh, __FILE__, __LINE__,
"server stopped after idle timeout");
} else if (!oneshot_fd) {
#ifdef HAVE_SIGACTION
log_error(srv->errh, __FILE__, __LINE__,
log_notice(srv->errh, __FILE__, __LINE__,
"server stopped by UID = %d PID = %d",
(int)last_sigterm_info.si_uid,
(int)last_sigterm_info.si_pid);
#else
log_error(srv->errh, __FILE__, __LINE__,
log_notice(srv->errh, __FILE__, __LINE__,
"server stopped");
#endif
}
Expand Down

0 comments on commit db37cbd

Please sign in to comment.