Giampaolo,

> Almost. One of the biggest problems I see is that one can't register a
> socket with AsyncLoop.pm. Thereby, when DNS lookups are finished, the whole
> loop stops regardless of outstanding non-DNS-based lookups.
>
> See sub complete_lookups in AsyncLoop.pm:
>     my $nfound = $self->{main}->{resolver}->poll_responses($timeout);
>     $nfound ||= 'no';
>     dbg ("async: select found $nfound socks ready");
>     foreach my $key (keys %{$pending}) {
>       my $ent = $pending->{$key};
>
> poll_responsens is in DnsResolver.pm and yield 0 when DNS queries are
> finished. This causes the complete_lookups call to terminate all the
> outstanding lookups, even the non-DNS-based ones.

Not really (at least not in the current trunk I'm looking at).
As long as there are any (non timed-out) requests in %$pending,
it does not terminate, even if poll returns empty-handed.
And 'a request' is a rather general term. Currently it covers
DNS requests, but in principle could be other kind of 'requests'.
There are routines for submitting and terminating requests.

I'd be interested too if more general usage emerges, perhaps
along with a somewhat cleaned/generalized API.  My wish is
to provide a mechanism for Plugins (such as DKIM, SPF, Razor2)
to use the same async services and avoid doing their network
lookups synchronously on their own. Suggestions welcome.
If only Perl could have a way of expressing co-routines,
then one could build a simple task scheduler, with task queues
on blocked resources, etc.

> Does anybody knows which is the API to the async stuff? Maybe
> I didn't  get it at all and I'm attempting to use it the wrong way...

Not much docs about API, but see comments on subroutines in
AsyncLoop.pm, and their typical usage by Dns.pm.

  Mark

Reply via email to