< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate] async MessageDecorator branch



I've made a first commit of this on b-dpocock-async-decorator

https://svn.resiprocate.org/rep/resiprocate/branches/b-dpocock-async-decorator

The basic idea is that a MessageDecorator can do some computational
activity asynchronously.  Just
- override the new decorateMessage() method,
- save the DecorationContext pointer somewhere and start a thread,
- return false from decorateMessage(),
- when the async work is done, call
     decorationContext->decoratorFinished()
- the stack will then continue calling any other decorators and
eventually send the message out on the network

The API for users of the stack (MessageDecorator and DecorationContext)
is not too complicated and will probably be stable.

If no decorator returns false from decorateMessage(), then everything
should work as it does now without any extra loop through the process()
loop.

However, the implementation may need to be revised a little before any
merge into the trunk

A few things stand out as potential discussion points:

- for DecorationContext to be passed back through the Fifo, it needs to
implement TransactionMessage.  I notice that DnsResultMessage is
initialized from TransactionState's mId and isClient().  For
DecorationContext, I'm initializing those values from the SipMessage (in
SipMessage::createDecorationContext()) - is this a reasonable alternative?

- it is a bit awkward trying to keep everything decoupled, I found that
a lot of state from the TransportSelector::transmit() needs to be
encapsulated in the DecorationContext().  My initial strategy involves a
bloated constructor.

- I notice that TransactionState.cxx has some code for handling timeouts
that occur during DNS and situations where the TU sends another message
before the async DNS lookup is complete.  Maybe there are similar
concerns for the decorator code - further checks may need to be added
for this.

Maybe more decoupling can be achieved by creating an additional class,
DecorationContextMessage perhaps.  However, I thought I would start out
with something simple and see if anybody else has comments.

SVN diff:

http://list.resiprocate.org/archive/resiprocate-commit/msg07859.html

github diff:

https://github.com/resiprocate/resiprocate/compare/0dcb63552280%5E...17b71b5dc8d0