Re: A global has among threads

From: Nicholas Dronen (ndronen_at_io.frii.com)
Date: 10/27/03


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


Relevant Pages

  • Re: Khorne Army 2500 points
    ... Stad Khorne 2.5kb2500 Pts - CSM: ... Daemon Prince @ 191 Pts ... Mark of Khorne ...
    (rec.games.miniatures.warhammer)
  • Re: An annoying memory leak
    ... I have to write a "daemon" in Perl, with the quite simple structure below ... Oracle database connection; ... Memory leaks happen. ...
    (perl.beginners)
  • An annoying memory leak
    ... Oracle database connection; ... I begin to believe writing a such "daemon" in Perl is not a good idea, ...
    (perl.beginners)
  • Re: daemon helper
    ... You need fork() and setsid() to start a daemon. ... I use dh to start shell and perl scripts which read FIFOs fed by syslog. ...
    (comp.lang.awk)
  • Re: An annoying memory leak
    ... I have to write a "daemon" in Perl, with the quite simple structure below: ... Oracle database connection; ... grows significantly during its running time, ...
    (perl.beginners)