Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 14622
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: OLAF [...] cpan.org
Requestors: talby [...] trap.mtview.ca.us
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.53
Fixed in: (no value)

Attachments
Net-DNS-0.53+async.diff.gz



Subject: Net::DNS::Nameserver::main_loop alternative
Net::DNS::Nameserver seems like a great tool, but the fact that it needs to take over the main runnning thread limits its audience. Since many daemon programs are already driven by a top level select loop, it seems useful to provide an API for the user to integrate Net::DNS::Nameserver processing to their own select loop. To show a possible implementation, the patch I have included delays the creation of the IO::Select object until main_loop() is entered using two new methods $obj->handles and $obj->process_client. With these, a user could integrate these handles into their own select loop. Their only obligation is to call process_client() each time one of the sockets is ready for reading. This of course is not full asynchronous processing, but is a step in that direction.
Download Net-DNS-0.53+async.diff.gz
application/x-gzip 920b

Message body not shown because it is not plain text.

Thanks for the contribution. I am catching up with fixing bugs.. it may take a while before I have time to disect your patch. I'll get back to you. --Olaf
I'll include this patch in the next release (expected soon). By what name would you like to be acknowledged. "Talby" is all I have --Olaf
From: talby [...] trap.mtview.ca.us
[OLAF - Wed Oct 5 09:44:30 2005]: Show quoted text
> > I'll include this patch in the next release (expected soon). By what > name would you like to be > acknowledged. >
Wow, that's great to hear. Thank you. My name is Robert Stone.
From: "Olaf M. Kolkman" <olaf [...] dacht.net>
Subject: Re: [cpan #14622] Net::DNS::Nameserver::main_loop alternative
Date: Wed, 5 Oct 2005 20:45:00 +0200
To: bug-Net-DNS [...] rt.cpan.org
RT-Send-Cc:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Robert, This is what I now have in the perlpod, would you think this is useful enough to point people to this featuere? You are being acknowledged in the Changes file. - --Olaf get_handles my $select = IO::Select->new($ns->get_handles); process_client_request $ns->process_client_request($sock) Process the client request that is waiting on the socket. If you want your script to perform other tasks instead of waiting around in the main_loop() then this function in combination with the get_handles() method provides an alternative. The core of your code should contain something like: my $select = IO::Select->new($self->get_handles); my @ready = $select->can_read; foreach my $sock (@ready){ $ns->process_client_request($sock) } Of course you have to take care of blocking and such. See the Name- server.pm module itself for an example how these methods are used to construct the main_loop(); -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) Comment: This message is locally signed. iD8DBQFDRB80tN/ca3YJIocRAjsdAJ4nO3kzpPwbSW5VnmBRbwNXM8LtGQCgpe6w yMXH87MZpmbjkurrB2PEi1Q= =PtbP -----END PGP SIGNATURE-----
In the forthcomming release a method make loop_once() is made available. The documentation is commented out in the source. The method is subject to change. I am closing this ticket for now. --Olaf
In the forthcomming release a method make loop_once() is made available. The documentation is commented out in the source. The method is subject to change. I am closing this ticket for now. --Olaf
In the forthcomming release a method make loop_once() is made available. The documentation is commented out in the source. The method is subject to change. I am closing this ticket for now. --Olaf