RE: DNS Lookups ? huh ?

2000-06-08 Thread Rob Tanner



--On 06/08/00 13:42:45 -0600 Marc Slemko <[EMAIL PROTECTED]> wrote:

> On Thu, 8 Jun 2000, Rob Tanner wrote:
>
>> I gotta read messages all the way down before I respond.. Duh.  You said
>> they were off and I told you to turn them off.  That's probably at least
>> three demerits for me.
>>
>> Anyway, unless you have an extremely busy server, those lookups are
>> generally not that expensive.  For instance, I run TCP wrappers on all
>> my  inetd monitored ports on all my machines, and I run in paranoid mode
>> (looks  up once to get the name and then looks up the name to make sure
>> it gets  that same address back -- makes spoofing harder).  This
>> includes just about  everything but sendmail and httpd.  Even the pop
>> and imap ports are  wrapped.  The impact is negligible.
>
> No, the impact is _HUGE_ in many cases.  The problem is that there
> are many addresses out there with broken reverse DNS, so they can
> take a significant time for the lookup attempt to timeout before
> serving the pages.  You can cry that the remote systems are broken
> until you are blue in the face, and you are right.  That doesn't stop
> you from hurting those users and having them go to another site that
> works for them.  On top of that, it ties up your httpds for longer, which
> is never a good thing.
>
> In addition, most of the time the hostnames are not used for anything, so
> going to the extra pain to log them doesn't make much sense.

I am not arguing that there aren't broken name servers out there.  The 
question is what is the imapact on your system.  Since I wrap ip ports I do 
two lookups (reverse followed by a forward) everytime anyone access my 
servers for anything -- which is a great deal more that just WEB traffic. 
Again, my experience is that its imapct on my systems is negligible.  And 
unless you are getting more simultaneous WEB hits than you have apache 
processes, only the folks coming from that misconfigured domains are 
affected -- they might therefore put pressure on their DNS admins to fix 
the problem.  BESIDES, the issue the original poster had was not one of 
logging, it was access control.  If the number of subnets you are either 
allowing or denying is small (like maybe just local traffic allowed in), 
than I agree that using IP addresses is more efficient.  But otherwise you 
have to use names.  Moreover, I've seen a number of sites that wrap there 
standard network service ports using the same paranoid scheme as I use.  It 
is a minimal, but very effective weapon against all but the most serious 
spoofer.  And if any of those folks in badly administered DNS domains need 
to access such a secured site, the slowness of your WEB response to them is 
the least of their problems.

Access control and security are almost always a more important 
consideration, and that conflicts with response times, response time should 
almost always take a back seat.

-- Rob



   _ _ _ _   __ _ _ _ _
  /\_\_\_\_\/\_\ /\_\_\_\_\_\
 /\/_/_/_/_/   /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __/\/_//\/_/  PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_//\/_/
  /\/_/ \/_/  /\/_/_/\/_//\/_/ (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/ \/_/  appears profound)

  Rob Tanner
  McMinnville, Oregon
  [EMAIL PROTECTED]



RE: DNS Lookups ? huh ?

2000-06-08 Thread Hasanuddin Tamir

>> I knew Karyn Ulriksen would say on Jun 8 that,

KU] Uhmmm.  The directive...
KU] 
KU] is not   HostnameLookups Off
KU] it ISHostNameLookups Off
KU] 
KU] The default is on.  Case sensitivity.  All that... give it a whirl.
KU] We've all done it before

It's in fact case insensitif.

> perl -pi.orig -e 's,(^\s*(?!#)(?: /usr/local/apache/bin/apachectl configtest
Syntax OK

> mv httpd.conf.orig httpd.conf
> perl -pi.orig -e 's,(^\s*(?!#)(?: /usr/local/apache/bin/apachectl configtest
Syntax OK

> mv httpd.conf.orig httpd.conf

I, however, prefer the mixed case.


san
-- 
trabasLabs - TRABAS http://www.trabas.com
Enjoy the Linux revolution! 
-
Not every question deserves an answer. --anonymous




tainted operation in Apache::Session::Lock::File

2000-06-08 Thread Bruce W. Hoylman


* Server Version: Apache/1.3.13-dev (Unix) mod_perl/1.24_01-dev
* perl, version 5.005_03 built for sun4-solaris
* SunOS 5.6
* Apache::Session 1.5
* Apache::Session::Lock::File 1.00

With taint checking turned on in my modperl server, as in:

PerlTaintCheck Off
PerlWarn Off
PerlFreshRestart Off

using the Apache::Session::File causes Apache::Session::Lock::File to
croak on the second access to the session file with a message in my
error_log stating:

[Thu Jun  8 21:15:03 2000] [error] access to /TS/ failed for XX.XX.XX.XX, reason: 
Could not access session storage: Insecure dependency in open while running with -T 
switch at /opt/gnu/lib/perl5/site_perl/5.005/Apache/Session/Lock/File.pm line 62.

The line of code in my handler that is outputing this message is:

eval {tie %$session, 'Apache::Session::File', $sesid, $SESSOPTS};
if ($@) {
  $r->log_reason("Could not access session storage: $@", $r->uri);
  return SERVER_ERROR;
}

and finally, the options passed to tie() are:

%SESSOPTS = {'Directory' => '/somepath/sessions',
 'LockDirectory' => '/pathtolocks/sessions',
 'Transaction'   => 1};

permissions on these two directories are:

drwxrwx---   2 nobody nobody 512 Jun  8 21:27 /somepath/sessions/
drwxrwx---   2 nobody nobody 512 Jun  8 21:28 /pathtolocks/sessions/

where nobody.nobody are the user/group of the httpd processes.

The file is initially created, along with its correspond lock file, but
a second attempt to tie() to the existing session file returns the taint
error.  Disabling taint checking in the server allows the session logic
to proceed without error, by the way.  I would prefer not to run in this
mode, however.

Having exhausted my understanding of tainted data, I'm hoping I can get
some hints from this list.

Thanks for your attention.

Peace.



Re: Template techniques [ newbie alert + long ]

2000-06-08 Thread Randal L. Schwartz

> "Perrin" == Perrin Harkins <[EMAIL PROTECTED]> writes:

Perrin> I think the world's record for most compact implementation
Perrin> goes to Randal for a small post you can find in the archive here:
Perrin> 
http:[EMAIL PROTECTED]

Ahh yes, Apache::Cachet (it's a cache, eh?), mostly proof of concept,
aborted when I started using HTML::Mason in a serious way.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



RE: DNS Lookups ? huh ?

2000-06-08 Thread Marc Slemko

On Thu, 8 Jun 2000, Rob Tanner wrote:

> I gotta read messages all the way down before I respond.. Duh.  You said 
> they were off and I told you to turn them off.  That's probably at least 
> three demerits for me.
> 
> Anyway, unless you have an extremely busy server, those lookups are 
> generally not that expensive.  For instance, I run TCP wrappers on all my 
> inetd monitored ports on all my machines, and I run in paranoid mode (looks 
> up once to get the name and then looks up the name to make sure it gets 
> that same address back -- makes spoofing harder).  This includes just about 
> everything but sendmail and httpd.  Even the pop and imap ports are 
> wrapped.  The impact is negligible.

No, the impact is _HUGE_ in many cases.  The problem is that there
are many addresses out there with broken reverse DNS, so they can
take a significant time for the lookup attempt to timeout before
serving the pages.  You can cry that the remote systems are broken 
until you are blue in the face, and you are right.  That doesn't stop
you from hurting those users and having them go to another site that
works for them.  On top of that, it ties up your httpds for longer, which
is never a good thing.

In addition, most of the time the hostnames are not used for anything, so 
going to the extra pain to log them doesn't make much sense.  And on 
top of it, unless you enable "Hostnamelookups double" (which does a 
reverse lookup then a forward on what it gets), which are even slower,
then you can end up with a hostname that is completely useless and gives
you far less information than the IP address would.

If you don't have any hostname based access restrictions, then you don't
get any security from requiring that the reverse DNS is there.

In any case, the default is off and that is for very good reasons.




Re: Template techniques [ newbie alert + long ]

2000-06-08 Thread Perrin Harkins

On Thu, 8 Jun 2000, Greg Cope wrote:
> > > - the area I was trying to explore was how to read a template (all
> > > HTML with a few  in it) and the sub in the new content.
> > 
> > Embperl would work fine for that, but it's overkill.  Your substitution
> > approach is slower than compiling to perl subs, especially since you have
> > to load the file, but saves lots of memory and is fine for something as
> > simple as this.
> 
> Can you enlighten me into the compiling to perl subs ?

It's what Matt was talking about.  Your program parses the template,
generates perl code that produces the correct output, evals the code, and
stores the results in a sub reference which you can call whenever you want
that template.

The first time I ever saw this done was with ePerl, but I don't know if
that was really the first.  All the embedded perl systems popular around
here (Embperl, Apache::ASP, Mason, etc.) use some variation on this
technique.  I think the world's record for most compact implementation
goes to Randal for a small post you can find in the archive here:
http:[EMAIL PROTECTED]

> The file gets loaded once into shared memory - most (stripped) HTML
> files are only a few 10's of K.
> 
> Also the file gets loaded once at startup - not during the request
> stage.

You probably won't get much faster than that then, no matter what you do.  
Just make sure your regexps are fast (maybe use "study"?) and use
references for passing data.

- Perrin




RE: DNS Lookups ? huh ?

2000-06-08 Thread Ask Bjoern Hansen

On Thu, 8 Jun 2000, Rob Tanner wrote:

> Anyway, unless you have an extremely busy server, those lookups are 
> generally not that expensive.

In the general case not for you, no (except for a tied up httpd process).
But many many addresses out there have broken name server and then it will
take a while before it times out / answers / whatever. Making your site
work a lot slower for those users.

"But they're just on broken networks". Oh yes, but you hurt yourself by
hurting those users. 


 - ask

-- 
ask bjoern hansen - 
more than 70M impressions per day, 




Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Steffers

Drew wrote:
> Well, it's the end of a long day on a long week - does that get me off
> the hook? Note to self:  double check your memory next time. :-)

yup, its been a long long week alright.

On the downside, i +still+ cant get the cookies to work,
although after faking a session via telnet it seems to work
jst fine. Set-Cookie and everything. It +seems+ to be setting
the cookie, but Apache is claiming that the browser doesnt
like them (and yes, i have double checked that cookies are
enabled on our netscape clients ;). I think its probably something
to do with the layout of the servers dirctories. FeH! 

On the upside, i have about 3 months to get this working
on Apache (there are requirements for going Apache :
persistant database handles across requests, quicker
invocation of perl using mod_perl, ties in nicely with
db's)

ach well, 
thanks for all the help anyway drew, promise to let you
know what it ends up being _especially_ if its down to
one of my idiotic mistakes ;>
regards,
Stefss



Re: DNS Lookups ? huh ?

2000-06-08 Thread Ian Kallen

IIRC (it's been a while!), Apache 1.2 defaulted hOstnAmelOokups On but
it wasn't case sensitive with directive names either.

Karyn Ulriksen wrote:
> 
> OK.  I'll shut up now.  Didn't it use to be this way?  Way back in 1.2 or
> something?  I must have picked up my analness on this somewhere... (because
> I *really* am not that anal. If anybody knows whether or not this was true
> at one point, I'd like to know (for my mind's own backward compatability
> sake!)  :)  Thx.
> 
> -Original Message-
> From: Ian Kallen [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 08, 2000 3:23 PM
> To: '[EMAIL PROTECTED]'
> Subject: Re: DNS Lookups ? huh ?
> 
> No wait, this is wrong twice:  see
> http://www.apache.org/docs/mod/core.html#hostnamelookups -- default is
> off and the directive names are case insensitive.
> 
> Karyn Ulriksen wrote:
> >
> > Uhmmm.  The directive...
> >
> > is not   HostnameLookups Off
> > it ISHostNameLookups Off
> >
> > The default is on.  Case sensitivity.  All that... give it a whirl.
> > We've all done it before
> 
> --
> Salon Internet  http://www.salon.com/
>   Manager, Software and Systems "Livin' La Vida Unix!"
> Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (415) 354-3326

--
Salon Internet  http://www.salon.com/
  Manager, Software and Systems "Livin' La Vida Unix!"
Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (415) 354-3326



subprocess_env

2000-06-08 Thread Ian Kallen


I'm using a third party module that writes a bunch of variables to the
subprocess_env table to setup data for the request. It has us making
repeated class method calls like this (for our usage with Mason):
<% Blah::foo('bletch') %>

where foo is in the Blah package merely doing this:

sub foo {
my($s) = @_;
my($r) = Apache->request();
return $r->subprocess_env('foo_' . $s);
}

I'm thinking of changing the behvior to 
<% $ENV{'foo_bletch'} %>
but foo_bletch isn't in the %ENV hash, so I'm looking at initializing
every request to do this:
$r->subprocess_env->do(
 sub { my($k,$v)=@_;
   $ENV{$k}=$v;
 1; 
 }
);
to eliminate repeated accesses of the subprocess_env table; one call
populates %ENV and that's it.

Now, I don't want to kick off a debate on the performance problems that
reading/writing to the environment incur; I didn't design this behavior
I just want to make the best of it since this is what the application
requires of us. I just need to optimize access to the environment by
turning the dozen or so calls per request to Blah::foo to just %ENV.  

Any ideas regarding the expense of mulitple $r->subprocess_env vs.
accessing %ENV?

--
Salon Internet  http://www.salon.com/
  Manager, Software and Systems "Livin' La Vida Unix!"
Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (415) 354-3326



Re: [OT] Re: [performance/benchmark] printing techniques

2000-06-08 Thread Mike Lambert

> Sometimes it's worse than just ugly.  See the entry in the Perl FAQ:
>
http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#What_s_wrong_with_
always_quoting
>
> Not likely that anyone would be using something as a hash key that would
> suffer from being stringified, but possible.  It's definitely a bit slower
> as well, but that's below the noise level.

Actually, when you use a reference as a hash key, it is automatically
stringified anyway.

http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#How_can_I_use_a_re
ference_as_a_h

So that means that: $hash{"$key"} and $hash{$key}differ only in the relative
merits of their beauty. :)

Mike Lambert




Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Drew Taylor

Jerrad Pierce wrote:
> 
> A server issues Set-Cookie: a client replies with Cookie:
It makes sense now that I think about it. I always use CGI.pm or
Apache::Cookie to get the cookies so I never had to look at the incoming
cookie headers. Live and learn eh? 

Well, it's the end of a long day on a long week - does that get me off
the hook? Note to self:  double check your memory next time. :-)

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



