Re: '' in regex

2002-05-18 Thread Perrin Harkins

Rizwan Majeed wrote:
 I was trying this out : $SomeVar =~ // ;$SomeVar =~ /''/ ;$SomeVar
 =~ /\/ ;none of these works.
 
 Need help

This list is for mod_perl questions.  For beginner Perl questions, you 
should try one of the mailing lists at http://lists.perl.org/ or post 
your question on http://perlmonks.org/.

- Perrin




Re: mod_perl and mod_cgi

2002-05-18 Thread Perrin Harkins

Konstantin Yotov wrote:
 MaxClients 150
 MaxRequestsPerChild 0

You're probably running out of memory and going into swap, which will 
give terrible performance.  MaxClients 150 is really high, and you 
should only set MaxRequestsPerChild to 0 if you're using 
Apache::SizeLimit or Apache::GTopLimit.

There's a lot of information about these settings in the guide at 
http://perl.apache.org/guide/.

- Perrin




Re: Apache::DBI

2002-05-18 Thread Perrin Harkins

Gregory Matthews wrote:
 Does this mean if each user has to use a unique username/password to 
 OPEN the database?

Yes, eaxctly.

 My prog will use the same database:username:password 
 for all connection requests opened with a 
 db_connect($database,$user,$password) call, however, each user will 
 have his/her own unique file/table within this database which requires a 
 unique username/password to access.

So that security is handled by your program, not by the database?  No 
problem for Apache::DBI logins then.

- Perrin




Re: Apache::DBI

2002-05-18 Thread Perrin Harkins

Gregory Matthews wrote:
 Yes, my prog checks for valid username/password requests and issues the 
 proper response. So it sounds like Apache::DBI is a good solution then 
 since all users will be working under the same handle?

Yes, that's correct.




Re: mod_perl and mod_cgi

2002-05-16 Thread Perrin Harkins

Konstantin Yotov wrote:
 On my
 development machine everything was ok, but when I move
 to productional server the mod_perl version works
 twice slower than mod_cgi.

Start by making sure you really have mod_perl installed and your scripts 
are running under it, and not mod_cgi.  You can verify this using the 
instructions in the guide.  One quick way is to check the value of 
$ENV{'MOD_PERL'}.

Also, which platform are you on and what are your settings for 
MaxClients and MaxRequestsPerChild form httpd.conf?

- Perrin




Re: Load Balancing, mod_proxy, rewrite problem

2002-05-14 Thread Perrin Harkins

mire wrote:
 I have code like this:
 
 RewriteEngine On
  
 RewriteLog /var/site/rewrite.log
 RewriteMaplb  prg:/tmp/lb
 
 RewriteRule  ^/trta$  http://${lb:prvi|drugi}  [proxy,last] 
 
 and a perl script (a copy from mod_proxy manual) but it doesn't work, it seems
 like perl script is waiting indeffinetly for input.

Sorry, this is not a mod_perl problem.  You should try the general 
Apache user mailing lists, or see if there's a list or newsgroup for 
mod_rewrite.

- Perrin




Re: Apache::Session

2002-05-09 Thread Perrin Harkins

Stathy G. Touloumis wrote:
You need to do some more debugging.  Problems with Apache::Session are 
usually due to scoping, so put in some debug statements to see that the 
session objects for the IDs having trouble are getting properly cleaned 
up (i.e. DESTROY is getting called).  It is possible to have problems 
with DB_File if it doesn't get untied after each request.
 
 
 Wouldn't the issue above (untie) be alleviated by restarting apache?

Probably.  There are some strange situations you can get into with 
DB_File if you don't untie (due to caching and lost updates), but you're 
right that the file locks would probably make the system hang if the 
session wasn't getting cleaned up.

I don't know what else could be causing your problem, but I would still 
suggest trying Apache::Session::File as a potential fix.

- Perrin




Re: convention on logging?

2002-05-07 Thread Perrin Harkins

F.Xavier Noria wrote:
 I am writing a web application that uses Apache modules and core classes
 in a MVC style.  AFAICT using $r-log-debug() is the standard way to
 print debug messages in Apache modules, but which would be the right way
 to print debug messages in the core classes provided both types of
 modules are going to run together?

You can use Apache-server-log().  If you want your modules to work 
outside of mod_perl, you can write a wrapper class that uses the server 
log when it sees you are in mod_perl and uses something else when you're 
not.  There are several fancy logging modules on CPAN.

- Perrin




Re: Using a 404 ErrorDocument to serve content

2002-05-06 Thread Perrin Harkins

Ken Williams wrote:
 The idea is that I'd put a bunch of JPEGs on the 
 server at locations like foo/123.jpg , and then if a request came for 
 foo/123-medium.jpg , I'd catch that with a 404 ErrorDocument and 
 generate the resized image using Imager.  If I wanted to, I could also 
 create the resized image on disk, so it wouldn't need to be generated 
 next time.

Incidentally, that's how Vignette StoryServer works.  You could also do 
this kind of thing with a transhandler (or mod_rewrite) that checks for 
the existence of a static file and rewrites the URL if it can't find 
one.  That might be more correct, but trapping 404 is the best 
possible performance, since there is no additional code in the response 
chain if the static file is there.

- Perrin




Re: Cheap and unique

2002-05-06 Thread Perrin Harkins

Ken Williams wrote:
 If you have the additional requirement that the unique values shouldn't 
 be easily *guessable*, that becomes a very hard problem, precisely 
 because random and unique are such poor friends.  Usually people 
 just cheat by generating a large random ID such that the probability of 
 it being already-used is low, and then they check all the previous IDs 
 to make sure.

The requirement to prevent guessing is usually aimed at security and 
preventing session hijacking and similar attacks (and believe me, this 
kind of attack is very common).  Another way to do this is to use a MAC 
like MD5 or SHA1, as described in the Eagle book and O'Reilly's CGI 
book.  This makes it very difficult for an attacker to generate a valid 
ID, even if the sequence of IDs is predictable.

- Perrin




Re: Cheap and unique

2002-05-06 Thread Perrin Harkins

[EMAIL PROTECTED] wrote:
 I've been following this conversation and I'd like to clarify whether my 
 idea (since I and others want to do this as well) would be use an 
 incrementing counter for uniqueness. Then also store a bit of secret 
 randomness, concatenate both values together and create a digest hash. 
 That hash would be sent along with the sequence as well. This would allow 
 uniqueness and prevent guessing since the digest would have to match as 
 well. Depending on my paranoia I could either get fresh random bits each 
 time (and have a good hardware source for this then) or keep it around for 
 a bit and throw it away after a period.

 Does that sound right?

Yes, except for the random part.  There is no randomness involved here. 
  You should use a secret key stored on your server.  There's an example 
of this technique here: 
http://www.oreilly.com/catalog/cgi2/chapter/ch08.html

- Perrin




Re: SOAP and web services

2002-05-02 Thread Perrin Harkins

Richard Clarke wrote:
 I use mod_perl/apache/soap::lite to create an internal application server
 so that I can distribute processing load from the public webserver.

That would be a lot more efficient if you just used vanilla HTTP.  Less 
wasted overhead.  This is the same principal at work when you use 
mod_proxy in your web server and a backend system with mod_perl on it.

- Perrin




Re: Cheap and unique

2002-04-30 Thread Perrin Harkins

David Jacobs wrote:
 I'm converting a few CGI scripts that used the PID as a cyclical unique 
 number (in concert with TIMESTAMP - so it was TIMESTAMP.PID).
 
 Our goal is to find a replacement function that is extremely cheap 
 (cheaper than say, random(100)) and will never repeat. Any ideas? 

Yes, mod_unique_id will do that, as will Sys::UniqueID and Data::UUID on 
CPAN.  Of course that random function is probably very lightweight, but 
it's not actually unique.

- Perrin




Re: Cheap and unique

2002-04-30 Thread Perrin Harkins

OCNS Consulting wrote:
 Check your Programming in PERL book. Specifically, the srand function.

'random' ne 'unique'

A random function could return the same number 10 times in a row.  It's 
very unlikely, but it could happen.  That's the definition of random.

- Perrin




Re: Memory explodes loading CSV into hash

2002-04-29 Thread Perrin Harkins

Ernest Lergon wrote:
 So I turned it around:
 
 $col holds now 18 arrays with 14000 entries each and prints the correct
 results:
...
 and gives:
 
 SIZE   RSS  SHARE
 12364  12M  1044
 
 Wow, 2 MB saved ;-))

That's pretty good, but obviously not what you were after.

I tried using the pre-size array syntax ($#array = 14000), but it didn't 
help any.  Incidentally, that map statement in your script isn't doing 
anything that I can see.

 I think, a reference is a pointer of 8 Bytes, so:
 
 14.000 * 8 = approx. 112 KBytes - right?

Probably more.  Perl data types are complex.  They hold a lot of meta 
data (is the ref blessed, for example).

 This doesn't explain the difference of 7 MB calculated and 14 MB
 measured.

The explanation of this is that perl uses a lot of memory.  For one 
thing, it allocates RAM in buckets.  When you hit the limit of the 
allocated memory, it grabs more, and I believe it grabs an amount in 
proportion to what you've already used.  That means that as your 
structures get bigger, it grabs bigger chunks.  The whole 12MB may not 
be in use, although perl has reserved it for possible use.  (Grabbing 
memory byte by byte would be less wasteful, but much too slow.)

The stuff in perldebguts is the best reference on this, and you've 
already looked at that.  I think your original calculation failed to 
account for the fact that the minimum numbers given there for scalars 
are minimums (i.e. scalars with something in them won't be that small) 
and that you are accessing many of these in more than one way (i.e. as 
string, float, and integer), which increases their size.  You can try 
playing with compile options (your choice of malloc affects this a 
little), but at this point it's probably not worth it.  There's nothing 
wrong with 12MB of shared memory, as long as it stays shared.  If that 
doesn't work for you, your only choice will be to trade some speed for 
reduced memory useage, by using a disk-based structure.

At any rate, mod_perl doesn't seem to be at fault here.  It's just a 
general perl issue.

- Perrin




Re: schedule server possible?

2002-04-29 Thread Perrin Harkins

Lihn, Steve wrote:
 How do you use cron to do scheduling, yet calls Apache/mod_perl to
 do the processing?

Your cron script just uses LWP to call a module running in mod_perl.

 Consider cron does not exist in Win32, maybe an all-Apache solution
 will be simpler and more elegant!?

Cron does exist on Win32.  It's called Scheduled Tasks.  I use it all 
the time to kick off perl scripts.

- Perrin




Re: Memory explodes loading CSV into hash

2002-04-28 Thread Perrin Harkins

 $foo-{$i} = [ record ];

You're creating 14000 arrays, and references to them (refs take up space
too!).  That's where the memory is going.

See if you can use a more efficient data structure.  For example, it
takes less space to make 4 arrays with 14000 entries in each than to
make 14000 arrays with 4 entries each.  There is some discussion of this
in the Advanced Perl Programming book, and probably some CPAN modules
that can help.

- Perrin




Re: Apache::OK error

2002-04-25 Thread Perrin Harkins

Lihn, Steve wrote:
 [Thu Apr 25 15:32:15 2002] [error] Bareword Apache::OK not allowed while
 strict subs in use at C:\Apache2/blib/lib/Apache2/Apache/Echo.pm line 25.
 Compilation failed in require at (eval 2) line 3.
 
 What do I miss?

Try Apache::OK() instead.  Damn these faux constants!




Re: Apache::OK error

2002-04-25 Thread Perrin Harkins

Oops, that's right, it's in the Apache::Constants package.  Changing 
your code to say Apache::Constants::OK should do it.  No need to import 
all of that stuff unless you want to.

Jon Robison wrote:
 maybe a use Apache::Constants qw/ :common /;  
 
 --Jon Robison
 
 Lihn, Steve wrote:
 
Hi,
I am testing the Apache::Echo connection handler for Apache2 and mod_perl 2.
But encounter the following error:

[Thu Apr 25 15:32:15 2002] [error] failed to resolve handler `Apache::Echo'
[Thu Apr 25 15:32:15 2002] [error] Bareword Apache::OK not allowed while
strict subs in use at C:\Apache2/blib/lib/Apache2/Apache/Echo.pm line 25.
Compilation failed in require at (eval 2) line 3.

What do I miss?

--Steve

--
package Apache::Echo;

 use strict;
 use Apache::Connection ();
 use APR::Socket ();

 use constant BUFF_LEN = 1024;

 sub handler {
 my Apache::Connection $c = shift;
 my APR::Socket $socket = $c-client_socket;

 my $buff;

 for (;;) {
 my($rlen, $wlen);
 my $rlen = BUFF_LEN;
 $socket-recv($buff, $rlen);
 last if $rlen = 0;
 $wlen = $rlen;
 $socket-send($buff, $wlen);
 last if $wlen != $rlen;
 }

 return Apache::OK;
 }

 1;
 __END__

  Steve Lihn
  FIS Database Support, Merck  Co., Inc.
  Tel: (908) 423 - 4441

--
Notice:  This e-mail message, together with any attachments, contains information of 
Merck  Co., Inc. (Whitehouse Station, New Jersey, USA) that may be confidential, 
proprietary copyrighted and/or legally privileged, and is intended solely for the use 
of the individual or entity named in this message.  If you are not the intended 
recipient, and have received this message in error, please immediately return this by 
e-mail and then delete it.

==
 
 






Re: [Q maybe OT] forward

2002-04-24 Thread Perrin Harkins

Martin Haase-Thomas wrote:
 forwarding is a term that i borrowed from the JSP concept - which i'm 
 currently trying to implement in perl.

JSP forward is directly equivalent to an internal redirect.  It's just 
an include that doesn't return.  In short, it's a GOTO statement.  Thank 
you Sun.

- Perrin




Re: Apache2/mod_perl2 an order of magnitude more powerful?

2002-04-24 Thread Perrin Harkins

Nigel Hamilton wrote:
   I would love to run 250 Apache children on my linux server but I
 just don't have enough memory (50 children max).

  thread still needs its own perl interpreter.Then you probably won't 
have enough memory with Apache 2 either.  There is some additional 
memory savings from sharing the opcode tree, but each   Expect it to be 
better, but you don't get something (unlimited parallelism) for nothing 
(limited RAM).

- Perrin




Re: full-featured online database apps

2002-04-24 Thread Perrin Harkins

Peter Bi wrote:
 Well, I changed it back to HTML::Template.

No template flame wars, please.  HTML::Template is not unique (it has 
much in common with Template Toolkit and dozens of other less famous 
modules from CPAN), and Embperl::Object is really pretty cool.  Your 
original point about separating presentation out into templates helping 
with code reusability is a good one, so let's just leave it at that.

- Perrin




Re: Q A: $r-custom_response

2002-04-23 Thread Perrin Harkins

Issac Goldstand wrote:
 Reposting a question (and the answer) that geoff and I discussed in the 
 IRC room, as I think it's worthwhile to mention...
 
 I had the following line of code (actually many of the sort):
 $r-custom_response(FORBIDDEN=File size exceeds quota.);
 
 And kept getting errors like:
 [Tue Apr 23 19:46:14 2002] null: Argument FORBIDDEN isn't numeric in 
 subroutine entry at /usr/local/httpd/lib/perl/Mine/Pic/Application.pm 
 line 1343.
 
 The answer to the problem is that by using '=' instead of ',', I was 
 making 'FORBIDDEN' become 'FORBIDDEN' (string instead of numeric 403).
 
 Moral of the story: don't use = with Apache::Constants!

In fact, don't use constants at all.  At least not the kind created by 
the use constants pragma and similar tricks.  They have all kinds of 
problems like this.  Use package variables instead ($FORBIDDEN).  Maybe 
some day Perl will have real constants, but I'm perfectly happy with 
package variables in the meantime.

- Perrin




Re: Q A: $r-custom_response

2002-04-23 Thread Perrin Harkins

Per Einar Ellefsen wrote:
 Well, this one is exported by Apache::Constants, so if you don't want to do
 $FORBIDDEN = FORBIDDEN;
 somewhere at the top of your code, you're bound to continue using 
 constants, right?

That's still safer.  I used the constants pragma on a big project and I 
saw people get bitten by $hash{CONSTANT} and string interp CONSTANT as 
well as the aforementioned CONSTANT = value problem.  It's just asking 
for trouble, in my opinion.

Can anyone tell us if the Apache::Constants all just standard HTTP 
response codes, or are some of them actually Apache-specific?

- Perrin






Re: Q A: $r-custom_response

2002-04-23 Thread Perrin Harkins

Per Einar Ellefsen wrote:
 I suppose Apache::Constants could have been extended to return globals 
 if requested... But is there really any gain in that?

Only in that people will not get tripped up by the possible bugs that 
using subroutines as constants causes.  I guess Apache::Constants is 
difficult to replace, so everyone will just have to keep an eye out for 
this sort of problem.

- Perrin




Re: [OT] Doubt on directories for development

2002-04-22 Thread Perrin Harkins

F. Xavier Noria wrote:
 The fact is that developers in my team have Apache under /usr/local in
 Linux machines, but we would prefer to develop as normal users, not as
 www or nobody, though that will be the user in production.
 
 What is the standard way to configure things for that? We have created
 somehow the Apache directory layout under the root of the project tree
 and call httpd -f project_root/conf/httpd.conf, where we customize the
 user and group (in my case fxn), full paths to log and pid files
 writable by that user, etc. but ServerRoot is /usr/local/apache and the
 original modules under /usr/local/apache are there, so we cannot use
 $r-server_root_relative to access, say, to application config files
 which seems to be standard (and quite natural) idiom. The httpd.conf in
 CVS is a template customized once per-machine with a script.

It doesn't seem worth it to me to go to a lot of trouble to avoid 
starting apache as root in development, especially if that's how you'll 
do it in production.  I've always just put my modules in 
/usr/local/apache/lib/perl where they get picked up automatically (with 
no use lib or INC changes).  I make that directory writeable by my 
standard login (a security hole, but it's just my personal machine and 
not visible on the Internet), and keep a root shell open for restarting 
the server.  That works fine unless you have mutiple users developing on 
the same box.

- Perrin




Re: Apache::DProf seg faulting

2002-04-19 Thread Perrin Harkins

Paul Lindner wrote:
But while I have your attention, why are you using Apache::DB at all?  The
Apache::DProf docs just have:

  PerlModule Apache::DProf
 
 
 Legacy knowledge :)
 
 I think it may have been required in the past, or perhaps I had some
 problems with my INC paths long-long ago..  And well, it just kinda
 stuck.

I used to do it because if I didn't DProf would not know anything about 
modules I pull in from startup.pl (since the debugger was not 
initialized until after they were loaded).  This may not be necessary 
anymore.

- Perrin




Re: [OT] Encrypting Embedded URLs

2002-04-18 Thread Perrin Harkins

Nigel Hamilton wrote:
   I'm looking for a two-way cipher to obfuscate URL parameters
 safely and succinctly (not too many extra characters).

Try Crypt::CBC.

- Perrin




Re: Sharing Variable Across Apache Children

2002-04-17 Thread Perrin Harkins

Benjamin Elbirt wrote:
 Well, lets assume that I were to go with
 the shared memory option anyway... what would the pitfalls be / concerns?

As mentioned before, you'd probably be better off with MLDBM::Sync or 
Cache::Cache.  You can try IPC::Shareable, but a lot of people seem to 
have trouble getting it to work.

Note that this is not shared acorss all the machine in the cluster 
unless you used a shared filesystem like NFS.

- Perrin




Re: Sharing Variable Across Apache Children

2002-04-17 Thread Perrin Harkins

 Abstracting access to data is only half of the storythe more
challenging
 part is race conditions and lock management...

All of the data sharing tools take the logistics of multi-process
read/write situations into account, although they do it in different
ways.  Some use file locking, others use semaphores, and still others
use tricks like atomic file renames.  The ones I mentioned in this thead
(MLDBM::Sync and Cache::Cache) are both written to provide safe
multi-process access.

- Perrin




Re: PerlRequire

2002-04-16 Thread Perrin Harkins

Florence Dardenne wrote:
 Does mod_perl 1.26 includes the 'PerlRequire' functionality or do I need
 higher version ?

All versions of mod_perl have that feature.  You must not have mod_perl 
compiled into that server.  See this entry in the guide:
http://perl.apache.org/guide/install.html#How_can_I_tell_whether_mod_perl_

- Perrin





Re: PerlRequire -mod_perl-2 - Apache 2.0.35

2002-04-16 Thread Perrin Harkins

[EMAIL PROTECTED] wrote:
 I am a newbie and had developed a proof-of-concept application on Apache 
1.3.23/Mod_Perl-1.26-dev. We are researching into moving away from ASP/IIS 
Webapplications to Apache/Mod_Perl. I am stuck with the latest Apache 2.0.35 with the 
following problems.

Do you really need to use Apache 2 and mod_perl 2?  Why not use the 
proven 1.x series?  It's still pretty early to be using the new stuff.

- Perrin




Re: Apache::DProf seg faulting

2002-04-16 Thread Perrin Harkins

Sam Tregar wrote:
 On Tue, 16 Apr 2002, Sam Tregar wrote:
 
 
On 16 Apr 2002, Garth Winter Webb wrote:


Sam, try getting rid of the 'PerlModule Apache::DB' line.  I've used
Apache::DProf w/o any problems by including only the one PerlModule
line.  Since they both want to use perl debugging hooks, I'm guessing
that Apache::DProf is getting crashed up when it tries to use hooks
already grabbed by Apache::DB...

Same result.  Thanks though!
 
 
 Aw nuts, that was the problem!  I thought I'd tried that already, but I
 guess not.  I actually got those PerlModule lines from the mod_perl
 Developers Cookbook - guess this is an errata!

Strange, that works for me.  I do it like this:
Perl
 use Apache::DProf;
 use Apache::DB;
 Apache::DB-init;
/Perl

Or at least I did last time.  Maybe this has changed in more recent 
versions.  At the time (June 2000), I discovered I needed to call 
Apache::DB-init or else the debugging symbols would not get put in for 
modules that I used in my startup.pl, and they would not get profiled.

- Perrin




Re: Enforcing user logged in from only 1 browser?

2002-04-15 Thread Perrin Harkins

Fran Fabrizio wrote:
 Unfortunately, there's some terminology muddling...AuthCookie calls it a 
 session when it establishes that a user is a valid user and sets a 
 cookie on their browser.  Apache::Session considers a session a series 
 of page hits from the same user.  It assumes you've already done 
 whatever you need to do to assure that the user is valid.

I think you may find that neither of these does everything you need 
without a bit of additional coding.  The common way to do this sort of 
thing is to use Apache::Session to track sessions (as in a series of 
page hits from the same user), and if the user authenticates, you put 
his user ID into the session data.

You would have to do the auth part yourself, as well as the actual 
cookie handling, or else hack AuthCookie to cooperate with Apache::Session.

- Perrin




Re: Kind-of PerlSections, and location question

2002-04-15 Thread Perrin Harkins

Daniel W. Burke wrote:
 We have an application we're serving by using the same
 set of source code, and setting up different Location
 sections in the virtual host to set different variables
 and path aliases based on who the customer is...
...
 What I'd like to do (if even possible!), is have something
 like this:
 
 Have a databae table that stores the information for each
 setting, then load it dynamically as a request comes in...

Off the top of my head, there are two simple ways to do this.  The first 
is to generate your httpd.conf using a template and database.  I've done 
this using Template Toolkit, and it worked great.  This also works for 
servers that don't have mod_perl, like proxy servers.

The other way would be to write a PerlTransHandler to look at all 
incoming requests and then decide how to handle them based on your 
database info.  This is better if you need to be able to update it 
without restarting apache.

- Perrin




Re: [OT] [ANNOUNCE] mod_log_sqlite

2002-04-15 Thread Perrin Harkins

Tatsuhiko Miyagawa wrote:
 Announcing new Apache module (written in C):
 
 mod_log_sqlite is an Apache logging module for sqlite database. It
 allows you to log your HTTP stats into sqlite, then you can do queries
 using sqlite's SQL feature (including subselects, views) to HTTP
 statistics.

The SQLite FAQ seems to suggest that SQLite isn't very good at parallel 
read/write situations: http://www.hwaci.com/sw/sqlite/faq.html#q6

Have you seen any problems so far?

- Perrin





Re: [Fwd: Re: How to reload PERL module in all Apache children]

2002-04-11 Thread Perrin Harkins

[EMAIL PROTECTED] wrote:
 On Fri, 12 Apr 2002, Stas Bekman wrote:
  
 
But if talk about futuristic Solar variables (perl globals shared 
between threads). what if a solar variable is a reference to CODE? Can 
this be shared? If so, will reloading this variable in one interpreter 
affect others?
 
 
 even if that would work, it would kill performance due to required mutex 
 locking.  and that locking would need to happen in the perl core, unlike
 simple scalars, arrays and hashes.

Does it look you'll be able to get the solar variables idea to work for 
those data types?

- Perrin




Re: Ordering in %INC for PerlRestart

2002-04-10 Thread Perrin Harkins

Sreeji K Das wrote:
 Thanx for the reply (I hardly get replies for subjects
 with restart :-( I guess I'm the only one using
 PerlFreshRestart (sic !).

Hopefully you are the only one!

 My requirement is to do a neat kill of children and
 then do a complete restart. I don't want any existing
 connections to be terminated abruptly.

I've done this in a load-balanced cluster by stopping all traffic to the 
machine I want to restart, allowing current requests to finish, and then 
restarting it.  It would be nice to have a graceful shutdown option 
though.

 Also I want a
 complete restart (ie. any modified files should be
 loaded - using Apache::Reload/StatINC does a lot of
 stat()'s  further each children would get a separate
 copy).

I could be wrong, but I'm pretty sure PerlFreshRestart will not result 
in as much shared memory as an actual restart.  How does your shared 
memory look after a clean restart vs. a PerlFreshRestart?

 Restart was working perfectly until mod_perl-1.19.

Maybe for you.  For many people it resulted in unexplained segfaults and 
closure problems in CPAN modules.  It's just not a very safe thing to do.

 After that a lot has changed. Now I have fixed a lot
 in mod_perl to get Restart fully working.

You can send your patches to the dev list.  However, most effort is 
focused on getting mod_perl 2 out right now.

- Perrin




Re: alarms

2002-04-10 Thread Perrin Harkins

mire wrote:
 1) what happens when you set an alarm for lets say 30 seconds and the request
 finishes in 20 ?

You are supposed to unset the alarm if the event you were timing 
finishes before it goes off.

 2) does apache child die when you issue die; from perl code (mod_perl
 ofcourse) ?

No, only when you call exit or child_terminate().

- Perrin







Re: Unsubscribe me please [KILL THIS THREAD]

2002-04-09 Thread Perrin Harkins

Please kill this thread.  Some people are not good at dealing with
mailing lists.  At least this guy was polite.

- Perrin





Re: tt2 using mason tags

2002-04-08 Thread Perrin Harkins

Mark Fowler wrote:
 Sounds like you're getting confused between [% %] for template code 
 and [% PERL %] ... [% END %] for actual real perl code

Agreed.  Also, any significant Mason component is likely to use Mason's 
built-in object model, which is not part of TT.  You will probably have 
to port some code before it will run.

- Perrin




Re: Ordering in %INC for PerlRestart

2002-04-08 Thread Perrin Harkins

Ged Haywood wrote:
 Hi there,
 
 On Tue, 2 Apr 2002, [iso-8859-1] Sreeji K Das wrote:
 
 
I use PerlFreshRestart on to reload my modules.
 
 [snip]
 
However, here my modules are getting loaded before the
PerlRequire'd is loaded (since %INC is a hash).

First, can some1 suggest a solution for this ?
 
 
 I always stop (with SIGTERM) and start my servers rather than using
 restart (SIGUSR1) as I find that there are fewer surprises.  I think
 that Perrin will agree.  There are very few systems that can't cope
 with a few seconds of downtime.

It's certainly a lot safer, and it won't trash your shared memory the 
way PerlFreshRestart will.

- Perrin




Re: mod_perl and open files limit

2002-04-08 Thread Perrin Harkins

Ged Haywood wrote:
 I'd suggest setting MaxRequestsPerChild to a low value (I generally
 use something in the range of 50-100 but Perrin will tell you that's
 *very* low... :) to avoid leak problems.

A setting of 0 is fine, as long as you are using Apache::SizeLimit or 
Apache::GTopLimit.  In fact, that's the best way to do it, since it 
gives your child processes the longest possible lifespan while 
preventing them from getting too big.

As for the source of the original problem, it is probably a bug in the 
local code.  You should check to make sure all of your filehandles are 
being closed.  The other suspicious-sounding module is 
Apache::Lock::File.  You can check it by replacing it with NullLocker 
and watching to see if the problem disappears.

- Perrin




Re: tt2 using mason tags

2002-04-08 Thread Perrin Harkins

Rafiq Ismail (ADMIN) wrote:
 It's just the fact that in spite of my specifying that it should use
 inline_perl, it didn't interpolate the inline code which uses custom
 modules in mason tags.  I've got it to try and interpolate now, however it
 seems to warn that $VARNAME's are odd symbols.

If you post an example of the troublesome templates on the TT list, 
someone will probably be able to help you.

- Perrin




Re: Thanks and GoodBye

2002-04-05 Thread Perrin Harkins

John Kolvereid wrote:
Thanks for all your help, but I am NOT able to
 install mod_perl.  It's probably something that is not
 installed on my particular server - I'll never know. 

I suspect you were just trying to do too much at once on your first try 
by throwing PHP and SSL in the mix.  I suggest you look at SpeedyCGI 
(http://daemoninc.com/speedycgi/), which offers similar speedups for CGI 
scripts but does not require you to recompile Apache.  It doesn't have 
the same feature set as mod_perl, but all you wanted to do was speed up 
your existing CGI scripts anyway.

- Perrin




Re: mod_perl Cook Book

2002-04-05 Thread Perrin Harkins

Rasoul Hajikhani wrote:
 Has anyone purchased the mod_perl cook book from this list? If so, what
 do you think of it? Is it a good buy?

Yes.  Go get it.

- Perrin





Re: Pipelinning Output APP Framework

2002-04-05 Thread Perrin Harkins

[EMAIL PROTECTED] wrote:
 I know alot of you must do this.
 
 I want build a simple APP framework to chain the output of all my content
 handlers, which would live in many different PM's for easy code management.
 
 for example:
 APP::Header
 APP::Footer
 APP::Content
 APP::Chemical_entry
 APP::...
 APP::Controller
 - would push_handlers based on uri and/or app logic
 - The result would be the entire html output in ( via print array )
 
 WHY ( so that my content can: )
 
 - pass named paired parameters to following handlers
 - modify previous content ( eg update html header code with a msg from
 main content handler )

This is not the best way to think about the problem, especially if you 
want it to be FAST, FAST, FAST.  Having one piece of code manipulate 
the HTML output from another piece is messy, slow, and will probably 
break every time your designers change the HTML.  Instead, build a 
pipeline for working on the data to be displayed, which you can easilly 
pass through method arguments or $r-pnotes(), and then run a template 
(which may include many smaller templates) at the end to generate HTML. 
  There are several templating tools you can use for this, and I've 
summarized the best ones at http://perl.apache.org/features/tmpl-cmp.html.

- Perrin




Re: PDF generation

2002-04-04 Thread Perrin Harkins

Mike808 wrote:
 Don't know if you can run a JServ+mod_perl or JPerl hybrid, though.

You can, but it would be the biggest memory hog every created, since it 
would be running a JVM in addition to the Perl interpreters.

- Perrin






Re: Problem with DBM concurrent access

2002-04-04 Thread Perrin Harkins

Franck PORCHER wrote:
 So my question narrows down to :
 How to flush on disk the cache of a tied DBM (DB_File) structure
 in a way that any concurrent process accessing it in *read only* mode
 would automatically get the new values as soon as they
 are published (synchronisation)

You have to tie and untie on each request.  There's some discussion of 
this in the Guide.  As an alternative, you could look at using 
BerkeleyDB, or MLDBM::Sync (which does the tie/untie for you).

- Perrin




Re: Problem with DBM concurrent access

2002-04-04 Thread Perrin Harkins

  Isn't that just as simple as
 
  tied(%dbm_array)-sync();

 I believe that's not enough, because the reader may read data during
the
 write, resulting in corrupted data read.

Not only that, there's also the issue with at least some dbm
implementations that they cache part of the file in memory and will not
pick up changed data unless you untie and re-tie.  I remember a good
discussion about this on the list a year or two back.

- Perrin




Re: Apache::DBI or What ?

2002-04-02 Thread Perrin Harkins

Eric Frazier wrote:
 I also still don't see how a connection can be reconnected at such a high
 level.

It can't, unless your database specifically supports the command 
reauthenticate.  Oracle does, which is what he wrote this for, but I 
don't think it's a standard part of SQL syntax so it will probably not 
work with MySQL.

Of course MySQL connects really quickly, so you can probably get 
perfectly good performance without using Apache::DBI at all.

- Perrin




Re: startup vs. child initialization question

2002-04-01 Thread Perrin Harkins

 Also, I read about issues of database handlers becoming
unstable across forks.  So should I place this initialization
information into a perl child init handler?

See the connect_on_init() method in the Apache::DBI docs.

We use PerlSetVar's for this where I work.

That's how I would do it too, for anything that might vary by virtual host.

- Perrin




Re: Global Config Module

2002-04-01 Thread Perrin Harkins

Christopher H. Laco wrote:
 If I use the module in startup.pl, and have it load all of it's data at
 startup, it that the instance all child processes will use?

Yes, that's the best way to do it.

 On a side note, I'm fairly comfortable with Perl/OOP at the
 batch/command/cgi level, but the where's and whens of mod_perl still leave
 me a bit unclear.

It's mostly a question of understanding the lifecycle of the Apache 
server.  You'll get it.

- Perrin




Re: Global Config Module

2002-04-01 Thread Perrin Harkins

 In my limited understanding then,  in the startup.pl, one could do the
 following:

 use strict;
 use MyMod::Config();

 MyMod::Config::load();

Yes.  Then you can have a function for accessing the config variables,
or put them in globals ($MyMod::Config::database_password), or various
other things.

 What about existing components the are normally created in scripts
using
 new..
 use strict;
 use MyMod::Config();

 my $config = MyMod::Config-new();

What about them?  That's a lexical variable, and not a problem.

 Since the use of globals is bad,  should existing things be converted
to
 pure packages instead of oop classes.

 Is it prefered in the mod_perl world to create packages rather than
classes?

I think you're getting your terminology a little mixed up.  In Perl,
packages are classes.  And I'm not sure what globals you're talking
about.

 What about statefull vs. stateless objects?

Since users are not guaranteed to return to the same Apache process each
time, you can't keep read/write data in memory between requests (at
least not without some kind of expiration system).  Read-only data, like
your config info, is fine to keep in memory.  If you want to keep some
sort of global application state, use MLDBM::Sync or Cache::Cache.  For
user sessions, look at Apache::Session.

- Perrin




Re: general timeout for mod_perl scripts?

2002-04-01 Thread Perrin Harkins

 i would like to prevent any of my mod_perl scripts from running longer
than
 5 seconds.  is there an elegant way to make a general timeout that
does not
 require changing all my scripts?  i run both Registry and Mason
scripts in
 my environment.

You could try setting an alarm in a fixup handler.  But if you're just
trying to prevent runaway servers, I'd suggest Apache::Resource.

- Perrin




Re: Proxy authentication against a mod_perl backend - how?

2002-04-01 Thread Perrin Harkins

 My first thoughts were to use mod_proxy to forward requests for
 /protected/login to the backend, where the authentication will be
done.
 Then, just redirect the request to another URL behind /protected.  The
 authentication information should be passed as part of the request,
should
 it not?

Sure, but your proxy server won't be checking to see what it is.  People
could go to any of your proctected pages freely if they know the URL.

Sounds like you're going to a lot of trouble to avoid using standard
auth to me.  There are a number of auth modules out there which don't
need mod_perl, and you may find one that will play nicely with your
backend programs.  Modules that auth against MySQL or LDAP servers
exist.

If you're determined to do auth on the backend, I would just let the
backend do the auth and serving of the static pages.  It will dump them
out fast and let the proxy servers do the slow work of dribbling the
bytes out to clients.

- Perrin




Re: Astronomical Information

2002-04-01 Thread Perrin Harkins

 Maybe i have been searching for the wrong keywords or been looking in
 the wrong places

You have.  Try this:
http://search.cpan.org/search?mode=distquery=astro

- Perrin



Re: Segmentation fault 11 (php/mod_perl)

2002-03-28 Thread Perrin Harkins

Bob Pickles wrote:
 I've been hacking at this a couple days.  At first I really wanted to 
 get mod_perl working as a DSO.  Got everything compiled, and added lines 
 to httpd.conf.  Died on startup if I had AddModule mod_perl.c.  
 Following  a tip on this list, I gave up on DSO and went static 
 compile.

And then what happened?  Did you start with a clean conf file?  There 
should be no LoadModule/AddModule stuff in it for a static server.

- Perrin





Re: AddModule mod_perl.c

2002-03-27 Thread Perrin Harkins

Stas Bekman wrote:
 Arh, I mean to use the hints how to get the core dump backtrace.

Hang on, this guy is just trying to do an install.  He shouldn't need to 
troubleshoot at that low a level.

John, who built this server and why is it DSO?  If you have control of 
this system, I would recommend that you simply start over and build 
Apache/mod_perl statically, following the instructions that come in the 
mod_perl package.  It completely avoids all of the AddModule business 
that is getting you confused.

I've always avoided DSO like the plague, but if you're really determined 
to use it your best bet is to let the mod_perl build script do the 
LoadModule/AddModule stuff for you, which it will do if you tell it to 
with the USE_DSO=1 flag.

- Perrin




Re: AddModule mod_perl.c

2002-03-27 Thread Perrin Harkins

Sorry you're having so much trouble with the install.  It goes pretty
smoothly for most people, but you are complicating things a bit by
putting PHP and SSL in the mix on your first try.

Perrin, I have no idea if DSO is still involved

Apache will not build DSO unless you tell it to.

Your build routine looks fine to me.  I do the same except I don't
usually build in mod_ssl, and it works.

After I install the apache server I check the
 httpd.conf.  In it are 2 key lines:
 
   LoadModule perl_module  libexec/libperl.so
   AddModule mod_perl.c

Get rid of your old conf file.  You don't want any of that
LoadModule/AddModule junk at all in a static server.  That's DSO-only. 
(Anyone know if mod_ssl somehow forces you to use DSO?)

 However, when I try to browse my hello.pl
 file (from Apache Modules w/ Perl  C, pp 42-4) it
 displays it as text rather than an html page.  It's as
 if the Options ExecCGI were not applied.

That script should work under CGI as well.  Does it?  Did you remember
to make it executable?

I'm afraid I'm not that much help with install problems because I just
haven't had any of my own to deal with.  You can try using Apache
Toolbox to do the build.  It's supposed to make this stuff easier.  If
it seems hopeless, you could always check out SpeedyCGI, which gives a
similar speedup for perl CGI scripts bu does not require apache to be
recompiled.  It doesn't give you access to the full range of mod_perl
tools, but it may be all you need in this case.

- Perrin





Re: How to get two perl namespaces in apache

2002-03-26 Thread Perrin Harkins

Ernest Lergon wrote:
 just throwing a glance I found:
 
 http://thingy.kcilink.com/modperlguide/modules/Apache_PerlVINC_Allows_Module.html

Not a good idea for production use.  It will slow things down.  Handy 
for development with multiple projects using separate virtual hosts though.

- Perrin




Re: Apache::DBI or What ?

2002-03-25 Thread Perrin Harkins

Ed Grimm wrote:
 First, I'll suggest that there are hopefully other areas you can look at
 optimizing that will get you a bigger bang for your time - in my test
 environment (old hardware), it takes 7.4 ms per
 disconnect/reconnect/rebind and 4.8 ms per rebind.  Admittedly, I'm
 dealing with LDAP instead of SQL, and I've no idea how they compare.

Connecting to Oracle can take 30 seconds on a busy system.  It doesn't 
usually take that long, but it often takes a second or two.  It is a 
very important optimization to hold the connection.  Postgres may not be 
as bad, but it's common for SQL systems to have slow connection times.

There are databases that allow you to change the current user without 
reconnecting.  In fact someone posted a module to do this a while back, 
but I can't remember which database it was for.  Seems like it was 
Sybase or Informix.

- Perrin




Re: the Guide

2002-03-24 Thread Perrin Harkins

  Wouldn't it thus be simpler and more convenient
 for 1st times like myself if the guide download were
 simply the already created html pages which appear
 online.

Frankly, hardly anyone does that.  Most people refer to the guide
on-line.  I've used mod_perl for years, referred to the guide
frequently, and never downloaded it.  If you have to work over a slow
link I can understand why you might want a local copy, but a quick wget
command can mirror it all for you pretty easilly.

People usually only download the CPAN package if they're planning to do
some hacking on it.  Mentioning the module dependency in the text next
to the download link is probably a good idea, and offering a .tgz of all
the generated HTML files as well as the PDF, but I think you may be the
first to request such a thing.

  It's hard enough to install mod_perl itself.  Why
 add an extra burden for the manual also.

There is plenty of documentation on building and working with mod_perl
included in the standard mod_perl package.  The guide is in addition to
that documentation.

- Perrin




Re: Performace...

2002-03-23 Thread Perrin Harkins

 Im curious as to the difference in performance when using perl scripts
with
 Apache::Registry or writing complete Apache Modules in Perl that
conform to
 the API?

Check the list archives for benchmarks by Joshua Chamas.  Note that
there are other reasons to use handlers instead of Registry, which you
will also find in the archives.

- Perrin




Re: 'Pinning' the root apache process in memory with mlockall

2002-03-22 Thread Perrin Harkins

Stas Bekman wrote:
 Moreover the memory doesn't
 get unshared
 when the parent pages are paged out, it's the reporting tools that 
 report the wrong
 information and of course mislead the the size limiting modules which 
 start killing
 the processes.

Apache::SizeLimit just reads /proc on Linux.  Is that going to report a 
shared page as an unshared page if it has been swapped out?

Of course you can void these issues if you tune your machine not to 
swap.  The trick is, you really have to tune it for the worst case, i.e. 
look at the memory usage while beating it to a pulp with httperf or 
http_load and tune for that.  That will result in MaxClients and memory 
limit settings that underutilize the machine when things aren't so busy. 
  At one point I was thinking of trying to dynamically adjust memory 
limits to allow processes to get much bigger when things are slow on the 
machine (giving better performance for the people who are on at that 
time), but I never thought of a good way to do it.

- Perrin




Re: PerlModule hell - questions and comments

2002-03-22 Thread Perrin Harkins

Kee Hinckley wrote: 1. *Why* are the apache config files executed twice (completely 
with 
 loading and unloading all the modules)?

This is a core apache thing.  Apache does it to verify that a restart is 
safe.  See 
http://thingy.kcilink.com/modperlguide/config/Apache_Restarts_Twice_On_Start.html

I'm not saying I think it's the greatest idea, but that's the reason 
behind it.

Modules loaded with PerlModule and PerlRequire are not supposed to be 
loaded again the second time.  I seem to remember that they are loaded 
again when using DSO though, so if you're using DSO you may want to 
recompile as static.  Also, if you have PerlFreshRestart on that will 
cause a reload.

A couple of people reported a bug that they were seeing which caused 
these modules to be loaded twice anyway.  That sounds like the issue you 
saw with Perl sections.  I haven't tested this myself, and fixing it 
would probably require help from Doug.  As a workaround, it is possible 
to do all of your module loading from a startup.pl called from 
PerlRequire, and avoid that problem.  That's what I do.

Of course my goal here sounds like exactly the opposite of yours: you 
actually *want* Embperl to get loaded both times so that your conf 
directives will work.  I haven't run into that problem before because I 
don't use any modules that add conf directives.  Maybe Gerald will have 
an explanation of what the expected behavior is on his end.  It can't be 
this much trouble for most people or no one would be using Embperl or 
custom conf directives.

- Perrin




Re: PerlModule hell - questions and comments

2002-03-22 Thread Perrin Harkins

Kee Hinckley wrote:
 At Embperl 2.0b6 Gerald switched to a new architecture.  The previous 
 version was just a plain Perl module loaded as a handler by mod_perl. 
 This version is also an Apache module.

Okay, if it's only in the recent betas then it's possible that only a 
few people have encountered this.  Can anyone else who has built a 
module with custom conf directives comment on this issue?

 Maybe we need an option for PerlModule that forces a load each time?

It seems like something to keep the C and perl sides doing the same 
thing is what's needed, so that if the C stuff gets unloaded the perl 
stuff will too.

In your case, PerlFreshRestart might help with what you're trying to do 
since it will clear %INC, but you may still have the problem with 
needing to call Init.

- Perrin




Re: Subroutines taking time to return..

2002-03-21 Thread Perrin Harkins

David Brown wrote:
 All good and well I thought.. But erm.. nothing is being created in the
 dprof directory in the server-root.

When you call the script, do you get segfaults in the error log?

Make sure that you do the DProf stuff, including Apache::DB-init(), 
before you load any of your other modules.  Otherwise, the debugging 
symbols don't get put into your code.

- Perrin




Re: Off topic question a little worried

2002-03-21 Thread Perrin Harkins

John Michael wrote:
 Any idea as to how it got on my server.

Someone found a serious security hole in something you're running.  You 
have to assume that your server has been completely compromised and that 
the entire world now has root access to it through a hundred backdoors 
they installed.  Take it off-line now, before you find out it sent 
millions of porn spam messages.  You can study it later to try and find 
the problem.

- Perrin




Re: modperl and SQL db select

2002-03-21 Thread Perrin Harkins


Please, please, please KILL THIS THREAD!




Re: Berkeley DB 4.0.14 not releasing lockers under mod_perl

2002-03-21 Thread Perrin Harkins

Dan Wilga wrote:
 If I either use DB 3.x or even run this from the commandline (bypassing 
 mod_perl) under DB 4 the problem goes away: only one locker is allocated 
 per loop, and therefore the total number used does not increase 
 unexpectedly.

This sort of begs the question: why not use DB 3.x?  Is there some new 
feature you need in DB 4?

It's been a little while since I messed with this stuff, but I don't 
think you need to tear down the Env each time.  I think you can just 
create it the first time and reuse it after that.  Maybe that will help.

(Ah, Mount Holyoke.  As a Five College alumn, I remember it well.)

- Perrin






Re: Berkeley DB 4.0.14 not releasing lockers under mod_perl

2002-03-21 Thread Perrin Harkins

Dan Wilga wrote:
 What surprises me is that all I have to do to introduce the problem is 
 run it under mod_perl. It acts normally when run from the commandline.

Well, let's see, what would be different...

Is it possible that the problem is concurrency from multiple mod_perl 
processes?  What happens when you run it with httpd -X ?

Could there be a permissions issue involved?

Are you sure you're only invoking the script once under mod_perl?  If 
you raise the number of repetitions, does the command-line version 
exhibit the problem?

I don't see any scoping issues in your script, but are you running it 
under Apache::Registry?  Maybe the nested subroutines that creates are 
causing problems.

- Perrin




Re: Global configuration

2002-03-19 Thread Perrin Harkins

In addition to the techniques Stas mentioned (which I've always found to
be more than adequate), there are tons of configuration modules on CPAN.
AppConfig, Config::* modules, etc.  Just make sure you choose one that
can do layered configs, so that you can specify a configuration that's
shared and then override certain settings with a local file on each
machine.

- Perrin




Re: Security of a modperl enabled site

2002-03-19 Thread Perrin Harkins

 I am in front of a security issue. We are running several site using
 modperl. Last days, a hacker used a script to call some script of our
sites
 for bad purpose. He needed to be authenticated, but we are only using
 session cookies. Then, once he was loged in, he could retrieve this id
and
 use it in his home made script.

Think about what's different between his behavior and legitimate users'
behavior.  Is it that he's sending tons of requests in a brief period of
time?  Limit the frequency.

Randal wrote a column about how to do this:

http://www.stonehenge.com/merlyn/LinuxMag/col17.html

- Perrin




Re: 2 httpd processes looping in SQL statement

2002-03-18 Thread Perrin Harkins

Andre Terroux wrote:
 Hi Team, new subscriber here hoping someone can help me out. I'm getting a
 weird behavior with Apache: after running for a while, always two httpd
 processes have to be restarted because they use up around 8% of CPU each.

This is probably caused by a bug in your perl code.  You should try to 
figure out what sort of request triggers it.  Maybe you can add some 
logging to your application or use the MOD_PERL_TRACE feature to figure 
it out.

- Perrin




[OT] underscores vs. init caps

2002-03-15 Thread Perrin Harkins

Georgy Vladimirov wrote:
 The Java people escaped from the underscore and started
 capitalization.

underscores_are_much_easier_to_read ThanSomeSillyCapitalizationScheme.

Underscores are the standard for Perl variable names, and for good reason.

Anyway, it's a moot point because the name isn't changing.

- Perrin




Re: Serious bug, mixing mod-perl content

2002-03-14 Thread Perrin Harkins

mire wrote:
 Beta contains new code and www is old code. We were calling www but once a
 while beta would pop in.  We noticed error messages that were giving whole
 stack trace (caller) but those error messages were not present in www code,
 they are implemented as a change in beta code.

Are you sure you aren't just having namespace problems?  If this code is 
in a module which has the same name for both versions, you can only have 
one version loaded in each perl interpreter.

- Perrin




Re: query

2002-03-13 Thread Perrin Harkins

Parag R Naik wrote:
 We have installed perl 5.6 but we are 
 not able to figure out how to instruct apache to use that version of 
 perl(5.6

You have to re-compile mod_perl.

 Is the our directive used in some of files  new to perl 5.6 because we 
 could not find that directive in the most of the perl books we referered 
 to.

Yes, it is new in 5.6.  The most recent version of the camel book 
describes it, and so do the man pages.

- Perrin




Re: Memory query

2002-03-13 Thread Perrin Harkins

Andrew Green wrote:
 In particular, I'm
 looking for reassurance that passing a reference to a hash doesn't copy
 the hash itself into memory in any way, and that the memory overhead is
 only as large as the largest $item.

That's basically correct, but some dbm implementations will use their 
own caching and that may increase this overhead.

 Similarly, if I was to
 
  use vars(%hash);
 
 and initialise the tied hash as a global, does this have a significant
 memory overhead?

No, it's the same except for the addition of an entry in the symbol table.

 Does untie-ing the hash clear the hash contents from
 memory, or do I also need to undef the hash to avoid the hash contents
 persisting from one request to the next?

If you actually want to free the memory, you need to undef it.  The 
untie prevents it from persisting, but the memory stays allocated unless 
  you undef.

 Is one approach better than the
 other?

Not in terms of memory.  The thing you need to think about with regard 
to dbm files is how to make sure they are synchronized between multiple 
processes.  You basically just need to untie them after each request 
(unless it's read-only data).  By the way, MLDBM::Sync takes care of all 
of that for you.

- Perrin




Re: performance testing - emulating real world use

2002-03-13 Thread Perrin Harkins

Jauder Ho wrote:
 Another application (commercial) is Mercury Interactive's LoadRunner.

My experience with commercial load-testing apps is that they are 
outrageously expensive, a pain to program, don't really scale all that 
well, and mostly have to run on Windows with someone sitting at the 
mouse.  There are some that work better than others, but the free stuff 
in this areas is quite good.

I recommend httperf and http_load for banging on lists of URLs really 
hard.  At eToys, one of our developers rigged up some shell scripts that 
would play back log files through httperf and that worked pretty well.

If you want to record browser sessions for testing specific paths 
through the site, look at http://sourceforge.net/projects/http-recorder/ 
or http://sourceforge.net/projects/roboweb/.  There's also webchatpp, 
HTTP::WebTest, and HTTP::MonkeyWrench on CPAN.  All of these have been 
discussed on this list before.

- Perrin




Re: Serious bug, mixing mod-perl content

2002-03-13 Thread Perrin Harkins

Could you describe the actual nature of the error?  How can you tell 
that the response you're getting is from the wrong virtual host and what 
is different about the virtual hosts' setup that causes the difference 
in responses?

- Perrin




Re: Apache-print Timeout

2002-03-13 Thread Perrin Harkins

Geoffrey Young wrote:
 I don't have a copy of the Eagle book in front of me

The API chapter is online and it talks about print() and timeouts:
http://modperl.com:9000/book/chapters/ch9.html

- Perrin




Re: [OT?] What exactly is forwarding?

2002-03-12 Thread Perrin Harkins

Paul Lindner wrote:
 You'll find that $r-internal_redirect() is the mod_perl equivalent.
 Also Apache::ASP containts the Transfer() method which accomplishes
 the same thing.

Personally, I always thought this was sort of a strange part of JSP.  It 
really shows the page-centric thinking behind it.  Doing a forward is 
essentially a GOTO statement for JSP.  When I write mod_perl apps, I 
never feel the need for that sort of thing, with so many better ways to 
accomplish things (OO, method calls, dispatch tables, template includes).

- Perrin




Re: loss of shared memory in parent httpd

2002-03-12 Thread Perrin Harkins

Elizabeth Mattijsen wrote:
 Since Perl is basically all data, you would need to find a way of 
 localizing all memory that is changing to as few memory chunks as 
 possible.

That certainly would help.  However, I don't think you can do that in 
any easy way.  Perl doesn't try to keep compiled code on separate pages 
from variable storage.

- Perrin




Re: Debugging mod_perl

2002-03-12 Thread Perrin Harkins

Nico Erfurth wrote:
 Today i had a big problem, and i don't know how to track it down.
 After changing one of my tool-modules apache segfaults on startup.
 
 So, how can i debug something like this?

Do you know exactly what you changed?  In that case, you have a small 
amount of code to look through for the problem.  Take stuff out until it 
stops segfaulting.  If you want some help figuring out why that part 
segfaults when you find it, post it here.

- Perrin




Re: loss of shared memory in parent httpd

2002-03-12 Thread Perrin Harkins

Bill Marrs wrote:
 But... recently, something happened, and things have changed.  After 
 some random amount of time (1 to 40 minutes or so, under load), the 
 parent httpd suddenly loses about 7-10mb of share between it and any new 
 child it spawns.

One possible reason is that a perl memory structure in there might be 
changing.  Perl is able to grow variables dynamically by allocating 
memory in buckets, and it tends to be greedy when grabbing more.  You 
might trigger another large allocation by something as simple as 
implicitly converting a string to a number, or adding one element to an 
array.

Over time, I always see the parent process lose some shared memory.  My 
advice is to base your tuning not on the way it looks right after you 
start it, but on the way it looks after serving pages for a few hours. 
Yes, you will underutilize the box just after a restart, but you will 
also avoid overloading it when things get going.  I also recommend 
restarting your server every 24 hours, to reset things.

One more piece of advice: I find it easier to tune memory control with a 
single parameter.  Setting up a maximum size and a minumum shared size 
is not as effective as setting up a maximum *UNSHARED* size.  After all, 
it's the amount of real memory being used by each child that you care 
about, right?  Apache::SizeLimit has this now, and it would be easy to 
add to GTopLimit (it's just $SIZE - $SHARED).  Doing it this way helps 
avoid unnecessary process turnover.

- Perrin




Re: Apache::TicketAccess

2002-03-12 Thread Perrin Harkins

Ray Recendez wrote:
 I am new to perl/mod_perl and I am trying to implement secure 
 authentication with expirable ticket/cookies on our website (Apache 
 1.3.9-Solaris 2.8). I am trying to use Apache::TicketAccess with Apache 
 1.3.9, modssl, openssl, and mod_ssl installed but I am having problems 
 even though everything compiled and installed without errors. It seems 
 like Apache/mod_perl can?t locate some of the *.pm files even though I 
 add the lib paths using ?use lib.?

The error message says it's looking for the MD5 module.  Do you have it?

 What is the difference between 
 /usr/local/lib/perl5/5.6.1 directory and /usr/local/lib/perl/site_perl?

The site_perl directory is for modules you install, as opposed to Perl's 
standard library.

 Is site_perl platform specific?

There are subdirectories under it for platform specific stuff.  Usually 
only XS modules will have anything there.

 Where should modules be installed?

The installation scripts for CPAN modules know where to install 
themselves: site_perl.

If you need more information on module installation, I suggest checking 
out man perlmod and the CPAN FAQ.  There's also lots of info in the 
Programming Perl book.

- Perrin




Re: trouble with GTop and

2002-03-12 Thread Perrin Harkins

Bill Marrs wrote:
 When I install the recent Redhat 7.2 updates for glibc:
 
 glibc-2.2.4-19.3.i386.rpm
 glibc-common-2.2.4-19.3.i386.rpm
 glibc-devel-2.2.4-19.3.i386.rpm
 
 It breaks my Apache GTop-based Perl modules, in a way that I don't 
 understand.
[...]
 Anyone have a clue about what I'd need to do to get this working?

Re-install/re-compile GTop?  RedHat probably changed some of the Gnome 
libs that it uses.




Re: Apache::TicketAccess

2002-03-12 Thread Perrin Harkins

Ray Recendez wrote:
 Yes I have MD5 installed. However, MD5.pm is located in the following
 locations: /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/MD5.pm ;
 /usr/local/lib/perl5/site_perl/5.6.1/sun4-solaris/MD5/MD5.pm ; and
 /usr/local/lib/perl5/site_perl/5.6.1/MD5.pm. Which one is correct?

All of them.  There are platform-specific parts installed under the 
paths with solaris in them.

Does it work when you use it from command-line?

perl -MMD5 -e 'print ok\n;'

 Is there
 another similar authentication package or is Apache::TicketAccess the best
 one out there.

I've never used Apache::TicketAccess, but it looks fine.  Anyway, you 
aren't having problems with Apache::TicketAccess, you're having problems 
with MD5.  Any auth scheme is likely to want a working MD5.

- Perrin




Re: Cache::SharedMemoryCache locking up on Solaris

2002-03-12 Thread Perrin Harkins

Chris Allen wrote:
 In desperation, I have switched to Cache::FileCache - which
 works fine, but I would be interested to know, for a system
 that handles several hundred database queries per minute:
 
 - What is the performance difference between SharedMemoryCache
 and FileCache?

You can test it yourself with the supplied benchmark script.  In 
general, file caching is faster for most applications.

 - What is the performance difference between FileCache and a
 local MySQL database (on a simple indexed query)?

FileCache will probably beat MySQL, but maybe not by much.  There were 
some benchmarks posted here a while back which might interest you.  The 
thread starts here:
http://marc.theaimsgroup.com/?l=apache-modperlm=10081212375w=2

- Perrin




Re: Apache::TicketAccess

2002-03-12 Thread Perrin Harkins

Ray Recendez wrote:
 Running it from the command line seems to work:
 rift_rootperl -MMD5 -e 'print ok\n;'
 ok

Is it possible that you may have installed this module using a different 
compiler from the one you used for mod_perl?  or maybe built mod_perl 
against a different perl installation?

Also, take all of those 'use libe' statements out of your script.  If 
you are using the perl installed at /usr/local/lib/perl5/5.6.1/ and 
those things aren't in your INC already, you have serious problems with 
your installation and should probably rebuild perl and mod_perl from 
scratch.

- Perrin




Re: apache for windows/linux

2002-03-11 Thread Perrin Harkins

Wilfred Chan wrote:
 I am fairly new at 
 this and I just wanted to ask what you guys think the differences are 
 between running apache on Windows VS on linux.

The bottom line is that mod_perl has better performance on Linux because 
of threading issues on Windows.  There's a link to a writeup about this 
on the main mod_perl page.

- Perrin




Re: Response-Debug and IIS

2002-03-08 Thread Perrin Harkins

Mike Martinet wrote:
 Can anyone tell me if $Response-Debug from Apache::ASP is implemented 
 in ActiveState Perl under IIS?

Since your questions is about Microsoft ASP, you might want to ask it on 
a Microsoft ASP list.  You already know that Apache::ASP supports it.

- Perrin




Re: Document Caching

2002-03-07 Thread Perrin Harkins

Cahill, Earl wrote:
 I would not be opposed to calling a different,
 more standard function to check the cache (set up in a more standard way),
 and then fetch accordingly.

Look at how the Memoize module does it.  You may be able to do something 
similar that would allow caching to be added easilly to any pure virtual 
function.

- Perrin





Re: PerlFreshRestart, mod_perl DSO, and Apache::StatINC

2002-03-07 Thread Perrin Harkins

Gordon Henriksen wrote:
 I see three options open to me:
 
  1. static mod_perl w/ PerlFreshRestart
   Reloads %INC.
   downside: Heresay claims historical instablity.
 
  2. dynamic mod_perl
   Tears down  cleans up Perl interpreter on graceful restart.
   downside: Heresay claims historical instablity.
 
  3. static mod_perl w/ Apache::StatInc
   Runs many stat()'s per request.
   downside: Runs many stat()'s per request.

Frankly, those options all suck for anything other than development 
servers.  A production server on a busy site needs to be fully stopped 
and restarted when you upgrade your code.  Doing anything else is just 
asking for trouble (strange closure issues, for example) and will trash 
your shared memory to boot.

The best way I've found to deal with this problem is to have multiple 
servers behind a load-balancer and do a rolling restart.  If you have 
servers A and B, you take A out of the load balancer temporarilly, 
upgrade it, add it back in, take B out, upgrade it, add it back in. 
Using this technique, we were able to smoothly upgrade production 
servers on a very busy cluster of machines during normal business hours 
while customers were on the site.

- Perrin




Re: PerlFreshRestart, mod_perl DSO, and Apache::StatINC

2002-03-07 Thread Perrin Harkins

Geoffrey Young wrote:
 we do that frequently here - 7 servers behind a BigIP.  I've always
 wondered, though, whether this approach is foolproof for major
 upgrades for applications that maintain state - since a user might
 have a session created using a new-code box, then hit an old-code box
 on the next page view.  it takes us many minutes to work through
 restarting the entire array.
 
 were you ever concerned about something like that?

We also used BigIP, with the sticky load-balancing option on.  (Well, we 
used two, and only the application servers were sticky.  It didn't 
matter which proxy/web server you went to.)  This prevents the problem 
you're talking about.

Of course if the upgrade involves changing some shared resource like a 
database as well, you have to take the site off-line while you do it.  I 
suppose it's possible to rig up something crazy with multiple databases 
and synchronization, but it's just not worth it.

- Perrin






Re: PerlFreshRestart, mod_perl DSO, and Apache::StatINC

2002-03-07 Thread Perrin Harkins

 We had been using Option 1 for a long time  we had
 absolutely no problems

But doesn't it totally wreck your shared memory?  For me that would make
it unusable.  I usually get a pretty large percentage of memory to be
shared and count on that for getting maximum capacity from each box.

- Perrin




Re: mod_perl and perl RPMs and Oracle 9iAS

2002-03-06 Thread Perrin Harkins

Rafael Caceres wrote:
 I'm facing a dilemma here. We are testing an Oracle 9iAS installation 
 (Apache 1.3.19, mod_ssl 2.8.1, mod_perl 1.25 as DSO, Perl 5.005_03) on 
 Red Hat Linux 7.2, which itself came with Perl 5.6.0, and from your 
 comments, that's bad..

First of all, if it's working for you then don't worry about it.

I'm curious about this though:
 On the other hand, Oracle's product does not include all the sources 
 -which could have patches- making up the mod_perl enabled Apache

Are you saying Oracle provided special modules for you to use?  Are you 
sure they aren't just the standard DBD::Oracle stuff?  Oracle has never 
been very interested in helping people solve DBD::Oracle problems 
before, so I don't see why they would be secretly distributing special 
versions with private patches.

Unless there is some additional module provided by Oracle which has a C 
component and no source, you should be fine to replace everything they 
gave you if you want to.  I wouldn't bother though, unless it's giving 
you trouble.

- Perrin




Re: Where was that success story?

2002-03-06 Thread Perrin Harkins

Fulko Hew wrote:
 Hang on.  I just found it (by way of Slashdot)...  it was about eToys,
 October 17, 2001, its web 5 pages long, and mentions Randal Schwartz
 and Damian Conway.  I knew I wasn't dreamming!

Um, that was my article, and it certainly doesn't say anything like but 
in the end the customer threw it out and went for a competing 
technology.  You must have been thinking of something else for that part.

- Perrin




Re: Where was that success story?

2002-03-06 Thread Perrin Harkins

Kurt Hansen wrote:
 What I really want to know is: what ever happened to that eToys jingle that was on
 the commercials?

That song is by Hawaiian performer Israel Kamakawiwo`ole.  Here's a link 
to the CD:
http://album.yahoo.com/shop?d=haid=1804600529cf=10intl=us

- Perrin




<    1   2   3   4   5   6   7   8   9   10   >