run once at apache stop

2007-03-05 Thread Sergey Borodich
Hi,

I need some technique what work as
PerlRequire (or PerlPostConfigHandler)
at apache start (it run only once)

but I need similar technique for stop apache
it must run if "apache stop" only once

it need for cleanup shared memory before stop, etc

and also desirably for mp1/mp2 both

prompt something please...

-- 
Sergey Borodich
http://bor.org.ua


Re: run once at apache stop

2007-03-05 Thread Torsten Foertsch
On Monday 05 March 2007 12:42, Sergey Borodich wrote:
> I need some technique what work as
> PerlRequire (or PerlPostConfigHandler)
> at apache start (it run only once)
>
> but I need similar technique for stop apache
> it must run if "apache stop" only once
>
> it need for cleanup shared memory before stop, etc
>
> and also desirably for mp1/mp2 both
>
> prompt something please...

1) Create an object and store it in a global variable. Then use the DESTROY 
method to do what you want. That is what Perl::AtEndOfScope does.

2) Another way for mp2: create a cleanup handler APR::Pool::cleanup_register 
for one of the global pools. Apache2::ServerRec::pool or 
Apache2::Process::pool come to mind.

3) And what about a simple END{} block?

Torsten


pgpNkcCNf10nb.pgp
Description: PGP signature


Re: Converting a String of bits into a binary number in perl?

2007-03-05 Thread Steven Lembark



-- Deepak Mallya <[EMAIL PROTECTED]>



Hi,
Can anyone tell me how do I convert a String of bits into a binary
number in Perl

For eg:- $a="100";  I want to convert this into perl's interpretation of
binary no ie $a=0b100


You have to mask the value to 32 bits and then use
"unpack". Issue is that with a string you may have
more than the upper limit of bits, which will lead
to overflows (or having to use BigIntegers ).

One apprach that uses a simpler pack string is

   my @intz = ();

   while( my $bits = substr $bitstring, -32, 32, '' )
   {
   push @intz, pack $pack_format, $bits;
   }

that or

   my $bits = substr $bitstring, -32, 32, '';

   my $int  = $pack_format, $bits;

   carp "Oversize bitstring: '$bitstring' remaining after $int";

Note that the substr and pack options have to be
consistent with the storage on the architecture
you are using (low- or high-endian) or you have
to force the bits into network order before making
the bitstring.


--
Steven Lembark   85-09 90th Street
Workhorse ComputingWoodhaven, NY 11421
[EMAIL PROTECTED] 1 888 359 3508


Re: run once at apache stop

2007-03-05 Thread Sergey Borodich
Torsten Foertsch пишет:
> On Monday 05 March 2007 12:42, Sergey Borodich wrote:
>> I need some technique what work as
>> PerlRequire (or PerlPostConfigHandler)
>> at apache start (it run only once)
>>
>> but I need similar technique for stop apache
>> it must run if "apache stop" only once
>>
>> it need for cleanup shared memory before stop, etc
>>
>> and also desirably for mp1/mp2 both
>>
>> prompt something please...

thanks for answer

> 1) Create an object and store it in a global variable. Then use the DESTROY 
> method to do what you want. That is what Perl::AtEndOfScope does.
it run after each child exit :(

> 2) Another way for mp2: create a cleanup handler APR::Pool::cleanup_register 
> for one of the global pools. Apache2::ServerRec::pool or 
> Apache2::Process::pool come to mind.
thanks for way, I try exploring it
I hope for mp1 something similar good also

> 3) And what about a simple END{} block?
it run after each child exit too :(

I try 1,3 before

I put END(DESTROY) in startup.pl and Lib.pm(loaded from startup)
but result it similar - it run after each apache child exit
tested on mp1(apache1) and mp2(apache2.0)

-- 
Sergey Borodich
http://bor.org.ua



Re: run once at apache stop

2007-03-05 Thread Sergey Borodich
Sergey Borodich пишет:

>> 2) Another way for mp2: create a cleanup handler APR::Pool::cleanup_register 
>> for one of the global pools. Apache2::ServerRec::pool or 
>> Apache2::Process::pool come to mind.
> thanks for way, I try exploring it
> I hope for mp1 something similar good also

