]> git.ipfire.org Git - thirdparty/squid.git/commit - src/client_side.cc
Cleaned up ConnStateData's closing and destruction.
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 11 Sep 2008 04:54:34 +0000 (22:54 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Thu, 11 Sep 2008 04:54:34 +0000 (22:54 -0600)
commit6e1d409c65c63e90343e9156a43dbbc87ff96e59
treeef22f2436cea07018d928b53a9338d8f4fc7d205
parent82cac9ff68751bb9ea6f8db2d41adb63130a5b28
Cleaned up ConnStateData's closing and destruction.

1) Despite its name and the "if (open) close" use in ConnStateData destructor,
ConnStateData::close() was not closing anything. It was called from the Comm
close handler and from the destructor and would attempt to immediately delete
the ConnStateData object. Protecting code in deleteThis() may have prevented
the actual [double] delete from happening, but it is difficult to say exactly
what was going on when close() was being called from the destructor.

I converted ConnStateData::close to swanSong, which is the standard AsyncJob
cleanup method. As before, the method does not close anything (which may be
wrong). The swanSong method is never called directly by the user code. It is
called by lower layers just before the job is destroyed.

We may need to add Comm closing code to swanSong. For now, the updated
ConnStateData destructor will warn if ConnStateData forgot to close
the connection. The destructor will also warn if swanSong was not called,
which would mean that the job object is being deleted incorrectly.

2) Polished ClientSocketContext::writeComplete to distinguish
STREAM_UNPLANNED_COMPLETE from STREAM_FAILED closing state. This helps when
looking at stack traces.

3) Added an XXX comment about duplicated code.

4) Documented ClientSocketContext::initiateClose purpose and context.
src/client_side.cc
src/client_side.h