You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spamassassin.apache.org by "Malte S. Stretz" <ms...@gmx.net> on 2005/06/02 12:13:26 UTC

Polling vs. a factory (was: Renaming DnsResolver::search to send)

On Tuesday 31 May 2005 23:37 CET Justin Mason wrote:
> Sidney Markowitz writes:
> > Justin Mason said:
> > > fwiw, if you do do that, it'd be very useful to include a polling
> > > mode,
> >
> > I thought that's what Malte was talking about regarding using
> > DnsResolver in the new SPF class. Or are you pointing out that it
> > should not only use background queries itself, it should also present a
> > polling interface that hides the places where it has to do multiple
> > sequential queries? Yes, that would be the right way to do it.
>
> using DnsResolver in SPF wouldn't do this by itself -- the SPF code
> would have to be modified to allow this.  DnsResolver just gives the
> "plumbing" to support that model, when issuing DNS queries.

Yeah, I hope I might get SPF to do it that way, too.

> I was suggesting this for the Mail::MTAMark::Query class.

The approach I chose for MTAMark::Query is a bit different:  The Query 
object can act as a factory for a Net::DNS::Packet.  So if you want to use 
your own polling algorithm, you call
  $query->create();
and get a Net::DNS::Packet.  What you do with that is completely up to you.  
But When you've got a reply, you can feed it to
  $query->process($answer);

The Query internally has a queue of stuff to be done.  process() returns 
true if it needs another packet to finish the stuff or false if not.  So 
you loop over that until it returns false.  Then you can call result() and 
will get your data.

That way I only have to implement the simple blocking query in the module.  
I think everybody will use his own polling algorithm, so the caller can 
also do the bgsend() stuff IMO.  Does that sound reasonable?

Btw. MTAMark only needs additional queries if you either (a) feed it both an 
IPv4 and an IPv6 address (it will check the IPv6 one only if the IPv4 one 
doesn't have an entry) or (b) want to have the RP data for the queried zone 
(as suggested in the draft).

The current (uncommented and still buggy) code is available here [1].

Cheers,
Malte

[1]http://msquadrat.de/tmp/Mail-MTAMark-Query.tar.bz2

-- 
[SGT] Simon G. Tatham: "How to Report Bugs Effectively"
      <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
[ESR] Eric S. Raymond: "How To Ask Questions The Smart Way"
      <http://www.catb.org/~esr/faqs/smart-questions.html>