thanks again
it is what I need

mp1
http://perl.apache.org/docs/1.0/guide/porting.html#END_blocks
mp2
http://perl.apache.org/docs/2.0/user/porting/compat.html#C__s_E_gt_register_cleanup_

-- 
Sergey Borodich
http://bor.org.ua


Re: mod_perl installation problem

2007-03-05 Thread Anoop kumar V

I think I figured out the exact problem (not the solution)... apache starts
fine when forced to start on the commandline, but fails to start as a
service. SO it is not a problem of the apachemonitor per se.

It is wierd that something stops apache running as a service. Also it does
not write any logs whatsoever, to help troubleshooting!

Anoop

On 3/4/07, Anoop kumar V <[EMAIL PROTECTED]> wrote:


Thank you for the suggestion Randy - but perl had always been in my path.
I think that gets set when perl is installed.

I think I will have to do a manual start / ^C the apache process until the
monitor gets fixed.

Thanks,
Anoop

On 3/3/07, Randy Kobes <[EMAIL PROTECTED]> wrote:
>
> On Fri, 2 Mar 2007, Anoop kumar V wrote:
>
> > Yes - I checked that - without mod_perl enabled, with a vanilla Apache
> > installation (and with weblogic module enabled), the apachemonitor
> starts
> > and stops apache fine. With the mod_perl line: (LoadModule .) in
> > httpd.conf it errors out. If I remove the line it again works
> flawlessly.
> > The thing is this breaks in both the apache versions I mentioned
> above...
> >
> > I am the administrator on this Win XP machine.
> >
> > Its not a big issue - since apache runs fine from the commandline, but
> it
> > would have been great if I could manage from the monitor, else I need
> to
> > keep cmd prompt window open just for this thing...
>
> The only thing I can suggest checking is that you have a
> LoadFile "C:/Path/to/Perl/bin/perl58.dll"
> before loading mod_perl.so, in case Perl isn't in
> your PATH environment variable.
>
> --
> best regards,
> Randy
>



--
Thanks and best regards,
Anoop





--
Thanks and best regards,
Anoop


Re: mod_perl installation problem

2007-03-05 Thread Jeremy Wall
On Monday 05 March 2007 10:26, Anoop kumar V wrote:
> I think I figured out the exact problem (not the solution)... apache starts
> fine when forced to start on the commandline, but fails to start as a
> service. SO it is not a problem of the apachemonitor per se.
>
> It is wierd that something stops apache running as a service. Also it does
> not write any logs whatsoever, to help troubleshooting!
>
What user is Apache running as when run as a service? It sounds like the user 
it runs as does not have perl in it's path or does not have permission to 
read the perl path location.

To check path make sure the the perl is added to the path globally and not 
just for a user.

For the second look at perls installation path and make sure that Apache's 
runas user is able to read the files from there.

