rdfield has asked for the wisdom of the Perl Monks concerning the following question:

This little problem has been bugging me for a bit and I wondered if anyone could explain the behaviour of Apache::StatINC to me?

The situation is as follows: I have a page which calls a function in a module (say module1). So far so good. This module then calls a function in another module(say module2). Great: everything displays as it should. If I make a change to module2 and reload the client page (did I say this was running under Apache/mod_perl?) the original output is displayed. If I then make a change (or just touch) module1, the changes to module2 appear.

An extract of the error.log:

test v1! at /my/module2.pm line 790 Apache::StatINC: process 1440 reloading module2.pm test v1! at /my/module2.pm line 790 Apache::StatINC: process 1440 reloading module1.pm test v2! at /my/module2.pm line 790

rdfield

Replies are listed 'Best First'.
Re: Apache::StatINC reload explaination required
by samurai (Monk) on Sep 04, 2002 at 13:31 UTC
    I can't exactly explain what happens with StatINC, for I have always used Apache::Reload. I believe it gives you more control. I would suggest using Apache::Reload as a replacement for Apache::StatINC, it may solve your problem. Just a suggestion.

    --
    perl: code of the samurai

      Is Module2 in your %INC path, or have you modified %INC in Module1 in order that you can load Module2?

      Apache::StatINC checks the last modified time of each module in your %INC hash at the initialisation phase. If the module isn't there or hasn't changed it wont be reloaded. If you're loading Module2 from outside your %INC in Module1 you should modify your startup.pl so that directory is included.

      Let us know how you get on.

      Steve.
        Module2 is in the same directory as Module1. As you can see from the error.log StatINC correctly identifies the module as requiring a reload, but the reload does not take effect until the calling module has been 'touched' and therefore reloaded. I looked at the code for Apache::Reload and as far as I could tell the only relevent difference was that the reload was done directly rather than through an eval. I changed my local StatINC to remove the eval and tried again to no avail.

        rdfield