RE: DNS Lookups ? huh ?

2000-06-08 Thread Karyn Ulriksen

OK.  I'll shut up now.  Didn't it use to be this way?  Way back in 1.2 or
something?  I must have picked up my analness on this somewhere... (because 
I *really* am not that anal. If anybody knows whether or not this was true 
at one point, I'd like to know (for my mind's own backward compatability 
sake!)  :)  Thx.

-Original Message-
From: Ian Kallen [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 08, 2000 3:23 PM
To: '[EMAIL PROTECTED]'
Subject: Re: DNS Lookups ? huh ?


No wait, this is wrong twice:  see
http://www.apache.org/docs/mod/core.html#hostnamelookups -- default is
off and the directive names are case insensitive.

Karyn Ulriksen wrote:
> 
> Uhmmm.  The directive...
> 
> is not   HostnameLookups Off
> it ISHostNameLookups Off
> 
> The default is on.  Case sensitivity.  All that... give it a whirl.
> We've all done it before

--
Salon Internet  http://www.salon.com/
  Manager, Software and Systems "Livin' La Vida Unix!"
Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (415) 354-3326



Re: DNS Lookups ? huh ?

2000-06-08 Thread Ian Kallen

No wait, this is wrong twice:  see
http://www.apache.org/docs/mod/core.html#hostnamelookups -- default is
off and the directive names are case insensitive.

Karyn Ulriksen wrote:
> 
> Uhmmm.  The directive...
> 
> is not   HostnameLookups Off
> it ISHostNameLookups Off
> 
> The default is on.  Case sensitivity.  All that... give it a whirl.
> We've all done it before

--
Salon Internet  http://www.salon.com/
  Manager, Software and Systems "Livin' La Vida Unix!"
Ian Kallen <[EMAIL PROTECTED]> / AIM: iankallen / Fax: (415) 354-3326



RE: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Jerrad Pierce

A server issues Set-Cookie: a client replies with Cookie:

  o _
 /|/ |   Jerrad Pierce \ | __|_ _|
 /||/   http://pthbb.org  .  | _|   |
 \||  _.-~-._.-~-._.-~-._@"  _|\_|___|___|


> -Original Message-
> From: Drew Taylor [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 08, 2000 18:11
> To: Paul
> Cc: modperl
> Subject: Re: Apache, Mod_Perl and Custom Access/Authentication
> 
> 
> Paul wrote:
> > 
> > > Drew wrote:
> > > > Going by your previous example, you should use
> > > > $cookie = $r->header_in('Set-Cookie');
> > 
> > Quick reality check here -- I'm easy to confuse. =o)
> > 
> > Shouldn't that be
> > 
> >$cookie = $r->header_in('Cookie')
> > 
> > to get cookies the browser sends, and then something like
> > 
> >$r->headers_out->add('Set-Cookie' => "$name=$val")
> > 
> > to place new ones?
> I'm pretty sure I'm right on this one. ;-) $r->headers_in|out are
> getting/setting actual HTTP headers. Last I checked, the HTTP 
> spec says
> you use 'Set-Cookie' for cookies. Of course, I am frequently wrong as
> well, but I don't think I am in this case.
> 
> 
> -- 
> Drew Taylor
> Vialogix Communications, Inc.
> 501 N. College Street
> Charlotte, NC 28202
> 704 370 0550
> http://www.vialogix.com/
> 



Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Drew Taylor

Paul wrote:
> 
> > Drew wrote:
> > > Going by your previous example, you should use
> > > $cookie = $r->header_in('Set-Cookie');
> 
> Quick reality check here -- I'm easy to confuse. =o)
> 
> Shouldn't that be
> 
>$cookie = $r->header_in('Cookie')
> 
> to get cookies the browser sends, and then something like
> 
>$r->headers_out->add('Set-Cookie' => "$name=$val")
> 
> to place new ones?
I'm pretty sure I'm right on this one. ;-) $r->headers_in|out are
getting/setting actual HTTP headers. Last I checked, the HTTP spec says
you use 'Set-Cookie' for cookies. Of course, I am frequently wrong as
well, but I don't think I am in this case.


-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



Re: Template techniques [ newbie alert + long ]

2000-06-08 Thread Greg Cope

Perrin Harkins wrote:
> 
> On Thu, 8 Jun 2000, Greg Cope wrote:
> > My original question was not related to templates (I'll use embperl for
> > that)
> 
> Well, I'm confused now.  You'll use Embperl for templates but you're not
> using Embperl for templates?

I use Embperl when I want a templating system - but not when using HTML
templates (wrong use of names on my part) - I am refering to a template
in this case as an HTML file with a few special tags.

> 
> > - the area I was trying to explore was how to read a template (all
> > HTML with a few  in it) and the sub in the new content.
> 
> Embperl would work fine for that, but it's overkill.  Your substitution
> approach is slower than compiling to perl subs, especially since you have
> to load the file, but saves lots of memory and is fine for something as
> simple as this.

Can you enlighten me into the compiling to perl subs ?

The file gets loaded once into shared memory - most (stripped) HTML
files are only a few 10's of K.

Also the file gets loaded once at startup - not during the request
stage.

> > Has anyone any suggestions as to speeding this up - yet keeping it
> > simple - I have played with referances to avoid all the variable copying
> > etc . ?
> 
> Caching templates in memory would certainly help, but you'll eat up a
> chunk of RAM.

If the html is usually reasonable in size, and the code I C&P'ed strips
the template into one long strip with spaces / tabs (designers making
things all indented etc ..) at each end of the string - and chomp.

Also the templates are modular - in that one template covers main part
of the page, and other templates cover the rest.  This helps contiunity
in HTML design etc .. (i.e only make one changen in one place)


Thanks for the input.

Greg

> 
> - Perrin



Re: Any suggestions or help, Thanks

2000-06-08 Thread Perrin Harkins

Turn on Apache::DBI's debugging messages and see if it's working
properly.
- Perrin

On Wed, 7 Jun 2000, Hui Zhu wrote:

> Hi Everybody:
> 
> I got big problems. Same query and same script. Sometimes it works fine
> but sometimes i get the following
> errors (i am so frustrated, have no idea what i need to do):
> 
> DBD::mysql::db do failed: MySQL server has gone away at cnznetmod.pm
> line 151.
> DBD::mysql::st execute failed: MySQL server has gone away at
> cnznetmod.pm line 159.
> DBD::mysql::st execute failed: MySQL server has gone away at
> cnznetmod.pm line 130.
> DBD::mysql::st fetchrow failed: fetch() without execute() at
> cnznetmod.pm line 131.
> 
> I remember that i had a same problem when our system upgrated last time.
> Once i reinstalled ApacheDBI-0.87,
> it works fine. But this time, i did so but it still doesn't work. Thank
> you for your help.
> 
> Steven.
> 
> BTW: Linux redhat6.2, ApacheDBI-0.87, DBI-1.13, Modperl-1.21,
> Msql-Mysql-modules-1.22
>   Mysql3.22
> 
> 
> 
> 
> 




Re: [OT] Re: [performance/benchmark] printing techniques

2000-06-08 Thread Perrin Harkins

On Thu, 8 Jun 2000, Matt Sergeant wrote:

> > The one that bugs me is when I see people doing this:
> > 
> > $hash{"$key"}
> > 
> > instead of this:
> > 
> > $hash{$key}
> 
> Those two now also result in the same code. ;-)
> 
> But the former is just ugly.

Sometimes it's worse than just ugly.  See the entry in the Perl FAQ:
http://www.perl.com/pub/doc/manual/html/pod/perlfaq4.html#What_s_wrong_with_always_quoting

Not likely that anyone would be using something as a hash key that would
suffer from being stringified, but possible.  It's definitely a bit slower
as well, but that's below the noise level.

- Perrin




Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Paul

> Drew wrote:
> > Going by your previous example, you should use 
> > $cookie = $r->header_in('Set-Cookie');

Quick reality check here -- I'm easy to confuse. =o)

Shouldn't that be

   $cookie = $r->header_in('Cookie')

to get cookies the browser sends, and then something like

   $r->headers_out->add('Set-Cookie' => "$name=$val")

to place new ones?
Not that there aren't plenty more ways

Paul

At the hat-check, why don't they? ;o]
(grenade humor...tickingdud?)

__
Do You Yahoo!?
Yahoo! Photos -- now, 100 FREE prints!
http://photos.yahoo.com



Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Drew Taylor

Steffers wrote:
> 
> you know, its really funny. We have the book right on our
> shelf, but we are more a 'perl cookbook' sort (need an answer
> then heres sample code).
Use the tool that best fits the situation. I have both books on my
shelf. ;-)


> When I run the Ticket code from chapter 6 i +always+ get the
> 'no cookies' error.
> 
> Now, the netscape here is 4.73 and it DOES have 'always accept
> cookies' activated. I can set cookies on this browser without using
> Apache code jsst plain CGI, so i thought it must be a configure
> option missed at compile time. I read and as far as I am aware i
> got evrything in there (EVERYTHING=1 and lots of ACAPI modules)
> but i DIDNT install mod_usertrack from what I can see, but this doesnt
> matter with 'ordinary' cookies only for click tracking right ?
Check the domain for the cookie... The default is nothing, which just
uses the current host. I fell prey to that at first too. :-) Barring
that, using lwp-request or plain old telnet to see the exact headers
being sent will give you more ideas.

Keep it up. I had problems first implementing the Ticket system in Ch 6,
but it's successfully working now on our Intranet. You WILL get it to
work eventually...

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



Re: Template techniques [ newbie alert + long ]

2000-06-08 Thread Perrin Harkins

On Thu, 8 Jun 2000, Greg Cope wrote:
> My original question was not related to templates (I'll use embperl for
> that)

Well, I'm confused now.  You'll use Embperl for templates but you're not
using Embperl for templates?

> - the area I was trying to explore was how to read a template (all
> HTML with a few  in it) and the sub in the new content.

Embperl would work fine for that, but it's overkill.  Your substitution
approach is slower than compiling to perl subs, especially since you have
to load the file, but saves lots of memory and is fine for something as
simple as this.
 
> Has anyone any suggestions as to speeding this up - yet keeping it
> simple - I have played with referances to avoid all the variable copying
> etc . ?

Caching templates in memory would certainly help, but you'll eat up a
chunk of RAM.

- Perrin




Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Steffers

Drew wrote:
> Going by your previous example, you should use 
> $cookie = $r->header_in('Set-Cookie');

i actually prefer the headers_in after reading about it.
(personal preference and lazy to boot ;)

> You might also want to take a look at headers_in() (that's PLURAL). It
> is a little more flexible in retrieving values.

indeed it is. much preferred.

> I can't say off the top of my head. Have you read the mod_perl book?
> Chapter 6 is all about authentication & Authorization. Reading it might
> help you understand the concepts better. As for your code, I
> unfortuntely am not sure where to tell you to start.
> 

you know, its really funny. We have the book right on our
shelf, but we are more a 'perl cookbook' sort (need an answer
then heres sample code). 

ANYWAY, I went to the modperl site and downloaded the code
for chapter 6, seemed to be sorta what I want, so I have hacked
the authenticate code to jst connect up using login & passwd
and then return ("") on success (almost the same).

I have also plan to take out the 'secret' (dont need that functionality)
and also add in ssl's at some point in the future.

Here is the clincher. 

When I run the Ticket code from chapter 6 i +always+ get the 
'no cookies' error. 

Now, the netscape here is 4.73 and it DOES have 'always accept
cookies' activated. I can set cookies on this browser without using
Apache code jsst plain CGI, so i thought it must be a configure
option missed at compile time. I read and as far as I am aware i
got evrything in there (EVERYTHING=1 and lots of ACAPI modules)
but i DIDNT install mod_usertrack from what I can see, but this doesnt
matter with 'ordinary' cookies only for click tracking right ?

So what could possibly be wrong ? The Apache test 'skips' the cookies
test on this platform (Stock Mandrake 7 linux + Perl 5.6 + DBI 1.13 and
Pg 0.93). hhrmm.

have i been an idiot here ;> 

thanks for the help btw,
^Stefs^



Re: Template techniques

2000-06-08 Thread Perrin Harkins

On Thu, 8 Jun 2000, Bernhard Graf wrote:

> Chris Winters wrote:
> 
> > The newest version of Template Toolkit (currently in alpha) supports
> > compiling templates to perl code. See about 2/3 of the way down the
> > the README at www.template-toolkit.org. Why reinvent the wheel? :)
> 
> Also the current stable (1.06) can do this.