> Anoop
>
> On 3/4/07, Anoop kumar V <[EMAIL PROTECTED]> wrote:
> > Thank you for the suggestion Randy - but perl had always been in my path.
> > I think that gets set when perl is installed.
> >
> > I think I will have to do a manual start / ^C the apache process until
> > the monitor gets fixed.
> >
> > Thanks,
> > Anoop
> >
> > On 3/3/07, Randy Kobes <[EMAIL PROTECTED]> wrote:
> > > On Fri, 2 Mar 2007, Anoop kumar V wrote:
> > > > Yes - I checked that - without mod_perl enabled, with a vanilla
> > > > Apache installation (and with weblogic module enabled), the
> > > > apachemonitor
> > >
> > > starts
> > >
> > > > and stops apache fine. With the mod_perl line: (LoadModule .) in
> > > > httpd.conf it errors out. If I remove the line it again works
> > >
> > > flawlessly.
> > >
> > > > The thing is this breaks in both the apache versions I mentioned
> > >
> > > above...
> > >
> > > > I am the administrator on this Win XP machine.
> > > >
> > > > Its not a big issue - since apache runs fine from the commandline,
> > > > but
> > >
> > > it
> > >
> > > > would have been great if I could manage from the monitor, else I need
> > >
> > > to
> > >
> > > > keep cmd prompt window open just for this thing...
> > >
> > > The only thing I can suggest checking is that you have a
> > > LoadFile "C:/Path/to/Perl/bin/perl58.dll"
> > > before loading mod_perl.so, in case Perl isn't in
> > > your PATH environment variable.
> > >
> > > --
> > > best regards,
> > > Randy
> >
> > --
> > Thanks and best regards,
> > Anoop


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Jeremy Wall
On Friday 02 March 2007 23:40, Perrin Harkins wrote:
> On 3/2/07, Jeremy Wall <[EMAIL PROTECTED]> wrote:
> > I'm using a mod_perl response handler for the pages in question.
> > Periodically and with no pattern I can detect a page request will simply
> > timeout.
>
> If you want to know which requests do this, you can use
> mod_log_forensic.

OK I set up forensic logging. I also seperated the OpenSSL requests from the 
non OpenSSL requests in the log files. None of the non SSL requests showed 
any failures in the log. However I'm not sure that is significant since the 
majority of the traffic is SSL on this server and All of the mod_perl traffic 
is SSL.

I get 16 timeouts out of a total of 3402 requests in the forensic log for a 
half day of traffic. Some of the requests are strait pass a file on with no 
logic. Some are dynamic requests with logic. Would posting the contents of 
the forensic Log entries that timed out be of help?

Jeremy Wall


Re: Detecting Unused Variables

2007-03-05 Thread Perrin Harkins

On 2/28/07, Tyler Bird <[EMAIL PROTECTED]> wrote:

I was wondering if there was some way I could run a script and have it
detect all unused variables for me?


No.   You might be able to write a tool to do static analysis on your
code using PPI (from CPAN).  It's what Perl::Critic uses.

- Perrin


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Perrin Harkins

On 3/5/07, Jeremy Wall <[EMAIL PROTECTED]> wrote:

I get 16 timeouts out of a total of 3402 requests in the forensic log for a
half day of traffic. Some of the requests are strait pass a file on with no
logic.


On those, do you have any auth handlers, session activity, etc?  If
there's no mod_perl involved in those at all, you'll have to look at
the other modules that get used in those requests.

- Perrin


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Jeremy Wall
On Monday 05 March 2007 13:35, Perrin Harkins wrote:
> On 3/5/07, Jeremy Wall <[EMAIL PROTECTED]> wrote:
> > I get 16 timeouts out of a total of 3402 requests in the forensic log for
> > a half day of traffic. Some of the requests are strait pass a file on
> > with no logic.
>
> On those, do you have any auth handlers, session activity, etc?  If
> there's no mod_perl involved in those at all, you'll have to look at
> the other modules that get used in those requests.
>
> - Perrin

I'm sorry I didn't communicate that very well. The requests are still handled 
by a response handler. The requests in question however were basically just 
sending an html page or a template with no template tags in them so no logic 
was involved except for validating their login information. I've been over 
that code with a fine tooth comb but nothing seems like it could cause a 
problem. Maybe I just don't know what to look for.

Jeremy Wall


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Perrin Harkins

On 3/5/07, Jeremy Wall <[EMAIL PROTECTED]> wrote:

The requests are still handled
by a response handler. The requests in question however were basically just
sending an html page or a template with no template tags in them so no logic
was involved except for validating their login information.


That sounds like plenty of code is running to me.


I've been over
that code with a fine tooth comb but nothing seems like it could cause a
problem. Maybe I just don't know what to look for.


Look for things that use locking.  Anything that updates a file or a
database row.  In particular, look for things that do this and would
happen on every type of request that you've seen hanging so far.

- Perrin


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Jonathan Vanasco


On Mar 5, 2007, at 3:40 PM, Perrin Harkins wrote:


Look for things that use locking.  Anything that updates a file or a
database row.  In particular, look for things that do this and would
happen on every type of request that you've seen hanging so far.


As a note, you could run into blocks/locks/stalls from foreign keys.

I recently had this code in my system

handle 1-   select * from account where id = 1;
	handle 2- 	update visit set visit_count= visit_count+1 where  
account_id = 1;	# account_id fkeys on account


it took me forever to realize why my system kept locking.  the select  
+ transaction on handle 1 was getting an exclusive lock, and the  
update was queued , trying to do an internal select on the fkey for  
integrity checks


the moral: db lock problems can happen where you least expect them


// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -

| SyndiClick.com
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -

|  FindMeOn.com - The cure for Multiple Web Personality Disorder
|  Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -

|  RoadSound.com - Tools For Bands, Stuff For Fans
|  Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - - - - -





Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Perrin Harkins

On 3/5/07, Jonathan Vanasco <[EMAIL PROTECTED]> wrote:

I recently had this code in my system

handle 1-   select * from account where id = 1;
handle 2-   update visit set visit_count= visit_count+1 where
account_id = 1; # account_id fkeys on account

it took me forever to realize why my system kept locking.  the select
+ transaction on handle 1 was getting an exclusive lock, and the
update was queued , trying to do an internal select on the fkey for
integrity checks


I'm no Postgres expert, but I don't think a SELECT should block an
UPDATE in an MVCC database system unless the first statement is a
SELECT FOR UPDATE or similar.  Maybe if you use an isolation level of
REPEATABLE READ.

- Perrin


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Jeremy Wall
On Monday 05 March 2007 15:08, Jonathan Vanasco wrote:
> On Mar 5, 2007, at 3:40 PM, Perrin Harkins wrote:
> > Look for things that use locking.  Anything that updates a file or a
> > database row.  In particular, look for things that do this and would
> > happen on every type of request that you've seen hanging so far.
>
> As a note, you could run into blocks/locks/stalls from foreign keys.
>
> I recently had this code in my system
>
>   handle 1-   select * from account where id = 1;
>   handle 2-   update visit set visit_count= visit_count+1 where
> account_id = 1;   # account_id fkeys on account
>
> it took me forever to realize why my system kept locking.  the select
> + transaction on handle 1 was getting an exclusive lock, and the
> update was queued , trying to do an internal select on the fkey for
> integrity checks
>
> the moral: db lock problems can happen where you least expect them
>

There is an update that occurs to the session management tables everytime a 
request is made when the user is logged in. I'll take a look at those updates 
maybe something is going on there. Thanks for the insights guys you've been 
very helpful.

>
> // Jonathan Vanasco
>

Jeremy Wall


Re: Apache2.2 - openssl 0.9.8d - modperl 2.03 unpredictable timeouts during requests

2007-03-05 Thread Jonathan Vanasco



On Mar 5, 2007, at 4:16 PM, Perrin Harkins wrote:


I'm no Postgres expert, but I don't think a SELECT should block an
UPDATE in an MVCC database system unless the first statement is a
SELECT FOR UPDATE or similar.  Maybe if you use an isolation level of
REPEATABLE READ.


Yeah.

I think the system was configured to select for update by default.

There were a bunch of fixes possible:
change default isolation level
use the locking db handle for that call
"SELECT FOR SHARE"
migrate the call

i ended up being lazy, and just moved the call a few lines down, so  
no issues would occur for now. not the best fix, but it works and  
frees me some time for other important issues ;)


i also put a request in with rosedb , so that people can "FOR UPDATE"  
or "FOR SHARE" explicitly,  which I would have rather done.  I tried  
to patch things myself, but it started touching so many internals of  
rose that I figured jon would yell at me for submitting a patch  
before asking :)



// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -

| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -

| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -