From 889e705f35b3f382509ee302fc57d55aead91ba2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 11 Apr 2015 00:08:28 +0900 Subject: [PATCH] nghttpx: Add logging for somewhat important events (logs, tickets, and ocsp) --- src/shrpx.cc | 9 +++------ src/shrpx_connection_handler.cc | 31 +++++++++++++++++++------------ src/shrpx_worker.cc | 8 ++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/shrpx.cc b/src/shrpx.cc index e225a121..6d9e1a7a 100644 --- a/src/shrpx.cc +++ b/src/shrpx.cc @@ -417,9 +417,7 @@ namespace { void reopen_log_signal_cb(struct ev_loop *loop, ev_signal *w, int revents) { auto conn_handler = static_cast(w->data); - if (LOG_ENABLED(INFO)) { - LOG(INFO) << "Reopening log files: main"; - } + LOG(NOTICE) << "Reopening log files: main"; (void)reopen_log_files(); redirect_stderr_to_errorlog(); @@ -573,9 +571,8 @@ void renew_ticket_key_cb(struct ev_loop *loop, ev_timer *w, int revents) { const auto &old_ticket_keys = conn_handler->get_ticket_keys(); auto ticket_keys = std::make_shared(); - if (LOG_ENABLED(INFO)) { - LOG(INFO) << "renew ticket key"; - } + LOG(NOTICE) << "Renew ticket keys: main"; + // We store at most 2 ticket keys if (old_ticket_keys) { auto &old_keys = old_ticket_keys->keys; diff --git a/src/shrpx_connection_handler.cc b/src/shrpx_connection_handler.cc index 1fdbc867..8779779d 100644 --- a/src/shrpx_connection_handler.cc +++ b/src/shrpx_connection_handler.cc @@ -69,6 +69,8 @@ void ocsp_cb(struct ev_loop *loop, ev_timer *w, int revent) { return; } + LOG(NOTICE) << "Start ocsp update"; + h->proceed_next_cert_ocsp(); } } // namespace @@ -358,6 +360,10 @@ int ConnectionHandler::start_ocsp_update(const char *cert_file) { int rv; int pfd[2]; + if (LOG_ENABLED(INFO)) { + LOG(INFO) << "Start ocsp update for " << cert_file; + } + assert(!ev_is_active(&ocsp_.rev)); assert(!ev_is_active(&ocsp_.chldev)); @@ -391,8 +397,8 @@ int ConnectionHandler::start_ocsp_update(const char *cert_file) { auto pid = fork(); if (pid == -1) { auto error = errno; - LOG(WARN) << "Could not execute ocsp query command: " << argv[0] - << ", fork() failed, errno=" << error; + LOG(WARN) << "Could not execute ocsp query command for " << cert_file + << ": " << argv[0] << ", fork() failed, errno=" << error; return -1; } @@ -461,22 +467,23 @@ void ConnectionHandler::handle_ocsp_complete() { ev_io_stop(loop_, &ocsp_.rev); ev_child_stop(loop_, &ocsp_.chldev); - auto rstatus = ocsp_.chldev.rstatus; - auto status = WEXITSTATUS(rstatus); - if (ocsp_.error || !WIFEXITED(rstatus) || status != 0) { - LOG(WARN) << "ocsp query command failed: error=" << ocsp_.error - << ", rstatus=" << rstatus << ", status=" << status; - ++ocsp_.next; - proceed_next_cert_ocsp(); - return; - } - assert(ocsp_.next < all_ssl_ctx_.size()); auto ssl_ctx = all_ssl_ctx_[ocsp_.next]; auto tls_ctx_data = static_cast(SSL_CTX_get_app_data(ssl_ctx)); + auto rstatus = ocsp_.chldev.rstatus; + auto status = WEXITSTATUS(rstatus); + if (ocsp_.error || !WIFEXITED(rstatus) || status != 0) { + LOG(WARN) << "ocsp query command for " << tls_ctx_data->cert_file + << " failed: error=" << ocsp_.error << ", rstatus=" << rstatus + << ", status=" << status; + ++ocsp_.next; + proceed_next_cert_ocsp(); + return; + } + if (LOG_ENABLED(INFO)) { LOG(INFO) << "ocsp update for " << tls_ctx_data->cert_file << " finished successfully"; diff --git a/src/shrpx_worker.cc b/src/shrpx_worker.cc index bbae73b1..6b2b658b 100644 --- a/src/shrpx_worker.cc +++ b/src/shrpx_worker.cc @@ -160,17 +160,13 @@ void Worker::process_events() { break; } case RENEW_TICKET_KEYS: - if (LOG_ENABLED(INFO)) { - WLOG(INFO, this) << "Renew ticket keys: worker(" << this << ")"; - } + WLOG(NOTICE, this) << "Renew ticket keys: worker(" << this << ")"; ticket_keys_ = wev.ticket_keys; break; case REOPEN_LOG: - if (LOG_ENABLED(INFO)) { - WLOG(INFO, this) << "Reopening log files: worker(" << this << ")"; - } + WLOG(NOTICE, this) << "Reopening log files: worker(" << this << ")"; reopen_log_files();