Not quite.  The current version uses its own system of opcodes (!) which
are implemented as closures.  Compiling to perl code gives much better
performance, which is why Andy is changing this.

Template Toolkit rocks, and will rock even more when it has the extra
speed.

- Perrin




stack dump

2000-06-08 Thread Blue


Apache 1.3.12, mod_perl 1.24 (USE_EVERYTHING=1), perl 5.6, linux 2.2.12

#0  0x4030d130 in XS_Apache_content_type ()
   from /usr/local/apache/libexec/libperl.so
#1  0x4030d104 in XS_Apache_content_type ()
   from /usr/local/apache/libexec/libperl.so
#2  0x806b9e4 in run_method ()
#3  0x806bae8 in ap_header_parse ()
#4  0x807f049 in process_request_internal ()
#5  0x807f3fc in ap_process_request ()
#6  0x8076c9e in child_main ()
#7  0x8076e2c in make_child ()
#8  0x8076f89 in startup_children ()
#9  0x80775b6 in standalone_main ()
#10 0x8077d43 in main ()
#11 0x4007f9cb in __libc_start_main (main=0x80779fc , argc=2, 
argv=0xbb74, init=0x804ebf4 <_init>, fini=0x80ac03c <_fini>, 
rtld_fini=0x4000ae60 <_dl_fini>, stack_end=0xbb6c)
at ../sysdeps/generic/libc-start.c:92


happens every time i try to load the web page. if there is any more info i
can give, please let me know.

thanks,

-- 
Blue Lang  Unix Systems Admin
QSP, Inc., 3200 Atlantic Ave, Ste 100, Raleigh, NC, 27604
Home: 919 835 1540  Work: 919 875 6994  Fax: 919 872 4015





Re: Template techniques [ newbie alert + long ]

2000-06-08 Thread Greg Cope

Chris Winters wrote:
> 
> * [EMAIL PROTECTED] ([EMAIL PROTECTED]) [000608 11:07]:
> > I'm curious Matt, as opposed to what?, reparsing the template each
> > run?  Clearly reparsing would be a big loser in terms of performance.
> >
> > But what other technique could be used..., hrm.., without direct
> > control over the pipe, I really don't think it would get too much
> > better than this.  I mean, you could yank out sections and stuff it
> > into an array that would be like: text, coderef, coderef, text, etc.
> > Like in an ASP template you would parse the file, grab sections
> > between <% %> and eval it as a code ref, and stuff it into your array.
> > But this would probably not work specifically in ASP's case, but you
> > might be able to pull it off in Embperl.  (Unless the array itself
> > could also point to arrays, etc.)  Overall..., I think compiling it
> > directly makes a lot more sense in 99.999% of template languages...,
> > otherwise you'd end up putting too many restrictions on the template
> > language itself.
> >
> > Hmm..., sort of an interesting question, what ways could be utilized
> > in order to maximize speed in template execution.  I thought about
> > this a while ago, but after the fact I have to agree with Matt...,
> > just evaling each template as a package, or a code ref would be a
> > lot quicker, and if you could cook up another scheme, the resulting
> > code complexity might not pan out to be worth it.
> 
> The newest version of Template Toolkit (currently in alpha) supports
> compiling templates to perl code. See about 2/3 of the way down the
> the README at www.template-toolkit.org. Why reinvent the wheel? :)

My original question was not related to templates (I'll use embperl for
that) - the area I was trying to explore was how to read a template (all
HTML with a few  in it) and the sub in the new content.

My pages usually have serveral templates - or one larger template with
comments arround iterative bits (tables) so that I end up with a main
template which may look something like:







>





and a table template:



The Designers / HTML coders I work with can then chop and change these
templates - I have made a template loader that strips the iterative
table content out into a seperate template, so that they can code a fake
entry for design reasons - and I then strip it out (looking for some
special HTML comment tags).

In a startup.pl The code then looks somat like this forgive the probably
uncompliable perl etc ... this is for explaination purposes:

use vars (MAINTMP TABLETMP);

$MAINTMP = &load('main.tmp');
$TABLETMP = &load('table.tmp');


sub load {

my $file = shift;
my $html = '';

open (TEMPLATE, $file) || die ('Cant open : ', $file, $!);
while () {
chomp;
$_ =~ s/^\s+//;
$_ =~ s/\s+$//;
$html = $html . $_;
}
close (TEMPLATE)  || die ('Cant close : ', $file, $!);
return $html; 
}


then in a handler:

sub makeTableContents {

# assumes @_ is a nice list in order of values
# to insert into the table ..
my $template = $TABLETMP;
my $tablehtml;
foreach (@_) {
$template ~= s//$_/;
$tableHTML .= $template;
}
return $tableHTML;
}


sub doStuff {

# assumes that it is passed in the return value from
# makeTableContents and a title
my $tableHTML = shift;
my $title = shift;
my $template = $MAINTMP;

$template =~ s//$title/;
$template =~ s//$tableHTML/;

return $template;
}

Then when I want to send it I just print the return value of doStuff

This may not be OO - but it is simplistic, and although not benchmarked,
should be fast.  I have seen another OO ish implentation, that uses a
hash a bit like  Mats example - this allows more flexibility as all you
need do is add the tag to the HTML, and then add the tag to the hash -
then when you do the regex it gets put in.

Has anyone any suggestions as to speeding this up - yet keeping it
simple - I have played with referances to avoid all the variable copying
etc . ?

Thinking about it Mat's example is far more scalable, and reusable.

I am enjoying this thread ;-)

Greg Cope


> Chris
> 
> --
> Chris Winters
> Internet DeveloperINTES Networking
> [EMAIL PROTECTED]http://www.intes.net/
> Integrated hardware/software solutions to make the Internet work for you.




Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Drew Taylor

Steffers wrote:
> 
> Drew wrote:
> > Steffers wrote:
> > > my $header_ID=$r->header_in('sessionID');
> > If you're trying to get at the cookie, this is not the way. Either use
> > Apache::Cookie or CGI.pm to get the cookie contents.
> >
> 
> okay. I have changd the line to the usual
> 
> my $header_ID=cookie(-name=>'sessionID');
Going by your previous example, you should use 

$cookie = $r->header_in('Set-Cookie');
# stuff if you cookie value contains more then 
# just the sessionID - ie ID=1234567&foo=bar

