]> git.ipfire.org Git - thirdparty/squid.git/commit
Report exception locations and exception-related polish (#119)
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 10 Jan 2018 15:45:43 +0000 (08:45 -0700)
committerGitHub <noreply@github.com>
Wed, 10 Jan 2018 15:45:43 +0000 (08:45 -0700)
commitebaabe74128fe480b35ece2d46816f2c6fd7f888
tree0d6b7ff88796946544dd24ad946447d96e97753a
parent505f9427c55a365b464f1b204880df1d3ccccb7f
Report exception locations and exception-related polish (#119)

Without location, many exceptions look identical: A growing number of
Must(entry != NULL) and Must(request) complicate triage. The location
info was already stored in TextException but was not reported.

Reporting exception location on a separate line makes admin-visible
FATAL/ERROR/WARNING messages easier to comprehend, and their primary
text becomes more "stable", which is good for documentation. Also, some
future exceptions will probably report multiple details, possibly even
context details collected as a low-level exception bubbles up to its
high-level handling/reporting code.

Also simplified/optimized TextException:

* TextException now reuses std::runtime_error message memory management
  code, including its CoW optimizations/guarantees.

* Debug and TextException code now share the source location reporting
  code (including Squid build prefix elision) in base/Here.{cc,h}.

Also simplified and polished SBuf-related exceptions, removing a few:

* Removed InvalidParamException as unused.

* Replaced SBufTooBigException with generic exceptions.
  SBufTooBigException was misused (by SBuf::plength) and not useful. No
  need to create a whole class just to parameterize an object!

* Replaced OutOfBoundsException with a generic exception.
  OutOfBoundsException was not very useful (see SBufTooBigException). It
  was used by one test case, that did not justify adding a whole class.

Also added SWALLOW_EXCEPTIONS() API to protect any code that may throw
unwanted exceptions. Reworked a few destructors after Must() changes
made it easier for GCC v6 to detect (and warn about) throwing code:

* Polished Ipc::Forwarder cleanup sequence. For Forwarders, I see no
  reason to split/duplicate swanSong() functionality via a cleanup()
  method. The swanSong() API exists so that job destructors do not need
  to make confusing virtual method calls!

* Hid the AsyncJob destructor because all jobs should be "automatically"
  deleted by the internal job code that guarantees a swanSong() call.

* Removed a bad (pair-less) StoreEntry::unregisterAbort() call from
  Mgr::Forwarder destructor, possibly left behind in or around 51ea090.

* Removed ctor/dtor entrance debugging from the classes affected by the
  "throwing destructor issue". AsyncJob covers that debugging need.

* TODO: Adjust all throwing destructors.
38 files changed:
scripts/calc-must-ids.pl
src/Debug.h
src/DiskIO/IpcIo/IpcIoFile.cc
src/FadingCounter.cc
src/SquidString.h
src/adaptation/icap/ServiceRep.cc
src/base/AsyncJob.h
src/base/Here.cc [new file with mode: 0644]
src/base/Here.h [new file with mode: 0644]
src/base/Makefile.am
src/base/RunnersRegistry.cc
src/base/TextException.cc
src/base/TextException.h
src/base/YesNoNone.h
src/debug.cc
src/ipc/Forwarder.cc
src/ipc/Forwarder.h
src/main.cc
src/mgr/Forwarder.cc
src/mgr/Forwarder.h
src/mgr/IntParam.cc
src/sbuf/Exceptions.cc [deleted file]
src/sbuf/Exceptions.h [deleted file]
src/sbuf/Makefile.am
src/sbuf/OutOfBoundsException.h [deleted file]
src/sbuf/SBuf.cc
src/sbuf/SBuf.h
src/sbuf/forward.h
src/snmp/Forwarder.cc
src/snmp/Forwarder.h
src/ssl/support.cc
src/tests/stub_debug.cc
src/tests/stub_libmgr.cc
src/tests/testSBuf.h
src/tests/testSBufList.h
test-suite/mem_hdr_test.cc
tools/Makefile.am
tools/squidclient/Makefile.am