[MERGE] Cleanup, the client_side part

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Wed, 10 Sep 2008 23:49:16 -0600

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 the
close() method 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 still 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. The updated close handler initiates job destruction by
calling deleteThis().

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.

Received on Thu Sep 11 2008 - 05:49:58 MDT

This archive was generated by hypermail 2.2.0 : Fri Sep 12 2008 - 12:00:06 MDT