[MP2][QUESTION]Session and inactivity

[MP2][QUESTION]Session and inactivity

am 06.02.2008 12:14:57 von titetluc

------=_Part_10290_1235706.1202296497285
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello mod_perl users,

I am developing a mod_perl module (MyModule) to manage
sessions/authentication.
This module:
- uses Apache::Session to store session-related information
- is cookie-based
- manages session inactivity

This module could be used in the following example.


PerlAuthenHandler MyModule
AuthType Basic
AuthBasicProvider ...
require valid-user
PerlFixupHandler MyModule->cookie_create_refresh


If request has no cookie, then basic authentication is required.
If basic authent is correct, then a cookie is created in the fixup
handler.
If request has a cookie, then the cookie is refreshed in the fixup handler.


A basic description of the module in pseudo-perl:

package MyModule;
use Apache::Session::xxx;
use Apache::Cookie;

sub handler{
my $r = shift;

if (cookie_not_present_in_request()){
return DECLINED;
}
return cookie_verify(); #use of Apache::Session as a DB storage
}

sub cookie_create_refresh{
my $class = shift;
if (cookie_not_present_in_request()){
create_cookie_with_Apache::Session::xxx_module();
create_cookie_with_Apache::Cookie_module();
}
else {
refresh_cookie_with_Apache::Session::xxx_module();
refresh_cookie_with_Apache::Cookie_module();
}
return OK;
}

The module I am developing has to delete the cookie if it is not refreshed
regularly.
The question: how can I manage this timeout inactivity ?
The best solution would be to use a mechanism where callbacks (deleting the
cookie rfom the database) would be called automatically on inactivity.
Does such an API is proposed by :
. the APR API
. mod_perl API
. an Apache2::xxx perl module
. a CPAN module

If not, how can I solve my problem ? (I could verify regularly in the DB
storage, but this is a last resort solution. Even in this case, how could I
implement it ?)

Thanks

Gaetan

------=_Part_10290_1235706.1202296497285
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello mod_perl users,

I am developing a mod_perl module (MyModule) to manage sessions/authentication.
This module:
     - uses Apache::Session to store session-related information
     - is cookie-based




     - manages session inactivity



This module could be used in the following example.


<Location /protected_url>
PerlAuthenHandler MyModule
AuthType Basic
AuthBasicProvider ...
require valid-user
PerlFixupHandler MyModule->cookie_create_refresh
</Location>

If request has no cookie, then basic authentication is required.




     If basic authent is correct, then a cookie is created in the fixup handler.
If request has a cookie, then the cookie is refreshed in the fixup handler.


A basic description of the module in pseudo-perl:





package MyModule;
use Apache::Session::xxx;
use Apache::Cookie;

sub handler{
    my $r = shift;

    if (cookie_not_present_in_request()){
         return DECLINED;
     }
    return cookie_verify();  #use of Apache::Session as a DB storage




}

sub cookie_create_refresh{
   my $class = shift;
    if (cookie_not_present_in_request()){
          create_cookie_with_Apache::Session::xxx_module();

          create_cookie_with_Apache::Cookie_module();

    }
    else {
          refresh_cookie_with_Apache::Session::xxx_module();


          refresh_cookie_with_Apache::Cookie_module();
    }
    return OK;
}

The module I am developing has to delete the cookie if it is not refreshed regularly.
The question: how can I manage this timeout inactivity ?




The best solution would be to use a mechanism where callbacks (deleting the cookie rfom the database) would be called automatically on inactivity.
Does such an API is proposed by :
     . the APR API
     . mod_perl API




     . an Apache2::xxx perl module
     . a CPAN module

If not, how can I solve my problem ? (I could verify regularly in the DB storage, but this is a last resort solution. Even in this case, how could I implement it ?)





Thanks

Gaetan



------=_Part_10290_1235706.1202296497285--

Re: [MP2][QUESTION]Session and inactivity

am 06.02.2008 14:53:17 von torsten.foertsch

On Wed 06 Feb 2008, titetluc titetluc wrote:
> The module I am developing has to delete the cookie if it is not refreshed
> regularly.
> The question: how can I manage this timeout inactivity ?
> The best solution would be to use a mechanism where callbacks (deleting t=
he
> cookie rfom the database) would be called automatically on inactivity.
> Does such an API is proposed by :
> =A0 =A0 =A0. the APR API
> =A0 =A0 =A0. mod_perl API
> =A0 =A0 =A0. an Apache2::xxx perl module
> =A0 =A0 =A0. a CPAN module
>
> If not, how can I solve my problem ? (I could verify regularly in the DB
> storage, but this is a last resort solution. Even in this case, how could=
I
> implement it ?)

Apache (at least 2.2.x) implements a "monitor" hook, see server/mpm_common.=
c.=20
To use this hook you'd have to write a bit XS stuff like Geoff's=20
AuthenHook, ... since there is AFAIK no CPAN module. This hook is run from=
=20
time to time in the parent apache.

Otherwise there are 2 standard ways to do that:

=2D a cron job or something similar in the DB itself
=2D check each time in a connection cleanup handler (to do it not too often=
you=20
can use a global variable that holds the timestamp of the last cleanup and=
=20
run it only if the difference to the current time grows too big.)

I'd go for one of the standard ways since:

=2D easier to implement
=2D your code doesn't run as root

Torsten

Re: [MP2][QUESTION]Session and inactivity

am 06.02.2008 17:43:09 von titetluc

------=_Part_11818_13584220.1202316189772
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Oups
I answered directly to Torsten by error
Here is my answer and the reply

2008/2/6, Torsten Foertsch :
>
> On Wed 06 Feb 2008, titetluc titetluc wrote:
> > The module I am developing has to delete the cookie if it is not
> refreshed
> > regularly.
> > The question: how can I manage this timeout inactivity ?
> > The best solution would be to use a mechanism where callbacks (deleting
> the
> > cookie rfom the database) would be called automatically on inactivity.
> > Does such an API is proposed by :
> > . the APR API
> > . mod_perl API
> > . an Apache2::xxx perl module
> > . a CPAN module
> >
> > If not, how can I solve my problem ? (I could verify regularly in the DB
> > storage, but this is a last resort solution. Even in this case, how
> could I
> > implement it ?)
>
>
> Apache (at least 2.2.x) implements a "monitor" hook, see
> server/mpm_common.c.
> To use this hook you'd have to write a bit XS stuff like Geoff's
> AuthenHook, ... since there is AFAIK no CPAN module. This hook is run from
> time to time in the parent apache.
>
> Otherwise there are 2 standard ways to do that:
>
> - a cron job or something similar in the DB itself
> - check each time in a connection cleanup handler (to do it not too often
> you
> can use a global variable that holds the timestamp of the last cleanup and
> run it only if the difference to the current time grows too big.)
>
> I'd go for one of the standard ways since:
>
> - easier to implement
> - your code doesn't run as root




> One naive question: how can I declare a global variable under mod_perl ?
> Each request is run with a thread and by default Perl does not share
> variables !
> I declared my variable as shared (using the threads::shared module) but
> this declaration does not seem to be sufficient in a mod_perl environment
> !!!

I meant something like this:

package My::Cleanup;

use strict;
use Apache2::Const -compile=>('OK', 'DECLINED');
use Apache2::RequestRec ();
use Apache2::Connection ();
use APR::Pool ();

my $lastrun=0; # this is the global variable: one per process
my $check_interval=60; #check every minute

sub run {
my $time=time;
if( $time>$lastrun+$check_interval ) {
$lastrun=$time;
# here you can check the modification time ((stat)[9]) of a file on disk
# flock() it with LOCK_NB set and return if flock fails.
# alternatively you can implement an interface to apr_proc_mutex which is
# quite easy, see ThreadMutex for example.
# or you implement $lastrun in your database.
# or you use BerkeleyDB which is actually shared memory.

# doit
...
}
return Apache2:Const::OK;
}

sub handler {
my ($r)=@_;
unless( $r->connection->pnotes->{cleanup_installed} ) {
$r->connection->pool->cleanup_register(\&run);
$r->connection->pnotes->{cleanup_installed}=1;
}
return Apache2::Const::DECLINED;
}

Then:

# install it either as PerlPostReadRequestHandler or as
# PerlHeaderParserHandler
PerlInitHandler My::Cleanup

I'd implement the process global variable as shown plus perhaps another
variable in the database if the session is stored there. It depends on how
expensive your cleanup is.

Torsten

Torsten
>

------=_Part_11818_13584220.1202316189772
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Oups
I answered directly to Torsten by error
Here is my answer and the reply

2008/2/6, Torsten Foertsch <>:

On Wed 06 Feb 2008, titetluc titetluc wrote:
> The module I am developing has to delete the cookie if it is not refreshed
> regularly.
> The question: how can I manage this timeout inactivity ?
> The best solution would be to use a mechanism where callbacks (deleting the

> cookie rfom the database) would be called automatically on inactivity.
> Does such an API is proposed by :
>      . the APR API
>      . mod_perl API
>      . an Apache2::xxx perl module

>      . a CPAN module
>
> If not, how can I solve my problem ? (I could verify regularly in the DB
> storage, but this is a last resort solution. Even in this case, how could I
> implement it ?)



Apache (at least 2.2.x) implements a "monitor" hook, see server/mpm_common.c.
To use this hook you'd have to write a bit XS stuff like Geoff's
AuthenHook, ... since there is AFAIK no CPAN module. This hook is run from

time to time in the parent apache.

Otherwise there are 2 standard ways to do that:

- a cron job or something similar in the DB itself
- check each time in a connection cleanup handler (to do it not too often you

can use a global variable that holds the timestamp of the last cleanup and
run it only if the difference to the current time grows too big.)

I'd go for one of the standard ways since:

- easier to implement

- your code doesn't run as root

 

> One naive question: how can I declare a global variable under mod_perl ?

> Each request is run with a thread and by default Perl does not share

> variables !

> I declared my variable as shared (using the threads::shared module) but

> this declaration does not seem to be sufficient in a mod_perl environment

> !!!



I meant something like this:



package My::Cleanup;



use strict;

use Apache2::Const -compile=>('OK', 'DECLINED');

use Apache2::RequestRec ();

use Apache2::Connection ();

use APR::Pool ();



my $lastrun=0;         # this is the global variable: one per process

my $check_interval=60; #check every minute



sub run {

 my $time=time;

 if( $time>$lastrun+$check_interval ) {

   $lastrun=$time;

   # here you can check the modification time ((stat)[9]) of a file on disk

   # flock() it with LOCK_NB set and return if flock fails.

   # alternatively you can implement an interface to apr_proc_mutex which is

   # quite easy, see ThreadMutex for example.

   # or you implement $lastrun in your database.

   # or you use BerkeleyDB which is actually shared memory.



   # doit

   ...

 }

 return Apache2:Const::OK;

}



sub handler {

 my ($r)=@_;

 unless( $r->connection->pnotes->{cleanup_installed} ) {

   $r->connection->pool->cleanup_register(\&run);

   $r->connection->pnotes->{cleanup_installed}=1;

 }

 return Apache2::Const::DECLINED;

}



Then:



# install it either as PerlPostReadRequestHandler or as

# PerlHeaderParserHandler

PerlInitHandler My::Cleanup



I'd implement the process global variable as shown plus perhaps another

variable in the database if the session is stored there. It depends on how

expensive your cleanup is.



Torsten


Torsten



------=_Part_11818_13584220.1202316189772--

Re: [MP2][QUESTION]Session and inactivity

am 07.02.2008 17:09:31 von titetluc

------=_Part_2927_27315578.1202400571907
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello all,



2008/2/6, titetluc titetluc :
>
> Oups
> I answered directly to Torsten by error
> Here is my answer and the reply
>
> 2008/2/6, Torsten Foertsch :
> >
> > On Wed 06 Feb 2008, titetluc titetluc wrote:
> > > The module I am developing has to delete the cookie if it is not
> > refreshed
> > > regularly.
> > > The question: how can I manage this timeout inactivity ?
> > > The best solution would be to use a mechanism where callbacks
> > (deleting the
> > > cookie rfom the database) would be called automatically on inactivity.
> > > Does such an API is proposed by :
> > > . the APR API
> > > . mod_perl API
> > > . an Apache2::xxx perl module
> > > . a CPAN module
> > >
> > > If not, how can I solve my problem ? (I could verify regularly in the
> > DB
> > > storage, but this is a last resort solution. Even in this case, how
> > could I
> > > implement it ?)
> >
> >
> > Apache (at least 2.2.x) implements a "monitor" hook, see
> > server/mpm_common.c.
> > To use this hook you'd have to write a bit XS stuff like Geoff's
> > AuthenHook, ... since there is AFAIK no CPAN module. This hook is run
> > from
> > time to time in the parent apache.
> >
> > Otherwise there are 2 standard ways to do that:
> >
> > - a cron job or something similar in the DB itself
> > - check each time in a connection cleanup handler (to do it not too
> > often you
> > can use a global variable that holds the timestamp of the last cleanup
> > and
> > run it only if the difference to the current time grows too big.)
>
>
I am using the Apache::Session module to manage ... sessions.
Apache::Session does not manage session expiration
I found the following comment on the CPAN rating on Apache::Session module (
http://cpanratings.perl.org/dist/Apache-Session)
Quotation:

"There is no support for temporary session keys. I'd like to be able to set
a key that expires in X minutes. This can be handled by writing your own
wrapper that sets a special session key, but it would be nice to be in the
API somewhere.

I've since switched my site over to using Data::Uniqid for session ID
generation and Cache::FileCache for storing temporary form data.
Data::Uniqid assures me that the ID it generates is very unique, so I don't
have to store every session in my database. And FileCache has the expiration
support I need for holding temporary form data."

I am not sure this will solve my problem, but I think this is also a good

I'd go for one of the standard ways since:
> >
> > - easier to implement
> > - your code doesn't run as root
>
>
>
>
> > One naive question: how can I declare a global variable under mod_perl ?
> > Each request is run with a thread and by default Perl does not share
> > variables !
> > I declared my variable as shared (using the threads::shared module) but
> > this declaration does not seem to be sufficient in a mod_perl
> environment
> > !!!
>
> I meant something like this:
>
> package My::Cleanup;
>
> use strict;
> use Apache2::Const -compile=>('OK', 'DECLINED');
> use Apache2::RequestRec ();
> use Apache2::Connection ();
> use APR::Pool ();
>
> my $lastrun=0; # this is the global variable: one per process
>


my $check_interval=60; #check every minute
>
> sub run {
> my $time=time;
> if( $time>$lastrun+$check_interval ) {
> $lastrun=$time;
> # here you can check the modification time ((stat)[9]) of a file on
> disk
> # flock() it with LOCK_NB set and return if flock fails.
> # alternatively you can implement an interface to apr_proc_mutex which
> is
> # quite easy, see ThreadMutex for example.
> # or you implement $lastrun in your database.
> # or you use BerkeleyDB which is actually shared memory.
>
> # doit
> ...
> }
> return Apache2:Const::OK;
> }
>
> sub handler {
> my ($r)=@_;
> unless( $r->connection->pnotes->{cleanup_installed} ) {
> $r->connection->pool->cleanup_register(\&run);
> $r->connection->pnotes->{cleanup_installed}=1;
> }
> return Apache2::Const::DECLINED;
> }
>
> Then:
>
> # install it either as PerlPostReadRequestHandler or as
> # PerlHeaderParserHandler
> PerlInitHandler My::Cleanup
>
> I'd implement the process global variable as shown plus perhaps another
> variable in the database if the session is stored there. It depends on how
> expensive your cleanup is.
>
> Torsten
>
> Torsten
> >
>
>

------=_Part_2927_27315578.1202400571907
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hello all,



2008/2/6, titetluc titetluc <>:

Oups
I answered directly to Torsten by error
Here is my answer and the reply

2008/2/6, Torsten Foertsch <>:


On Wed 06 Feb 2008, titetluc titetluc wrote:
> The module I am developing has to delete the cookie if it is not refreshed
> regularly.
> The question: how can I manage this timeout inactivity ?
> The best solution would be to use a mechanism where callbacks (deleting the


> cookie rfom the database) would be called automatically on inactivity.
> Does such an API is proposed by :
>      . the APR API
>      . mod_perl API
>      . an Apache2::xxx perl module


>      . a CPAN module
>
> If not, how can I solve my problem ? (I could verify regularly in the DB
> storage, but this is a last resort solution. Even in this case, how could I
> implement it ?)




Apache (at least 2.2.x) implements a "monitor" hook, see server/mpm_common.c.
To use this hook you'd have to write a bit XS stuff like Geoff's
AuthenHook, ... since there is AFAIK no CPAN module. This hook is run from


time to time in the parent apache.

Otherwise there are 2 standard ways to do that:

- a cron job or something similar in the DB itself
- check each time in a connection cleanup handler (to do it not too often you


can use a global variable that holds the timestamp of the last cleanup and
run it only if the difference to the current time grows too big.)

I am using the Apache::Session module to manage  ... sessions. Apache::Session does not manage session expiration

I found the following comment on the CPAN rating on Apache::Session module ()
Quotation:

"There is no support for temporary session keys. I'd like to be able to
set a key that expires in X minutes. This can be handled by writing
your own wrapper that sets a special session key, but it would be nice
to be in the API somewhere.



I've since switched my site over to using Data::Uniqid for session
ID generation and Cache::FileCache for storing temporary form data.
Data::Uniqid assures me that the ID it generates is very unique, so I
don't have to store every session in my database. And FileCache has the
expiration support I need for holding temporary form data."

I am not sure this will solve my problem, but I think this is also a good


I'd go for one of the standard ways since:


- easier to implement

- your code doesn't run as root

 

> One naive question: how can I declare a global variable under mod_perl ?


> Each request is run with a thread and by default Perl does not share

> variables !

> I declared my variable as shared (using the threads::shared module) but

> this declaration does not seem to be sufficient in a mod_perl environment

> !!!



I meant something like this:



package My::Cleanup;



use strict;

use Apache2::Const -compile=>('OK', 'DECLINED');

use Apache2::RequestRec ();

use Apache2::Connection ();

use APR::Pool ();



my $lastrun=0;         # this is the global variable: one per process
 



my $check_interval=60; #check every minute



sub run {

 my $time=time;

 if( $time>$lastrun+$check_interval ) {

   $lastrun=$time;

   # here you can check the modification time ((stat)[9]) of a file on disk

   # flock() it with LOCK_NB set and return if flock fails.

   # alternatively you can implement an interface to apr_proc_mutex which is

   # quite easy, see ThreadMutex for example.

   # or you implement $lastrun in your database.

   # or you use BerkeleyDB which is actually shared memory.



   # doit

   ...

 }

 return Apache2:Const::OK;

}



sub handler {

 my ($r)=@_;

 unless( $r->connection->pnotes->{cleanup_installed} ) {

   $r->connection->pool->cleanup_register(\&run);

   $r->connection->pnotes->{cleanup_installed}=1;

 }

 return Apache2::Const::DECLINED;

}



Then:



# install it either as PerlPostReadRequestHandler or as

# PerlHeaderParserHandler

PerlInitHandler My::Cleanup



I'd implement the process global variable as shown plus perhaps another

variable in the database if the session is stored there. It depends on how

expensive your cleanup is.



Torsten


Torsten





------=_Part_2927_27315578.1202400571907--

Re: [MP2][QUESTION]Session and inactivity

am 07.02.2008 20:41:00 von Perrin Harkins

On Feb 7, 2008 11:09 AM, titetluc titetluc wrote:
> I am using the Apache::Session module to manage ... sessions.
> Apache::Session does not manage session expiration

Sure, it's a building block. You build the expiration part on top of
it. Either you use a timestamp column in your database or you update
a timestamp in the session data. Then you check that to see if too
much time has passed.

You can certainly build it on something else, like CHI (the new cache
module interface). Or look at Apache::SessionManager or mod_auth_tkt
for built-in support.

- Perrin

Re: [MP2][QUESTION]Session and inactivity

am 08.02.2008 22:39:27 von jonathan vanasco

On Feb 7, 2008, at 2:41 PM, Perrin Harkins wrote:

> Sure, it's a building block. You build the expiration part on top of
> it. Either you use a timestamp column in your database or you update
> a timestamp in the session data. Then you check that to see if too
> much time has passed.
>
> You can certainly build it on something else, like CHI (the new cache
> module interface). Or look at Apache::SessionManager or mod_auth_tkt
> for built-in support.


I do the timestamp trick..

you overload apache::session to add a 'last accessed' timestamp

then you do one of 2 things:

a- write a daemon/cronjob/@job to clear old sessions
b- have your apache module run a session-clear every 1hr or so
( storing last-cleared on a file or memcache )

it's easy to do.

Re: [MP2][QUESTION]Session and inactivity

am 11.02.2008 17:10:29 von titetluc

------=_Part_7966_15647234.1202746229172
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

2008/2/8, Jonathan Vanasco :
>
>
> On Feb 7, 2008, at 2:41 PM, Perrin Harkins wrote:
>
> > Sure, it's a building block. You build the expiration part on top of
> > it. Either you use a timestamp column in your database or you update
> > a timestamp in the session data. Then you check that to see if too
> > much time has passed.
> >
> > You can certainly build it on something else, like CHI (the new cache
> > module interface). Or look at Apache::SessionManager or mod_auth_tkt
> > for built-in support.
>
>
>
> I do the timestamp trick..
>
> you overload apache::session to add a 'last accessed' timestamp
>
> then you do one of 2 things:
>
> a- write a daemon/cronjob/@job to clear old sessions
> b- have your apache module run a session-clear every 1hr or so
> ( storing last-cleared on a file or memcache )
>
> it's easy to do.
>

Thanks to everybody.

From your previous answers, I conclude that there is no way to suppress a
session automagically by using the mod_perl API (unless using XS to
implement a "monitor" hook -proposed in Apache 2.2 native API by Torsten).
The only way to suppress sessions is to use a pooling mechanism.

Again thanks a lot.

Gaetan

------=_Part_7966_15647234.1202746229172
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline



2008/2/8, Jonathan Vanasco <>:


On Feb 7, 2008, at 2:41 PM, Perrin Harkins wrote:

> Sure, it's a building block.  You build the expiration part on top of
> it.  Either you use a timestamp column in your database or you update

> a timestamp in the session data.  Then you check that to see if too
> much time has passed.
>
> You can certainly build it on something else, like CHI (the new cache
> module interface).  Or look at Apache::SessionManager or mod_auth_tkt

> for built-in support.



I do the timestamp trick..

you overload apache::session to add a 'last accessed' timestamp

then you do one of 2 things:

        a- write a daemon/cronjob/@job to clear old sessions

        b- have your apache module run a session-clear every 1hr or so
( storing last-cleared on a file or memcache )

it's easy to do.

Thanks to everybody.

From your previous answers, I conclude that there is no way to suppress a session automagically by using the mod_perl API (unless using XS to implement a "monitor" hook -proposed in Apache 2.2 native API by Torsten).

The only way to suppress sessions is to use a pooling mechanism.

Again thanks a lot.

Gaetan



------=_Part_7966_15647234.1202746229172--

Re: [MP2][QUESTION]Session and inactivity

am 11.02.2008 20:58:06 von Perrin Harkins

On Feb 11, 2008 11:10 AM, titetluc titetluc wrote:
> From your previous answers, I conclude that there is no way to suppress a
> session automagically by using the mod_perl API (unless using XS to
> implement a "monitor" hook -proposed in Apache 2.2 native API by Torsten).

Sessions are not part of the mod_perl (or apache) API at all, so
working with them will always be a separate thing. I think there were
some pretty good tools pointed out though, and hopefully one of them
suits your needs. You can always install custom code at various
phases of the request to validate a user's credentials and take action
based on them.

> The only way to suppress sessions is to use a pooling mechanism.

I don't know what you mean by "pooling" here.

- Perrin

Re: [MP2][QUESTION]Session and inactivity

am 13.02.2008 08:03:53 von titetluc

------=_Part_6098_26415771.1202886233296
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

2008/2/11, Perrin Harkins :
>
> On Feb 11, 2008 11:10 AM, titetluc titetluc wrote:
> > From your previous answers, I conclude that there is no way to suppress
> a
> > session automagically by using the mod_perl API (unless using XS to
> > implement a "monitor" hook -proposed in Apache 2.2 native API by
> Torsten).
>
>
> Sessions are not part of the mod_perl (or apache) API at all, so
> working with them will always be a separate thing. I think there were
> some pretty good tools pointed out though, and hopefully one of them
> suits your needs. You can always install custom code at various
> phases of the request to validate a user's credentials and take action
> based on them.
>
>
> > The only way to suppress sessions is to use a pooling mechanism.
>
>
> I don't know what you mean by "pooling" here.


OK, pooling is maybe a franglais (mix of French and English) term


By pooling, I mean the fact that expired sessionS have to be REGULARLY purge
(in opposed to a callback mechanism (IMHO, the best solution ). This
callback would be called on ONE session expiration and would suppress it.
You would not have any purge latency with such a solution).

Gaetan

- Perrin
>

------=_Part_6098_26415771.1202886233296
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline



2008/2/11, Perrin Harkins <>:

On Feb 11, 2008 11:10 AM, titetluc titetluc <> wrote:
> From your previous answers, I conclude that there is no way to suppress a
> session automagically by using the mod_perl API (unless using XS to

> implement a "monitor" hook -proposed in Apache 2.2 native API by Torsten).


Sessions are not part of the mod_perl (or apache) API at all, so
working with them will always be a separate thing.  I think there were

some pretty good tools pointed out though, and hopefully one of them
suits your needs.  You can always install custom code at various
phases of the request to validate a user's credentials and take action

based on them.


>  The only way to suppress sessions is to use a pooling mechanism.


I don't know what you mean by "pooling" here.

OK, pooling is maybe a franglais (mix of French and English) term



By pooling, I mean the fact that expired sessionS have to be REGULARLY purge (in opposed to a callback mechanism (IMHO,  the best solution ). This callback would be called on ONE session expiration and would suppress it. You would not have any purge latency with such a solution).


Gaetan

- Perrin



------=_Part_6098_26415771.1202886233296--

Re: [MP2][QUESTION]Session and inactivity

am 13.02.2008 10:17:43 von aw

titetluc titetluc wrote:
>
> OK, pooling is maybe a franglais (mix of French and English) term
>
>
> By pooling, I mean the fact that expired sessionS have to be REGULARLY purge
> (in opposed to a callback mechanism (IMHO, the best solution ). This
> callback would be called on ONE session expiration and would suppress it.
> You would not have any purge latency with such a solution).
>
Polling ?
pool : a group of things or persons among which you can choose (or a big
hole with liquid in it, but that's something else)

poll : an election (you ask several people something, and collect the
answers). By extension : from time to time, you check a list of sessions
if there is any expired one, to clean it up.

(s) André (just another Franglais speaker)

MP1 -> MP2 migration Problems.

am 13.02.2008 15:09:44 von Roman.Petry

Hello @all,

we are just transfering our Intranet Server which used Apache 1.3 and mod_p=
erl1 from SLES8 to SLES10 wiht Apache2 and mod_perl2.

The switch has to go quick and we can=B4t redesign all of our old mp1 progr=
ams to mp2, so we try to use the compat module. But I have no luck with it.=
=20
I tested my config with SELS10, Opensuse 10.3 and Ubuntu but i hit everytim=
e the same problem.
I searched the Mail Archvie and the Documentation, but no luck.

I have the following test script.Very simple.

test1.pl
#!/usr/bin/perl
my $r =3D Apache->request();
$r->send_http_header('text/plain');
$r->print("mod_perl rules!\n");

apache2 config looks like this.=20

ScriptAlias /perl/ /usr/lib/cgi-bin/

# mod_perl mode
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI


and

root@lamp:/etc/apache2/conf.d# cat perl.conf
PerlRequire "/etc/apache2/mod_perl-startup.pl"

and mod_perl-startup.pl looks like this

root@lamp:/etc/apache2# cat mod_perl-startup.pl
# This file is a placeholder; you can safely ignore or delete it.
print "startup perl dh";
use lib '/usr/lib/perl5/';

# enable if the mod_perl 1.0 compatibility is needed
use Apache2::compat ();


I get the following output..

Software error:
Can't locate object method "request" via package "Apache" at /usr/lib/cgi-b=
in/test1.pl line 4.
For help, please send mail to the webmaster (webmaster@localhost), giving t=
his error message and the time and date of the error.=20

It seems, he can=B4t find the requested methods.. How can i validate that t=
he compat module is loaded and working ?


if i print the @env array with this perl script i get.
#!/usr/bin/perl -w
use strict;
use CGI::Carp qw(fatalsToBrowser);

print "Content-type: text/html\n\n";
print '', "\=
n";
print "env array\n";
print "

Umgebungsvariablen:

\n";
print "\n";
print "",
"\n";
foreach(keys(%ENV)) {
print "\n";
}
print "\n";
print "
varnamevalue
$_$ENV{$_}
sum: =
",
scalar keys(%ENV)," envarray
\n";
print "\n";

here the output...

MOD_PERL_API_VERSION 2
PATH /usr/local/bin:/usr/bin:/bin
REQUEST_URI /perl/env.pl
GATEWAY_INTERFACE CGI/1.1
SERVER_ADDR 172.31.127.193
DOCUMENT_ROOT /var/www/html
HTTP_HOST 172.31.127.193
MOD_PERL mod_perl/2.0.2

so i think mod_perl2 is enabled.

Any help would be great.
bye
Roman

--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Re: [MP2][QUESTION]Session and inactivity

am 13.02.2008 16:04:54 von Perrin Harkins

On Feb 13, 2008 2:03 AM, titetluc titetluc wrote:
> By pooling, I mean the fact that expired sessionS have to be REGULARLY purge
> (in opposed to a callback mechanism (IMHO, the best solution ). This
> callback would be called on ONE session expiration and would suppress it.
> You would not have any purge latency with such a solution).

There were multiple suggestions that worked through the sort of
callback solution you describe: mod_auth_tkt, CHI, storing a timestamp
in the session (as opposed to in a separate column in the sessions
database table), Apache::SessionManager...

- Perrin

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 17:46:22 von Jim Brandt

You might try it without the parens:

use Apache2::compat;


Petry Roman, IT wrote:
> Hello @all,
>
> we are just transfering our Intranet Server which used Apache 1.3 and mod_perl1 from SLES8 to SLES10 wiht Apache2 and mod_perl2.
>
> The switch has to go quick and we can´t redesign all of our old mp1 programs to mp2, so we try to use the compat module. But I have no luck with it.
> I tested my config with SELS10, Opensuse 10.3 and Ubuntu but i hit everytime the same problem.
> I searched the Mail Archvie and the Documentation, but no luck.
>
> I have the following test script.Very simple.
>
> test1.pl
> #!/usr/bin/perl
> my $r = Apache->request();
> $r->send_http_header('text/plain');
> $r->print("mod_perl rules!\n");
>
> apache2 config looks like this.
>
> ScriptAlias /perl/ /usr/lib/cgi-bin/
>
> # mod_perl mode
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> PerlOptions +ParseHeaders
> Options +ExecCGI
>

>
> and
>
> root@lamp:/etc/apache2/conf.d# cat perl.conf
> PerlRequire "/etc/apache2/mod_perl-startup.pl"
>
> and mod_perl-startup.pl looks like this
>
> root@lamp:/etc/apache2# cat mod_perl-startup.pl
> # This file is a placeholder; you can safely ignore or delete it.
> print "startup perl dh";
> use lib '/usr/lib/perl5/';
>
> # enable if the mod_perl 1.0 compatibility is needed
> use Apache2::compat ();
>
>
> I get the following output..
>
> Software error:
> Can't locate object method "request" via package "Apache" at /usr/lib/cgi-bin/test1.pl line 4.
> For help, please send mail to the webmaster (webmaster@localhost), giving this error message and the time and date of the error.
>
> It seems, he can´t find the requested methods.. How can i validate that the compat module is loaded and working ?
>
>
> if i print the @env array with this perl script i get.
> #!/usr/bin/perl -w
> use strict;
> use CGI::Carp qw(fatalsToBrowser);
>
> print "Content-type: text/html\n\n";
> print '', "\n";
> print "env array\n";
> print "

Umgebungsvariablen:

\n";
> print "\n";
> print "",
> "\n";
> foreach(keys(%ENV)) {
> print "\n";
> }
> print "\n";
> print "
varnamevalue
$_$ENV{$_}
sum: ",
> scalar keys(%ENV)," envarray
\n";
> print "\n";
>
> here the output...
>
> MOD_PERL_API_VERSION 2
> PATH /usr/local/bin:/usr/bin:/bin
> REQUEST_URI /perl/env.pl
> GATEWAY_INTERFACE CGI/1.1
> SERVER_ADDR 172.31.127.193
> DOCUMENT_ROOT /var/www/html
> HTTP_HOST 172.31.127.193
> MOD_PERL mod_perl/2.0.2
>
> so i think mod_perl2 is enabled.
>
> Any help would be great.
> bye
> Roman
>

--
Jim Brandt
Administrative Computing Services
University at Buffalo

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 17:54:58 von Randy Kobes

On Wed, 13 Feb 2008, Petry Roman, IT wrote:

> Hello @all,
>
> we are just transfering our Intranet Server which used
> Apache 1.3 and mod_perl1 from SLES8 to SLES10 wiht Apache2
> and mod_perl2.

There's a couple of documents:
http://perl.apache.org/docs/2.0/user/porting/porting.html
http://perl.apache.org/docs/2.0/user/porting/compat.html
that may help in this regard.

--
best regards,
Randy Kobes

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 18:02:15 von Roman.Petry

Hello Jim,
thanks for fast answer, but i still get this erros in the error file of apa=
che, afteri have replaced the parens.

[Wed Feb 13 18:02:04 2008] [error] Can't locate object method "request" via=
package "Apache" at /usr/lib/cgi-bin/test1.pl line 4.\n

-----Ursprüngliche Nachricht-----
Von: Jim Brandt [mailto:cbrandt@buffalo.edu]
Gesendet: Mittwoch, 13. Februar 2008 17:46
An: Petry Roman, IT
Cc: modperl@perl.apache.org
Betreff: Re: MP1 -> MP2 migration Problems.


You might try it without the parens:

use Apache2::compat;


Petry Roman, IT wrote:
> Hello @all,
>=20
> we are just transfering our Intranet Server which used Apache 1.3 and mod=
_perl1 from SLES8 to SLES10 wiht Apache2 and mod_perl2.
>=20
> The switch has to go quick and we can=B4t redesign all of our old mp1 pro=
grams to mp2, so we try to use the compat module. But I have no luck with i=
t.=20
> I tested my config with SELS10, Opensuse 10.3 and Ubuntu but i hit everyt=
ime the same problem.
> I searched the Mail Archvie and the Documentation, but no luck.
>=20
> I have the following test script.Very simple.
>=20
> test1.pl
> #!/usr/bin/perl
> my $r =3D Apache->request();
> $r->send_http_header('text/plain');
> $r->print("mod_perl rules!\n");
>=20
> apache2 config looks like this.=20
>=20
> ScriptAlias /perl/ /usr/lib/cgi-bin/
>
> # mod_perl mode
> SetHandler perl-script
> PerlResponseHandler ModPerl::Registry
> PerlOptions +ParseHeaders
> Options +ExecCGI
>

>=20
> and
>=20
> root@lamp:/etc/apache2/conf.d# cat perl.conf
> PerlRequire "/etc/apache2/mod_perl-startup.pl"
>=20
> and mod_perl-startup.pl looks like this
>=20
> root@lamp:/etc/apache2# cat mod_perl-startup.pl
> # This file is a placeholder; you can safely ignore or delete it.
> print "startup perl dh";
> use lib '/usr/lib/perl5/';
>=20
> # enable if the mod_perl 1.0 compatibility is needed
> use Apache2::compat ();
>=20
>=20
> I get the following output..
>=20
> Software error:
> Can't locate object method "request" via package "Apache" at /usr/lib/cgi=
-bin/test1.pl line 4.
> For help, please send mail to the webmaster (webmaster@localhost), giving=
this error message and the time and date of the error.=20
>=20
> It seems, he can=B4t find the requested methods.. How can i validate that=
the compat module is loaded and working ?
>=20
>=20
> if i print the @env array with this perl script i get.
> #!/usr/bin/perl -w
> use strict;
> use CGI::Carp qw(fatalsToBrowser);
>=20
> print "Content-type: text/html\n\n";
> print '', =
"\n";
> print "env array\n";
> print "

Umgebungsvariablen:

\n";
> print "\n";
> print "",
> "\n";
> foreach(keys(%ENV)) {
> print "\n";
> }
> print "\n";
> print "
varnamevalue
$_$ENV{$_}
sum=
: ",
> scalar keys(%ENV)," envarray
\n";
> print "\n";
>=20
> here the output...
>=20
> MOD_PERL_API_VERSION 2
> PATH /usr/local/bin:/usr/bin:/bin
> REQUEST_URI /perl/env.pl
> GATEWAY_INTERFACE CGI/1.1
> SERVER_ADDR 172.31.127.193
> DOCUMENT_ROOT /var/www/html
> HTTP_HOST 172.31.127.193
> MOD_PERL mod_perl/2.0.2
>=20
> so i think mod_perl2 is enabled.
>=20
> Any help would be great.
> bye
> Roman
>=20

--=20
Jim Brandt
Administrative Computing Services
University at Buffalo


--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

AW: MP1 -> MP2 migration Problems.

am 13.02.2008 18:04:25 von Roman.Petry

Hello Randy,

i did read those documents again and again, but i can=B4t find the cause of=
my problems with the compat module 8-(..
If i try the new mod_perl2 syntax everything is o.k.. but to redesign all s=
cripts is not an solution at this time. i need backward compatibility with =
mod_perl1 at this time..
Sorry it=B4s not my decision.

Another tip 8-)
bye
ROman

-----Ursprüngliche Nachricht-----
Von: Randy Kobes [mailto:randy@theoryx5.uwinnipeg.ca]
Gesendet: Mittwoch, 13. Februar 2008 17:55
An: Petry Roman, IT
Cc: modperl@perl.apache.org
Betreff: Re: MP1 -> MP2 migration Problems.


On Wed, 13 Feb 2008, Petry Roman, IT wrote:

> Hello @all,
>
> we are just transfering our Intranet Server which used=20
> Apache 1.3 and mod_perl1 from SLES8 to SLES10 wiht Apache2=20
> and mod_perl2.

There's a couple of documents:
http://perl.apache.org/docs/2.0/user/porting/porting.html
http://perl.apache.org/docs/2.0/user/porting/compat.html
that may help in this regard.

--=20
best regards,
Randy Kobes

--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 20:47:20 von Perrin Harkins

On Feb 13, 2008 9:09 AM, Petry Roman, IT wrote:
> Can't locate object method "request" via package "Apache" at /usr/lib/cgi-bin/test1.pl line 4.

If Apache2::compat is loaded, it should create that namespace. Dump
%INC from your script and see if Apache.pm is in it.

- Perrin

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 21:08:01 von Roman.Petry

Hello Perrin, thanks for this hint.. here comes the output..

Lodded modules in %INC:
re.pm=09
APR/Const.pm=09
File/Spec/Functions.pm=09
Apache2/URI.pm=09
APR/Status.pm=09
warnings.pm=09
Apache2/Connection.pm=09
Apache2/XSLoader.pm=09
Apache2/Util.pm=09
Fcntl.pm=09
Symbol.pm=09
Exporter.pm=09
ModPerl/RegistryCooker.pm=09
Apache2/Response.pm=09
File/Spec.pm=09
Apache2/Const.pm=09
Apache2/ServerUtil.pm=09
APR/Date.pm=09
ModPerl/Global.pm=09
mod_perl.pm=09
warnings/register.pm=09
XSLoader.pm=09
APR/Bucket.pm=09
/etc/apache2/mod_perl-startup.pl=09
Apache2/SubRequest.pm=09
Apache2/Log.pm=09
ModPerl/Const.pm=09
Apache/Table.pm=09
Apache2/Filter.pm=09
APR/URI.pm=09
base.pm=09
APR/Util.pm=09
File/Basename.pm=09
Config.pm=09
Apache2/RequestRec.pm=09
ModPerl/Util.pm=09
APR/Pool.pm=09
mod_perl2.pm=09
Carp.pm=09
File/Spec/Unix.pm=09
Apache2/RequestUtil.pm=09
APR.pm=09
Apache.pm=09
strict.pm=09
vars.pm=09
CGI/Carp.pm=09
constant.pm=09
APR/XSLoader.pm=09
Apache2/compat.pm=09
Apache2/ServerRec.pm=09
Apache2/Access.pm=09
Apache/Constants.pm=09
APR/Brigade.pm=09
AutoLoader.pm=09
Apache2/Module.pm=09
lib.pm=09
ModPerl/Registry.pm=09
DynaLoader.pm=09
Apache2/RequestIO.pm=09
Apache/File.pm=09
APR/Table.pm=09
sum: 61=20

Looks ok i think. Apache.pm is loaded.. So why can=B4t i get it to work.. d=
amn thing 8-).
bye
roman
-----Ursprüngliche Nachricht-----
Von: pharkins@gmail.com [mailto:pharkins@gmail.com]Im Auftrag von Perrin
Harkins
Gesendet: Mittwoch, 13. Februar 2008 20:47
An: Petry Roman, IT
Cc: modperl@perl.apache.org
Betreff: Re: MP1 -> MP2 migration Problems.


On Feb 13, 2008 9:09 AM, Petry Roman, IT wrote:
> Can't locate object method "request" via package "Apache" at /usr/lib/cgi=
-bin/test1.pl line 4.

If Apache2::compat is loaded, it should create that namespace. Dump
%INC from your script and see if Apache.pm is in it.

- Perrin

--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 22:49:43 von aw

Hi.

About your problem below...

I am not sure that this is going to help, nor even if it is really
relevant to your specific problem. Just trying to give you ideas,
because it reminds me of something.
Below are two configurations, of two of our systems which have slightly
different versions of mod_perl and the rest.
I went through the same kind of problems you're going through, a while
ago when going from Apache 1.x to Apache 2.x, and then again more
recently when there were some changes in the mod_perl naming of modules
between mod_perl 1.9xx and mod_perl 2.0, and then some additional things
happened during a Linux Debian upgrade from Sarge to Etch, which changed
the location where some Apache2 stuff was installed.
And there is still some difference to this day in some Perl scripts or
modules between these two systems, which greatly bothers me, but it
basically works.

The main difference is in the two first "use" statements in our
"startup.pl" script (which I assume you are familiar with, as a way to
pre-load some perl stuff when the server starts).
I do not remember precisely which problems we had, but they were of the
same "general gist" as yours, so maybe this helps.
Here it goes :

1) system "colin" (Debian Sarge, older)
=================
version (uname -a) :
Linux colin 2.6.8-11-amd64-k8 #1 Sun Oct 2 21:26:54 UTC 2005 x86_64
GNU/Linux
Apache2 version : see below
Perl version (perl -v) : 5.8.4
mod_perl version (per Apache log) :
[Wed Feb 13 22:24:59 2008] [notice] Apache/2.0.54 (Debian GNU/Linux)
DAV/2 mod_jk/1.2.6 PHP/4.3.10-22 mod_perl/1.999.21 Perl/v5.8.4
configured -- resuming normal operations

mod_perl "startup.pl" script : (invoked via "PerlRequire" in httpd config)
------------------------------

#!/usr/bin/perl
# modperl2_startup.pl
# Apache2 / mod_perl 2 startup script

use Apache2 ();
use Apache::compat ();
use lib "/usr/lib/apache2/perllib"; # that's a local perl lib directory
use lib "/home/EFS/lib"; # that also
use ModPerl::Util ();
use Apache::RequestRec ();
use Apache::RequestIO ();
use Apache::RequestUtil ();
use Apache::Filter ();
use Apache::ServerUtil ();
use Apache::Connection ();
use Apache::Log ();
use Apache::Const -compile => qw(:common :log REDIRECT);
use APR::Const -compile => ':common';
use APR::Table ();
use ModPerl::Registry ();
use CGI ();
CGI->compile(':all');
1;

lines in httpd.conf :
(or, rather, in /etc/apache2/mods-available/perl.conf) :
PerlRequire "/usr/lib/apache2/perllib/modperl2_startup.pl"
SetEnv PERL5LIB "/usr/lib/apache2/perllib"




2) system "arthur" (Debian Etch, more recent)
==================
version (uname -a) :
Linux arthur 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 GNU/Linux

Apache2 version : see below
Perl version (perl -v) : 5.8.8
mod_perl version (per Apache log) :
[Wed Feb 13 22:29:38 2008] [notice] Apache/2.2.3 (Debian) DAV/2
mod_jk/1.2.18 PHP/4.4.4-8+etch4 mod_ssl/2.2.3 OpenSSL/0.9.8c
mod_perl/2.0.2 Perl/v5.8.8 configured -- resuming normal operations

mod_perl "startup.pl" script :
------------------------------

#!/usr/bin/perl
# modperl2_startup.pl
# Apache2 / mod_perl 2 startup script

use Bundle::Apache2 ();
use Apache2::compat ();
use lib "/usr/local/lib/apache2/perllib"; # that's a local perl lib
directory
use lib "/home/EFS/lib"; # that also
use ModPerl::Util ();
use Apache2::RequestRec ();
use Apache2::RequestIO ();
use Apache2::RequestUtil ();
use Apache2::Filter ();
use Apache2::ServerUtil ();
use Apache2::Connection ();
use Apache2::Log ();
use Apache2::Const -compile => qw(:common :log REDIRECT);
use APR::Const -compile => ':common';
use APR::Table ();
use ModPerl::Registry ();
use CGI ();
CGI->compile(':all');
1;

lines in httpd.conf :
(or, rather, in /etc/apache2/mods-available/perl.conf) :
PerlRequire "/usr/local/lib/apache2/perllib/modperl2_startup.pl"
SetEnv PERL5LIB "/usr/local/lib/apache2/perllib"




Petry Roman, IT wrote:
> Hello Perrin, thanks for this hint.. here comes the output..
>
> Lodded modules in %INC:
> re.pm
> APR/Const.pm
> File/Spec/Functions.pm
> Apache2/URI.pm
> APR/Status.pm
> warnings.pm
> Apache2/Connection.pm
> Apache2/XSLoader.pm
> Apache2/Util.pm
> Fcntl.pm
> Symbol.pm
> Exporter.pm
> ModPerl/RegistryCooker.pm
> Apache2/Response.pm
> File/Spec.pm
> Apache2/Const.pm
> Apache2/ServerUtil.pm
> APR/Date.pm
> ModPerl/Global.pm
> mod_perl.pm
> warnings/register.pm
> XSLoader.pm
> APR/Bucket.pm
> /etc/apache2/mod_perl-startup.pl
> Apache2/SubRequest.pm
> Apache2/Log.pm
> ModPerl/Const.pm
> Apache/Table.pm
> Apache2/Filter.pm
> APR/URI.pm
> base.pm
> APR/Util.pm
> File/Basename.pm
> Config.pm
> Apache2/RequestRec.pm
> ModPerl/Util.pm
> APR/Pool.pm
> mod_perl2.pm
> Carp.pm
> File/Spec/Unix.pm
> Apache2/RequestUtil.pm
> APR.pm
> Apache.pm
> strict.pm
> vars.pm
> CGI/Carp.pm
> constant.pm
> APR/XSLoader.pm
> Apache2/compat.pm
> Apache2/ServerRec.pm
> Apache2/Access.pm
> Apache/Constants.pm
> APR/Brigade.pm
> AutoLoader.pm
> Apache2/Module.pm
> lib.pm
> ModPerl/Registry.pm
> DynaLoader.pm
> Apache2/RequestIO.pm
> Apache/File.pm
> APR/Table.pm
> sum: 61
>
> Looks ok i think. Apache.pm is loaded.. So why can´t i get it to work.. damn thing 8-).
> bye
> roman
> -----Ursprüngliche Nachricht-----
> Von: pharkins@gmail.com [mailto:pharkins@gmail.com]Im Auftrag von Perrin
> Harkins
> Gesendet: Mittwoch, 13. Februar 2008 20:47
> An: Petry Roman, IT
> Cc: modperl@perl.apache.org
> Betreff: Re: MP1 -> MP2 migration Problems.
>
>
> On Feb 13, 2008 9:09 AM, Petry Roman, IT wrote:
>> Can't locate object method "request" via package "Apache" at /usr/lib/cgi-bin/test1.pl line 4.
>
> If Apache2::compat is loaded, it should create that namespace. Dump
> %INC from your script and see if Apache.pm is in it.
>
> - Perrin
>

Re: MP1 -> MP2 migration Problems.

am 13.02.2008 23:00:56 von aw

Of course, what I forgot to mention below - and sorry if you know that
already - is that whichever perl modules you pre-load in your main
Apache server config via the startup.pl script, you do not need to "use"
anymore in all your perl scripts or Apache/mod_perl handlers.
(At the cost of having them (insibly) duplicated in all the children
processes).
But it may simplify your migration problems, and you can always tune
this later.

André

André Warnier wrote:
>
> Hi.
>
> About your problem below...
>
> I am not sure that this is going to help, nor even if it is really
> relevant to your specific problem. Just trying to give you ideas,
> because it reminds me of something.
> Below are two configurations, of two of our systems which have slightly
> different versions of mod_perl and the rest.
> I went through the same kind of problems you're going through, a while
> ago when going from Apache 1.x to Apache 2.x, and then again more
> recently when there were some changes in the mod_perl naming of modules
> between mod_perl 1.9xx and mod_perl 2.0, and then some additional things
> happened during a Linux Debian upgrade from Sarge to Etch, which changed
> the location where some Apache2 stuff was installed.
> And there is still some difference to this day in some Perl scripts or
> modules between these two systems, which greatly bothers me, but it
> basically works.
>
> The main difference is in the two first "use" statements in our
> "startup.pl" script (which I assume you are familiar with, as a way to
> pre-load some perl stuff when the server starts).
> I do not remember precisely which problems we had, but they were of the
> same "general gist" as yours, so maybe this helps.
> Here it goes :
>
> 1) system "colin" (Debian Sarge, older)
> =================
> version (uname -a) :
> Linux colin 2.6.8-11-amd64-k8 #1 Sun Oct 2 21:26:54 UTC 2005 x86_64
> GNU/Linux
> Apache2 version : see below
> Perl version (perl -v) : 5.8.4
> mod_perl version (per Apache log) :
> [Wed Feb 13 22:24:59 2008] [notice] Apache/2.0.54 (Debian GNU/Linux)
> DAV/2 mod_jk/1.2.6 PHP/4.3.10-22 mod_perl/1.999.21 Perl/v5.8.4
> configured -- resuming normal operations
>
> mod_perl "startup.pl" script : (invoked via "PerlRequire" in httpd config)
> ------------------------------
>
> #!/usr/bin/perl
> # modperl2_startup.pl
> # Apache2 / mod_perl 2 startup script
>
> use Apache2 ();
> use Apache::compat ();
> use lib "/usr/lib/apache2/perllib"; # that's a local perl lib directory
> use lib "/home/EFS/lib"; # that also
> use ModPerl::Util ();
> use Apache::RequestRec ();
> use Apache::RequestIO ();
> use Apache::RequestUtil ();
> use Apache::Filter ();
> use Apache::ServerUtil ();
> use Apache::Connection ();
> use Apache::Log ();
> use Apache::Const -compile => qw(:common :log REDIRECT);
> use APR::Const -compile => ':common';
> use APR::Table ();
> use ModPerl::Registry ();
> use CGI ();
> CGI->compile(':all');
> 1;
>
> lines in httpd.conf :
> (or, rather, in /etc/apache2/mods-available/perl.conf) :
> PerlRequire "/usr/lib/apache2/perllib/modperl2_startup.pl"
> SetEnv PERL5LIB "/usr/lib/apache2/perllib"
>
>
>
>
> 2) system "arthur" (Debian Etch, more recent)
> ==================
> version (uname -a) :
> Linux arthur 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 GNU/Linux
>
> Apache2 version : see below
> Perl version (perl -v) : 5.8.8
> mod_perl version (per Apache log) :
> [Wed Feb 13 22:29:38 2008] [notice] Apache/2.2.3 (Debian) DAV/2
> mod_jk/1.2.18 PHP/4.4.4-8+etch4 mod_ssl/2.2.3 OpenSSL/0.9.8c
> mod_perl/2.0.2 Perl/v5.8.8 configured -- resuming normal operations
>
> mod_perl "startup.pl" script :
> ------------------------------
>
> #!/usr/bin/perl
> # modperl2_startup.pl
> # Apache2 / mod_perl 2 startup script
>
> use Bundle::Apache2 ();
> use Apache2::compat ();
> use lib "/usr/local/lib/apache2/perllib"; # that's a local perl lib
> directory
> use lib "/home/EFS/lib"; # that also
> use ModPerl::Util ();
> use Apache2::RequestRec ();
> use Apache2::RequestIO ();
> use Apache2::RequestUtil ();
> use Apache2::Filter ();
> use Apache2::ServerUtil ();
> use Apache2::Connection ();
> use Apache2::Log ();
> use Apache2::Const -compile => qw(:common :log REDIRECT);
> use APR::Const -compile => ':common';
> use APR::Table ();
> use ModPerl::Registry ();
> use CGI ();
> CGI->compile(':all');
> 1;
>
> lines in httpd.conf :
> (or, rather, in /etc/apache2/mods-available/perl.conf) :
> PerlRequire "/usr/local/lib/apache2/perllib/modperl2_startup.pl"
> SetEnv PERL5LIB "/usr/local/lib/apache2/perllib"
>
>
>
>
> Petry Roman, IT wrote:
>> Hello Perrin, thanks for this hint.. here comes the output..
>>
>> Lodded modules in %INC:
>> re.pm
>> APR/Const.pm
>> File/Spec/Functions.pm
>> Apache2/URI.pm
>> APR/Status.pm
>> warnings.pm
>> Apache2/Connection.pm
>> Apache2/XSLoader.pm
>> Apache2/Util.pm
>> Fcntl.pm
>> Symbol.pm
>> Exporter.pm
>> ModPerl/RegistryCooker.pm
>> Apache2/Response.pm
>> File/Spec.pm
>> Apache2/Const.pm
>> Apache2/ServerUtil.pm
>> APR/Date.pm
>> ModPerl/Global.pm
>> mod_perl.pm
>> warnings/register.pm
>> XSLoader.pm
>> APR/Bucket.pm
>> /etc/apache2/mod_perl-startup.pl
>> Apache2/SubRequest.pm
>> Apache2/Log.pm
>> ModPerl/Const.pm
>> Apache/Table.pm
>> Apache2/Filter.pm
>> APR/URI.pm
>> base.pm
>> APR/Util.pm
>> File/Basename.pm
>> Config.pm
>> Apache2/RequestRec.pm
>> ModPerl/Util.pm
>> APR/Pool.pm
>> mod_perl2.pm
>> Carp.pm
>> File/Spec/Unix.pm
>> Apache2/RequestUtil.pm
>> APR.pm
>> Apache.pm
>> strict.pm
>> vars.pm
>> CGI/Carp.pm
>> constant.pm
>> APR/XSLoader.pm
>> Apache2/compat.pm
>> Apache2/ServerRec.pm
>> Apache2/Access.pm
>> Apache/Constants.pm
>> APR/Brigade.pm
>> AutoLoader.pm
>> Apache2/Module.pm
>> lib.pm
>> ModPerl/Registry.pm
>> DynaLoader.pm
>> Apache2/RequestIO.pm
>> Apache/File.pm
>> APR/Table.pm
>> sum: 61
>> Looks ok i think. Apache.pm is loaded.. So why can´t i get it to
>> work.. damn thing 8-).
>> bye
>> roman
>> -----Ursprüngliche Nachricht-----
>> Von: pharkins@gmail.com [mailto:pharkins@gmail.com]Im Auftrag von Perrin
>> Harkins
>> Gesendet: Mittwoch, 13. Februar 2008 20:47
>> An: Petry Roman, IT
>> Cc: modperl@perl.apache.org
>> Betreff: Re: MP1 -> MP2 migration Problems.
>>
>>
>> On Feb 13, 2008 9:09 AM, Petry Roman, IT
>> wrote:
>>> Can't locate object method "request" via package "Apache" at
>>> /usr/lib/cgi-bin/test1.pl line 4.
>>
>> If Apache2::compat is loaded, it should create that namespace. Dump
>> %INC from your script and see if Apache.pm is in it.
>>
>> - Perrin
>>
>

Re: [MP2][QUESTION]Session and inactivity

am 14.02.2008 08:01:17 von titetluc

------=_Part_12930_3794033.1202972477474
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

2008/2/13, Perrin Harkins :
>
> On Feb 13, 2008 2:03 AM, titetluc titetluc wrote:
> > By pooling, I mean the fact that expired sessionS have to be REGULARLY
> purge
> > (in opposed to a callback mechanism (IMHO, the best solution ). This
> > callback would be called on ONE session expiration and would suppress
> it.
> > You would not have any purge latency with such a solution).
>
>
> There were multiple suggestions that worked through the sort of
> callback solution you describe: mod_auth_tkt, CHI, storing a timestamp
> in the session (as opposed to in a separate column in the sessions
> database table), Apache::SessionManager...


All of these modules propose an expiration mechanism, but they do not
propose a mechanism to automatically destroy session at expiration (this is
what I call a "callback" mechanism).
This implies that the session destruction has to be called explicitly.

We could imagine an interface where a callback is defined when a session is
created

For example,
session_create(inactivity => 30, callback => sub{print "Session
automagically destroyed";})

There would be no need to call a session_delete function !!

Gaetan

- Perrin
>

------=_Part_12930_3794033.1202972477474
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline



2008/2/13, Perrin Harkins <>:

On Feb 13, 2008 2:03 AM, titetluc titetluc <> wrote:
> By pooling, I mean the fact that expired sessionS have to be REGULARLY purge
> (in opposed to a callback mechanism (IMHO,  the best solution ). This

> callback would be called on ONE session expiration and would suppress it.
> You would not have any purge latency with such a solution).


There were multiple suggestions that worked through the sort of

callback solution you describe: mod_auth_tkt, CHI, storing a timestamp
in the session (as opposed to in a separate column in the sessions
database table), Apache::SessionManager...

All of these modules propose an expiration mechanism, but they do not propose a mechanism to automatically destroy session at expiration (this is what I call a "callback" mechanism).

This implies that the session destruction has to be called explicitly.

We could imagine an interface where a callback is defined when a session is created

For example,
session_create(inactivity => 30, callback => sub{print "Session automagically destroyed";})


There would be no need to call a session_delete function !!

Gaetan

- Perrin




------=_Part_12930_3794033.1202972477474--

AW: MP1 -> MP2 migration Problems.

am 14.02.2008 14:38:50 von Roman.Petry

Hello again,

i did a new setup of our Apache and mod_perl2 with your hint=B4s.. Configur=
ed again some startup.pl stuff. but no luck 8-)

Error is still the same in error.log from apache.

[Thu Feb 14 14:33:58 2008] [error] [Thu Feb 14 14:33:58 2008] -e: Can't loc=
ate object method "request" via package "Apache" at /usr/lib/cgi-bin/test1.=
pl line 4.\n

Code looks like this for test1.pl
#!/usr/bin/perl
my $r =3D Apache->request;
$r->send_http_header('text/plain');
$r->print("mod_perl rules!\n");

Hmm. Is someone able to use this code under apache2 with compat enabled. Pe=
rhaps it is broken in some ways ?

bye
Roman


-----Ursprüngliche Nachricht-----
Von: Andr=E9 Warnier [mailto:aw@ice-sa.com]
Gesendet: Mittwoch, 13. Februar 2008 23:01
An: modperl@perl.apache.org
Cc: Petry Roman, IT
Betreff: Re: MP1 -> MP2 migration Problems.


Of course, what I forgot to mention below - and sorry if you know that=20
already - is that whichever perl modules you pre-load in your main=20
Apache server config via the startup.pl script, you do not need to "use"=20
anymore in all your perl scripts or Apache/mod_perl handlers.
(At the cost of having them (insibly) duplicated in all the children=20
processes).
But it may simplify your migration problems, and you can always tune=20
this later.

Andr=E9

Andr=E9 Warnier wrote:
>=20
> Hi.
>=20
> About your problem below...
>=20
> I am not sure that this is going to help, nor even if it is really=20
> relevant to your specific problem. Just trying to give you ideas,=20
> because it reminds me of something.
> Below are two configurations, of two of our systems which have slightly=
=20
> different versions of mod_perl and the rest.
> I went through the same kind of problems you're going through, a while=20
> ago when going from Apache 1.x to Apache 2.x, and then again more=20
> recently when there were some changes in the mod_perl naming of modules=
=20
> between mod_perl 1.9xx and mod_perl 2.0, and then some additional things=
=20
> happened during a Linux Debian upgrade from Sarge to Etch, which changed=
=20
> the location where some Apache2 stuff was installed.
> And there is still some difference to this day in some Perl scripts or=20
> modules between these two systems, which greatly bothers me, but it=20
> basically works.
>=20
> The main difference is in the two first "use" statements in our=20
> "startup.pl" script (which I assume you are familiar with, as a way to=20
> pre-load some perl stuff when the server starts).
> I do not remember precisely which problems we had, but they were of the=
=20
> same "general gist" as yours, so maybe this helps.
> Here it goes :
>=20
> 1) system "colin" (Debian Sarge, older)
> =================3D
> version (uname -a) :
> Linux colin 2.6.8-11-amd64-k8 #1 Sun Oct 2 21:26:54 UTC 2005 x86_64=20
> GNU/Linux
> Apache2 version : see below
> Perl version (perl -v) : 5.8.4
> mod_perl version (per Apache log) :
> [Wed Feb 13 22:24:59 2008] [notice] Apache/2.0.54 (Debian GNU/Linux)=20
> DAV/2 mod_jk/1.2.6 PHP/4.3.10-22 mod_perl/1.999.21 Perl/v5.8.4=20
> configured -- resuming normal operations
>=20
> mod_perl "startup.pl" script : (invoked via "PerlRequire" in httpd confi=
g)
> ------------------------------
>=20
> #!/usr/bin/perl
> # modperl2_startup.pl
> # Apache2 / mod_perl 2 startup script
>=20
> use Apache2 ();
> use Apache::compat ();
> use lib "/usr/lib/apache2/perllib"; # that's a local perl lib directo=
ry
> use lib "/home/EFS/lib"; # that also
> use ModPerl::Util ();
> use Apache::RequestRec ();
> use Apache::RequestIO ();
> use Apache::RequestUtil ();
> use Apache::Filter ();
> use Apache::ServerUtil ();
> use Apache::Connection ();
> use Apache::Log ();
> use Apache::Const -compile =3D> qw(:common :log REDIRECT);
> use APR::Const -compile =3D> ':common';
> use APR::Table ();
> use ModPerl::Registry ();
> use CGI ();
> CGI->compile(':all');
> 1;
>=20
> lines in httpd.conf :
> (or, rather, in /etc/apache2/mods-available/perl.conf) :
> PerlRequire "/usr/lib/apache2/perllib/modperl2_startup.pl"
> SetEnv PERL5LIB "/usr/lib/apache2/perllib"
>=20
>=20
>=20
>=20
> 2) system "arthur" (Debian Etch, more recent)
> ==================
> version (uname -a) :
> Linux arthur 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 UTC 2007 i686 GNU/Lin=
ux
>=20
> Apache2 version : see below
> Perl version (perl -v) : 5.8.8
> mod_perl version (per Apache log) :
> [Wed Feb 13 22:29:38 2008] [notice] Apache/2.2.3 (Debian) DAV/2=20
> mod_jk/1.2.18 PHP/4.4.4-8+etch4 mod_ssl/2.2.3 OpenSSL/0.9.8c=20
> mod_perl/2.0.2 Perl/v5.8.8 configured -- resuming normal operations
>=20
> mod_perl "startup.pl" script :
> ------------------------------
>=20
> #!/usr/bin/perl
> # modperl2_startup.pl
> # Apache2 / mod_perl 2 startup script
>=20
> use Bundle::Apache2 ();
> use Apache2::compat ();
> use lib "/usr/local/lib/apache2/perllib"; # that's a local perl lib=20
> directory
> use lib "/home/EFS/lib"; # that also
> use ModPerl::Util ();
> use Apache2::RequestRec ();
> use Apache2::RequestIO ();
> use Apache2::RequestUtil ();
> use Apache2::Filter ();
> use Apache2::ServerUtil ();
> use Apache2::Connection ();
> use Apache2::Log ();
> use Apache2::Const -compile =3D> qw(:common :log REDIRECT);
> use APR::Const -compile =3D> ':common';
> use APR::Table ();
> use ModPerl::Registry ();
> use CGI ();
> CGI->compile(':all');
> 1;
>=20
> lines in httpd.conf :
> (or, rather, in /etc/apache2/mods-available/perl.conf) :
> PerlRequire "/usr/local/lib/apache2/perllib/modperl2_startup.pl"
> SetEnv PERL5LIB "/usr/local/lib/apache2/perllib"
>=20
>=20
>=20
>=20
> Petry Roman, IT wrote:
>> Hello Perrin, thanks for this hint.. here comes the output..
>>
>> Lodded modules in %INC:
>> re.pm =20
>> APR/Const.pm =20
>> File/Spec/Functions.pm =20
>> Apache2/URI.pm =20
>> APR/Status.pm =20
>> warnings.pm =20
>> Apache2/Connection.pm =20
>> Apache2/XSLoader.pm =20
>> Apache2/Util.pm =20
>> Fcntl.pm =20
>> Symbol.pm =20
>> Exporter.pm =20
>> ModPerl/RegistryCooker.pm =20
>> Apache2/Response.pm =20
>> File/Spec.pm =20
>> Apache2/Const.pm =20
>> Apache2/ServerUtil.pm =20
>> APR/Date.pm =20
>> ModPerl/Global.pm =20
>> mod_perl.pm =20
>> warnings/register.pm =20
>> XSLoader.pm =20
>> APR/Bucket.pm =20
>> /etc/apache2/mod_perl-startup.pl =20
>> Apache2/SubRequest.pm =20
>> Apache2/Log.pm =20
>> ModPerl/Const.pm =20
>> Apache/Table.pm =20
>> Apache2/Filter.pm =20
>> APR/URI.pm =20
>> base.pm =20
>> APR/Util.pm =20
>> File/Basename.pm =20
>> Config.pm =20
>> Apache2/RequestRec.pm =20
>> ModPerl/Util.pm =20
>> APR/Pool.pm =20
>> mod_perl2.pm =20
>> Carp.pm =20
>> File/Spec/Unix.pm =20
>> Apache2/RequestUtil.pm =20
>> APR.pm =20
>> Apache.pm =20
>> strict.pm =20
>> vars.pm =20
>> CGI/Carp.pm =20
>> constant.pm =20
>> APR/XSLoader.pm =20
>> Apache2/compat.pm =20
>> Apache2/ServerRec.pm =20
>> Apache2/Access.pm =20
>> Apache/Constants.pm =20
>> APR/Brigade.pm =20
>> AutoLoader.pm =20
>> Apache2/Module.pm =20
>> lib.pm =20
>> ModPerl/Registry.pm =20
>> DynaLoader.pm =20
>> Apache2/RequestIO.pm =20
>> Apache/File.pm =20
>> APR/Table.pm =20
>> sum: 61
>> Looks ok i think. Apache.pm is loaded.. So why can=B4t i get it to=20
>> work.. damn thing 8-).
>> bye
>> roman
>> -----Ursprüngliche Nachricht-----
>> Von: pharkins@gmail.com [mailto:pharkins@gmail.com]Im Auftrag von Perrin
>> Harkins
>> Gesendet: Mittwoch, 13. Februar 2008 20:47
>> An: Petry Roman, IT
>> Cc: modperl@perl.apache.org
>> Betreff: Re: MP1 -> MP2 migration Problems.
>>
>>
>> On Feb 13, 2008 9:09 AM, Petry Roman, IT =20
>> wrote:
>>> Can't locate object method "request" via package "Apache" at=20
>>> /usr/lib/cgi-bin/test1.pl line 4.
>>
>> If Apache2::compat is loaded, it should create that namespace. Dump
>> %INC from your script and see if Apache.pm is in it.
>>
>> - Perrin
>>
>=20

--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Re: MP1 -> MP2 migration Problems.

am 14.02.2008 15:13:41 von Rafael Caceres

Andre,

On Wed, 2008-02-13 at 23:00 +0100, André Warnier wrote:
> Of course, what I forgot to mention below - and sorry if you know that
> already - is that whichever perl modules you pre-load in your main
> Apache server config via the startup.pl script, you do not need to "use"
> anymore in all your perl scripts or Apache/mod_perl handlers.
This is the first time that NOT using "use" because it was preloaded is
mentioned. In fact, how would the modules compile (while testing for
example)?

> (At the cost of having them (insibly) duplicated in all the children
> processes).
Again, this is the first time this is mentioned. It would mean that, say
10 or 20 scripts under mod_perl using DBI,DBD::Oracle,CGI and Template
would have the effect of using up to 20 times the memory footprint?
Wasn't preloading suposed to do the exact opposite?

I'm at a loss here

> But it may simplify your migration problems, and you can always tune
> this later.
>
> André
>
Regards,
Rafael Caceres

Re: [MP2][QUESTION]Session and inactivity

am 14.02.2008 16:38:35 von Perrin Harkins

On Thu, Feb 14, 2008 at 2:01 AM, titetluc titetluc wrote:
> All of these modules propose an expiration mechanism, but they do not
> propose a mechanism to automatically destroy session at expiration (this is
> what I call a "callback" mechanism).
> This implies that the session destruction has to be called explicitly.

No, mod_auth_tkt simply uses cookies so there is nothing to destroy,
CHI will automatically stop returning expired data,
Apache::SessionManager will automatically stop returning expired
sessions. No explicit checks are required. The only suggestion that
requires you to check if a session is expired is storing a timestamp
in a session yourself.

