Commit 177d0a51 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: More logging for backend connection initiation

parent dfc02843
...@@ -258,8 +258,10 @@ int Http2Session::initiate_connection() { ...@@ -258,8 +258,10 @@ int Http2Session::initiate_connection() {
if (state_ == DISCONNECTED) { if (state_ == DISCONNECTED) {
if (worker_blocker->blocked()) { if (worker_blocker->blocked()) {
DLOG(INFO, this) if (LOG_ENABLED(INFO)) {
<< "Worker wide backend connection was blocked temporarily"; SSLOG(INFO, this)
<< "Worker wide backend connection was blocked temporarily";
}
return -1; return -1;
} }
...@@ -277,8 +279,8 @@ int Http2Session::initiate_connection() { ...@@ -277,8 +279,8 @@ int Http2Session::initiate_connection() {
if (connect_blocker->blocked()) { if (connect_blocker->blocked()) {
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
DCLOG(INFO, this) << "Backend server " SSLOG(INFO, this) << "Backend server "
<< (addr.host_unix ? addr.host : addr.hostport) << util::to_numeric_addr(&addr.addr)
<< " was not available temporarily"; << " was not available temporarily";
} }
...@@ -312,6 +314,11 @@ int Http2Session::initiate_connection() { ...@@ -312,6 +314,11 @@ int Http2Session::initiate_connection() {
conn_.fd = util::create_nonblock_socket(proxy.addr.su.storage.ss_family); conn_.fd = util::create_nonblock_socket(proxy.addr.su.storage.ss_family);
if (conn_.fd == -1) { if (conn_.fd == -1) {
auto error = errno;
SSLOG(WARN, this) << "Backend proxy socket() failed; addr="
<< util::to_numeric_addr(&proxy.addr)
<< ", errno=" << error;
worker_blocker->on_failure(); worker_blocker->on_failure();
return -1; return -1;
} }
...@@ -320,8 +327,11 @@ int Http2Session::initiate_connection() { ...@@ -320,8 +327,11 @@ int Http2Session::initiate_connection() {
rv = connect(conn_.fd, &proxy.addr.su.sa, proxy.addr.len); rv = connect(conn_.fd, &proxy.addr.su.sa, proxy.addr.len);
if (rv != 0 && errno != EINPROGRESS) { if (rv != 0 && errno != EINPROGRESS) {
SSLOG(ERROR, this) << "Failed to connect to the proxy " << proxy.host auto error = errno;
<< ":" << proxy.port; SSLOG(WARN, this) << "Backend proxy connect() failed; addr="
<< util::to_numeric_addr(&proxy.addr)
<< ", errno=" << error;
connect_blocker->on_failure(); connect_blocker->on_failure();
return -1; return -1;
} }
...@@ -382,6 +392,11 @@ int Http2Session::initiate_connection() { ...@@ -382,6 +392,11 @@ int Http2Session::initiate_connection() {
conn_.fd = conn_.fd =
util::create_nonblock_socket(addr_->addr.su.storage.ss_family); util::create_nonblock_socket(addr_->addr.su.storage.ss_family);
if (conn_.fd == -1) { if (conn_.fd == -1) {
auto error = errno;
SSLOG(WARN, this)
<< "socket() failed; addr=" << util::to_numeric_addr(&addr_->addr)
<< ", errno=" << error;
worker_blocker->on_failure(); worker_blocker->on_failure();
return -1; return -1;
} }
...@@ -393,6 +408,11 @@ int Http2Session::initiate_connection() { ...@@ -393,6 +408,11 @@ int Http2Session::initiate_connection() {
const_cast<sockaddr *>(&addr_->addr.su.sa), const_cast<sockaddr *>(&addr_->addr.su.sa),
addr_->addr.len); addr_->addr.len);
if (rv != 0 && errno != EINPROGRESS) { if (rv != 0 && errno != EINPROGRESS) {
auto error = errno;
SSLOG(WARN, this) << "connect() failed; addr="
<< util::to_numeric_addr(&addr_->addr)
<< ", errno=" << error;
connect_blocker->on_failure(); connect_blocker->on_failure();
return -1; return -1;
} }
...@@ -411,6 +431,11 @@ int Http2Session::initiate_connection() { ...@@ -411,6 +431,11 @@ int Http2Session::initiate_connection() {
util::create_nonblock_socket(addr_->addr.su.storage.ss_family); util::create_nonblock_socket(addr_->addr.su.storage.ss_family);
if (conn_.fd == -1) { if (conn_.fd == -1) {
auto error = errno;
SSLOG(WARN, this)
<< "socket() failed; addr=" << util::to_numeric_addr(&addr_->addr)
<< ", errno=" << error;
worker_blocker->on_failure(); worker_blocker->on_failure();
return -1; return -1;
} }
...@@ -420,6 +445,11 @@ int Http2Session::initiate_connection() { ...@@ -420,6 +445,11 @@ int Http2Session::initiate_connection() {
rv = connect(conn_.fd, const_cast<sockaddr *>(&addr_->addr.su.sa), rv = connect(conn_.fd, const_cast<sockaddr *>(&addr_->addr.su.sa),
addr_->addr.len); addr_->addr.len);
if (rv != 0 && errno != EINPROGRESS) { if (rv != 0 && errno != EINPROGRESS) {
auto error = errno;
SSLOG(WARN, this) << "connect() failed; addr="
<< util::to_numeric_addr(&addr_->addr)
<< ", errno=" << error;
connect_blocker->on_failure(); connect_blocker->on_failure();
return -1; return -1;
} }
...@@ -1648,6 +1678,11 @@ int Http2Session::connected() { ...@@ -1648,6 +1678,11 @@ int Http2Session::connected() {
auto &connect_blocker = addr_->connect_blocker; auto &connect_blocker = addr_->connect_blocker;
if (!util::check_socket_connected(conn_.fd)) { if (!util::check_socket_connected(conn_.fd)) {
if (LOG_ENABLED(INFO)) {
SSLOG(INFO, this) << "Backend connect failed; addr="
<< util::to_numeric_addr(&addr_->addr);
}
connect_blocker->on_failure(); connect_blocker->on_failure();
return -1; return -1;
......
...@@ -146,8 +146,10 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) { ...@@ -146,8 +146,10 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
auto worker_blocker = worker_->get_connect_blocker(); auto worker_blocker = worker_->get_connect_blocker();
if (worker_blocker->blocked()) { if (worker_blocker->blocked()) {
DLOG(INFO, this) if (LOG_ENABLED(INFO)) {
<< "Worker wide backend connection was blocked temporarily"; DCLOG(INFO, this)
<< "Worker wide backend connection was blocked temporarily";
}
return SHRPX_ERR_NETWORK; return SHRPX_ERR_NETWORK;
} }
...@@ -179,7 +181,7 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) { ...@@ -179,7 +181,7 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
if (connect_blocker->blocked()) { if (connect_blocker->blocked()) {
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
DCLOG(INFO, this) << "Backend server " DCLOG(INFO, this) << "Backend server "
<< (addr.host_unix ? addr.host : addr.hostport) << util::to_numeric_addr(&addr.addr)
<< " was not available temporarily"; << " was not available temporarily";
} }
...@@ -194,7 +196,9 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) { ...@@ -194,7 +196,9 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
if (conn_.fd == -1) { if (conn_.fd == -1) {
auto error = errno; auto error = errno;
DCLOG(WARN, this) << "socket() failed; errno=" << error; DCLOG(WARN, this) << "socket() failed; addr="
<< util::to_numeric_addr(&addr.addr)
<< ", errno=" << error;
worker_blocker->on_failure(); worker_blocker->on_failure();
...@@ -207,7 +211,9 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) { ...@@ -207,7 +211,9 @@ int HttpDownstreamConnection::attach_downstream(Downstream *downstream) {
rv = connect(conn_.fd, &addr.addr.su.sa, addr.addr.len); rv = connect(conn_.fd, &addr.addr.su.sa, addr.addr.len);
if (rv != 0 && errno != EINPROGRESS) { if (rv != 0 && errno != EINPROGRESS) {
auto error = errno; auto error = errno;
DCLOG(WARN, this) << "connect() failed; errno=" << error; DCLOG(WARN, this) << "connect() failed; addr="
<< util::to_numeric_addr(&addr.addr)
<< ", errno=" << error;
connect_blocker->on_failure(); connect_blocker->on_failure();
close(conn_.fd); close(conn_.fd);
...@@ -1034,7 +1040,8 @@ int HttpDownstreamConnection::connected() { ...@@ -1034,7 +1040,8 @@ int HttpDownstreamConnection::connected() {
conn_.wlimit.stopw(); conn_.wlimit.stopw();
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
DLOG(INFO, this) << "downstream connect failed"; DCLOG(INFO, this) << "Backend connect failed; addr="
<< util::to_numeric_addr(&addr_->addr);
} }
connect_blocker->on_failure(); connect_blocker->on_failure();
...@@ -1045,7 +1052,7 @@ int HttpDownstreamConnection::connected() { ...@@ -1045,7 +1052,7 @@ int HttpDownstreamConnection::connected() {
} }
if (LOG_ENABLED(INFO)) { if (LOG_ENABLED(INFO)) {
DLOG(INFO, this) << "Connected to downstream host"; DCLOG(INFO, this) << "Connected to downstream host";
} }
connect_blocker->on_success(); connect_blocker->on_success();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment