[PATCH] raw-FD related AsyncCall classes

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Thu, 24 Nov 2011 01:11:25 +1300

The problem:
   CommCalls functionality is conflated with calls created to do general
FD handling (FD as pipe handle, FD as disk handle, FD as pointer into
the fd_table structure). Sometimes because they do operations mirroring
comm handlers and also use FD. None of this actually requires the comm
layer to be involved though. The Comm::Connection objects which comm
handlers pass around is also very inappropriate for these FD types.

This patch adds functionality for two types of AsyncCall to replace the
Comm parameters being abused.

  * FdeCbParams is added to CommCalls infrastructure, for use internally
and "lower" than comm API to pass around raw FD values. This should be
avoided on TCP socket FD, but may be used by callers needing FD where
Comm::Connection is inappropriate.

* UnaryCbdataDialer<T> template is added to dial a call on any wrapper
function taking one cbdata state object as a parameter pointer.
  This dialer checks the cbdata base object validity prior to calling.
As such it acts like the cbdata callbacks, but adding async scheduling
ability.
  It also adds the AsyncCalls ability for the wrapper functions to have
typed parameters instead of "void *data" and casting.

  Alex: I've been searching the Async code for a long while trying to
figure out how to do this with the existing API. If you can point me at
how to do it without adding a new template I'd be grateful. Or
alternatively for any reasons why this does not already exist.

For now this dialer template is isolated in helper.cc and used only for
the helper pipe() FD close handlers. If others agree I'd like to make it
globally available in new src/base/AsyncCbdataCalls.h and use it to ease
the transition from cbdata objects to Jobs. It seems the big hitch
currently to transitioning is that to use generic Unary/Nullary
templates the object must be a fully transitioned AsyncJob so we end up
with custom-coded dialers for each cbdata class type.

Amos

Received on Wed Nov 23 2011 - 12:11:33 MST

This archive was generated by hypermail 2.2.0 : Wed Nov 23 2011 - 12:00:13 MST