From: Alex Rousskov Date: Wed, 5 Jun 2024 18:55:06 +0000 (+0000) Subject: Improve ErrorState debugging (#1768) X-Git-Tag: SQUID_7_0_1~110 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=abb5139d5fdae3d66861b109539d271f671bef16;p=thirdparty%2Fsquid.git Improve ErrorState debugging (#1768) In triage, it is often useful to know that ErrorState was created _when_ it was created rather than waiting for errorAppendEntry() or errorSend() debugging, especially if those error handling stages are not reached. Also report HTTP status code of the error response (when available). --- diff --git a/src/FwdState.cc b/src/FwdState.cc index 1e2eb30ae5..bac0aa5df8 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -456,7 +456,7 @@ FwdState::useDestinations() void FwdState::fail(ErrorState * errorState) { - debugs(17, 3, err_type_str[errorState->type] << " \"" << Http::StatusCodeString(errorState->httpStatus) << "\"\n\t" << entry->url()); + debugs(17, 3, errorState << "; was: " << err); delete err; err = errorState; diff --git a/src/errorpage.cc b/src/errorpage.cc index c01a2c4365..de01966732 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -677,6 +677,16 @@ errorPageName(int pageId) return "ERR_UNKNOWN"; /* should not happen */ } +/// compactly prints top-level ErrorState information (for debugging) +static std::ostream & +operator <<(std::ostream &os, const ErrorState &err) +{ + os << errorPageName(err.type); + if (err.httpStatus != Http::scNone) + os << "/http_status=" << err.httpStatus; + return os; +} + ErrorState * ErrorState::NewForwarding(err_type type, HttpRequestPointer &request, const AccessLogEntry::Pointer &ale) { @@ -705,6 +715,8 @@ ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req, c request = req; src_addr = req->client_addr; } + + debugs(4, 3, "constructed, this=" << static_cast(this) << ' ' << *this); } ErrorState::ErrorState(HttpRequest * req, HttpReply *errorReply, const AccessLogEntry::Pointer &anAle): @@ -718,6 +730,8 @@ ErrorState::ErrorState(HttpRequest * req, HttpReply *errorReply, const AccessLog request = req; src_addr = req->client_addr; } + + debugs(4, 3, "constructed, this=" << static_cast(this) << " relaying " << *this); } void @@ -796,6 +810,8 @@ errorSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm ErrorState::~ErrorState() { + debugs(4, 7, "destructing, this=" << static_cast(this)); + safe_free(redirect_url); safe_free(url); safe_free(request_hdrs); @@ -1527,10 +1543,7 @@ ErrorPage::ValidateStaticError(const int page_id, const SBuf &inputLocation) std::ostream & operator <<(std::ostream &os, const ErrorState *err) { - if (err) - os << errorPageName(err->page_id); - else - os << "[none]"; + os << RawPointer(err).orNil(); return os; }