From d648cfdaf8b32ae3c0197c0d310c2dd0e1c9b8ca Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Wed, 20 Mar 2024 15:25:51 +0700 Subject: [PATCH 01/11] turn output into yaml and simplify --- src/BodyPipe.cc | 4 ---- src/HappyConnOpener.cc | 6 ++---- src/adaptation/ecap/ServiceRep.cc | 2 -- src/adaptation/ecap/XactionRep.cc | 4 ---- src/adaptation/icap/ServiceRep.cc | 5 ++--- src/adaptation/icap/Xaction.cc | 2 -- src/base/AsyncJob.cc | 23 ++++++++++------------- src/clients/HttpTunneler.cc | 3 +-- src/comm/TcpAcceptor.cc | 2 +- src/ipc/Inquirer.cc | 2 +- src/security/PeerConnector.cc | 2 -- 11 files changed, 17 insertions(+), 38 deletions(-) diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index dfdf53ae1c9..fee1593ad67 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -448,8 +448,6 @@ const char *BodyPipe::status() const static MemBuf outputBuffer; outputBuffer.reset(); - outputBuffer.append(" [", 2); - outputBuffer.appendf("%" PRIu64 "<=%" PRIu64, theGetSize, thePutSize); if (theBodySize >= 0) outputBuffer.appendf("<=%" PRId64, theBodySize); @@ -471,8 +469,6 @@ const char *BodyPipe::status() const if (isCheckedOut) outputBuffer.append(" L", 2); // Locked - outputBuffer.append("]", 1); - outputBuffer.terminate(); return outputBuffer.content(); diff --git a/src/HappyConnOpener.cc b/src/HappyConnOpener.cc index a2d3052583c..9a003d86115 100644 --- a/src/HappyConnOpener.cc +++ b/src/HappyConnOpener.cc @@ -437,17 +437,15 @@ HappyConnOpener::status() const SBufStream os(buf); - os.write(" [", 2); if (stopReason) os << "Stopped:" << stopReason; if (prime) - os << "prime:" << prime; + os << " prime:" << prime; if (spare) - os << "spare:" << spare; + os << " spare:" << spare; if (n_tries) os << " tries:" << n_tries; os << " dst:" << *destinations; - os << ' ' << id << ']'; buf = os.buf(); return buf.c_str(); diff --git a/src/adaptation/ecap/ServiceRep.cc b/src/adaptation/ecap/ServiceRep.cc index 1d3339020f2..c28704d62e9 100644 --- a/src/adaptation/ecap/ServiceRep.cc +++ b/src/adaptation/ecap/ServiceRep.cc @@ -284,7 +284,6 @@ const char *Adaptation::Ecap::ServiceRep::status() const static MemBuf buf; buf.reset(); - buf.append("[", 1); if (up()) buf.append("up", 2); @@ -294,7 +293,6 @@ const char *Adaptation::Ecap::ServiceRep::status() const if (detached()) buf.append(",detached", 9); - buf.append("]", 1); buf.terminate(); return buf.content(); diff --git a/src/adaptation/ecap/XactionRep.cc b/src/adaptation/ecap/XactionRep.cc index b7cfe0d8455..ac01b9161ee 100644 --- a/src/adaptation/ecap/XactionRep.cc +++ b/src/adaptation/ecap/XactionRep.cc @@ -702,8 +702,6 @@ Adaptation::Ecap::XactionRep::status() const static MemBuf buf; buf.reset(); - buf.append(" [", 2); - if (makingVb) buf.appendf("M%d", static_cast(makingVb)); @@ -732,8 +730,6 @@ Adaptation::Ecap::XactionRep::status() const buf.append(" A?", 3); } - buf.appendf(" %s%u]", id.prefix(), id.value); - buf.terminate(); return buf.content(); diff --git a/src/adaptation/icap/ServiceRep.cc b/src/adaptation/icap/ServiceRep.cc index ddefdfefaaf..b2c6967886f 100644 --- a/src/adaptation/icap/ServiceRep.cc +++ b/src/adaptation/icap/ServiceRep.cc @@ -674,12 +674,12 @@ Adaptation::Icap::ServiceRep::makeXactLauncher(Http::Message *virgin, } // returns a temporary string depicting service status, for debugging -const char *Adaptation::Icap::ServiceRep::status() const +const char * +Adaptation::Icap::ServiceRep::status() const { static MemBuf buf; buf.reset(); - buf.append("[", 1); if (up()) buf.append("up", 2); @@ -708,7 +708,6 @@ const char *Adaptation::Icap::ServiceRep::status() const if (const int failures = theSessionFailures.remembered()) buf.appendf(",fail%d", failures); - buf.append("]", 1); buf.terminate(); return buf.content(); diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index c25d36c2a2e..c8dd8f1d50c 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -637,11 +637,9 @@ const char *Adaptation::Icap::Xaction::status() const { static MemBuf buf; buf.reset(); - buf.append(" [", 2); fillPendingStatus(buf); buf.append("/", 1); fillDoneStatus(buf); - buf.appendf(" %s%u]", id.prefix(), id.value); buf.terminate(); return buf.content(); diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 5c63bc6b26c..5d0c6bcb6bb 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -16,7 +16,6 @@ #include "base/TextException.h" #include "cbdata.h" #include "mem/PoolingAllocator.h" -#include "MemBuf.h" #include "mgr/Registration.h" #include "Store.h" @@ -179,16 +178,15 @@ void AsyncJob::callEnd() } // returns a temporary string depicting transaction status, for debugging -const char *AsyncJob::status() const +const char * +AsyncJob::status() const { static MemBuf buf; buf.reset(); - buf.append(" [", 2); if (stopReason != nullptr) { - buf.appendf("Stopped, reason:%s", stopReason); + buf.appendf("Stopped, reason: %s", stopReason); } - buf.appendf(" %s%u]", id.prefix(), id.value); buf.terminate(); return buf.content(); @@ -199,15 +197,14 @@ AsyncJob::ReportAllJobs(StoreEntry *e) { PackableStream os(*e); // this loop uses YAML syntax, but AsyncJob::status() still needs to be adjusted to use YAML - const char *indent = " "; + const std::string indent(" "); for (const auto job: AllJobs()) { - os << indent << job->id << ":\n"; - os << indent << indent << "type: '" << job->typeName << "'\n"; - os << indent << indent << "status:" << job->status() << '\n'; - if (!job->started_) - os << indent << indent << "started: false\n"; - if (job->stopReason) - os << indent << indent << "stopped: '" << job->stopReason << "'\n"; + os << job->id << ":\n"; + os << indent << "type: " << job->typeName << '\n'; + const char *status = job->status(); + if (status && strlen(status)) + os << indent << "status: " << job->status() << "\n"; + os << indent << "started: " << (job->started_ ? "yes": "no" ) << '\n'; } } diff --git a/src/clients/HttpTunneler.cc b/src/clients/HttpTunneler.cc index d52dd457e82..32b4e7b8966 100644 --- a/src/clients/HttpTunneler.cc +++ b/src/clients/HttpTunneler.cc @@ -439,7 +439,7 @@ Http::Tunneler::status() const // TODO: redesign AsyncJob::status() API to avoid // id and stop reason reporting duplication. - buf.append(" [state:", 8); + buf.append("state:", 8); if (requestWritten) buf.append("w", 1); // request sent if (tunnelEstablished) buf.append("t", 1); // tunnel established if (!callback) buf.append("x", 1); // caller informed @@ -449,7 +449,6 @@ Http::Tunneler::status() const } if (connection != nullptr) buf.appendf(" FD %d", connection->fd); - buf.appendf(" %s%u]", id.prefix(), id.value); buf.terminate(); return buf.content(); diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index aa082df4b46..5f0f3addda1 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -124,7 +124,7 @@ const char * Comm::TcpAcceptor::status() const { if (conn == nullptr) - return "[nil connection]"; + return "nil connection"; static char ipbuf[MAX_IPSTRLEN] = {'\0'}; if (ipbuf[0] == '\0') diff --git a/src/ipc/Inquirer.cc b/src/ipc/Inquirer.cc index e4438f0d1ae..7b30fae6619 100644 --- a/src/ipc/Inquirer.cc +++ b/src/ipc/Inquirer.cc @@ -221,7 +221,7 @@ Ipc::Inquirer::status() const { static MemBuf buf; buf.reset(); - buf.appendf(" [requestId %u]", request->requestId.index()); + buf.appendf("requestId %u", request->requestId.index()); buf.terminate(); return buf.content(); } diff --git a/src/security/PeerConnector.cc b/src/security/PeerConnector.cc index 96c2f0ed340..5da74147625 100644 --- a/src/security/PeerConnector.cc +++ b/src/security/PeerConnector.cc @@ -582,14 +582,12 @@ Security::PeerConnector::status() const // TODO: redesign AsyncJob::status() API to avoid this // id and stop reason reporting duplication. - buf.append(" [", 2); if (stopReason != nullptr) { buf.append("Stopped, reason:", 16); buf.appendf("%s",stopReason); } if (Comm::IsConnOpen(serverConn)) buf.appendf(" FD %d", serverConn->fd); - buf.appendf(" %s%u]", id.prefix(), id.value); buf.terminate(); return buf.content(); From 9cba29bccbfc66cc766e9d79fe28b3d201bd0b87 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Thu, 25 Apr 2024 15:10:52 +0100 Subject: [PATCH 02/11] Use proper yaml booleans for started field --- src/base/AsyncJob.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 5d0c6bcb6bb..14bd32d95cc 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -204,7 +204,7 @@ AsyncJob::ReportAllJobs(StoreEntry *e) const char *status = job->status(); if (status && strlen(status)) os << indent << "status: " << job->status() << "\n"; - os << indent << "started: " << (job->started_ ? "yes": "no" ) << '\n'; + os << indent << "started: " << (job->started_ ? "Yes": "No" ) << '\n'; } } From d0ff4abe9d1edf2d5381fa5242531a2fa96456d1 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Mon, 29 Apr 2024 17:37:05 +0100 Subject: [PATCH 03/11] Revert changes to BodyPipe --- src/BodyPipe.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index fee1593ad67..dfdf53ae1c9 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -448,6 +448,8 @@ const char *BodyPipe::status() const static MemBuf outputBuffer; outputBuffer.reset(); + outputBuffer.append(" [", 2); + outputBuffer.appendf("%" PRIu64 "<=%" PRIu64, theGetSize, thePutSize); if (theBodySize >= 0) outputBuffer.appendf("<=%" PRId64, theBodySize); @@ -469,6 +471,8 @@ const char *BodyPipe::status() const if (isCheckedOut) outputBuffer.append(" L", 2); // Locked + outputBuffer.append("]", 1); + outputBuffer.terminate(); return outputBuffer.content(); From 5e577058ac52818ec11570b826c6a16130b8e10c Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Mon, 29 Apr 2024 23:33:50 +0100 Subject: [PATCH 04/11] Move AsyncJob::status spacing to callers --- src/adaptation/ecap/XactionRep.cc | 6 +++--- src/base/AsyncJob.cc | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/adaptation/ecap/XactionRep.cc b/src/adaptation/ecap/XactionRep.cc index ac01b9161ee..49653e0cab9 100644 --- a/src/adaptation/ecap/XactionRep.cc +++ b/src/adaptation/ecap/XactionRep.cc @@ -357,7 +357,7 @@ Adaptation::Ecap::XactionRep::doneAll() const void Adaptation::Ecap::XactionRep::sinkVb(const char *reason) { - debugs(93,4, "sink for " << reason << "; status:" << status()); + debugs(93,4, "sink for " << reason << "; status: " << status()); // we reset raw().body_pipe when we are done, so use this one for checking const BodyPipePointer &permPipe = theVirginRep.raw().header->body_pipe; @@ -371,7 +371,7 @@ Adaptation::Ecap::XactionRep::sinkVb(const char *reason) void Adaptation::Ecap::XactionRep::preserveVb(const char *reason) { - debugs(93,4, "preserve for " << reason << "; status:" << status()); + debugs(93,4, "preserve for " << reason << "; status: " << status()); // we reset raw().body_pipe when we are done, so use this one for checking const BodyPipePointer &permPipe = theVirginRep.raw().header->body_pipe; @@ -387,7 +387,7 @@ Adaptation::Ecap::XactionRep::preserveVb(const char *reason) void Adaptation::Ecap::XactionRep::forgetVb(const char *reason) { - debugs(93,9, "forget vb " << reason << "; status:" << status()); + debugs(93,9, "forget vb " << reason << "; status: " << status()); BodyPipePointer &p = theVirginRep.raw().body_pipe; if (p != nullptr && p->stillConsuming(this)) diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 14bd32d95cc..3559c8a59fe 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -135,7 +135,7 @@ void AsyncJob::callStart(AsyncCall &call) inCall = &call; // XXX: ugly, but safe if callStart/callEnd,Ex are paired debugs(inCall->debugSection, inCall->debugLevel, - typeName << " status in:" << status()); + typeName << " status in: " << status()); } void @@ -173,7 +173,7 @@ void AsyncJob::callEnd() } debugs(inCall->debugSection, inCall->debugLevel, - typeName << " status out:" << status()); + typeName << " status out: " << status()); inCall = nullptr; } From 1d20c035305bfd6705487b0142c0d44c971cdc2d Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Mon, 29 Apr 2024 23:43:06 +0100 Subject: [PATCH 05/11] Ensure callers of AsyncJob::status() add space --- src/BodyPipe.cc | 22 ++++++++--------- src/adaptation/ecap/XactionRep.cc | 2 +- src/adaptation/icap/ModXact.cc | 40 +++++++++++++++---------------- src/adaptation/icap/OptXact.cc | 2 +- src/adaptation/icap/ServiceRep.cc | 2 +- src/adaptation/icap/Xaction.cc | 8 +++---- src/base/AsyncJob.cc | 2 +- src/client_side.cc | 6 ++--- src/clients/HttpTunneler.cc | 4 ++-- src/ipc/Inquirer.cc | 2 +- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/BodyPipe.cc b/src/BodyPipe.cc index dfdf53ae1c9..1e1aa2b22df 100644 --- a/src/BodyPipe.cc +++ b/src/BodyPipe.cc @@ -133,12 +133,12 @@ BodyPipe::BodyPipe(Producer *aProducer): theBodySize(-1), // TODO: teach MemBuf to start with zero minSize // TODO: limit maxSize by theBodySize, when known? theBuf.init(2*1024, MaxCapacity); - debugs(91,7, "created BodyPipe" << status()); + debugs(91,7, "created BodyPipe " << status()); } BodyPipe::~BodyPipe() { - debugs(91,7, "destroying BodyPipe" << status()); + debugs(91,7, "destroying BodyPipe " << status()); assert(!theProducer); assert(!theConsumer); theBuf.clean(); @@ -155,7 +155,7 @@ void BodyPipe::setBodySize(uint64_t aBodySize) assert(!theConsumer); theBodySize = aBodySize; - debugs(91,7, "set body size" << status()); + debugs(91,7, "set body size " << status()); } uint64_t BodyPipe::bodySize() const @@ -194,13 +194,13 @@ void BodyPipe::clearProducer(bool atEof) { if (theProducer.set()) { - debugs(91,7, "clearing BodyPipe producer" << status()); + debugs(91,7, "clearing BodyPipe producer " << status()); theProducer.clear(); if (atEof) { if (!bodySizeKnown()) theBodySize = thePutSize; else if (bodySize() != thePutSize) - debugs(91,3, "aborting on premature eof" << status()); + debugs(91,3, "aborting on premature eof " << status()); } else { // asserta that we can detect the abort if the consumer joins later assert(!bodySizeKnown() || bodySize() != thePutSize); @@ -241,7 +241,7 @@ BodyPipe::setConsumerIfNotLate(const Consumer::Pointer &aConsumer) Must(!abortedConsumption); // did not promise to never consume theConsumer = aConsumer; - debugs(91,7, "set consumer" << status()); + debugs(91,7, "set consumer " << status()); if (theBuf.hasContent()) scheduleBodyDataNotification(); if (!theProducer) @@ -254,7 +254,7 @@ void BodyPipe::clearConsumer() { if (theConsumer.set()) { - debugs(91,7, "clearing consumer" << status()); + debugs(91,7, "clearing consumer " << status()); theConsumer.clear(); // do not abort if we have not consumed so that HTTP or ICAP can retry // benign xaction failures due to persistent connection race conditions @@ -316,7 +316,7 @@ void BodyPipe::enableAutoConsumption() { mustAutoConsume = true; - debugs(91,5, "enabled auto consumption" << status()); + debugs(91,5, "enabled auto consumption " << status()); startAutoConsumptionIfNeeded(); } @@ -336,7 +336,7 @@ BodyPipe::startAutoConsumptionIfNeeded() theConsumer = new BodySink(this); AsyncJob::Start(theConsumer); - debugs(91,7, "starting auto consumption" << status()); + debugs(91,7, "starting auto consumption " << status()); scheduleBodyDataNotification(); } @@ -381,7 +381,7 @@ BodyPipe::postConsume(size_t size) { assert(!isCheckedOut); theGetSize += size; - debugs(91,7, "consumed " << size << " bytes" << status()); + debugs(91,7, "consumed " << size << " bytes " << status()); if (mayNeedMoreData()) { AsyncCall::Pointer call= asyncCall(91, 7, "BodyProducer::noteMoreBodySpaceAvailable", @@ -396,7 +396,7 @@ BodyPipe::postAppend(size_t size) { assert(!isCheckedOut); thePutSize += size; - debugs(91,7, "added " << size << " bytes" << status()); + debugs(91,7, "added " << size << " bytes " << status()); // We should not consume here even if mustAutoConsume because the // caller may not be ready for the data to be consumed during this call. diff --git a/src/adaptation/ecap/XactionRep.cc b/src/adaptation/ecap/XactionRep.cc index 49653e0cab9..2a92a3211ef 100644 --- a/src/adaptation/ecap/XactionRep.cc +++ b/src/adaptation/ecap/XactionRep.cc @@ -442,7 +442,7 @@ Adaptation::Ecap::XactionRep::useAdapted(const libecap::shared_ptrabMake(); // libecap will produce } } diff --git a/src/adaptation/icap/ModXact.cc b/src/adaptation/icap/ModXact.cc index 5c25b9ae245..d33bae978cb 100644 --- a/src/adaptation/icap/ModXact.cc +++ b/src/adaptation/icap/ModXact.cc @@ -81,7 +81,7 @@ Adaptation::Icap::ModXact::ModXact(Http::Message *virginHeader, icapReply = new HttpReply; icapReply->protoPrefix = "ICAP/"; // TODO: make an IcapReply class? - debugs(93,7, "initialized." << status()); + debugs(93,7, "initialized. " << status()); } // initiator wants us to start @@ -131,7 +131,7 @@ void Adaptation::Icap::ModXact::waitForService() disableRetries(); disableRepeats("ICAP service is not available"); - debugs(93, 7, "will not wait for the service to be available" << + debugs(93, 7, "will not wait for the service to be available " << status()); throw TexcHere("ICAP service is not available"); @@ -196,7 +196,7 @@ void Adaptation::Icap::ModXact::startShoveling() requestBuf.init(); makeRequestHeaders(requestBuf); - debugs(93, 9, "will write" << status() << ":\n" << + debugs(93, 9, "will write " << status() << ":\n" << (requestBuf.terminate(), requestBuf.content())); // write headers @@ -237,7 +237,7 @@ void Adaptation::Icap::ModXact::handleCommWroteHeaders() void Adaptation::Icap::ModXact::writeMore() { - debugs(93, 5, "checking whether to write more" << status()); + debugs(93, 5, "checking whether to write more " << status()); if (writer != nullptr) // already writing something return; @@ -274,7 +274,7 @@ void Adaptation::Icap::ModXact::writeMore() void Adaptation::Icap::ModXact::writePreviewBody() { debugs(93, 8, "will write Preview body from " << - virgin.body_pipe << status()); + virgin.body_pipe << ' ' << status()); Must(state.writing == State::writingPreview); Must(virgin.body_pipe != nullptr); @@ -298,7 +298,7 @@ void Adaptation::Icap::ModXact::decideWritingAfterPreview(const char *kind) else stopWriting(true); // ICAP server reply implies no post-preview writing - debugs(93, 6, "decided on writing after " << kind << " preview" << + debugs(93, 6, "decided on writing after " << kind << " preview " << status()); } @@ -490,12 +490,12 @@ void Adaptation::Icap::ModXact::stopWriting(bool nicely) if (writer != nullptr) { if (nicely) { - debugs(93, 7, "will wait for the last write" << status()); + debugs(93, 7, "will wait for the last write " << status()); state.writing = State::writingAlmostDone; // may already be set checkConsuming(); return; } - debugs(93, 3, "will NOT wait for the last write" << status()); + debugs(93, 3, "will NOT wait for the last write " << status()); // Comm does not have an interface to clear the writer callback nicely, // but without clearing the writer we cannot recycle the connection. @@ -506,7 +506,7 @@ void Adaptation::Icap::ModXact::stopWriting(bool nicely) ignoreLastWrite = true; } - debugs(93, 7, "will no longer write" << status()); + debugs(93, 7, "will no longer write " << status()); if (virginBodyWriting.active()) { virginBodyWriting.disable(); virginConsume(); @@ -520,7 +520,7 @@ void Adaptation::Icap::ModXact::stopBackup() if (!virginBodySending.active()) return; - debugs(93, 7, "will no longer backup" << status()); + debugs(93, 7, "will no longer backup " << status()); virginBodySending.disable(); virginConsume(); } @@ -581,7 +581,7 @@ void Adaptation::Icap::ModXact::echoMore() const size_t sizeMax = virginContentSize(virginBodySending); debugs(93,5, "will echo up to " << sizeMax << " bytes from " << virgin.body_pipe->status()); - debugs(93,5, "will echo up to " << sizeMax << " bytes to " << + debugs(93,5, "will echo up to " << sizeMax << " bytes to " << adapted.body_pipe->status()); if (sizeMax > 0) { @@ -595,12 +595,12 @@ void Adaptation::Icap::ModXact::echoMore() } if (virginBodyEndReached(virginBodySending)) { - debugs(93, 5, "echoed all" << status()); + debugs(93, 5, "echoed all " << status()); stopSending(true); } else { debugs(93, 5, "has " << virgin.body_pipe->buf().contentSize() << " bytes " << - "and expects more to echo" << status()); + "and expects more to echo " << status()); // TODO: timeout if virgin or adapted pipes are broken } } @@ -619,7 +619,7 @@ void Adaptation::Icap::ModXact::stopSending(bool nicely) debugs(93, 7, "Proceed with stop sending "); if (state.sending != State::sendingUndecided) { - debugs(93, 7, "will no longer send" << status()); + debugs(93, 7, "will no longer send " << status()); if (adapted.body_pipe != nullptr) { virginBodySending.disable(); // we may leave debts if we were echoing and the virgin @@ -628,7 +628,7 @@ void Adaptation::Icap::ModXact::stopSending(bool nicely) stopProducingFor(adapted.body_pipe, nicely && !leftDebts); } } else { - debugs(93, 7, "will not start sending" << status()); + debugs(93, 7, "will not start sending " << status()); Must(!adapted.body_pipe); } @@ -643,13 +643,13 @@ void Adaptation::Icap::ModXact::checkConsuming() if (!virgin.body_pipe || !state.doneConsumingVirgin()) return; - debugs(93, 7, "will stop consuming" << status()); + debugs(93, 7, "will stop consuming " << status()); stopConsumingFrom(virgin.body_pipe); } void Adaptation::Icap::ModXact::parseMore() { - debugs(93, 5, "have " << readBuf.length() << " bytes to parse" << status()); + debugs(93, 5, "have " << readBuf.length() << " bytes to parse " << status()); debugs(93, 5, "\n" << readBuf); if (state.parsingHeaders()) @@ -708,7 +708,7 @@ void Adaptation::Icap::ModXact::bypassFailure() reuseConnection = false; // be conservative cancelRead(); // may not work; and we cannot stop connecting either if (!doneWithIo()) - debugs(93, 7, "Warning: bypass failed to stop I/O" << status()); + debugs(93, 7, "Warning: bypass failed to stop I/O " << status()); } service().noteFailure(); // we are bypassing, but this is still a failure @@ -1218,7 +1218,7 @@ void Adaptation::Icap::ModXact::stopParsing(const bool checkUnparsedData) if (checkUnparsedData) Must(readBuf.isEmpty()); - debugs(93, 7, "will no longer parse" << status()); + debugs(93, 7, "will no longer parse " << status()); delete bodyParser; bodyParser = nullptr; @@ -1292,7 +1292,7 @@ Adaptation::Icap::ModXact::~ModXact() // internal cleanup void Adaptation::Icap::ModXact::swanSong() { - debugs(93, 5, "swan sings" << status()); + debugs(93, 5, "swan sings " << status()); stopWriting(false); stopSending(false); diff --git a/src/adaptation/icap/OptXact.cc b/src/adaptation/icap/OptXact.cc index 0cf5c7bab49..8d97f6f828e 100644 --- a/src/adaptation/icap/OptXact.cc +++ b/src/adaptation/icap/OptXact.cc @@ -101,7 +101,7 @@ void Adaptation::Icap::OptXact::handleCommRead(size_t) bool Adaptation::Icap::OptXact::parseResponse() { - debugs(93, 5, "have " << readBuf.length() << " bytes to parse" << status()); + debugs(93, 5, "have " << readBuf.length() << " bytes to parse " << status()); debugs(93, DBG_DATA, "\n" << readBuf); HttpReply::Pointer r(new HttpReply); diff --git a/src/adaptation/icap/ServiceRep.cc b/src/adaptation/icap/ServiceRep.cc index b2c6967886f..2f3a73801eb 100644 --- a/src/adaptation/icap/ServiceRep.cc +++ b/src/adaptation/icap/ServiceRep.cc @@ -567,7 +567,7 @@ void Adaptation::Icap::ServiceRep::callException(const std::exception &e) { clearAdaptation(theOptionsFetcher); debugs(93,2, "ICAP probably failed to fetch options (" << e.what() << - ")" << status()); + ") " << status()); handleNewOptions(nullptr); } diff --git a/src/adaptation/icap/Xaction.cc b/src/adaptation/icap/Xaction.cc index c8dd8f1d50c..200c0315b6a 100644 --- a/src/adaptation/icap/Xaction.cc +++ b/src/adaptation/icap/Xaction.cc @@ -232,7 +232,7 @@ void Adaptation::Icap::Xaction::closeConnection() if (reuseConnection && !doneWithIo()) { //status() adds leading spaces. - debugs(93,5, "not reusing pconn due to pending I/O" << status()); + debugs(93,5, "not reusing pconn due to pending I/O " << status()); reuseConnection = false; } @@ -349,8 +349,8 @@ void Adaptation::Icap::Xaction::noteCommWrote(const CommIoCbParams &io) void Adaptation::Icap::Xaction::noteCommTimedout(const CommTimeoutCbParams &) { debugs(93, 2, typeName << " failed: timeout with " << - theService->cfg().methodStr() << " " << - theService->cfg().uri << status()); + theService->cfg().methodStr() << ' ' << + theService->cfg().uri << ' ' << status()); reuseConnection = false; assert(haveConnection()); closeConnection(); @@ -381,7 +381,7 @@ void Adaptation::Icap::Xaction::callException(const std::exception &e) void Adaptation::Icap::Xaction::callEnd() { if (doneWithIo()) { - debugs(93, 5, typeName << " done with I/O" << status()); + debugs(93, 5, typeName << " done with I/O " << status()); closeConnection(); } Adaptation::Initiate::callEnd(); // may destroy us diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 3559c8a59fe..f6639956a09 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -151,7 +151,7 @@ AsyncJob::callException(const std::exception &ex) void AsyncJob::callEnd() { if (done()) { - debugs(93, 5, *inCall << " ends job" << status()); + debugs(93, 5, *inCall << " ends job " << status()); AsyncCall::Pointer inCallSaved = inCall; void *thisSaved = this; diff --git a/src/client_side.cc b/src/client_side.cc index eac7d93528f..7d0114940c1 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -2041,11 +2041,11 @@ ConnStateData::handleChunkedRequestBody() // if parser needs more space and we can consume nothing, we will stall Must(!bodyParser->needsMoreSpace() || bodyPipe->buf().hasContent()); } catch (...) { // TODO: be more specific - debugs(33, 3, "malformed chunks" << bodyPipe->status()); + debugs(33, 3, "malformed chunks " << bodyPipe->status()); return ERR_INVALID_REQ; } - debugs(33, 7, "need more chunked data" << *bodyPipe->status()); + debugs(33, 7, "need more chunked data " << *bodyPipe->status()); return ERR_NONE; } @@ -3618,7 +3618,7 @@ void ConnStateData::startDechunkingRequest() { Must(bodyPipe != nullptr); - debugs(33, 5, "start dechunking" << bodyPipe->status()); + debugs(33, 5, "start dechunking " << bodyPipe->status()); assert(!bodyParser); bodyParser = new Http1::TeChunkedParser; } diff --git a/src/clients/HttpTunneler.cc b/src/clients/HttpTunneler.cc index 32b4e7b8966..0a1a5266871 100644 --- a/src/clients/HttpTunneler.cc +++ b/src/clients/HttpTunneler.cc @@ -122,7 +122,7 @@ Http::Tunneler::handleTimeout(const CommTimeoutCbParams &) void Http::Tunneler::startReadingResponse() { - debugs(83, 5, connection << status()); + debugs(83, 5, connection << ' ' << status()); readBuf.reserveCapacity(SQUID_TCP_SO_RCVBUF); readMore(); @@ -410,7 +410,7 @@ Http::Tunneler::disconnect() void Http::Tunneler::callBack() { - debugs(83, 5, callback.answer().conn << status()); + debugs(83, 5, callback.answer().conn << ' ' << status()); assert(!connection); // returned inside callback.answer() or gone ScheduleCallHere(callback.release()); } diff --git a/src/ipc/Inquirer.cc b/src/ipc/Inquirer.cc index 7b30fae6619..0cccf803454 100644 --- a/src/ipc/Inquirer.cc +++ b/src/ipc/Inquirer.cc @@ -104,7 +104,7 @@ Ipc::Inquirer::inquire() ++LastRequestId; request->requestId = LastRequestId; const int kidId = pos->kidId; - debugs(54, 4, "inquire kid: " << kidId << status()); + debugs(54, 4, "inquire kid: " << kidId << ' ' << status()); TheWaitingInquirers[request->requestId] = this; TypedMsgHdr message; request->pack(message); From ae5f2bf0cdda3fa8ef2030945c47c076c33a3aa9 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 30 Apr 2024 15:50:28 +0100 Subject: [PATCH 06/11] Reformat HappyConnOpener --- src/HappyConnOpener.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/HappyConnOpener.cc b/src/HappyConnOpener.cc index 9a003d86115..ec8ac17f6b6 100644 --- a/src/HappyConnOpener.cc +++ b/src/HappyConnOpener.cc @@ -437,15 +437,18 @@ HappyConnOpener::status() const SBufStream os(buf); + os << "{ "; if (stopReason) - os << "Stopped:" << stopReason; + os << "stopped: \'" << stopReason << '\''; if (prime) - os << " prime:" << prime; + os << ", prime:" << prime; if (spare) - os << " spare:" << spare; + os << ", spare:" << spare; if (n_tries) - os << " tries:" << n_tries; - os << " dst:" << *destinations; + os << ", tries:" << n_tries; + os << ", dst:" << *destinations; + os << ", id: " << id; + os << " }"; buf = os.buf(); return buf.c_str(); From 82508b11da98d75f9b31243b67b8d99f56b61163 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 30 Apr 2024 15:50:54 +0100 Subject: [PATCH 07/11] Revert Adaptation::Ecap::ServiceRep::status --- src/adaptation/ecap/ServiceRep.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/adaptation/ecap/ServiceRep.cc b/src/adaptation/ecap/ServiceRep.cc index c28704d62e9..1d3339020f2 100644 --- a/src/adaptation/ecap/ServiceRep.cc +++ b/src/adaptation/ecap/ServiceRep.cc @@ -284,6 +284,7 @@ const char *Adaptation::Ecap::ServiceRep::status() const static MemBuf buf; buf.reset(); + buf.append("[", 1); if (up()) buf.append("up", 2); @@ -293,6 +294,7 @@ const char *Adaptation::Ecap::ServiceRep::status() const if (detached()) buf.append(",detached", 9); + buf.append("]", 1); buf.terminate(); return buf.content(); From b790a1ea7b83d9c99486f498b55ceff306f65e21 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 30 Apr 2024 16:11:25 +0100 Subject: [PATCH 08/11] Do not use std::string --- src/base/AsyncJob.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index f6639956a09..5bbcd4f232f 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -197,7 +197,7 @@ AsyncJob::ReportAllJobs(StoreEntry *e) { PackableStream os(*e); // this loop uses YAML syntax, but AsyncJob::status() still needs to be adjusted to use YAML - const std::string indent(" "); + const SBuf indent(" "); for (const auto job: AllJobs()) { os << job->id << ":\n"; os << indent << "type: " << job->typeName << '\n'; From 31865cae5766745c2fe467c1f76efe663ea2f7ef Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 30 Apr 2024 16:14:20 +0100 Subject: [PATCH 09/11] quote job type --- src/base/AsyncJob.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 5bbcd4f232f..4da4059a6f2 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -200,7 +200,7 @@ AsyncJob::ReportAllJobs(StoreEntry *e) const SBuf indent(" "); for (const auto job: AllJobs()) { os << job->id << ":\n"; - os << indent << "type: " << job->typeName << '\n'; + os << indent << "type: '" << job->typeName << "'\n"; const char *status = job->status(); if (status && strlen(status)) os << indent << "status: " << job->status() << "\n"; From f44573b85ffa09e33139abe7389576a13c610ca9 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 30 Apr 2024 16:19:18 +0100 Subject: [PATCH 10/11] quote status --- src/base/AsyncJob.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/base/AsyncJob.cc b/src/base/AsyncJob.cc index 4da4059a6f2..44954138e8f 100644 --- a/src/base/AsyncJob.cc +++ b/src/base/AsyncJob.cc @@ -203,8 +203,10 @@ AsyncJob::ReportAllJobs(StoreEntry *e) os << indent << "type: '" << job->typeName << "'\n"; const char *status = job->status(); if (status && strlen(status)) - os << indent << "status: " << job->status() << "\n"; + os << indent << "status: '" << job->status() << "'\n"; os << indent << "started: " << (job->started_ ? "Yes": "No" ) << '\n'; + if (job->stopReason) + os << indent << "stopped: \'" << job->stopReason << "'\n"; } } From a45698e02a2e80a80b15c7ab92130f477514a116 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli Date: Tue, 30 Apr 2024 16:19:22 +0100 Subject: [PATCH 11/11] fix spacing --- src/comm/TcpAcceptor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/comm/TcpAcceptor.cc b/src/comm/TcpAcceptor.cc index 5f0f3addda1..380c6b0da4f 100644 --- a/src/comm/TcpAcceptor.cc +++ b/src/comm/TcpAcceptor.cc @@ -132,7 +132,7 @@ Comm::TcpAcceptor::status() const static MemBuf buf; buf.reset(); - buf.appendf(" FD %d, %s",conn->fd, ipbuf); + buf.appendf("FD %d, %s",conn->fd, ipbuf); const char *jobStatus = AsyncJob::status(); buf.append(jobStatus, strlen(jobStatus));