[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re[2]: END blocks in perl modules
From:       Ilya Obshadko <ilya () zhurnal ! ru>
Date:       2000-02-12 18:58:30
[Download RAW message or body]

Hello James,

суббота, 12 февраля 2000 г., you wrote:

JGS> What you want to do, I think, is something like the following:

JGS>   sub tie_keys {
JGS>     unless(tied %Keys or not defined $IPC::Shareable::VERSION) {
JGS>       tie(%Keys, 'IPC::Shareable', 'abcd', {  # random glue...
JGS>                                   mode => 0600,  # a bit more secure
JGS>                                   destroy => 'no',
JGS>                                   exclusive => 'no',
JGS>                                   create => 'yes',
JGS>                                 });
JGS>     }
JGS>   }

My point was NOT to tie separately in each child, but execute tie()
once during startup. The code of module that is being loaded
from startup.pl looks like this:

BEGIN {
    use IPC::Shareable;
    tie %RADDR_CACHE, 
        'IPC::Shareable',
        { key => 'href', mode => 0666, create => 1 };
}

[bla-bla-bla]

END {
    untie %RADDR_CACHE;
}

It works fine for me, i.e. all children has a proper access to
segment, can read & write all that I need and so on.
But if I tie() with { destroy => 1 }, segment is being destroyed in
approximately 10 seconds after httpd startup (seems like httpd
parent restarts itself after initialization). So I've tried to destroy
segment manually and then found that END {} is not executed during
parent shutdown...

Actually, that is not a REAL problem, because httpd is running already
and garbage collector is on its way ;)

Best regards,
 Ilya                            mailto:ilya@zhurnal.ru

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic