]> git.ipfire.org Git - thirdparty/squid.git/commit
Report exception locations and exception-related polish (#119)
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 19 Jan 2018 03:27:01 +0000 (03:27 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Fri, 19 Jan 2018 09:04:36 +0000 (22:04 +1300)
commitfe35e35d1d85b1821c63c179af352dd77ec5cf02
treef2b4af4120009a934c525323cbbf59d7446b7cfb
parent21f79b1f2dcfade2909d2a91d10092f1ac139a56
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.

Conflicts:
src/SquidString.h
src/tests/testSBuf.h
test-suite/mem_hdr_test.cc
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