> For example,
> session_create(inactivity => 30, callback => sub{print "Session
> automagically destroyed";})
>
> There would be no need to call a session_delete function !!

What is it that you're concerned about here? Do you have code that
you need to run when a session expires? Or are you just worried about
running out of disk space?

- Perrin

Re: MP1 -> MP2 migration Problems.

am 14.02.2008 16:45:50 von Malcolm J Harwood

On Thursday 14 February 2008 09:13:41 am Rafael Caceres wrote:

> On Wed, 2008-02-13 at 23:00 +0100, André Warnier wrote:
> > Of course, what I forgot to mention below - and sorry if you know that
> > already - is that whichever perl modules you pre-load in your main
> > Apache server config via the startup.pl script, you do not need to "use"
> > anymore in all your perl scripts or Apache/mod_perl handlers.
>
> This is the first time that NOT using "use" because it was preloaded is
> mentioned. In fact, how would the modules compile (while testing for
> example)?

You can just call "import" on the modules rather than "use", but that doesn=
't=20
gain you a whole lot.

> > (At the cost of having them (insibly) duplicated in all the children
> > processes).

> Again, this is the first time this is mentioned. It would mean that, say
> 10 or 20 scripts under mod_perl using DBI,DBD::Oracle,CGI and Template
> would have the effect of using up to 20 times the memory footprint?
> Wasn't preloading suposed to do the exact opposite?

Preloading avoids the duplication (at least as far as copy-on-write=20
allows). "use"ing multiple times doesn't load multiple copies, it just=20
imports the symbols to the local namespace.

I'm not sure what led Andre to believe otherwise. (Andre, can you explain?)

Re: MP1 -> MP2 migration Problems.

am 14.02.2008 16:51:22 von Perrin Harkins

On Thu, Feb 14, 2008 at 9:13 AM, Rafael Caceres wrote:
> This is the first time that NOT using "use" because it was preloaded is
> mentioned. In fact, how would the modules compile (while testing for
> example)?

Modules loaded into the perl interpreter at startup are still there
when the process forks, so technically you don't have to ask for them
again. I still recommend that you use() them in every module that
needs them, for testing and for documentation.

> > (At the cost of having them (insibly) duplicated in all the children
> > processes).
> Again, this is the first time this is mentioned. It would mean that, say
> 10 or 20 scripts under mod_perl using DBI,DBD::Oracle,CGI and Template
> would have the effect of using up to 20 times the memory footprint?
> Wasn't preloading suposed to do the exact opposite?

I think that was just a wording mistake. When the process forks, the
loaded modules are shared by the operating system's copy-on-write
feature. I believe that's what he was trying to say.

- Perrin

Re: [MP2][QUESTION]Session and inactivity

am 14.02.2008 20:59:20 von jonathan vanasco

On Feb 14, 2008, at 2:01 AM, titetluc titetluc wrote:
> There were multiple suggestions that worked through the sort of
> callback solution you describe: mod_auth_tkt, CHI, storing a timestamp
> in the session (as opposed to in a separate column in the sessions
> database table), Apache::SessionManager...
>
> All of these modules propose an expiration mechanism, but they do
> not propose a mechanism to automatically destroy session at
> expiration (this is what I call a "callback" mechanism).
> This implies that the session destruction has to be called explicitly.
>
> We could imagine an interface where a callback is defined when a
> session is created
>
> For example,
> session_create(inactivity => 30, callback => sub{print "Session
> automagically destroyed";})
>
> There would be no need to call a session_delete function !!

when you're creating a callback function like that, you're specifying
the expiration... which means you're requiring some sort of polling
service to continually check the timing ( OLL, not OOL )

none of the perl modules do this, because something of that sort is
application or framework specific -- and will depend heavily on your
session datastore setup and parameters.

there might be something like that built into a framework like
catalyst... but callback functions and stuff like that are more of a
'framework' style feature, and not a module feature -- as they
require a bit of customization AND some sort of polling mechanism.
your inactivity notion requires some mechanism to constantly poll the
session store every second, looking for items newly ready for
deletion. frameworks that offer that, for example Twisted Python,
use a 'reactor' style daemon that has a subprocess that polls the db
for expiration time. however -- no systems i've seen expires
automatically, they all batch delete items that are past-expiration
at regular intervals. the intervals are either realized through an
internal timer on the daemon, or they use a hook every request to see
if it is time yet to empty the cache. This is considered a feature -
you dont want to waste CPU on deleting sessions every second.

if you were to take the combined advice of people on this list, you
could have a trivial solution that meets your goals.
i. create a session_create function, instantiate sessions with it.
have it specify a 'session inactivity' time and last acessed time.
a. db store
table: session
cols: session_id , inactivity , last_accessed , data
b. kv ( memcached ) store
table: session
cols: session_id , data
table: session_activity
cols session_id , timestamp_active + session->data->inactivity time
ii. overload the session access/saving mechanism to update the
last_accessed time
iii. create a polling standalone script, or some internal method
that expires the 'deletion ready' sessions at intervals, using some
sort of hook

the exact system that you described however is impossible under
mod_perl , which is request based ( a perl interpreter embedded under
apache).
you could do it with an event driven framework like poe ( http://
poe.perl.org ) or perlbal ( http://www.danga.com/perlbal/ ) , which
daemonize and will allow you to make time-based polling processes.
you could also use mod_perl for the request processing, and write a
session expiry system in an event driven framework ( or even use cron/
at jobs to trigger shell scripts )


// Jonathan Vanasco

w. http://findmeon.com/user/jvanasco
e. jonathan@findmeon.com

| Founder/CEO - FindMeOn, Inc.
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Privacy Minded Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - -

Re: MP1 -> MP2 migration Problems.

am 14.02.2008 21:01:09 von Perrin Harkins

On Wed, Feb 13, 2008 at 3:08 PM, Petry Roman, IT
wrote:
> Looks ok i think. Apache.pm is loaded.. So why can=B4t i get it to work.=
.. damn thing 8-).

This is starting to look like a bug in Apache2::compat to me. I think
request() is defined in the wrong namespace. I'll try to make a patch
for you to try.

Do you actually use the Apache->request() call? In a Registry script,
you can get $r just by calling shift at the beginning of the program.

- Perrin

Re: MP1 -> MP2 migration Problems.

am 14.02.2008 21:56:23 von Randy Kobes

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

---2071011042-691387405-1203022583=:9404
Content-Type: TEXT/PLAIN; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Thu, 14 Feb 2008, Perrin Harkins wrote:

> On Wed, Feb 13, 2008 at 3:08 PM, Petry Roman, IT
> wrote:
>> Looks ok i think. Apache.pm is loaded.. So why can=B4t i get it to work=
. damn thing 8-).
>
> This is starting to look like a bug in Apache2::compat to me. I think
> request() is defined in the wrong namespace. I'll try to make a patch
> for you to try.

Does the attached patch work (untested)?

> Do you actually use the Apache->request() call? In a Registry script,
> you can get $r just by calling shift at the beginning of the program.

That's a good point.

--=20
best regards,
Randy Kobes
---2071011042-691387405-1203022583=:9404
Content-Type: TEXT/PLAIN; charset=US-ASCII; name=compat.diff
Content-Transfer-Encoding: BASE64
Content-ID:
Content-Description:
Content-Disposition: attachment; filename=compat.diff

SW5kZXg6IGxpYi9BcGFjaGUyL2NvbXBhdC5wbQ0KPT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PQ0KLS0tIGxpYi9BcGFjaGUyL2NvbXBhdC5wbQkocmV2aXNpb24g
NjI3ODYzKQ0KKysrIGxpYi9BcGFjaGUyL2NvbXBhdC5wbQkod29ya2luZyBj
b3B5KQ0KQEAgLTI3OSwyMCArMjc5LDYgQEANCiAgICAgfQ0KIH0NCiANCi1z
dWIgcmVxdWVzdCB7DQotICAgIG15ICR3aGF0ID0gc2hpZnQ7DQotDQotICAg
IG15ICRyID0gQXBhY2hlMjo6UmVxdWVzdFV0aWwtPnJlcXVlc3Q7DQotDQot
ICAgIHVubGVzcyAoJHIpIHsNCi0gICAgICAgIGRpZSAiY2Fubm90IHVzZSAk
d2hhdCAiLA0KLSAgICAgICAgICAgICJ3aXRob3V0ICdTZXRIYW5kbGVyIHBl
cmwtc2NyaXB0JyAiLA0KLSAgICAgICAgICAgICJvciAnUGVybE9wdGlvbnMg
K0dsb2JhbFJlcXVlc3QnIjsNCi0gICAgfQ0KLQ0KLSAgICAkcjsNCi19DQot
DQogew0KICAgICBteSAkb3JpZ19zdWIgPSAqQXBhY2hlMjo6TW9kdWxlOjp0
b3BfbW9kdWxle0NPREV9Ow0KICAgICAqQXBhY2hlMjo6TW9kdWxlOjp0b3Bf
bW9kdWxlID0gc3ViIHsNCkBAIC0zMjEsNiArMzA3LDIwIEBADQogDQogcGFj
a2FnZSBBcGFjaGU7DQogDQorc3ViIHJlcXVlc3Qgew0KKyAgICBteSAkd2hh
dCA9IHNoaWZ0Ow0KKw0KKyAgICBteSAkciA9IEFwYWNoZTI6OlJlcXVlc3RV
dGlsLT5yZXF1ZXN0Ow0KKw0KKyAgICB1bmxlc3MgKCRyKSB7DQorICAgICAg
ICBkaWUgImNhbm5vdCB1c2UgJHdoYXQgIiwNCisgICAgICAgICAgICAid2l0
aG91dCAnU2V0SGFuZGxlciBwZXJsLXNjcmlwdCcgIiwNCisgICAgICAgICAg
ICAib3IgJ1BlcmxPcHRpb25zICtHbG9iYWxSZXF1ZXN0JyI7DQorICAgIH0N
CisNCisgICAgJHI7DQorfQ0KKw0KIHN1YiB1bmVzY2FwZV91cmxfaW5mbyB7
DQogICAgIG15ICgkY2xhc3MsICRzdHJpbmcpID0gQF87DQogICAgIEFwYWNo
ZTI6OlVSSTo6dW5lc2NhcGVfdXJsKCRzdHJpbmcpOw0K

---2071011042-691387405-1203022583=:9404--

RE: MP1 -> MP2 migration Problems.

am 15.02.2008 09:37:03 von Roman.Petry

Hello Randy, Hello Perrin,

8-) thanks a lot for your help. I tried to apply the patch , but my compat.=
pm is a little bit different to the source patch i think.
but no problem. i did a manual patch and only applied the namespace row.

package Apache;

in front ot the=20
sub request {

line

nothing more, nothing less .. and it WORKS 8-)..

Will try with our "normal" modperl scripts now, but my test.pl script works.

thanks again for your help .. and now you have a new patch for the next rel=
ease 8-)

bye
Roman
-----Ursprüngliche Nachricht-----
Von: Randy Kobes [mailto:randy@theoryx5.uwinnipeg.ca]
Gesendet: Donnerstag, 14. Februar 2008 21:56
An: Perrin Harkins
Cc: Petry Roman, IT; modperl@perl.apache.org
Betreff: Re: MP1 -> MP2 migration Problems.


On Thu, 14 Feb 2008, Perrin Harkins wrote:

> On Wed, Feb 13, 2008 at 3:08 PM, Petry Roman, IT
> wrote:
>> Looks ok i think. Apache.pm is loaded.. So why can=B4t i get it to work=
... damn thing 8-).
>
> This is starting to look like a bug in Apache2::compat to me. I think
> request() is defined in the wrong namespace. I'll try to make a patch
> for you to try.

Does the attached patch work (untested)?

> Do you actually use the Apache->request() call? In a Registry script,
> you can get $r just by calling shift at the beginning of the program.

That's a good point.

--=20
best regards,
Randy Kobes
--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.


--=20
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Re: MP1 -> MP2 migration Problems.

am 18.02.2008 10:40:55 von aw

Perrin Harkins wrote:
> On Thu, Feb 14, 2008 at 9:13 AM, Rafael Caceres wrote:
>> This is the first time that NOT using "use" because it was preloaded is
>> mentioned. In fact, how would the modules compile (while testing for
>> example)?
>
> Modules loaded into the perl interpreter at startup are still there
> when the process forks, so technically you don't have to ask for them
> again. I still recommend that you use() them in every module that
> needs them, for testing and for documentation.
>
>> > (At the cost of having them (insibly) duplicated in all the children
>> > processes).
>> Again, this is the first time this is mentioned. It would mean that, say
>> 10 or 20 scripts under mod_perl using DBI,DBD::Oracle,CGI and Template
>> would have the effect of using up to 20 times the memory footprint?
>> Wasn't preloading suposed to do the exact opposite?
>
> I think that was just a wording mistake. When the process forks, the
> loaded modules are shared by the operating system's copy-on-write
> feature. I believe that's what he was trying to say.
>
> - Perrin
>
Well, it was not exactly what I was trying to say, but undoubtedly this
reflects my incomplete personal understanding of the process anyway, and
I stand ready to be educated.

What I have until now believed is that perl "code" is in fact "data" for
the perl interpreter, and that as such it cannot really be "shared".
What I mean is that, as soon as some bit is changed in a "page" of any
perl module, that "page" is dirty and must be copied and made private to
the one child process. And since there is (in my understanding) not such
a clear separation as to which parts in "perl code" are data and which
are code, after a while one ends up with a full duplicate in each child
anyway. Probably badly explained, but not so in the general sense ?

- André

P.S. What I really meant originally, is that if the speed to make it
work was of the essence, it might be easier to (find/grep) and remove
the various use Apache-x() from the multiple modules or cgi scripts, and
put them all in the startup script. Then later one could go back and
refine things, if it makes a difference.

Re: MP1 -> MP2 migration Problems.

am 18.02.2008 20:55:03 von Perrin Harkins

On Feb 18, 2008 4:40 AM, Andr=E9 Warnier wrote:
> What I have until now believed is that perl "code" is in fact "data" for
> the perl interpreter, and that as such it cannot really be "shared".
> What I mean is that, as soon as some bit is changed in a "page" of any
> perl module, that "page" is dirty and must be copied and made private to
> the one child process. And since there is (in my understanding) not such
> a clear separation as to which parts in "perl code" are data and which
> are code, after a while one ends up with a full duplicate in each child
> anyway. Probably badly explained, but not so in the general sense ?

Your technical understanding is correct, but in practice most pages
remain shared. You can help this by using a tool like
Apache::SizeLimit that kills off processes after a while.

- Perrin