[PATCH] Updated Comm::Read I/O API

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Thu, 05 Jun 2014 03:10:31 +1200

Update the Comm:: API for read(2) using the algorithm suggested by Alex
Rousskov.

The code for Comm:: read operations is shuffled into comm/libcomm.la and
the files comm/Read.{h,cc} in symmetry with the current Comm::Write API.

The new API consists of:

 * Comm::Read() which accepts the Comm::Connection pointer for the
socket to read on and an AsyncCall callback to be run when read is
ready. The Job is responsible for separately initiating read(2) or
alternative action when that callback is run.

 * Comm::ReadNow() which accepts an SBuf buffer and a CommIoCbParams
initialized to contain the Comm::Connection pointer for the socket to
read on which will be filled out with result flag, xerrno, and size.
This synchronously performs read(2) operations to append bytes to the
provided buffer. It returns a comm_err_t flag for use in determining how
to handle the results and signalling one of OK, INPROGRESS, ERROR,
ERR_CLOSING as having happened.

comm_read() API is retained for backward compatibility during the
transitional period. However it is now deprecated and scheduled for
removal ASAP. The SBuf overloaded variant is now removed.

 * Comm::ReadCancel() - a renaming of the comm_read_cancel() AsyncCall
API. Other cancel API(s) are now deprecated and will be removed ASAP.

Code using comm_read_cancel() with AsyncCall may immediately switch to
this new API with no logic changes necessary even if they are not using
other new Comm API calls.

 * Comm::MonitorsRead() - a renaming of comm_monitors_read() AsyncCall
API. comm_monitors_read() is now removed.

Other changes:
 - the unused comm_has_pending_read_callback() API is erased.
 - the IoCallback::buf2 mechanism previously used for SBuf read I/O is
erased.
 - ConnStateData is converted to this new API for filling its SBuf I/O
buffer and for monitoring pinned connection closures.
 - fde::readPending() converted to new Comm::MonitorsRead() API.

NP: one bug in ConnStateData handling of intercepted HTTPS traffic is
noted but not fixed in this patch.

Amos

Received on Wed Jun 04 2014 - 15:10:46 MDT

This archive was generated by hypermail 2.2.0 : Wed Jun 04 2014 - 12:00:13 MDT