Re: A global has among threads
From: Nicholas Dronen (ndronen_at_io.frii.com)
Date: 10/27/03
- Next message: Mike: "Re: Installing Module on Remote Host"
- Previous message: William Herrera: "Re: Portable @INC"
- In reply to: Mark: "A global has among threads"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 27 Oct 2003 04:56:17 GMT
Mark <admin@asarian-host.net> wrote:
M> Hello,
M> Is there a way I can uses a global hash within Perl (5.8.0) with threads?
M> The reason I ask, is that I have a Milter (Sendmail::Milter) running, which
M> is a daemonized version of Perl 5.8.0 with threads enabled. I would like to
M> maintain a global hash of hostnames who have already been looked up
M> previously, so as to avoid renewed DNS queries.
M> Short of resorting to using shmget and all the other shared memory stuff, I
M> was wondering whether there is ANY way to maintain a global hash, shared
M> among all threads?
Hi, Mark:
If the occasional bad record doesn't concern you, ignore this post.
One thing to keep in mind is that, unless your daemon respects the
TTL, a simple host name -> address cache will become invalid when
a changed record expires.
A module like Net::DNSServer might be inappropriate for your threaded
daemon, but at least it'd handle TTL for you:
http://search.cpan.org/~bbb/Net-DNSServer-0.11/
Other possibilities are running a caching-only DNS server on the
machines that run your daemon, or writing TTL-aware code into your
daemon.
Regards,
Nicholas
-- "Why shouldn't I top-post?" http://www.aglami.com/tpfaq.html "Meanings are another story." http://www.ifas.org/wa/glossolalia.html
- Next message: Mike: "Re: Installing Module on Remote Host"
- Previous message: William Herrera: "Re: Portable @INC"
- In reply to: Mark: "A global has among threads"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|