develooper Front page | perl.qpsmtpd | Postings from June 2005

[high_perf] Continuation support

Thread Next
From:
Matt Sergeant
Date:
June 18, 2005 11:31
Subject:
[high_perf] Continuation support
Message ID:
094b09906057b895bc2dedd2cc183aef@sergeant.org
I've checked in support for a rudimentary form of continuations.

The basic idea is that previously you had to rely on the following 
sequence of events:

(((
  hook_connect : dnsbl -> fire off dns query and turn off read mode on 
socket.

  callback : get dns response - turn on read mode on socket. Can't send 
anything to client here as it's already been sent at the end of running 
all the connect hooks.

  hook_rcpt : process dns responses and send valid return codes.
)))

Now what you can do is:

(((
  hook_connect : dnsbl -> fire off dns query and turn off read mode on 
socket. Suspend remaining hooks as a continuation.

  callback : get dns response - turn on read mode on socket, but also 
continue the continuation.

  hook_connect(2) : dnsbl2 -> process dns responses and send valid 
return codes.
)))

Most of this is transparent - you just have to return CONTINUATION and 
remember to call $qp->finish_continuation when everything is ready to 
continue (see plugins/dnsbl for the example).

For those confused as to why all this was necessary - we needed a way 
to do the sort of things dnsbl does but without waiting for more input 
from the client to trigger another event - e.g. at data_post time where 
the client won't send anything more before we queue the mail. This 
gives us that capability in the high_perf branch. So now converting 
plugins/spamassassin to high_perf will (should) be fairly 
straightforward.

Enjoy.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About