[Xorp-hackers] [PATCH] Supporting asynchronous method implementations

Steven Simpson ss at comp.lancs.ac.uk
Mon Apr 11 03:10:43 PDT 2011


Hi again,

On 31/03/11 12:17, Steven Simpson wrote:
> So, XrlCmdMap retains its conditional
> declarations, but XrlDispatcher's interface is now unconditionally
> asynchronous.  I think if I went further, and made XrlCmdMap
> unconditionally asynchronous, it would unconditionally spill into the
> tgt-gen-erated code, and bloat the binaries.

I noticed that enable_tests=True wouldn't work with async, as the files
in xorp/libxipc/tests use XrlCmdMap directly.  I was going to go through
them to make them conditional on XORP_ENABLE_ASYNC_SERVER, but I
realised I could take XrlCmdMap a little further into being fully
asynchronous, by making it accept synchronous command implementations,
and making asynchronous ones out of them.

To start with, the two conditional forms of XrlRecvCallback are now
expressed by XrlRecvAsyncCallback and XrlRecvSyncCallback.  The only
places where the conditional declarations are now used are in
tgt-gen-erated code.

I had hoped to change this:

XrlCmdMap::add_handler(const string&, const XrlRecvCallback&);

…into this:

XrlCmdMap::add_handler(const string&, const XrlRecvAsyncCallback&);
XrlCmdMap::add_handler(const string&, const XrlRecvSyncCallback&);

…and get the second one to transform its argument and then call the
first, but you get compilation problems when XrlDispatcher/XrlRouter try
to override one of them (something about the overriding declaration
hiding the original).  So, instead, I've renamed the overridden method
to add_handler_internal, then created overloaded inline add_handlers
which delegate to add_handler_internal.

As before, enable_async_server=True increases stripped binaries by 2MB. 
I ran [scons check] with [enable_tests=True ignore_check_errors=True],
and there are no differences between lines containing "Tests".  Of lines
containing "Test", there is just one extra line in the async version:

[ 2011/04/07 18:33:29.605291  WARNING test_peer:10200 XrlTestPeerTarget 
obj/i686-pc-linux-gnu/xrl/targets/test_peer_base.cc:971 
callback_test_peer_0_1_send ] Handling method for test_peer/0.1/send failed: 
XrlCmdError 102 Command failed Not connected

I'm wondering whether it's significant or not.  It appears under TEST3,
which then says it succeeded.

Anyway, I'll send another patch...

Cheers,

Steven

-- 






More information about the Xorp-hackers mailing list