You might also want to take a look at headers_in() (that's PLURAL). It
is a little more flexible in retrieving values.

> > This code is good. But it doesn't jive with what you have above. Try
> > making the first handler() actually get the cookie. Or am I missing
> > something?
> 
> nope. i thought that header_in would get the cookie, and now
> i understand that it would if i had 'header_in('Set-Cookie')'
> (or maybe jst cookie) and then i would have to parse out the
> values myself.
If using the header_in() method, you have to get 'Set-Cookie'
(case-insensitive). It's part of the HTTP headers sent in the original
request.

> I jst dont understand quite what I am doing wrong. I know that i
> could get standard modules and +maybe+ get the functionality
> i want, but i would rather learn about Apache+perl than jst
> take some code at face value.
I can't say off the top of my head. Have you read the mod_perl book?
Chapter 6 is all about authentication & Authorization. Reading it might
help you understand the concepts better. As for your code, I
unfortuntely am not sure where to tell you to start.

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



RE: DNS Lookups ? huh ?

2000-06-08 Thread Vivek Khera

> "KU" == Karyn Ulriksen <[EMAIL PROTECTED]> writes:

KU> Uhmmm.  The directive...
KU> is not   HostnameLookups Off
KU> it ISHostNameLookups Off

If apache doesn't recognize a configuration directive, it will puke at
you, not just silently go about its merry way.



RE: DNS Lookups ? huh ?

2000-06-08 Thread Karyn Ulriksen

Uhmmm.  The directive...

is not   HostnameLookups Off
it ISHostNameLookups Off

The default is on.  Case sensitivity.  All that... give it a whirl.
We've all done it before

-Original Message-
From: Rob Tanner [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 08, 2000 11:36 AM
To: Paul G. Weiss; 'David Brown'; [EMAIL PROTECTED]
Subject: RE: DNS Lookups ? huh ?


I gotta read messages all the way down before I respond.. Duh.  You said 
they were off and I told you to turn them off.  That's probably at least 
three demerits for me.

Anyway, unless you have an extremely busy server, those lookups are 
generally not that expensive.  For instance, I run TCP wrappers on all my 
inetd monitored ports on all my machines, and I run in paranoid mode (looks 
up once to get the name and then looks up the name to make sure it gets 
that same address back -- makes spoofing harder).  This includes just about 
everything but sendmail and httpd.  Even the pop and imap ports are 
wrapped.  The impact is negligible.

As far as the access rule, if the number of IP networks in question makes 
doing access control by IP address too cumbersome, I suggest you install a 
local cache only name server (only configured with the cache and loopback 
files).  Since it caches addresses (as all name servers do), you'll spend 
somewhat less time in name lookups.  If it's only your own domain you want 
in, but it's still too cumbersome to do by IP, make the server a secondary 
server for those addreses and set it up to do non-recursive lookups.  That 
means that if it can't resolve the address itself, it sends back an error 
-- it doesn't go out to the net.  I presume that apache, at that point, 
will deny access.

Hope this is more useful than my last response.

-- Rob

--On Thursday, June 08, 2000 1:17 PM -0400 "Paul G. Weiss" 
<[EMAIL PROTECTED]> wrote:

> Usually this is a result of an access rule:
>
>deny from all
>allow from *.mydomain.com
>
> When this happens Apache needs to do a lookup on
> the name even though you specified HostnameLookups
> off.
>
> I don't know what mod_perl would have had to do with
> it unless the installation modified your httpd.conf
> file.
>
> -Paul
>
>
> -Original Message-
> From: David Brown [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 08, 2000 11:08 AM
> To: [EMAIL PROTECTED]
> Subject: DNS Lookups ? huh ?
>
>
> Since upgrading to the latest verion of mod_perl I've noticed that I get
> remote host names appearing in my access logs rather than IP addresses (in
> 80% of entries).
>
> My concern is that my machine is try to perform DNS lookups, and the
> subsequent load it may add.
>
> My httpd.conf has-> HostnameLookups Off
>
> Could it just be that many browsers are supplying their remote host in
> their request .. if so, why have I not seen it before ?
>
> None of my scripts query $REMOTE. values.
>
> Perhaps my recompilation of Apache triggered something I'd not had enabled
> before.
>
>




   _ _ _ _   __ _ _ _ _
  /\_\_\_\_\/\_\ /\_\_\_\_\_\
 /\/_/_/_/_/   /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __/\/_//\/_/  PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_//\/_/
  /\/_/ \/_/  /\/_/_/\/_//\/_/ (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/ \/_/  appears profound)

  Rob Tanner
  McMinnville, Oregon
  [EMAIL PROTECTED]



RE: DNS Lookups ? huh ?

2000-06-08 Thread Rob Tanner

I gotta read messages all the way down before I respond.. Duh.  You said 
they were off and I told you to turn them off.  That's probably at least 
three demerits for me.

Anyway, unless you have an extremely busy server, those lookups are 
generally not that expensive.  For instance, I run TCP wrappers on all my 
inetd monitored ports on all my machines, and I run in paranoid mode (looks 
up once to get the name and then looks up the name to make sure it gets 
that same address back -- makes spoofing harder).  This includes just about 
everything but sendmail and httpd.  Even the pop and imap ports are 
wrapped.  The impact is negligible.

As far as the access rule, if the number of IP networks in question makes 
doing access control by IP address too cumbersome, I suggest you install a 
local cache only name server (only configured with the cache and loopback 
files).  Since it caches addresses (as all name servers do), you'll spend 
somewhat less time in name lookups.  If it's only your own domain you want 
in, but it's still too cumbersome to do by IP, make the server a secondary 
server for those addreses and set it up to do non-recursive lookups.  That 
means that if it can't resolve the address itself, it sends back an error 
-- it doesn't go out to the net.  I presume that apache, at that point, 
will deny access.

Hope this is more useful than my last response.

-- Rob

--On Thursday, June 08, 2000 1:17 PM -0400 "Paul G. Weiss" 
<[EMAIL PROTECTED]> wrote:

> Usually this is a result of an access rule:
>
>deny from all
>allow from *.mydomain.com
>
> When this happens Apache needs to do a lookup on
> the name even though you specified HostnameLookups
> off.
>
> I don't know what mod_perl would have had to do with
> it unless the installation modified your httpd.conf
> file.
>
> -Paul
>
>
> -Original Message-
> From: David Brown [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 08, 2000 11:08 AM
> To: [EMAIL PROTECTED]
> Subject: DNS Lookups ? huh ?
>
>
> Since upgrading to the latest verion of mod_perl I've noticed that I get
> remote host names appearing in my access logs rather than IP addresses (in
> 80% of entries).
>
> My concern is that my machine is try to perform DNS lookups, and the
> subsequent load it may add.
>
> My httpd.conf has-> HostnameLookups Off
>
> Could it just be that many browsers are supplying their remote host in
> their request .. if so, why have I not seen it before ?
>
> None of my scripts query $REMOTE. values.
>
> Perhaps my recompilation of Apache triggered something I'd not had enabled
> before.
>
>




   _ _ _ _   __ _ _ _ _
  /\_\_\_\_\/\_\ /\_\_\_\_\_\
 /\/_/_/_/_/   /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __/\/_//\/_/  PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_//\/_/
  /\/_/ \/_/  /\/_/_/\/_//\/_/ (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/ \/_/  appears profound)

  Rob Tanner
  McMinnville, Oregon
  [EMAIL PROTECTED]



Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Steffers

Drew wrote:
> Steffers wrote:
> > my $header_ID=$r->header_in('sessionID');
> If you're trying to get at the cookie, this is not the way. Either use
> Apache::Cookie or CGI.pm to get the cookie contents.
> 

okay. I have changd the line to the usual 

my $header_ID=cookie(-name=>'sessionID');

but still no joy. If I put the .htaccess in the '/' of Apache
and then try to 'login'. The form that is generated by the 
403 is the default login screen, and the form calls a cgi
underneath the '/connect/' directory. (with an .htaccess
that calls only the PerlAuthen handler)

Now from reading the logs, I can see that the authenitication
isnt being called, so fair enough, i moved the .htaccess to a
'/login/' directory, so that users will have to go there to login,
and when they hit the submit button the custom generated
form will direct them to /connect/connect.cgi 

howver, all that happens now is that when i click the submit 
button i get the info box of no data returned. Still using the
same code (as it were). If i run the .cgi from command line
it does output the initial welcome screen.

Hrmmm. Any ideas ? maybe my conf is all stuffed up, but
i sincerely doubt it, its a pretty vanilla conf. nothing too
radical ;)

> This code is good. But it doesn't jive with what you have above. Try
> making the first handler() actually get the cookie. Or am I missing
> something?

nope. i thought that header_in would get the cookie, and now
i understand that it would if i had 'header_in('Set-Cookie')' 
(or maybe jst cookie) and then i would have to parse out the
values myself.

I jst dont understand quite what I am doing wrong. I know that i
could get standard modules and +maybe+ get the functionality
i want, but i would rather learn about Apache+perl than jst
take some code at face value.

anywayz,
many thanks for the help.
^Stefs^



[OT] Re: Apache::ASP

2000-06-08 Thread Mike Miller

On Thu, 08 Jun 2000 14:10:26 -0400, Drew Taylor wrote:

>As I believe someone else said earlier, your code is VisualBasic, which
>I'm reasonably sure Apache::ASP will NOT run. 

Would be truly neat if it did !  But then the question "why use VB instead of 
Perl in a perl based 
system (mod_perl) in the first place" comes to mind ...

Rgrds,

-M.






Re: Apache::ASP

2000-06-08 Thread Drew Taylor

Clement Law wrote:
> 
> Please help, this isn't a virus, I just want my asp thing to work.
> 
> I get a 500 Internal Server Error when I try to run a ASP file.
> I'm using Windows NT Server. And the webserver I'm using is Apache V1.3.12
> with Mod_perl
> Perl: c:\usr\perl\bin
> ASP.PM: c:\usr\perl\site\lib\apache\asp.pm
> Other: c:\usr\perl\lib
> I'm using Virtual Hosts in Apache too.
> I have no clue what's the problem right now.
As I believe someone else said earlier, your code is VisualBasic, which
I'm reasonably sure Apache::ASP will NOT run. You'd need to use IIS to
use VB based Active Server pages. Nothing you can do to Apache::ASP is
going to fix the problems you are having.

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



RE: DNS Lookups ? huh ?

2000-06-08 Thread Paul G. Weiss

Usually this is a result of an access rule:

deny from all
allow from *.mydomain.com

When this happens Apache needs to do a lookup on
the name even though you specified HostnameLookups
off.

I don't know what mod_perl would have had to do with
it unless the installation modified your httpd.conf
file.

-Paul


-Original Message-
From: David Brown [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 08, 2000 11:08 AM
To: [EMAIL PROTECTED]
Subject: DNS Lookups ? huh ?


Since upgrading to the latest verion of mod_perl I've noticed that I get
remote host names appearing in my access logs rather than IP addresses (in
80% of entries).

My concern is that my machine is try to perform DNS lookups, and the
subsequent load it may add.

My httpd.conf has-> HostnameLookups Off

Could it just be that many browsers are supplying their remote host in their
request .. if so, why have I not seen it before ?

None of my scripts query $REMOTE. values.

Perhaps my recompilation of Apache triggered something I'd not had enabled
before.





Re: DNS Lookups ? huh ?

2000-06-08 Thread David Brown

The problem was solved offline with the kind help of Bill Mosely, but I'll
post the solution here for the masses.

I had an entry in my httpd.conf to the tune of something like:

Deny from some.bad.domain.com

As this was a name and not an IP address, the machine had to lookup each
incoming IP address to make sure it didn't match the domain name listed in
Deny from...

(The rebuild of mod_perl coincided with some dolt flooding our machine)





Re: DNS Lookups ? huh ?

2000-06-08 Thread Rob Tanner

In httpd.conf, make sure HostNameLookups is OFF.  The default is ON when 
you build apache (in the httpd.conf that the build generates).

-- Rob


--On Thursday, June 08, 2000 4:08 PM +0100 David Brown <[EMAIL PROTECTED]> 
wrote:

> Since upgrading to the latest verion of mod_perl I've noticed that I get
> remote host names appearing in my access logs rather than IP addresses (in
> 80% of entries).
>
> My concern is that my machine is try to perform DNS lookups, and the
> subsequent load it may add.
>
> My httpd.conf has-> HostnameLookups Off
>
> Could it just be that many browsers are supplying their remote host in
> their request .. if so, why have I not seen it before ?
>
> None of my scripts query $REMOTE. values.
>
> Perhaps my recompilation of Apache triggered something I'd not had enabled
> before.
>
>
>


-- Rob

   _ _ _ _   __ _ _ _ _
  /\_\_\_\_\/\_\ /\_\_\_\_\_\
 /\/_/_/_/_/   /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __/\/_//\/_/  PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_//\/_/
  /\/_/ \/_/  /\/_/_/\/_//\/_/ (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/ \/_/  appears profound)

  Rob Tanner
  McMinnville, Oregon
  [EMAIL PROTECTED]



Re: Method overhead benchmarks [Was: [performance/benchmark] printingtechniques]

2000-06-08 Thread Barrie Slaymaker

Matt Sergeant wrote:
> 
> You also forgot that print() goes to a tied STDOUT, which is even more of
> an overhead...

Yeah, that'd probably swamp almost all other effects Stas is testing right
there, and it explains Stas's test results when varying $|.

- Barrie



Re: [performance/benchmark] printing techniques

2000-06-08 Thread Barrie Slaymaker

[Sorry for the delay: didn't notice this since it was sent only to the list]

Eric Cholet wrote, in part:
> 
> I never advocated optimizing at the expense of the above criteria, we
> were discussing optimizations only. I certainly believe a program is a
> compromise, and have often chosen some of those criteria as being
> more important than performance savings.

Sorry: I took your statement at face value.  I'm well aware that you're 
not that shallow :-).

- Barrie



Can't create custom config directives (long)

2000-06-08 Thread Rob Tanner

Hi All,

(This message is VERY long --I'm trying to include as much information as I 
can)

Back on June 3 I posted a message about a problem I was having installing 
custom configuration directives.  Since then, I have been going over 
everything with a fine tooth comb -- which was probably not worth the 
effort at all because the whole process (at least as explained in the eagle 
book) is a piece of cake.  Basically, perl does all the hard work and all I 
do is a couple of tables.

Last night I rebuilt apache and mod_perl (versions 1.3.12 and 1.23 
respectively -- mod_perl being compiled in and not a dso) in order to build 
mod_perl with the PERL_TRACE option, and also to discover if there was 
something flaky in the previous build.  If the latter is the case, the 
flakiness carried over since it still fails.

Basically, when you invoke httpd as a daemon, it starts up successfully, 
parses the httpd.conf file, finds no problem and returns with an exit code 
of '0', meaning that it found no problem and forked off the daemonm copy. 
Thus, apachectl reports that apache was successfully started.  Howver, the 
daemon dies quickly and reports in the error_log:

MirrorWiseKeyFile', perhaps mis-spelled or defined by a module not
included in the server configuration

If I actually mess with the directive, spell it wrong or add or remove an 
argument, when apache originally parses the httpd.conf file it finds reason 
to complain, and apachectl does not come back and report a successful 
startup.  Rather, it report an error, run "apachectl configtest" to see the 
error.  Also, when I add various debug hooks into the callback for the 
directive, I can confirm that it's being invoked and getting the argument 
(it's a TAKE1).  So, whatever is going on is something else, and it's 
happening after the initial fork.

I have included the debug output below, tracing was set to "all".

> [root@cheshire apache]# bin/httpd -X
> perl_parse args: '/dev/null' ...allocating perl interpreter...ok
> constructing perl interpreter...ok
> ok
> running perl interpreter...ok
> mod_perl: 0 END blocks encountered during server startup
> PerlRequire: arg=`conf/startup.pl'
> attempting to require `conf/startup.pl'
> loading perl module 'Apache::Constants::Exports'...ok
> perl_cmd_fresh_restart: 1
> perl_cmd_setenv: 'PERL_DESTRUCT_LEVEL' = '-1'
> perl_cmd_setenv: 'DBMauthFile' = 'private/authen/passwdMD5'
> loading perl module 'Apache'...ok
> PerlModule: arg='Apache::MirrorWise'
> loading perl module 'Apache::MirrorWise'...ok
> init `PerlHandler' stack
> perl_cmd_push_handlers: @PerlHandler, 'Apache::MirrorWise'
> pushing `Apache::MirrorWise' into `PerlHandler' handlers
> blessing cmd_parms=(0xbfffda68)

However, in the error log we read:

> Syntax error on line 16 of /usr/local/apache/conf/perl.conf:
> Invalid command 'MirrorWiseKeyFile', perhaps mis-spelled or defined by a 
> module not included in the server configuration

This is the perl.conf file that contains the directive:


> PerlRequire   conf/startup.pl
> PerlFreshRestart  On
>
> #
> #  SetHandler perl-script
> #  PerlHandler Apache::Hello
> #
> #
> PerlSetEnv PERL_DESTRUCT_LEVEL -1
> PerlSetEnv DBMauthFile private/authen/passwdMD5
> #
> PerlModule  Apache::MirrorWise
> SetHandler  perl-script
> PerlHandler Apache::MirrorWise
> #
> MirrorWiseKeyFile conf/keyfile
>

Anybody have any ideas?

Thanks,
Rob


ATTACHED HISTORY:

Here follows the original post and a dialogue I had with another member of 
the list.  His suggestions were helpful, but did not resolve the issue.

> Hi all,
>
> I'm trying to create several custom configuration directives, and have
> pretty mucg followed the eample in the eagle book (pp 387-394).
>
> I start Apache up -- get no configuration complaints and apachectl comes
> back saying Apache started.  The info messages in the error log,
> however, indicate otherwise.  To wit:
>
> Invalid command 'MirrorWiseKeyFile', perhaps mis-spelled or defined by a
> module not included in the server configuration
>
> In Makefile.PL, I include:
> my @directives = (
>  { name => 'MirrorWiseKeyFile',
>errmsg   => 'location of password DB key file',
>args_how => 'TAKE1',
>req_override => 'OR_ALL' },
>   {
>  added to httpd.conf>  },
>  );
>
> command_table(\@directives);
>
> # See lib/ExtUtils/MakeMaker.pm for details of how to influence
> # the contents of the Makefile that is written.
> WriteMakefile(
>  'NAME' => __PACKAGE__,
>  'VERSION_FROM' => 'MirrorWise.pm',
>  'INC'  => Apache::src->new->inc,
>  'INSTALLSITEARCH'   => $install_here,
>  'INSTALLSITELIB'=> $install_here,
> );
>
> 1;
>
> The $install_here, above, is simply a scalar set to the module root
> in the Apache doc root 

Re: Template techniques

2000-06-08 Thread Randal L. Schwartz

> "Bernhard" == Bernhard Graf <[EMAIL PROTECTED]> writes:

Bernhard> Chris Winters wrote:
>> The newest version of Template Toolkit (currently in alpha) supports
>> compiling templates to perl code. See about 2/3 of the way down the
>> the README at www.template-toolkit.org. Why reinvent the wheel? :)

Bernhard> Also the current stable (1.06) can do this.

And Mason was doing this from the beginning. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: Method overhead benchmarks [Was: [performance/benchmark] printing techniques]

2000-06-08 Thread Matt Sergeant

On Thu, 8 Jun 2000, Barrie Slaymaker wrote:

> Stephen Zander wrote:
> > 
> > As Matt has already commented, in the handler the method call
> > overheads swamps all the other activities.
> 
> Just to clarify: that's only important if you are doing very few other
> activities, or if those other activities also include a high percentage 
> of method calls:

You also forgot that print() goes to a tied STDOUT, which is even more of
an overhead...

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org





Apache::ASP

2000-06-08 Thread Clement Law

Please help, this isn't a virus, I just want my asp thing to work.

I get a 500 Internal Server Error when I try to run a ASP file.
I'm using Windows NT Server. And the webserver I'm using is Apache V1.3.12
with Mod_perl
Perl: c:\usr\perl\bin
ASP.PM: c:\usr\perl\site\lib\apache\asp.pm
Other: c:\usr\perl\lib
I'm using Virtual Hosts in Apache too.
I have no clue what's the problem right now.

this was the asp script I was trying to run, count.asp
-= START =-

<%IF IsEmpty(Session("TotalCount")) THEN
  Call MakeCount
End IF

Sub MakeCount()
  Dim FSO   ' FileSystemObject
  Dim TS' TextStreamObject
  Dim CountFileName ' Count File Name
  Dim OldCount, NewCount' Counting Variables
  Dim I 
  Dim Create

  Create = True 
  MyCountFile = Server.MapPath("Counter.txt")
  Set FSO = Server.CreateObject("Scripting.FileSystemObject")
  Set TS = FSO.OpenTextFile(MyCountFile, 1, Create)

  IF Not TS.AtEndOfStream Then
OldCount = TS.ReadAll
  Else
OldCount = 0
  End If
  TS.Close

  NewCount = OldCount + 1

  Session("TotalCount")= NewCount
  Set TS = FSO.CreateTextFile(MyCountFile, Create)
  TS.Write NewCount
  TS.Close
  Set FSO = Nothing
  Set TS = Nothing
End Sub
%>

-= END =-

my HTTPD.CONF is as follows:
-= START =-

ServerType standalone
ServerRoot "C:/Program Files/Apache"
PidFile logs/httpd.pid
ScoreBoardFile logs/apache_status
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MaxRequestsPerChild 0
ThreadsPerChild 50
Port 80
ServerAdmin [EMAIL PROTECTED]
DirectoryIndex index.html index.shtml index.htm index.shtm
AccessFileName .htaccess

Order allow,deny
Deny from all

UseCanonicalName On
TypesConfig conf/mime.types
DefaultType text/plain

MIMEMagicFile conf/magic

HostnameLookups Off
ErrorLog logs/error.log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog logs/access.log common
ServerSignature On
Alias /icons/ "/Apache/icons/"
IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/small/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/small/text.gif) text/*
AddIconByType (IMG,/icons/small/image2.gif) image/*
AddIconByType (SND,/icons/small/sound2.gif) audio/*
AddIconByType (VID,/icons/small/movie.gif) video/*
AddIcon /icons/small/binary.gif .bin .exe
AddIcon /icons/small/binhex.gif .hqx
AddIcon /icons/small/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/small/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/small/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/small/uu.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/small/text.gif .tex
AddIcon /icons/small/burst.gif core
AddIcon /icons/small/back.gif ..
AddIcon /icons/small/text.gif README

AddIcon /icons/small/dir.gif ^^DIRECTORY^^
AddIcon /icons/small/blank.gif ^^BLANKICON^^
DefaultIcon /icons/small/unknown.gif
AddDescription "GZIP compressed document" .gz
AddDescription "tar archive" .tar
AddDescription "GZIP compressed tar archive" .tgz
AddDescription "ZIP archive" .zip
AddDescription "CAB archive" .cab
AddDescription "Win32 Executable" .exe
ReadmeName README
HeaderName HEADER
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
AddEncoding x-compress Z
AddEncoding x-gzip gz
AddLanguage en .en
AddLanguage de .de
AddLanguage fr .fr
LanguagePriority en de fr
ScriptAlias /phpexecutable/ "/usr/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/phpexecutable/php.exe"
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
AddType text/html .shtml
AddType text/html .shtm
AddHandler server-parsed .shtml
AddHandler server-parsed .shtm
AddHandler server-parsed .html
AddHandler server-parsed .htm
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0
LoadModule perl_module modules/ApacheModulePerl
ScriptAlias /advertisments/ "C:/Program Files/Apache/cgi-bin/"

SetHandler perl-script
PerlHandler Apache::ASP
PerlSetVar Global /temp


-= END =- 



Method overhead benchmarks [Was: [performance/benchmark] printing techniques]

2000-06-08 Thread Barrie Slaymaker

Stephen Zander wrote:
> 
> As Matt has already commented, in the handler the method call
> overheads swamps all the other activities.

Just to clarify: that's only important if you are doing very few other
activities, or if those other activities also include a high percentage 
of method calls:

## Using an empty A::a() (see below):

Benchmark: running $a->a(), A->a(), A::a( "A" ), A::a( $a ), A::a(), a(), each for at 
least 3 CPU seconds...
   $a->a():  4 wallclock secs ( 3.24 usr +  0.02 sys =  3.26 CPU) @ 511465.64/s 
(n=1667378)
A->a():  2 wallclock secs ( 3.28 usr +  0.00 sys =  3.28 CPU) @ 290696.34/s 
(n=953484)
A::a( "A" ):  3 wallclock secs ( 3.08 usr +  0.00 sys =  3.08 CPU) @ 610704.55/s 
(n=1880970)
A::a( $a ):  3 wallclock secs ( 3.07 usr +  0.00 sys =  3.07 CPU) @ 623101.63/s 
(n=1912922)
A::a():  3 wallclock secs ( 3.22 usr +  0.00 sys =  3.22 CPU) @ 611970.19/s 
(n=1970544)
   a():  3 wallclock secs ( 3.14 usr +  0.00 sys =  3.14 CPU) @ 622945.22/s 
(n=1956048)

Rate   A->a()  $a->a() A::a( "A" )   A::a()   a() A::a( $a )
A->a()  290696/s   -- -43%-52% -52%  -53%   -53%
$a->a() 511466/s  76%   ---16% -16%  -18%   -18%
A::a( "A" ) 610705/s 110%  19%  --  -0%   -2%-2%
A::a()  611970/s 111%  20%  0%   --   -2%-2%
a() 622945/s 114%  22%  2%   2%---0%
A::a( $a )  623102/s 114%  22%  2%   2%0% --

## And doing some trivial work in A::a():

[barries@jester tmp]$ perl ./cmp2
Name "A::b" used only once: possible typo at ./cmp2 line 7.
Benchmark: running $a->a(), A->a(), A::a( "A" ), A::a( $a ), a(), each for at least 3 
CPU seconds...
   $a->a():  5 wallclock secs ( 3.19 usr +  0.00 sys =  3.19 CPU) @ 64346.39/s 
(n=205265)
A->a():  4 wallclock secs ( 3.21 usr +  0.00 sys =  3.21 CPU) @ 54105.30/s 
(n=173678)
A::a( "A" ):  2 wallclock secs ( 3.09 usr +  0.00 sys =  3.09 CPU) @ 70333.66/s 
(n=217331)
A::a( $a ):  3 wallclock secs ( 3.19 usr +  0.00 sys =  3.19 CPU) @ 68128.84/s 
(n=217331)
   a():  4 wallclock secs ( 3.10 usr +  0.00 sys =  3.10 CPU) @ 72231.29/s 
(n=223917)

   Rate  A->a() $a->a()  A::a( $a ) A::a( "A" ) a()
A->a()  54105/s  ---16%-21%-23%-25%
$a->a() 64346/s 19%  -- -6% -9%-11%
A::a( $a )  68129/s 26%  6%  -- -3% -6%
A::a( "A" ) 70334/s 30%  9%  3%  -- -3%
a() 72231/s 34% 12%  6%  3%  --



You can see that even doing a few things in A::a() cause the relative slowdown
due to method call overhead to drop significantly.  I suspect that your opcode
count has more to do with it than method overhead, unless I've goofed the
benchmarks somehow.

Hmmm, maybe this shows it best (though I did tweak aggrlist_print to
print STDERR):


[barries@jester tmp]$ perl ./aggr_cmp  2> /dev/null
Benchmark: running $a->aggrlist_print(), A->aggrlist_print(), aggrlist_print( $a ), 
each for at least 3 CPU seconds...
$a->aggrlist_print():  3 wallclock secs ( 2.69 usr +  0.41 sys =  3.10 CPU) @ 
15104.19/s (n=46823)
A->aggrlist_print():  3 wallclock secs ( 2.72 usr +  0.41 sys =  3.13 CPU) @ 
14492.01/s (n=45360)
aggrlist_print( $a ):  3 wallclock secs ( 2.81 usr +  0.24 sys =  3.05 CPU) @ 
15529.18/s (n=47364)

Rate A->aggrlist_print() $a->aggrlist_print() aggrlist_print( 
$a )
A->aggrlist_print()  14492/s  --  -4%  
-7%
$a->aggrlist_print() 15104/s  4%   --  
-3%
aggrlist_print( $a ) 15529/s  7%   3%  
 --


- Barrie

[barries@jester tmp]$ cat cmp
#!/usr/local/bin/perl -w

## cmp

package A ;

use Benchmark qw( cmpthese ) ;

sub a {}

my $a = bless {}, 'A' ;

cmpthese( -3, {
   'a()' => sub { a() },
   'A::a()'  => sub { A::a() },
   'A::a( "A" )' => sub { A::a( "A" ) },
   'A::a( $a )'  => sub { A::a( $a )  },
   'A->a()'  => sub { A->a()  },
   '$a->a()' => sub { $a->a() },
} ) ;


[barries@jester tmp]$ cat cmp2
#!/usr/local/bin/perl -w

## cmp2

package A ;

$b = {} ;

sub a {
   my $self = shift ;
   my ( $a, $b, $c ) = @_ ;
   $b->{FOO} = 'bar' ;
}

use Benchmark qw( cmpthese ) ;

my $a = bless {}, 'A' ;

cmpthese( -3, {
   'a()' => sub { a() },
   'A::a( "A" )' => sub { A::a( "A" ) },
   'A::a( $a )'  => sub { A::a( $a )  },
   'A->a()'  => sub { A->a()  },
   '$a->a()' => sub { $a->a() },
} ) ;


[barries@jester tmp]$ cat aggr_cmp 
#!/usr/local/bin/perl -w

package A ;

sub aggrlist_print{
   my @buffer = ();
   push @buffer,"\n";
   push @buffer,"\n";
   push @buffer,"  \n";
   

Re: [performance/benchmark] printing techniques

2000-06-08 Thread Matt Sergeant

On 8 Jun 2000, Stephen Zander wrote:

> As Matt has already commented, in the handler the method call
> overheads swamps all the other activities. so concat_print &
> aggrlist_print (yes, method invocation in perl really is that bad).
> When you remove that overhead the extra OPs in aggrlist_print become
> the dominating factor.

Perhaps it would be worth testing the horribly ugly:

Apache::print($r, );

Rather than plain print().

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




modperl@apache.org

2000-06-08 Thread Barrie Slaymaker

"Reilly, Thomas" wrote:
> If any one can give me a few lines of code I would appreciate it.

One way is:

use IPC::Run qw( run close_terminal ) ;

   run(
  sub {
 # ... your code here ...
 sleep 15 ;
  },
  init => sub {
 close_terminal ;
 exit if fork ;
  }
   ) or die "Run failed $!" ;

Note that this just fork()ed twice, once in run() then again in the init
sub.  Also note that run() has unsuprising result code semantics,
unlike system().

You can also run subcommands as daemons this way, FWIW:

   @cmd = qw( foo 1 2 3 ) ;
   run \@cmd, init => sub { ... } ;

and you can open pipes to the new daemon, too:

   $in = "stuff to send"
   run(
  sub { ...yer code...},
  init => sub {  }, '<', $to_daemon, '>', \$from_daemon 
   ) ;
   ## now $out == "stuff to recv" ;


   run(
  sub { ...yer code...},
  init => sub {  }, 'pipe', \*FROM_DAEMON
   ) ;
   write TO_DAEMON, ... ;
   read FROM_DAEMON, ... ;


Note: IPC::Run is in beta and under active development and debugging.

Here's the latest version, I just tweaked it to expose close_terminal() for
you:

   http://slaysys.com/src/IPC-Run-0.35.tar.gz

If people would prefer something like "detach" or even "daemonize" instead,
can-do.

- Barrie

> system("./cserver &") or die "system cserver failed: $?";

This is a common misunderstanding: system() returns whatever the process
returned, not system()'s success or failure.  Also, you're not closing your
terminal or changing the session ID (group leader).

> The reason i put it in the backround is to allow the main mod_perl script to
> continue and connect to the cserver process via unix domain sockets (after a
> small delay)

run()'ll let you connect via pipes or ptys opened by the parent, if you like.

> and exchange the required info (an XML string but thats irrelevant). The
> cserver process will login to a database, retrieve info and the plan is to
> send it back to the mod_perl process through the socket and all the way back
> to the client. (This is asking for trouble i'm sure! overhead, denial of
> service attacks etc..)

Why spawn a subprocess?  Memory usage?  Will the parent process be doing
something (ie coprocessing) in the meanwhile?

Also, why pass the XML to the daemon through a pipe?  If you prebuild it,
then fork(), the daemon'll have a copy.  Any why use XML as an intermediary
language (unless some external consideration makes it necessary), since
building the XML and parsing it consumes time and memory.

- Barrie



Re: [performance/benchmark] printing techniques

2000-06-08 Thread Stephen Zander

> "Stas" == Stas Bekman <[EMAIL PROTECTED]> writes:
Stas> Is this a question or a suggestion? but in both cases
Stas> (mod_perl and perl benchmark) the process doesn't exit, so
Stas> the allocated datastructure is reused... anyway it should be
Stas> the same. But it's not.

It was a suggestion.  Examining the optrees produced by aggrlist_print
and the following two routines which should be equivalent to
concat_print and multi_print from your original posting

   sub concat_print{
  my $buffer;
  $buffer .= "\n";
  $buffer .= "\n";
  $buffer .= "  \n";
  $buffer .= "\n";
  print $buffer;
   }

   sub aggrlist_print{
  my @buffer = ();
  push @buffer,"\n";
  push @buffer,"\n";
  push @buffer,"  \n";
  push @buffer,"\n";
  print @buffer;
   }

   sub multi_print{
  print "\n";
  print "\n";
  print "  \n";
  print "\n";
   }

shows that aggrlist_print performs 25% OPs than concat_list and 43%
more OPs than multi_print.

Stas> handler:
Stas> concat_print|111  5000  0876 
Stas> aggrlist_print  |113  5000  0862 
Stas> multi_print |118  5000  0820 

Stas> buffered benchmark:

Stas> concat_print:8 wallclock secs ( 8.23 usr +  0.05 sys =  8.28 CPU)
Stas> multi_print:10 wallclock secs (10.70 usr +  0.01 sys = 10.71 CPU)
Stas> aggrlist_print: 30 wallclock secs (31.06 usr +  0.04 sys = 31.10 CPU)

Stas> Watch the aggrlist_print gives such a bad perl benchmark,
Stas> but very good handler benchmark...

As Matt has already commented, in the handler the method call
overheads swamps all the other activities. so concat_print &
aggrlist_print (yes, method invocation in perl really is that bad).
When you remove that overhead the extra OPs in aggrlist_print become
the dominating factor.

-- 
Stephen

"So if she weighs the same as a duck, she's made of wood."... "And
therefore?"... "A witch!"



Re: Template techniques

2000-06-08 Thread Bernhard Graf

Chris Winters wrote:

> The newest version of Template Toolkit (currently in alpha) supports
> compiling templates to perl code. See about 2/3 of the way down the
> the README at www.template-toolkit.org. Why reinvent the wheel? :)

Also the current stable (1.06) can do this.

-- 
Bernhard Graf   -- s p e e d l i n k . d e --   fon +49-30-28000-182
[EMAIL PROTECTED]  http://www.speedlink.de  fax +49-30-28000-22
   y a programmer Dircksenstraße 47 D-10178 Berlin



DNS Lookups ? huh ?

2000-06-08 Thread David Brown

Since upgrading to the latest verion of mod_perl I've noticed that I get
remote host names appearing in my access logs rather than IP addresses (in
80% of entries).

My concern is that my machine is try to perform DNS lookups, and the
subsequent load it may add.

My httpd.conf has-> HostnameLookups Off

Could it just be that many browsers are supplying their remote host in their
request .. if so, why have I not seen it before ?

None of my scripts query $REMOTE. values.

Perhaps my recompilation of Apache triggered something I'd not had enabled
before.






Re: Template techniques

2000-06-08 Thread Chris Winters

* [EMAIL PROTECTED] ([EMAIL PROTECTED]) [000608 11:07]:
> I'm curious Matt, as opposed to what?, reparsing the template each
> run?  Clearly reparsing would be a big loser in terms of performance.
> 
> But what other technique could be used..., hrm.., without direct
> control over the pipe, I really don't think it would get too much
> better than this.  I mean, you could yank out sections and stuff it
> into an array that would be like: text, coderef, coderef, text, etc.
> Like in an ASP template you would parse the file, grab sections
> between <% %> and eval it as a code ref, and stuff it into your array.
> But this would probably not work specifically in ASP's case, but you
> might be able to pull it off in Embperl.  (Unless the array itself
> could also point to arrays, etc.)  Overall..., I think compiling it
> directly makes a lot more sense in 99.999% of template languages...,
> otherwise you'd end up putting too many restrictions on the template
> language itself.
> 
> Hmm..., sort of an interesting question, what ways could be utilized
> in order to maximize speed in template execution.  I thought about
> this a while ago, but after the fact I have to agree with Matt...,
> just evaling each template as a package, or a code ref would be a
> lot quicker, and if you could cook up another scheme, the resulting
> code complexity might not pan out to be worth it.

The newest version of Template Toolkit (currently in alpha) supports
compiling templates to perl code. See about 2/3 of the way down the
the README at www.template-toolkit.org. Why reinvent the wheel? :)

Chris

-- 
Chris Winters
Internet DeveloperINTES Networking
[EMAIL PROTECTED]http://www.intes.net/
Integrated hardware/software solutions to make the Internet work for you.



Re: Template techniques

2000-06-08 Thread Matt Sergeant

On Thu, 8 Jun 2000 [EMAIL PROTECTED] wrote:

> > As far as I've seen, the fastest template systems are the ones that
> > convert the template to Perl code. So that's what I do. The templates all
> > call a method (in my case $Response->Write()) which appends to a
> > string. If there are no exceptions (see the guide) the string is sent to
> > the browser. If there are exceptions, I parse/send an error template with
> > the error in the template.
> 
> I'm curious Matt, as opposed to what?, reparsing the template each
> run?  Clearly reparsing would be a big loser in terms of performance.

As opposed to parsing into a tree and working from that.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Re: Template techniques

2000-06-08 Thread shane

On Thu, Jun 08, 2000 at 01:48:40PM +0100, Matt Sergeant wrote:
> On Thu, 8 Jun 2000, Greg Cope wrote:
> 
> > This may be veering off topic - but its been on my mind for a while now 
> > 
> > Apart from thanking Stas for his benchmark work, which I find very
> > interesting (does he sleep ;-) - this and few few others (benchmarks) have
> > all touched on the area of including mod_perl output within HTML.  I have
> > always wonder what everyone else is doing on this front.
> > 
> > I usually suck a template into memory (one long line) - usually done at
> > startup.  I then create all the conent with either pushing onto an array, or
> > .= string concatination.  Finally I regex the template - looking for my tags
> > and replave those with output.  Needless to say that one page can onsists of
> > many templates (page or inside of table (bits from  ) etc ...).
> > 
> > From Stas previous benchmarks I've preloaded the mysql driver and now
> > usually use the "push" onto array to prepare content - Thanks Stas.
> > 
> > Who does everyone else do it ? Can this type of operation (that everyone
> > must do at some time) be optimised as aggressively as some of the others ?
> > Yet still keep the abstraction between design and content.
> 
> As far as I've seen, the fastest template systems are the ones that
> convert the template to Perl code. So that's what I do. The templates all
> call a method (in my case $Response->Write()) which appends to a
> string. If there are no exceptions (see the guide) the string is sent to
> the browser. If there are exceptions, I parse/send an error template with
> the error in the template.

I'm curious Matt, as opposed to what?, reparsing the template each
run?  Clearly reparsing would be a big loser in terms of performance.

But what other technique could be used..., hrm.., without direct
control over the pipe, I really don't think it would get too much
better than this.  I mean, you could yank out sections and stuff it
into an array that would be like: text, coderef, coderef, text, etc.
Like in an ASP template you would parse the file, grab sections
between <% %> and eval it as a code ref, and stuff it into your array.
But this would probably not work specifically in ASP's case, but you
might be able to pull it off in Embperl.  (Unless the array itself
could also point to arrays, etc.)  Overall..., I think compiling it
directly makes a lot more sense in 99.999% of template languages...,
otherwise you'd end up putting too many restrictions on the template
language itself.

Hmm..., sort of an interesting question, what ways could be utilized
in order to maximize speed in template execution.  I thought about
this a while ago, but after the fact I have to agree with Matt...,
just evaling each template as a package, or a code ref would be a
lot quicker, and if you could cook up another scheme, the resulting
code complexity might not pan out to be worth it.

> Of course I don't know if its the fastest possible method - I prefer to
> code cleanly first and worry about performance later. Much later. Clean
> code tends to lend itself to better performance in the long run anyway,
> because it's easier to optimise serious performance problems away.

Can't really disagree with that.  Clean code is 100x easier to work on
later.

Shane.



Re: Data structure question

2000-06-08 Thread Matt Sergeant

On 8 Jun 2000, Stephen Zander wrote:

> > "Drew" == Drew Taylor <[EMAIL PROTECTED]> writes:
> Drew> I would like to return a single data structure, but order IS
> Drew> important (hence the current setup). I was thinking of using
> Drew> an array, where each element is a hash reference. So I would
> Drew> return something like this:
> 
> In this case pseudohashes are absolutely what you're looking for.
> They'll also have the smallest impact on your code as you can walk
> @{$ref}[1..foo] when you need the items in order and grab $ref->{key}
> when you need a particular value.  Just remember that $ref->[0] is
> special.

Ugh. Psuedo hash references are badly broken even in 5.6. Anyone who's
done extensive work with them (or tried to) can tell you that.

Instead, write a class for your objects, and use arrays internally. Define
constants for the indexes of the arrays.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Re: ANNOUNCE: mod_perl Guide 1.24

2000-06-08 Thread Kees Vonk 7249 24549

Stas,

just did another search and now (13:15 BST) it is there.


Kees




Re: Data structure question

2000-06-08 Thread Stephen Zander

> "Drew" == Drew Taylor <[EMAIL PROTECTED]> writes:
Drew> I would like to return a single data structure, but order IS
Drew> important (hence the current setup). I was thinking of using
Drew> an array, where each element is a hash reference. So I would
Drew> return something like this:

In this case pseudohashes are absolutely what you're looking for.
They'll also have the smallest impact on your code as you can walk
@{$ref}[1..foo] when you need the items in order and grab $ref->{key}
when you need a particular value.  Just remember that $ref->[0] is
special.

-- 
Stephen

"Farcical aquatic ceremonies are no basis for a system of government!"



Re: ANNOUNCE: mod_perl Guide 1.24

2000-06-08 Thread Vivek Khera


> "SB" == Stas Bekman <[EMAIL PROTECTED]> writes:

SB> mod_perl Guide Version 1.24 Jun 7, 2000 has been released.

[ ... ]

SB> New 2 search engines and splitted version of the Guide. Vivek's version is
SB> almost up to date, Randy's is not. So please use Vivek's version for
SB> search. The search form is at http://perl.apache.org/guide/.

The nextrieve-based search is now up-to-date with Guide 1.24.  Let me
know if there are any problems with it.




Re: [performance/benchmark] printing techniques

2000-06-08 Thread Stas Bekman

Stephen Zander wrote:
> 
> > "Stas" == Stas Bekman <[EMAIL PROTECTED]> writes:
> Stas> Ouch :( Someone to explain this phenomena? and it's just
> Stas> fine under the handler puzzled, what can I say...
> 
> Continuous array growth and copying?

Is this a question or a suggestion? but in both cases (mod_perl and perl
benchmark) the process doesn't exit, so the allocated datastructure is
reused... anyway it should be the same. But it's not.

Just to remind the context (please quote the relevant parts or it's
impossible to understand what are you talking about. Thanks!):

handler:

single_print|108  5000  0890 
here_print  |110  5000  0887 
concat_print|111  5000  0876 
aggrlist_print  |113  5000  0862 
list_print  |113  5000  0861 
multi_print |118  5000  0820 

unbuffered benchmark:

single_print:2 wallclock secs ( 2.29 usr +  0.46 sys =  2.75 CPU)
here_print:  2 wallclock secs ( 2.42 usr +  0.50 sys =  2.92 CPU)
list_print:  7 wallclock secs ( 7.26 usr +  0.53 sys =  7.79 CPU)
concat_print:9 wallclock secs ( 8.90 usr +  0.60 sys =  9.50 CPU)
aggrlist_print: 32 wallclock secs (32.37 usr +  0.71 sys = 33.08 CPU)
multi_print:21 wallclock secs (16.47 usr +  5.84 sys = 22.31 CPU)

buffered benchmark:

single_print:3 wallclock secs ( 1.69 usr +  0.02 sys =  1.71 CPU)
here_print:  3 wallclock secs ( 1.76 usr +  0.01 sys =  1.77 CPU)
list_print:  7 wallclock secs ( 6.41 usr +  0.03 sys =  6.44 CPU)
concat_print:8 wallclock secs ( 8.23 usr +  0.05 sys =  8.28 CPU)
multi_print:10 wallclock secs (10.70 usr +  0.01 sys = 10.71 CPU)
aggrlist_print: 30 wallclock secs (31.06 usr +  0.04 sys = 31.10 CPU)

Watch the aggrlist_print gives such a bad perl benchmark, but very good
handler benchmark...

  sub aggrlist_print{
my @buffer = ();
push @buffer,"\n";
push @buffer,"\n";
push @buffer,"  \n";
[snip]
push @buffer,"\n";
print @buffer;
  }


 
_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://perl.org http://stason.org/TULARC
http://singlesheaven.com http://perlmonth.com http://sourcegarden.org



Re: [performance/benchmark] printing techniques

2000-06-08 Thread Stephen Zander

> "Stas" == Stas Bekman <[EMAIL PROTECTED]> writes:
Stas> Ouch :( Someone to explain this phenomena? and it's just
Stas> fine under the handler puzzled, what can I say...

Continuous array growth and copying?

-- 
Stephen

"So if she weighs the same as a duck, she's made of wood."... "And
therefore?"... "A witch!"



Re: ANNOUNCE: mod_perl Guide 1.24

2000-06-08 Thread Kees Vonk 7249 24549

Stas,

I was searched at search.cpan.org and then followed the link 
from there, as far as I know that is a link to www.perl.com.


Kees




Re: Template techniques

2000-06-08 Thread Matt Sergeant

On Thu, 8 Jun 2000, Richard L. Goerwitz wrote:

> > As far as I've seen, the fastest template systems are the ones that
> > convert the template to Perl code. So that's what I do. The templates all
> > call a method (in my case $Response->Write()) which appends to a
> > string. If there are no exceptions (see the guide) the string is sent to
> > the browser. If there are exceptions, I parse/send an error template with
> > the error in the template.
> 
> I'm trying to follow this explanation, but can't quite visualize what
> you're doing.  I wonder if you could perhaps post a code fragment to the
> list elucidating...

Err... It's a bit complicated. I'm porting someone else's template system
from a VB environment, and it's not pretty, but basically I have a
response class with a Write method that looks like this:

sub Write {
my $self = shift;
$self->{output} .= join('', @_);
}

I then have templates that get turned from this:



Into the following Perl code:

sub handler {
my ($Response, , $__params) = @_;
$Response->Write(q||);
$Response->Write($__params{'xx-mytag'});
$Response->Write(q||);
}

And then my handler looks like:

sub handler {
my $r = shift;

# setup $Response, etc...
...

eval {
do_stuff();
}
if ($@) {
if ($@->isa('Foo')) {
# process foo exception
}
elsif ($@->isa('Bar')) {
# process bar exception
}
elsif ($@->isa('Error')) {
# error
$db->rollback();
Template->Output('error.html', text => $@->{error});
}
}

$db->commit;
$Response->Send;
return OK;

and do_stuff() calls:

Template->Output('templatefilename', %params);

But if it errors out for some reason (db fails, etc) then it gets trapped
by the exception handler, and instead of giving a 500 internal server
error, we get an nice error page which they can take massive .bmp screen
shots of and mail to their sysadmin over a 56k connection ;-)

See the guide for the exception handling class I use (or variant of).

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Re: Apache, Mod_Perl and Custom Access/Authentication

2000-06-08 Thread Drew Taylor

Steffers wrote:
> 
> hello,
> first let me apologise for jst jumping straight into asking
> questions on the mailing list, but this is really puzzling me. First
> some background.
> 
> I have been using perl for the past 3 years. I think (note
> +think+) that I understand perl quite well, so when the job came up
> at work here to tie the programs into Apache using mod_perl I
> figured it wouldnt be that hard. (Apache 1.3.12 and latest mod_perl)
> 
> I am still trying to get out of my 'cgi' ways (exit and $| and
> such forth), so the code attached my look a tad strange. apologies
> again for that.
> 
> The problem is, that I want to first have the access working
> so that if someone doesnt have a cookie with 'sessionID' set in it,
> then we know that they are a 'new user'.  In this case, no other checks
> are needed (we require valid-user).
> 
> IF the sessionid is valid, then we move onto authentication
> which in this case is simply firing off the username and password to
> PostgreSQL. The way that PostgreSQL is setup, it uses encrypted
> passwords for connection, so simply getting a valid connection is
> 'good enough' to prove the user (in my eyes for the moment).
> 
> So once they have connected up succesfully, I cache the
> DBI connection (by using Apache::DBI) and then creating a sessionID
> cookie for the user.
> 
> This then means that the user will only have to 're-authenticate'
> when the cookie times out. I dont know if i need to use the 'ping function'
> to keep PostgreSQL alive, but thats a 'todo' for sure.
> 
> So what am I doing wrong ? There is probably a hundred things
> here, and I +have+ read the faqs and even the oreilly book, i dont see
> anything glaring, but then this is why its a learning process. (oh and
> for what its worth the database and apache are working fine. its my code
> that has the 'features' (okay okay, bugs ;))
> 
> Feel free to critisce my code/offer guidance/nudge improvments
> or jst hit me with a large pointed stick ;)
> many thanks
> Stefs.
> 
> .htaccess
> ---
> PerlAccessHandler Apache::ResAcc
> PerlAuthenHandler Apache::ResAuth
> require valid-user
> 
> ResAcc.pm
> 
> package Apache::ResAcc;
> use strict;
> use Apache::Constants qw(:common);
> use Safe();
> 
> my $Safe=Safe->new;
> 
> use vars qw(@EXPORT $USE_THREAD $USE_SFIO $PERL_DIR);
> use Exporter ();
> use Config;
> use FileHandle ();
> *import = \&Exporter::import;
> 
> @EXPORT = qw(handler);
> 
> use subs @EXPORT;
> 
> # This module will check for the presence of a sessionid and if found will
> # allow access, otherwise it will print out the login screen with two inputs
> # one for username and the other for password
> sub handler
> {   my $r = shift;
> my $login = "\n\n\n#Imagine a password
> form here\n\n";
> 
> my $header_ID=$r->header_in('sessionID');
If you're trying to get at the cookie, this is not the way. Either use
Apache::Cookie or CGI.pm to get the cookie contents.


>  my $query=CGI::new();
>  my $my_cookie=$query->cookie(-name=>'sessionID',
>   -value=>'1',
>   -path=>'/',
>   -expires=>'+30m');
>  $r->header_out->add("Set-cookie"=>$my_cookie);
> return OK;
> }
This code is good. But it doesn't jive with what you have above. Try
making the first handler() actually get the cookie. Or am I missing
something?

-- 
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/



Newbie: virtual hosts and includes

2000-06-08 Thread Winfried . Soltys

The scenario:

A script under a shared location (/www/shared/myscript) parses a html template and 
print it out.
For each virtual host exists a template with the same name but different root 
directories:
/www/a/htdocs/templates/mytemplate
/www/b/htdocs/templates/mytemplate  ... and so on (root: /www/?/htdocs)
Each template includes a header with a relative path to its root 
(ex. /headers/myheader located under /www/a/htdocs/headers/myheader).
Weird, but all files have to remain where they are.
Under mod_cgi it works fine, with mod_perl I get sometimes the right template but with 
a
header from another virtual host 
(ex. /www/a/hdocs/templates/mytemplate includes sometimes 
/www/b/htdocs/headers/myheader).

My configuration:

PerlWarn On
Alias /bin/ /www/shared/myscript/

SetHandler perl-script
PerlHandler Apache::PerlRun
Options ExecCGI
PerlSendHeader On


PerlSendHeader Off


I read the dokumentation but even the 'dirty configuration' didn't help.
Hope anyone can help me :-)
Thanks,

Winni



Re: non-DSO mod_perl, Embperl, and AIX not working (duplicate ?)

2000-06-08 Thread Jens-Uwe Mager

On Mon, Jun 05, 2000 at 08:59:39AM -0700, Michael Nachbaur wrote:

> AIX's C compiler is as buggy as a Florida chineese resturaunt.  I
> couldn't even get Apache to install right (it kept saying something to
> the effect of "Found , expected "...Sheesh!)
> Anyhoo, I went to IBMs site, downloaded the patches, and everything is
> happy again.  I had to install somewhere near 45-50 patches to make it
> current.  One of these days, I'm going to install GCC and be done with
> it.

GCC does not grok the command line options used by perl to build modules
on AIX, so you pretty much have only one choice, namely use the IBM C
compiler. I had more than one problem with gcc over the years, so I
believe both compilers are on par problem wise. The IBM C compiler
appears to produce much better code on POWER/PowerPC machines, so I
stick with it.

-- 
Jens-Uwe Mager

HELIOS Software GmbH
Steinriede 3
30827 Garbsen
Germany

Phone:  +49 5131 709320
FAX:+49 5131 709325
Internet:   [EMAIL PROTECTED]



Re: [performance/benchmark] $|=1 doesn't matter ?!

2000-06-08 Thread Stas Bekman

Matt Sergeant wrote:
> 
> On Wed, 7 Jun 2000, Stas Bekman wrote:
> 
> > Ok, you'd get surprised on this one. I cannot make benchmark show me
> > unbuffered output worse than buffered. Anyone can tell me why? there is
> > ap_flash call after each print in the unbuffered case, how comes the
> > results are the same?
> 
> I assume that's ap_flush ;-)

Right, hey Doug, how about implementing the real ap_flash :) wired to the
digital cam :)


> I'd guess this is probably OS dependant to do with socket libraries and
> such. But I'm just guessing. It's probably also to do with the size of the
> output.

Argh, but then I don't know what to do with this section... From one side
I claim that you shouldn't use $|=1, from the other side the benchmark
shows no difference (in the handler) can anyone prove it different? Using
a different OS maybe? I did mine on linux of course... Thanks a lot!
 
> I'm sorry I flamed the original benchmark, but now you've done some more
> real tests, I'm not sorry, if you see what I mean ;-)

Oh, no, Matt. I post these to learn the real world application and
truthfulness of my benchmarks. Otherwise what's the point of having a
great benchmarking results when in reallity the application is slow. So
critics are absolutely wonderful, even if they raise the heat. In
arguments the truth gets born... or not :) 


_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://perl.org http://stason.org/TULARC
http://singlesheaven.com http://perlmonth.com http://sourcegarden.org



Template techniques

2000-06-08 Thread Matt Sergeant

On Thu, 8 Jun 2000, Greg Cope wrote:

> This may be veering off topic - but its been on my mind for a while now 
> 
> Apart from thanking Stas for his benchmark work, which I find very
> interesting (does he sleep ;-) - this and few few others (benchmarks) have
> all touched on the area of including mod_perl output within HTML.  I have
> always wonder what everyone else is doing on this front.
> 
> I usually suck a template into memory (one long line) - usually done at
> startup.  I then create all the conent with either pushing onto an array, or
> .= string concatination.  Finally I regex the template - looking for my tags
> and replave those with output.  Needless to say that one page can onsists of
> many templates (page or inside of table (bits from  ) etc ...).
> 
> From Stas previous benchmarks I've preloaded the mysql driver and now
> usually use the "push" onto array to prepare content - Thanks Stas.
> 
> Who does everyone else do it ? Can this type of operation (that everyone
> must do at some time) be optimised as aggressively as some of the others ?
> Yet still keep the abstraction between design and content.

As far as I've seen, the fastest template systems are the ones that
convert the template to Perl code. So that's what I do. The templates all
call a method (in my case $Response->Write()) which appends to a
string. If there are no exceptions (see the guide) the string is sent to
the browser. If there are exceptions, I parse/send an error template with
the error in the template.

Of course I don't know if its the fastest possible method - I prefer to
code cleanly first and worry about performance later. Much later. Clean
code tends to lend itself to better performance in the long run anyway,
because it's easier to optimise serious performance problems away.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Re: non-DSO mod_perl, Embperl, and AIX not working

2000-06-08 Thread Jens-Uwe Mager

On Thu, Jun 01, 2000 at 07:40:58AM -0400, Greg Estep wrote:

> I am using IBM's C complier (cc) under AIX 4.3.3 with Apache 1.3.12, 
> mod_perl 1.24 (statically linked, not DSO), perl 5.00503, and Embperl 
> 1.3b3.
> 
> The "offline", "execute function", and "cgi mode" Embperl tests are 
> all successful. In the "mod_perl" mode, even the simple "ascii" test 
> fails.  It fails with a seg. fault and a dbx stack trace that looks 
> like this:
> 
> ap_palloc() at 0xd1179d98
> EMBPERL__malloc() at 0xd1178b98
> EMBPERL_SetupFileData() at 0xd1177118
> EMBPERL_SetupRequest() at 0xd1177764
> XS_HTML__Embperl_SetupRequest() at 0xd116fcb8
> .() at 0x1004a344
> .() at 0x100536f0
> .() at 0x1002ff98
> perl_call_handler(??, ??, ??) at 0x10113f70
> perl_run_stacked_handlers(??, ??, ??) at 0x10113160
> perl_handler(??) at 0x10111d38
> ap_invoke_handler(0x2011f1f0) at 0x100c42bc
> process_request_internal(0x2011f1f0) at 0x100f4d6c
> ap_process_request(0x2011f1f0) at 0x100f648c
> child_main(0x0) at 0x10002d24
> make_child(0x200498e0, 0x0, 0x39363aa3) at 0x100025a0
> startup_children(0x2) at 0x1000248c
> standalone_main(0x4, 0x2ff228c8) at 0x10001928
> main(0x4, 0x2ff228c8) at 0x100014b0
> 
> 
> To get Embperl.so to successfully build I added "-b erok" to 
> LDDLFLAGS.  I also tried '-G' with similar results. Without the 
> modification to LDDLFLAGS I got several "unresolved symbol" errors.
> 
> I also get similar results with Embperl 1.2b9, Apache 1.3.9, and 
> mod_perl 1.23.

I did not yet try to compile mod_perl into Apache statically, so I am
not 100% sure why you get unresolved symbols, it would be interesting to
see which ones are unresolved. There are actually two ways to do dynamic
linking under AIX nowadays, namely the classic AIX way that was
available since AIX 3.1 (uses export files like under Windows or OS/2)
and for System V compatibility the runtime linking style which more or
less is like ELF dynamic linking used under Linux or Solaris. Both
Apache and Perl are only doing the classic AIX style dynamic linking, so
you cannot use the Linker Option -G to turn on runtime linking for a
module, you must use the -bE:export file -bM:SRE options instead. The
option -berok may not be used with the classic style dynamic linking,
this is causing the segfault here.

-- 
Jens-Uwe Mager

HELIOS Software GmbH
Steinriede 3
30827 Garbsen
Germany

Phone:  +49 5131 709320
FAX:+49 5131 709325
Internet:   [EMAIL PROTECTED]



Re: ANNOUNCE: mod_perl Guide 1.24

2000-06-08 Thread Stas Bekman

Kees Vonk 7249 24549 wrote:
> 
> Stas,
> 
> I just logged on to CPAN to download the latest version of
> the guide, and even though CPAN thinks version 1.24 is there
> (search for mod_perl_guide) the actual file is not there in
> your directory (this was at 11:20 BST (08/06/2000)).

What server are you getting it from? May be it's a broken mirror?
I get this one with no problems Hey may be the mirror wasn't completed
when you have tried it and it was in the middle?

http://www.perl.com/CPAN-local/authors/id/S/ST/STAS/Apache-mod_perl_guide-1.24.tar.gz

Hey may be the mirror wasn't completed when you have tried it and it was
in the middle?
_
Stas Bekman  JAm_pH --   Just Another mod_perl Hacker
http://stason.org/   mod_perl Guide  http://perl.apache.org/guide 
mailto:[EMAIL PROTECTED]   http://perl.org http://stason.org/TULARC
http://singlesheaven.com http://perlmonth.com http://sourcegarden.org



Apache::URI

2000-06-08 Thread Joerg Haertwig

Hello,

I unfortunately still don't understood the API. How can I process e.g.
the URI in a normal perl script that runs under Apache - mod_perl.
I build Apache 1.3.12 (with DSO) and mod_perl 1.22 on Linux 2.3.35.

For example my script: start-page.pl

--

use Apache::URI ();

my $uri = $r->parsed_uri;

system("echo $uri >/tmp/uri_test");

--

The index.html has a  I want
draw out the userinfo of the URI. The access method is basic with
.htaccess.

Next: How can I break a session from sever-side, so that a user who
still logged in (client Netscape) have to pass a new login procedure
with username/password, when he send a new request?

I beg your pardon if it is a simple question, but I'm new in this
technique.

Thanx in advance, Joerg.





Re: [performance/benchmark] printing techniques

2000-06-08 Thread Greg Cope


From: "Matt Sergeant" <[EMAIL PROTECTED]>
To: "Stas Bekman" <[EMAIL PROTECTED]>
Cc: "___cliff rayman___" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: 08 June 2000 09:23
Subject: Re: [performance/benchmark] printing techniques


: On Wed, 7 Jun 2000, Stas Bekman wrote:
:
: > On Wed, 7 Jun 2000, ___cliff rayman___ wrote:
: >
: > >
: > >
: > > Stas Bekman wrote:
: > >
: > > >
: > > >
: > > > Per your request:
: > > >
: > > > The handler:
: > > >
: > > > query | avtime completed failedrps
: > > > ---
: > > > single_print  |110  5000  0881
: > > > here_print|111  5000  0881
: > > > list_print|111  5000  0880
: > > > concat_print  |111  5000  0873
: > > > multi_print   |119  5000  0820
: > > > ---
: > >
: > > not very much difference once stuck in a handler.
: > > obviously multi_print is both ugly and slow, but the rest should be
used by the
: > > discretion of the programmer based on the one that is easiest to
maintain in
: > > the code.
: >
: > absolutely. I'd also love to know why is it different under the handler.
: > (talking about relative performance!)
:
: Because as I said - the method dispatch and the overhead of the mod_perl
: handler takes over. multi-print is the only one that has to call methods
: several times. The rest are almost equal.
:
: This also demonstrates some of the value in template systems that send all
: their output at once, however often these template systems use method
: calls too, so it all gets messed up.

This may be veering off topic - but its been on my mind for a while now 

Apart from thanking Stas for his benchmark work, which I find very
interesting (does he sleep ;-) - this and few few others (benchmarks) have
all touched on the area of including mod_perl output within HTML.  I have
always wonder what everyone else is doing on this front.

I usually suck a template into memory (one long line) - usually done at
startup.  I then create all the conent with either pushing onto an array, or
.= string concatination.  Finally I regex the template - looking for my tags
and replave those with output.  Needless to say that one page can onsists of
many templates (page or inside of table (bits from  ) etc ...).

>From Stas previous benchmarks I've preloaded the mysql driver and now
usually use the "push" onto array to prepare content - Thanks Stas.

Who does everyone else do it ? Can this type of operation (that everyone
must do at some time) be optimised as aggressively as some of the others ?
Yet still keep the abstraction between design and content.

Greg Cope

:
: --
: 
:
: Fastnet Software Ltd. High Performance Web Specialists
: Providing mod_perl, XML, Sybase and Oracle solutions
: Email for training and consultancy availability.
: http://sergeant.org http://xml.sergeant.org
:
:




RE: ANNOUNCE: mod_perl Guide 1.24

2000-06-08 Thread Kees Vonk 7249 24549

Stas,

I just logged on to CPAN to download the latest version of 
the guide, and even though CPAN thinks version 1.24 is there 
(search for mod_perl_guide) the actual file is not there in 
your directory (this was at 11:20 BST (08/06/2000)).


Kees



modperl@apache.org

2000-06-08 Thread Kees Vonk 7249 24549

> The command i use is:
> 
> system("./cserver &") or die "system cserver failed: $?";
> 
> what i get in the error log is:
> 
> null:system cserver failed: 0 at /home/httpd/perl/test.pl line 35

Are sure that cserver fails? I have come across several unix programs that 
return 0 on success. You can always do:

system("./cserver >mylogfile 2>&1 &")

to see what cserver outputs on STDOUT and STDERR. Also make sure that your 
working directory is what you expect it to be. (Try for instance Cwd.pm to 
check that.)


Hope this helps,


Kees Vonk



DBI-Module and mod_perl

2000-06-08 Thread Rolf Stoll

Hello,

I have Problems with mod-perl and a script that use DBI.
As a CGI without mod_perl the script works fine.
With mod_perl I get a:

 [notice] child pid 652 exit signal Segmentation fault (11).

What is this? Does the DBI-Module not work with mod_perl?
Should i use Apache::DBI, or what is the reason for the Segmentation
fault?

Hope someone can help.

Rolf




Newbie: virtual hosts and includes

2000-06-08 Thread Winfried . Soltys

> The scenario:
> 
> A script under a shared location (/www/shared/myscript) parses a html template and 
>print it out.
> For each virtual host exists a template with the same name but different root 
>directories:
> /www/a/htdocs/templates/mytemplate
> /www/b/htdocs/templates/mytemplate... and so on (root: /www/?/htdocs)
> Each template includes a header with a relative path to its root 
> (ex. /headers/myheader located under /www/a/htdocs/headers/myheader).
> Weird, but all files have to remain where they are.
> Under mod_cgi it works fine, with mod_perl I get sometimes the right template but 
>with a
> header from another virtual host 
> (ex. /www/a/hdocs/templates/mytemplate includes sometimes 
>/www/b/htdocs/headers/myheader).
> 
> My configuration:
> 
> PerlWarn On
> Alias /bin/   /www/shared/myscript/
> 
> SetHandler perl-script
> PerlHandler Apache::PerlRun
> Options ExecCGI
> PerlSendHeader On
> 
> 
> PerlSendHeader Off
> 
> 
> I read the dokumentation but even the 'dirty configuration' didn't help.
> Hope anyone can help me :-)
> Thanks,
> 
> Winni



modperl@apache.org

2000-06-08 Thread Reilly, Thomas


Hi,
I'm having trouble spawning a sub-process from mod_perl. I've read
the guide and it recommends spawning, handing the info the process needs and
have it detach (close STDIN,STDOUT and STDERR + execute setsid()). I'm not
sure how to go about this correctly. If any one can give me a few lines of
code I would appreciate it.
I've successfully spawned the server using the system command from a
standalone perl program but the system command always fails in my mod_perl
script.
The command i use is:

system("./cserver &") or die "system cserver failed: $?";

what i get in the error log is:

null:system cserver failed: 0 at /home/httpd/perl/test.pl line 35

the permissions on the executable cserver located in /home/httpd/perl/ is
-rwxr-xr-x (executable by everyone!)

The reason i put it in the backround is to allow the main mod_perl script to
continue and connect to the cserver process via unix domain sockets (after a
small delay)
and exchange the required info (an XML string but thats irrelevant). The
cserver process will login to a database, retrieve info and the plan is to
send it back to the mod_perl process through the socket and all the way back
to the client. (This is asking for trouble i'm sure! overhead, denial of
service attacks etc..)
Can anyone tell me why the above system & command doesn't work from mod_perl
(it is succesfull in starting the cserver in a normal perl script)
and can anyone also tell me if i'm completely insane in the way i'm going
about this!

Apache/1.3.12 (Red Hat linux 6.2)
mod_perl/1.21
Perl 5.00503

Any help would be greatly appreciated!

Thomas Reilly
Software Consultant,

Distributed Software Consultancy Ltd.,
Ballybrit Business Park,Galway,Ireland.
Tel: +353 (91) 760541 Fax: +353 (91) 760542
e-mail: [EMAIL PROTECTED]
web: http://www.dscie.com





Re: [performance/benchmark] $|=1 doesn't matter ?!

2000-06-08 Thread Matt Sergeant

On Wed, 7 Jun 2000, Stas Bekman wrote:

> Ok, you'd get surprised on this one. I cannot make benchmark show me
> unbuffered output worse than buffered. Anyone can tell me why? there is
> ap_flash call after each print in the unbuffered case, how comes the
> results are the same?

I assume that's ap_flush ;-)

I'd guess this is probably OS dependant to do with socket libraries and
such. But I'm just guessing. It's probably also to do with the size of the
output.

I'm sorry I flamed the original benchmark, but now you've done some more
real tests, I'm not sorry, if you see what I mean ;-)

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Re: [OT] Re: [performance/benchmark] printing techniques

2000-06-08 Thread Matt Sergeant

On Wed, 7 Jun 2000, Perrin Harkins wrote:

> On Wed, 7 Jun 2000, Matt Sergeant wrote:
> 
> > On Wed, 7 Jun 2000, Eric Cholet wrote:
> > 
> > > This said, i hurry back to s/"constant strings"/'constant strings'/g;
> > 
> > Those two are equal.
> 
> Yes, although it's counter-intutive there's no real performance hit
> from double-quoting constant strings.
> 
> The one that bugs me is when I see people doing this:
> 
> $hash{"$key"}
> 
> instead of this:
> 
> $hash{$key}

Those two now also result in the same code. ;-)

But the former is just ugly.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Re: [performance/benchmark] printing techniques

2000-06-08 Thread Matt Sergeant

On Wed, 7 Jun 2000, Stas Bekman wrote:

> On Wed, 7 Jun 2000, ___cliff rayman___ wrote:
> 
> > 
> > 
> > Stas Bekman wrote:
> > 
> > >
> > >
> > > Per your request:
> > >
> > > The handler:
> > >
> > > query | avtime completed failedrps
> > > ---
> > > single_print  |110  5000  0881
> > > here_print|111  5000  0881
> > > list_print|111  5000  0880
> > > concat_print  |111  5000  0873
> > > multi_print   |119  5000  0820
> > > ---
> > 
> > not very much difference once stuck in a handler.
> > obviously multi_print is both ugly and slow, but the rest should be used by the
> > discretion of the programmer based on the one that is easiest to maintain in
> > the code.
> 
> absolutely. I'd also love to know why is it different under the handler.
> (talking about relative performance!)

Because as I said - the method dispatch and the overhead of the mod_perl
handler takes over. multi-print is the only one that has to call methods
several times. The rest are almost equal.

This also demonstrates some of the value in template systems that send all
their output at once, however often these template systems use method
calls too, so it all gets messed up.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org




Problems with installing mod_perl

2000-06-08 Thread Wrobel, Thomas

Hi,

I have some problems installing mod_perl.
My system is a Mandrake 7.0 Kernel 2.2.14.
I have compiled apache 1.3.12 mod_ssl 2.6.4/openssl 0.9.5a
with DSO. Next, I compiled php4RC2 with apxs and
apache runs correctly.
But after installing mod_perl with:
perl Makefile.PL USE_APXS=1 WITH_APXS=/home/httpd/bin/apxs EVERYTHING=1
make
make install
i become an error: document contains no data ...
In the error_log i have the warning:
 [warn] x pid child stopped, segmantation fault (11)
If i deactivate mod_perl the server runs correctly.

Can everybody help me?

best regards

Thomas Wrobel