From: Alex Rousskov Date: Tue, 16 Mar 2021 17:51:05 +0000 (+0000) Subject: Bug 5112: Excessively loud chunked reply parsing error reporting (#789) X-Git-Tag: 4.15-20210522-snapshot~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a89d435a0c4951fa951c74e526cd92beaa8c00b;p=thirdparty%2Fsquid.git Bug 5112: Excessively loud chunked reply parsing error reporting (#789) Traffic parsing errors should be reported at level 2 (or below) because Squid admins can usually do nothing about them and a noisy cache.log hides important problems that they can and should do something about. TODO: Detail this and similar parsing errors for %err_detail logging. Also removed an unnecessary used-once macro. --- diff --git a/src/http.cc b/src/http.cc index 04ecd8848b..ac89872370 100644 --- a/src/http.cc +++ b/src/http.cc @@ -67,15 +67,6 @@ #include "DelayPools.h" #endif -#define SQUID_ENTER_THROWING_CODE() try { -#define SQUID_EXIT_THROWING_CODE(status) \ - status = true; \ - } \ - catch (const std::exception &e) { \ - debugs (11, 1, "Exception error:" << e.what()); \ - status = false; \ - } - CBDATA_CLASS_INIT(HttpStateData); static const char *const crlf = "\r\n"; @@ -1461,26 +1452,25 @@ HttpStateData::writeReplyBody() bool HttpStateData::decodeAndWriteReplyBody() { - const char *data = NULL; - int len; - bool wasThereAnException = false; assert(flags.chunked); assert(httpChunkDecoder); - SQUID_ENTER_THROWING_CODE(); - MemBuf decodedData; - decodedData.init(); - httpChunkDecoder->setPayloadBuffer(&decodedData); - const bool doneParsing = httpChunkDecoder->parse(inBuf); - inBuf = httpChunkDecoder->remaining(); // sync buffers after parse - len = decodedData.contentSize(); - data=decodedData.content(); - addVirginReplyBody(data, len); - if (doneParsing) { - lastChunk = 1; - flags.do_next_read = false; + try { + MemBuf decodedData; + decodedData.init(); + httpChunkDecoder->setPayloadBuffer(&decodedData); + const bool doneParsing = httpChunkDecoder->parse(inBuf); + inBuf = httpChunkDecoder->remaining(); // sync buffers after parse + addVirginReplyBody(decodedData.content(), decodedData.contentSize()); + if (doneParsing) { + lastChunk = 1; + flags.do_next_read = false; + } + return true; } - SQUID_EXIT_THROWING_CODE(wasThereAnException); - return wasThereAnException; + catch (...) { + debugs (11, 2, "de-chunking failure: " << CurrentException); + } + return false; } /**