Re: Apache::Session getting DESTROYed in wrong order

2002-01-04 Thread Ken Williams

Hey,

For the sake of thread completion, here's a script which demonstrates 
the bug.  It turns out to be a Perl bug (5.6.1, at least), not an 
Apache::Session bug.  I'll post to p5p after I post here.

Note that $foo and %bar are cleaned up by refcount, but %foo isn't 
cleaned up until global destruction.  This means there must be some bad 
interaction between tie(), closures, and global variables, I guess.

-
#!/usr/bin/perl

use strict;

{
   package Dummy;
   sub new { bless {@_[1,2]} }
   sub TIEHASH { bless {@_[1,2]} }
   sub DESTROY { warn Destroying $_[0]-{name}: $_[0] }
}

use vars qw(%foo $foo);

{
   # Will get cleaned up properly
   local $foo = new Dummy(name = '$foo');

   # Will get cleaned up properly
   my %bar;
   tie %bar, 'Dummy', name = '%bar';

   # Won't get cleaned up properly
   local %foo;
   tie %foo, 'Dummy', name = '%foo';
}

Destroying %bar: Dummy=HASH(0x632c) at destroy.pl line 9.
Destroying $foo: Dummy=HASH(0x641c) at destroy.pl line 9.
Destroying %foo: Dummy=HASH(0x22ccc) at destroy.pl line 9 during global 
destruction.


Investigating with Devel::Peek suggests that it's a %foo refcount 
problem, it's somehow getting set to 2 after tie(%foo).

  -Ken




Re: Apache::Session getting DESTROYed in wrong order

2002-01-04 Thread Gerald Richter

# Won't get cleaned up properly
local %foo;
tie %foo, 'Dummy', name = '%foo';

local only make a copy of the original value and restores it at the end of
the scope, so %foo will not destroyed, but restored at the end of the scope.
I guess this is the reason my it still stays tied.

In my experiences there are more weired behaviours with tied hashs and
arrays. (e.g. don't access a tied hash inside of a method of a tied hash,
use FETCH instead, tied hash element doesn't always spring into existence,
like normal hash elements does). You have to use them with some care.



 Investigating with Devel::Peek suggests that it's a %foo refcount
 problem, it's somehow getting set to 2 after tie(%foo).


2 is ok. one for %foo itself and one because it's tied to another object

Gerald


-
Gerald Richterecos electronic communication services gmbh
Internetconnect * Webserver/-design/-datenbanken * Consulting

Post:   Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: [EMAIL PROTECTED] Voice:+49 6133 925131
WWW:http://www.ecos.de  Fax:  +49 6133 925152
-






AccelPass interferes with RedirectPermanent

2002-01-04 Thread Philip Mak

The following configuration:

RedirectPermanent /~arcimpulse http://arcimpulse.shoujoai.com
AccelPass / http://127.0.0.1:8002/

did not work as I expected. Instead of being redirected, /~arcimpulse gets
passed to port 8002 (except for URLs that match AccelNoPass), so I had to
put RedirectPermament also in the configuration for the Apache in port
8002.

Is this a bug, or a feature?



Error log executing scripts?

2002-01-04 Thread Magnús Þór Jónsson

Hello,
I was wondering if there is any way of making the error log in Apache to
execute a script when an error is occurred, perhaps instead of writing the
error directly to the log.

For example, if there is a image missing Apache excutes a script that
generates a replacement image?

Thanx in advance
Maggi
[EMAIL PROTECTED]




Re: Error log executing scripts?

2002-01-04 Thread Geoffrey Young

Magnús Þór Jónsson wrote:
 
 Hello,
 I was wondering if there is any way of making the error log in Apache to
 execute a script when an error is occurred, perhaps instead of writing the
 error directly to the log.
 
 For example, if there is a image missing Apache excutes a script that
 generates a replacement image?

well, you can do just about anything you want :)

however, althoughit is possible to intercept the actual errors Apache
(and mod_perl) generates, it is rather complex, and really not the
proper approach here.

the better way is to just write your own handler to add the logic you
are seeking.

for instance, you could write a PerlFixupHandler that

$r-filename('/some/other/file') unless -e $r-finfo;

or whatnot.

if you want a script to run, you could replace the $r-filename('foo')
call with something like

$r-set_handlers(PerlHandler = 'My::ImageGenerating::Package');
$r-handler('perl-script');

or some combination that changed $r-uri if you wanted to use a
Registry script I suppose.

HTH

--Geoff



RE: Error log executing scripts?

2002-01-04 Thread Matt Sergeant

 -Original Message-
 From: Geoffrey Young [mailto:[EMAIL PROTECTED]]
 
 Magnús Þór Jónsson wrote:
  
  Hello,
  I was wondering if there is any way of making the error log 
 in Apache to
  execute a script when an error is occurred, perhaps instead 
 of writing the
  error directly to the log.
  
  For example, if there is a image missing Apache excutes a 
 script that
  generates a replacement image?
 
 well, you can do just about anything you want :)
 
 however, althoughit is possible to intercept the actual errors Apache
 (and mod_perl) generates, it is rather complex, and really not the
 proper approach here.

Really? I would have thought it could make an interesting caching technique
- on a 404 you try and generate the file, and store in that slot in the
filesystem. A cache cleanup daemon runs to clean out TTL'd files.

Warning: don't try and implement this in a commercial application - it's
patented by vignette.

Matt.

This email has been scanned for all viruses by Star Internet. The service is powered 
by MessageLabs. For more information on a proactive anti-virus service working around 
the clock, around the globe, visit www.star.net.uk



Re: Error log executing scripts?

2002-01-04 Thread Geoffrey Young


 
  however, althoughit is possible to intercept the actual errors Apache
  (and mod_perl) generates, it is rather complex, and really not the
  proper approach here.
 
 Really? I would have thought it could make an interesting caching technique
 - on a 404 you try and generate the file, and store in that slot in the
 filesystem. A cache cleanup daemon runs to clean out TTL'd files.

well, I thought he meant by intercepting the actual writes to the
error_log.

Tatushiro actually has an interesting module on CPAN -
http://cpan.valueclick.com/modules/by-module/Apache/Apache-No404Proxy-0.03.tar.gz

it uses a google cache to display 404s (much to google's dismay I
think :)

 
 Warning: don't try and implement this in a commercial application - it's
 patented by vignette.

dirty-box/clean-box :)

--Geoff



Re: Error log executing scripts?

2002-01-04 Thread Geoffrey Young


 Tatushiro

er, Tastuhiko I mean.  (sorry :)

--Geoff



Problems with cookies in Apache::AuthCookie

2002-01-04 Thread Øyvind Gjerstad

I'm trying to get Apache::AuthCookie and Apache::AuthCookieDBI to work. 
However it seems like I can't set any cookies. I have cookies enabled in 
my browser (with warnings), but I can't read the cookie after the 
redirect from the login-script. I'm pretty sure the cookie is never sent 
to the browser. How can I check if the redirect is happening?

Here is the log with AuthCookieDebug set to 3:

[Fri Jan  4 14:23:46 2002] [error] credential_0 ogj
[Fri Jan  4 14:23:46 2002] [error] credential_1 xxx
[Fri Jan  4 14:23:46 2002] [error] ses_key 
ogj:2002-01-04-14-23-46:2002-01-05-14
-23-46:54f7553ccb96d3af70abe449f053ee3d
[Fri Jan  4 14:23:46 2002] [error] auth_type Apache::AuthCookieDBI
[Fri Jan  4 14:23:46 2002] [error] auth_name PrisInformasjon
[Fri Jan  4 14:23:46 2002] [error] ses_key_cookie
[Fri Jan  4 14:23:46 2002] [error] uri /tgweb/protected/index.html


I get a ses_key, but no value in ses_key_cookie. I tried to dump all 
headers to the log, but there were no signs of any cookie-related things.

I must admit that I don't quite understand how the setting of 
WhatEverPath (in my case PrisInformasjonPath) relates to the rest of 
my configuration.

Btw: is setting a cookie and then doing a redirect safe with all 
browsers (at least those with cookies turned on)?

Using AuthCookie 3.00 and AuthCookieDBI 1.18, mod_perl 1.25, perl 
5.005_03 under Apache 1.3.19, HP-UX  10.20. Currently testing with 
Mozilla 1.9.6, Linux.

Thanks,
-- 
Øyvind



**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager. (mailto:[EMAIL PROTECTED])

This footnote also confirms that this email message has been swept by
viruscheckers for the presence of computer viruses.
**




Re: Problems with cookies in Apache::AuthCookie

2002-01-04 Thread Geoffrey Young

Øyvind Gjerstad wrote:
 
 Geoffrey Young wrote:
 
 [Fri Jan  4 14:23:46 2002] [error] credential_0 ogj
 [Fri Jan  4 14:23:46 2002] [error] credential_1 xxx
 [Fri Jan  4 14:23:46 2002] [error] ses_key
 ogj:2002-01-04-14-23-46:2002-01-05-14
 -23-46:54f7553ccb96d3af70abe449f053ee3d
 [Fri Jan  4 14:23:46 2002] [error] auth_type Apache::AuthCookieDBI
 
 
  the AuthType setting should be the name of the class that inherits
  from Apache::AuthCookie (or Apache::AuthCookieDBI I suppose, I've
  never used it)
 
  for instance
 
  PerlSetVar PrisInformasjonPath /
  PerlSetVar PrisInformasjonLoginScript /login.html
  PerlSetVar AuthCookieDebug 3
 
  Location /tgweb/protected
AuthType PrisInformasjon::Authenticate
AuthName PrisInformasjon
PerlAuthenHandler PrisInformasjon::Authenticate-authenticate
Require vaild-user
 
 Hmm. I thought I didn't need to subclass AuthCookieDBI. I thought that I
 should be able to just configure that to authenticate to a database
 (that part works, as far as I can tell), and write a login-script (which
 I have done).

ah, you are right.  I don't use Apache::AuthCookieDBI, and apparently
it works slightly differently from Apache::AuthCookie.

anyway, CC'd to the list so perhaps someone more familiar can see your
httpd.conf

--Geoff

 
 Here are the relevant parts (I think) from httpd.conf:
 
 PerlSetVar PrisInformasjonPath /
 PerlSetVar PrisInformasjonLoginScript /wwwappl/login.epl
 PerlSetVar PrisInformasjonDomain .tollpost.no
 PerlSetVar PrisInformasjonDBI_DSN DBI:Informix:testogj1
 PerlSetVar PrisInformasjonDBI_SecretKeyFile /etc/opt/apache/secret.key
 PerlSetVar PrisInformasjonDBI_UserField username
 PerlSetVar AuthCookieDebug 3
 
 PerlModule Apache::AuthCookieDBI
 
 Directory /opt/www/tgweb/protected/
  AuthType Apache::AuthCookieDBI
  AuthName PrisInformasjon
  PerlAuthenHandler Apache::AuthCookieDBI-authenticate
  PerlAuthzHandler Apache::AuthCookieDBI-authorize
  require valid-user
 /Directory
 
 Files LOGIN
  AuthType Apache::AuthCookieDBI
  AuthName PrisInformasjon
  SetHandler perl-script
  PerlHandler Apache::AuthCookieDBI-login
 /Files
 
 [Fri Jan  4 14:23:46 2002] [error] auth_name PrisInformasjon
 [Fri Jan  4 14:23:46 2002] [error] ses_key_cookie
 [Fri Jan  4 14:23:46 2002] [error] uri /tgweb/protected/index.html
 
 --
 Øyvind
 
 **
 This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they
 are addressed. If you have received this email in error please notify
 the system manager. (mailto:[EMAIL PROTECTED])
 
 This footnote also confirms that this email message has been swept by
 viruscheckers for the presence of computer viruses.
 **



O'Reilly Open Source Convention Call for Proposals

2002-01-04 Thread Stas Bekman

O'Reilly Open Source Convention
Sheraton San Diego Hotel and Marina
July 22-26, 2002 -- San Diego, CA

The call for proposals is here:
http://conferences.oreillynet.com/cs/os2002/create/e_sess

This year, all speakers must submit their proposals via the web form
on the CFP page. Compared to the last year where the mod_perl committee 
was collecting the proposals.

This year, after the submission deadline the program committee will be 
given access to the proposals database and will vote via the web on the 
relevant proposals. This is done in order to make sure that no proposal 
falls between chairs.

So start submitting your proposals en masse. Last year mod_perl had a 
great presence at OSC. Let's do even better this year.

The deadline for submitting proposals is March 1, 2002.

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




ANNOUNCE: YAPC::Europe::2002 (Munich) - Call for Papers

2002-01-04 Thread Stas Bekman

Here is another another great place to be as a speaker or an attendee.

 Original Message 
Subject: ANNOUNCE: YAPC::Europe::2002 (Munich) - Call for Papers
Date: Wed, 02 Jan 2002 11:17:45 +0100
From: [EMAIL PROTECTED] (Richard Foley)
Reply-To: [EMAIL PROTECTED]
Organization: RFI
To: [EMAIL PROTECTED]
CC: Norbert Gruener [EMAIL PROTECTED], [EMAIL PROTECTED],  
[EMAIL PROTECTED], 
[EMAIL PROTECTED], [EMAIL PROTECTED],   Jarkko Hietaniemi [EMAIL PROTECTED], Chris Nandor 
[EMAIL PROTECTED], Simon Cozens 
[EMAIL PROTECTED], [EMAIL PROTECTED], Hugo [EMAIL PROTECTED], 
[EMAIL PROTECTED]

ANNOUNCE: YAPC::Europe::2002 (Munich) - Call for Papers

Call for Participation will follow in a couple of weeks, when we should
have some accommodation organised.

http://www.yapc.org/Europe/

Look forward to seeing you there.

-- 
Ciao
Richard Foley
Ciao - shorter than AufWiederSehen!

ps. Thoren, please html-ize this onto YAPC website - TIA :-)

-- 


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



# $Id: call-for-papers,v 1.3 2001/12/17 08:38:44 yapc Exp $

Call For Papers YAPC::Europe::2002 - September 18-20

Proposals may be submitted between January 1st. 2002 and July 30th 2002.

Share your 'pe[a]rls of wisdom' with the perl community: attendees from
all around the world, gurus and geeks alike, will converge on Munich to
listen to the talks and tutorials presented at this gathering of minds.

This year's theme is 'The Science of Perl', which means that we would
really like to hear about suggestions for talks, projects, experiences
which involve both perl and science.  This should not be regarded as a
restriction, more as a 'nice to have' :-)

We have available a mixture of short and long tutorials and talks
time-slots, loosely including the following:

Presentation:   30 mins to 1.5 hours

Lightning talk: 7 min (5 was too short ;-)

Tutorial:   2-3 hours

BOF session:1-2 hours (usually evenings)

Abstracts, outlining the main thrust of the proposal and including an
expected duration, should inititially be sent to the Program Committee
in the form of a short ascii email to the following address:

To: [EMAIL PROTECTED]

Final submissions should be in the form of, (in order of preference),
POD or Ascii or HTML.  Associated graphics should be submitted in a form
to be agreed upon between the commitee and the presenter.

The committee reserves the right to publish any and all presentations,
only for the purpose of this conference.

Finally: conference fees will of course be waived for speakers,
(lightening talks excepted), though as this is a 'not-for-profit' venture,
please feel free to donate your unpaid fee to the YAPC organisation
itself, to assist in this and future perl conferences.











Re: Strange Apache 2.0 rewrite/proxy issue

2002-01-04 Thread Vivek Khera

 JA == John Armstrong [EMAIL PROTECTED] writes:

JA Because the front end reverse proxy needs to connect to one of 3
JA different servers.


JA 1) Static html server.

I always make my front end reverse proxy handle static content
directly.

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Vivek Khera, Ph.D.Khera Communications, Inc.
Internet: [EMAIL PROTECTED]   Rockville, MD   +1-240-453-8497
AIM: vivekkhera Y!: vivek_khera   http://www.khera.org/~vivek/



Re: Suggestions on an XML-RPC Service using modperl?

2002-01-04 Thread Bruce W. Hoylman


Ciao!

I'm on the modper digest list so pardon the delayed response to your
input.

 Aaron == Aaron E Ross [EMAIL PROTECTED] writes:

Aaron   I've been working with a mod_perl based XML-RPC/SOAP
Aaron   service for a few months now and I thought I'd share some
Aaron   quick thoughts.

Thanks!  I'll take 'um.
 
Aaron   As long as you are _sure_ that you won't be writing data,
Aaron   in-memory will be fast and easy to code.  if you use
Aaron   objects you can pretty easily build an interface
Aaron   encouraging programmers to avoid modifying shared data.

Yes, I refuse to do *any* data arbitration between the localized
portions of the data (if any?) and the remote or official copies of it.
Copying it to a local store is meant to remove the access latency and
availability of the data, although I have not yet determined there to be
latency issues.  There are however availability issues surround these
databases.  I agree, an OO interface to it will facilitate its use and
certainly simplify any data format changes that are almost certain to
take place over the life of the service itself.
 
Aaron   Aim for what you may need later, 5+ will be easy as long as
Aaron   you have some memory.

I'm lobbying for excessive memory as we speak!  Good point.
 
Aaron   I have found the Cache::Cache modules really easy to use,
Aaron   well written, documented and supported.  MLDBM::Sync
Aaron   provides some locking, but if you really need concurrent
Aaron   access I would highly recommend BerkeleyDB,
Aaron   http://sleepycat.com/, nb this is _not_ DB_File.

Mr. Turner also mentioned the Cache::* modules for this.  I'm not really
interested in locking the data in any way whatsoever.  It's strictly
read-only so I see no reason to have to manage read locks.  Therefore
concurrent access to an in-memory data store between all the modperl
processes should be no problem, correct?

Aaron   You haven't explained the cacheing logic at all.. perhaps
Aaron   you don't need a cache? maybe just an object that reads
Aaron   from the data stores on startup?

This is a good idea.  It would eliminate the interim step of loading the
data onto the local machines prior to bringing it into memory.  I'm
working on data access issues this week and want to be able to describe
the data better as well as gain query access to it.  Then I should be
able to benchmark access and availability, my two primary concerns with
the data.

Aaron   If you do need a cacheing layer that updates on some event
Aaron   or expiration, remember to seperate the cacheing logic and
Aaron   the storage as much as possible to be able to tune and to
Aaron   scale up later on.

I'll keep this in mind.
 
Aaron   Why not write a simple object? I try to avoid tie's, b/c
Aaron   they are too magical for my taste, but i don't think
Aaron   there is any inherent overhead.

The object description of the data seems to be a good way to go.  I
believe this will end up being the API I present to the handler for data
access.  I agree.

Aaron   I would recommend using SOAP::Lite for both XML-RPC and
Aaron   SOAP. While the code is unreadable, the author is
Aaron   responsive and helpful, and the switch from XML-RPC to SOAP
Aaron   couldn't be easier.

You got the unreadable part right (c:  Sorry.  I've had occasion to use
Randy Ray's RPC-XML module in the past and it functioned very well.  He
describes it as a reference implementation of the XML-RPC specification
and does not attest to its effeciency or speed.  I'll do some comparison
shopping here with SOAP::Lite and see what comes out.

Aaron   Hope this helps, Aaron

Thanks for your insight into this matter.  I really appreciate your
input.

Peace.



Re: Suggestions on an XML-RPC Service using modperl?

2002-01-04 Thread Bruce W. Hoylman


Ciao!

 Jon == Jon Robison [EMAIL PROTECTED] writes:

Jon As far as the cacheing goes, we have had extremely good luck
Jon with IPC::ShareLite used to share info across mod_perl
Jon processes.

Have you compared this module to the Cache::* modules?  I believe the
Cache::SharedMemoryCache module provides a shared memory implementation,
for example.  I have had a few suggestions offered surrounding the use
of the Cache::* modules which is why I ask.

Thanks for your thoughts.

Peace.



Need Some Help

2002-01-04 Thread N.K.Mukul

Dear Mr. Vivek,
   I am a beginner of PERL. I want to know from where I can start, please
kindly suggest me. I am a Computer engineer but I am in Networking Field now
I want to start Web page designing. I am able to design Static Page but not
able make a dynamic page so that I  start Learning Perl.

I am Very Grateful to you if provide some guide line to me.

Regards

Nirmal Kumar Mukul
(System Administrator)
IIMT, 336, Phase-IV
Udyog Vihar, Gurgaon
Haryana-122001
INDIA
Ph:-91-124-6397783/5/6
FAX:-91-124-6397784





More Strange Behavior

2002-01-04 Thread Stathy Touloumis

Hello,

I have currently added cutom apache directives using
'Apache::ModuleConfig,Apache::ExtUtils' and have come across some strange
behavior when trying to use a custom mod_perl handler that worked fine
before.  I get this error :
[Fri Jan  4 11:39:25 2002] [error] Uncaught exception from user code:
Undefined subroutine MyModule::Server::Content::handler called.
eval {...} called at /dev/null line 0

which is strange even after I modified the subroutine 'handler' within
'MyModule::Server::Content' to be as basic as :
sub MyModule::Server::Content::handler { return Apache::Constants::OK; }

The module which contains the custom directive callback routines is in
MyModule::Server.

When commenting out :
#PerlFixupHandler MyModule::Server::Fixup
#Files *.html
#   SetHandler perl-script
#   PerlHandler MyModule::Server::Content
#/Files

Pages are returned fine . . .

Any help would be appreciated.




Re: Strange Apache 2.0 rewrite/proxy issue

2002-01-04 Thread Nick Tonkin


On 4 Jan 2002, Vivek Khera wrote:

  JA == John Armstrong [EMAIL PROTECTED] writes:
 
 JA Because the front end reverse proxy needs to connect to one of 3
 JA different servers.
 
 
 JA 1) Static html server.
 
 I always make my front end reverse proxy handle static content
 directly.

Always is a strong word! At ValueClick we used thttpd servers to deliver
gif images ... one thttpd could efficiently handle the same number of
requests as several (non-mod_perl) front end reverse proxies ...

- nick


Nick Tonkin   {|8^)






Re: Strange Apache 2.0 rewrite/proxy issue

2002-01-04 Thread Vivek Khera

 NT == Nick Tonkin [EMAIL PROTECTED] writes:

JA 1) Static html server.
 
 I always make my front end reverse proxy handle static content
 directly.

NT Always is a strong word! At ValueClick we used thttpd servers to deliver
NT gif images ... one thttpd could efficiently handle the same number of
NT requests as several (non-mod_perl) front end reverse proxies ...

Did you make a front-end proxy talk to your thttpd servers?  I think
not...  I suspect you set the URLs to have the client talk to the
thttpd servers directly.







Re: Suggestions on an XML-RPC Service using modperl?

2002-01-04 Thread Bruce W. Hoylman


Ciao!

I'm on the digest for this list, so pardon my delay in responding to
everyone's comments.

 Chip == Chip Turner [EMAIL PROTECTED] writes:

Chip Bruce W. Hoylman [EMAIL PROTECTED] writes:
 Ciao!

 I would like some input on an intranet web service I am currently
 in the process of designing, the core of which will be modperl on
 UN*X.

Chip Excellent choice.  This works quite well.  Of course, like
Chip others on this list, I might be a bit biased.

I'm sort of sneaking this in the back door.  Much of the development
surrounding these new objectives is centered in the J2EE architecture.
I'm taking a 'don't say much' approach until it's working and cranking
out the data.  Then I'll be able to meet any advances on architecture
choices.  It's not that perl/Apache is taboo here, just not looked upon
as an implementation solution of choice.  However it won't be the first
time I have faced these pundits.

Chip How often does the data change?  How is it stored on the back
Chip end?  You may not need to cache anything if, say, you have a
Chip decent SQL database on the backend.  Caching never hurts, but
Chip it isn't always necessary.  The Cache::* modules may be of use
Chip for this, though, should you still need it.  You also might
Chip want to consider not sharing the data in each process; the
Chip complexity gained vs the memory lost by storing it in each
Chip process may be a workable tradeoff.  I probably would try it
Chip first with no cache, then a per-process on-demand cache, then
Chip finally a shared cache, in that order.

I still have to determine the dynamic characteristics of the data in
question.  This certainly needs to be taken into account in any cacheing
or local storage of the data.  The remote data is Oracle-ized in some
7.x database instances.  When I speak of cacheing I'm referring to
taking remote data sources and making the local for some period of time,
after which they must be refreshed and localized again.  I don't believe
the service can withstand the cost of remote database access and still
be as streamlined as the requirements specify.  However I will be going
through a series of benchmarks to see just which data management
approach is appropriate.  I also am keen to the unavailability of these
external, remote data sources.  They seem to be 'down' at the most
inopportune moments.  In summation, data throughput and availability are
the two most compelling reasons for considering a localized, and I
emphasize READ-ONLY capture of the remote stores (there are two).

Chip Five hits/second should be absolutely no problem.  If you
Chip expect slow clients, a mod_proxy in front of things
Chip (http://perl.apache.org/guide) can help.

This is a very interesting section of the guide.  I recommend it to
everyone simply for the sake knowing alternative configurations that
include a modperl component.

Chip There are a lot of options, but really, I would hold off on
Chip deciding complicated caching schemes until you know what
Chip throughput you get without them.  Even then, I'd avoid
Chip disk-based cache systems, instead preferring Cache::* if it
Chip must be shared, or just global variables if it doesn't need to
Chip be.

This is a good point.  I'm working on securing access to the data stores
this week, so I should be able to measure throughput soon.  Loading the
in-memory stores direct from the data sources is a good idea, if
necessary.  This precludes any local storage of the data which precludes
any refresh to disk logic, although I still will need to flush/fill
memory on a regular basis.  Thus I don't want to utilize per-process
data stores, but rather a common shared memory represenetation that all
the modperl processes can draw from

Chip Can you be more specific about what the data looks like, where
Chip it resides, and how expensive loading it is?  I wouldn't worry
Chip about optimization yet, unless you know beyond the shadow of a
Chip doubt speed will be a problem.  My hunch is you can do maybe
Chip 50-100 hits/second on decent Intel hardware via the Frontier
Chip modules, so I don't think performance will be a problem.  This
Chip is unverified, though; I really need to benchmark it sometime.
Chip Maybe others have pushed Frontier to its speed limits?

I'll be able to provide some numbers and the actual data representation
later on this week.  I agree on performance numbers.  I'm getting
awesome throuput now acording to ApacheBench, but that's only with my
skeletal handler.  As it I fill it out, I plan on benchmarking each
significant piece of functionality for comparison purposes.

Should be fun.

Chip Chip

Thanks so much for your insightful comments.  I appreciate the time you
took to respond to my queries.

Peace.



Re: Problems with mod_perl and mod_dir (Segmentation fault)

2002-01-04 Thread William T. Martin


I found my problem.  The mod_perl module needed to be compiled with the
same version of gcc as the perl executable.  I recompiled and reinstalled
perl and rebuilt mod_perl and apache.  Everything is working fine now.

-- Bill --


On Thu, Jan 03, 2002 at 02:52:02PM -0500, William T. Martin wrote:
 I am having problems getting mod_dir to work with mod_perl.  When mod_perl
 is loaded, mod_dir does not work.  In particular, I want to specify
 DirectoryIndex index.html in my httpd.conf file to set the default file
 to be accessed.  When mod_perl is loaded, http://somehost/~someuser does
 not work, but http://somehost/~someuser/index.html does.  The error
 message I get is Document contains no data.  The error log shows:
 
 [Thu Jan  3 14:48:19 2002] [notice] child pid 2934 exit signal
 Segmentation Fault (11)
 
 If mod_perl is not loaded, then both forms of the address work and there
 is no Segmentation Fault.
 
 I saw this problem posted somewhere, but do not know if it was answered. 
 
 As an alternative, I tried loading the mod_perl version of AutoIndex
 (http://www.dmi.usherb.ca/laboratoires/documentations-logiciels/Perl/lib/Apache/
 AutoIndex.html), but I get a perl compilation error at runtime. 
 
 Here is my Apache configuration:
 
 # ./httpd -v
 Server version: Apache/1.3.22 (Unix)
 Server built:   Jan  3 2002 13:44:35
 
 # ./httpd -l
 Compiled-in modules:
   http_core.c
   mod_env.c
   mod_log_config.c
   mod_mime.c
   mod_negotiation.c
   mod_status.c
   mod_info.c
   mod_include.c
   mod_autoindex.c
   mod_dir.c
   mod_cgi.c
   mod_asis.c
   mod_imap.c
   mod_actions.c
   mod_userdir.c
   mod_alias.c
   mod_rewrite.c
  mod_access.c
   mod_auth.c
   mod_cern_meta.c
   mod_expires.c
   mod_headers.c
   mod_so.c
   mod_setenvif.c
   mod_ssl.c
   mod_php4.c
   mod_auth_kerb.c
   mod_auth_mysql.c
   mod_perl.c
   mod_autoindex.c
 
 # /usr/local/bin/perl -v
 This is perl, v5.6.1 built for sun4-solaris
 
 I am using mod_perl-1.26
 
 Please help me.
 
 Thank you,
 
 -- Bill --
 
 
 -- 
 ===
 William T. Martin email:  [EMAIL PROTECTED]
 Cornell University/ORIE   Fax:(607) 255-9129
 257 Rhodes Hall   Phone:  (607) 255-9134
 Ithaca, NY 14853  
 Public Key: http://www.orie.cornell.edu/~martin/public_key.html
 ===

-- 
===
William T. Martin   email:  [EMAIL PROTECTED]
Cornell University/ORIE Fax:(607) 255-9129
257 Rhodes Hall Phone:  (607) 255-9134
Ithaca, NY 14853
Public Key: http://www.orie.cornell.edu/~martin/public_key.html
===



Re: Error log executing scripts?

2002-01-04 Thread Paul Lindner

On Fri, Jan 04, 2002 at 01:13:37PM -, Matt Sergeant wrote:
   Hello,
   I was wondering if there is any way of making the error log 
  in Apache to
   execute a script when an error is occurred, perhaps instead 
  of writing the
   error directly to the log.

There is a way to redirect errors to your own code.  It's not pretty.

You can see some example code that does this at
http://www.modperlcookbook.org/code/ch16/

You can also download an example module that uses this code to
intercept error log entries and post them to an IRC channel.  Nothing
like real-time errors to keep you on your toes :)

You can now read that entire chapter (and two others) online at

  http://www.modperlcookbook.org/chapters.html

Enjoy!

   For example, if there is a image missing Apache excutes a 
  script that
   generates a replacement image?

In this case you're talking about a different type of error condition.
As Matt and Geoff mentioned you can use an ErrorDocument script that
runs whenever this condition exists.  This does not handle other output
that flows into your error_log.

  well, you can do just about anything you want :)
  
  however, althoughit is possible to intercept the actual errors Apache
  (and mod_perl) generates, it is rather complex, and really not the
  proper approach here.
 
 Really? I would have thought it could make an interesting caching technique
 - on a 404 you try and generate the file, and store in that slot in the
 filesystem. A cache cleanup daemon runs to clean out TTL'd files.

Check out Apache::CacheContent - it implements something similar,
available on CPAN or at http://www.modperlcookbook.org/code.html

 Warning: don't try and implement this in a commercial application - it's
 patented by vignette.

Hmmm, I implemented something like this in the early 90s...  Long
before vignette was even around..


-- 
Paul Lindner[EMAIL PROTECTED]   | | | | |  |  |  |   |   |

mod_perl Developer's Cookbook   http://www.modperlcookbook.org
 Human Rights Declaration   http://www.unhchr.ch/udhr/index.htm



Lost form values with direct calls to param in CGI.pm

2002-01-04 Thread Hans Poo

I'am migrating some scripts to run under Apache::Registry. The scripts are 
programmed with the typical: use CGI qw/:standard/ ... and then recover the 
parameter values wityh direct call to the function param(somefield). 

This is happening with the last versions: apache:1.3.22 and mod_perl 1.26

Detail: 

if i do:
use CGI qw/:standard/;

and call the form values with: 

print param(somefield);

The form fields don't appear to exist. 

Instead if i use the object oriented syntax:

my $q = new CGI;

and then

print $q-param(somefield);

everything works fine...

I have been the whole day chasing this ...

The same thing happen with Apache::PerlRun

To finish, the httpd.conf file is:

VirtualHost 64.76.145.88
ServerName www.polla.cl
DocumentRoot /home/www/html
Alias /cgi-bin /home/www/cgi-bin

PerlModule Apache::Registry

Location /cgi-bin
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
/Location

/VirtualHost

Hans Poo



Feeling stupid

2002-01-04 Thread tarkhil

Hello!

I'm trying to set up (again; I've done it a couple of times) mod_perl'ed
Apache.

With THAT simple addition to base config

Location /
SetHandler PerlScript 
PerlHandler Apache::PerlRun
Options +ExecCGI 
/Location

I'm getting script source instead of result.

I've even attepmted to add

Files *.pl 
SetHandler PerlScript 
PerlHandler Apache::Registry 
Options ExecCgi 
/Files 

below the Location, but result is the same.

That script worked and works under non-modperl'ed Apache.

I've read all documentation as carefully as possible, and I'm feeling
immesurably stupid :-(((

Mod_perl IS active, at least, other virtual site with HTML::Mason runs
neatly!

What could I do wrong?

Alex.





Re: Feeling stupid

2002-01-04 Thread Hans Poo

El Vie 04 Ene 2002 18:26, [EMAIL PROTECTED] escribió:
 Hello!

 I'm trying to set up (again; I've done it a couple of times) mod_perl'ed
 Apache.

 With THAT simple addition to base config

 Location /
 SetHandler PerlScript
 PerlHandler Apache::PerlRun
 Options +ExecCGI
 /Location

 I'm getting script source instead of result.

 I've even attepmted to add

 Files *.pl
 SetHandler PerlScript
 PerlHandler Apache::Registry
 Options ExecCgi
 /Files

 below the Location, but result is the same.

 That script worked and works under non-modperl'ed Apache.

 I've read all documentation as carefully as possible, and I'm feeling
 immesurably stupid :-(((

 Mod_perl IS active, at least, other virtual site with HTML::Mason runs
 neatly!

 What could I do wrong?

 Alex.

the line must be:

SetHandler perl-script 

with a dash between perl an script.

Hans Poo



Re: Feeling stupid

2002-01-04 Thread tarkhil

On Fri, Jan 04, 2002 at 06:32:10PM -0300, Hans Poo wrote:
 SetHandler perl-script 
 
 with a dash between perl an script.
Oh yes. I'm a dashed... err... damned idiot...

BTW, what is the best way to process lots of Include virtual in .shtmls?

Alex.



Lost form values with direct calls to param in CGI.pm

2002-01-04 Thread Hans Poo


I'am migrating some scripts to run under Apache::Registry. The scripts are 
programmed with the typical: use CGI qw/:standard/ ... and then recover the 
parameter values wityh direct call to the function param(somefield). 

This is happening with the last versions: apache:1.3.22 and mod_perl 1.26

Detail: 

if i do:
use CGI qw/:standard/;

and call the form values with: 

print param(somefield);

The form fields don't appear to exist. 

Instead if i use the object oriented syntax:

my $q = new CGI;

and then

print $q-param(somefield);

everything works fine...

I have been the whole day chasing this ...

The same thing happen with Apache::PerlRun

To finish, the httpd.conf file is:

VirtualHost 64.76.145.88
ServerName www.polla.cl
DocumentRoot /home/www/html
Alias /cgi-bin /home/www/cgi-bin

PerlModule Apache::Registry

Location /cgi-bin
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
/Location

/VirtualHost

Note: I've just changing my email, may be this email is going to be 
duplicated. Sorry if this happen.

Hans Poo



Re: Apache::Session getting DESTROYed in wrong order

2002-01-04 Thread Ken Williams


On Friday, January 4, 2002, at 02:48 AM, Gerald Richter wrote:

# Won't get cleaned up properly
local %foo;
tie %foo, 'Dummy', name = '%foo';

 local only make a copy of the original value and restores it at the end 
 of
 the scope, so %foo will not destroyed, but restored at the end of the 
 scope.
 I guess this is the reason my it still stays tied.

AMS just posted this small test case to p5p:

 sub X::TIEHASH{bless{}}
 { local %x; tie %x, X } print tied %x ? a : b;

5.004_03 prints b, and 5.004_04 (and higher) prints a.  I think b 
is the proper behavior, at least that's my opinion.


  -Ken




POST_MAX not working

2002-01-04 Thread Trond Arve Nordheim

Hi.

I'm trying to limit the size of uploads using Apache::Request. Right
now, I'm using the following code:

my $r = Apache::Request-new($self-{request}, POST_MAX = 1024);

Where $self-{request} is the original Apache::Request-object originally
passed to the handler()-function in my mod_perl loader.

Then, I do as explained in perldoc Apache::Request:
my $status = $r-parse;
if ($status) {
warn POST too large\n;
}

Just to see if it actually does limit anything. When I then try to post
a 5MB file to this component, no warning is generated in the Apache log.
I've even tried setting POST_MAX to 1 byte, still nothing.

Right now you're probably assuming somethings wrong in my module,
-but-... ;)

When I remove POST_MAX, and instead put DISABLE_UPLOADS = 1, the
warning appears. So it -does- work, just not with POST_MAX.

Any ideas why this is happening?

-- 
Trond Arve Nordheim
 - This message is ROT13-encrypted twice for extra security.




RE: POST_MAX not working

2002-01-04 Thread Jonathan M. Hollin

:: Just to see if it actually does limit anything. When I then 
:: try to post a 5MB file to this component, no warning is 
:: generated in the Apache log. I've even tried setting 
:: POST_MAX to 1 byte, still nothing.

Trond, I've encountered the same with both Apache::Request and CGI.pm.
Are you on a Windows server???

Jonathan M. Hollin - WYPUG Co-ordinator
West Yorkshire Perl User Group
http://wypug.pm.org/ 




RE: POST_MAX not working

2002-01-04 Thread Trond Arve Nordheim

On Sat, 2002-01-05 at 01:03, Jonathan M. Hollin wrote:
 Trond, I've encountered the same with both Apache::Request and CGI.pm.
 Are you on a Windows server???

Nope, using Linux (Debian sid) with Apache 1.3.22 and mod_perl 1.26
w/libapreq 0.33, all three compiled from source...

-- 
Trond Arve Nordheim
 - This message is ROT13-encrypted twice for extra security.




Re: Need Some Help

2002-01-04 Thread ___cliff rayman___

here is the learning guide and the bible.

Learning Perl
http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0596001320vm=

Programming Perl
http://www1.fatbrain.com/asp/bookinfo/bookinfo.asp?theisbn=0596000278vm=

make sure you get third editions for both!


here are relevant sources on the web:
http://www.perlmonks.com/
http://www.perl.com/
http://use.perl.org/

news://comp.lang.perl.moderated
news://comp.lang.perl.misc

good luck!!


N.K.Mukul wrote:

 Dear Mr. Vivek,
I am a beginner of PERL. I want to know from where I can start, please
 kindly suggest me. I am a Computer engineer but I am in Networking Field now
 I want to start Web page designing. I am able to design Static Page but not
 able make a dynamic page so that I  start Learning Perl.


--
___cliff [EMAIL PROTECTED]http://www.genwax.com/





RE: Strange Apache 2.0 rewrite/proxy issue

2002-01-04 Thread Adam Sussman


There are some stability issues in mod_proxy for apache 2.0.28.
It can segfault or display run-away cpu issues in the following cases:

1) backend server closes connection without sending any data
2) backend sends bogus status line
3) backend sends HTTP/0.9 response

You might want to look and see if your backend server is mis-behaving
in any way.

These issues have been fixed and the current CVS version of mod_proxy
is more stable.  Not sure when the next public beta will be though.

-adam
 
-Original Message-
From: John Armstrong [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 03, 2002 11:26 AM
To: [EMAIL PROTECTED]
Subject: Strange Apache 2.0 rewrite/proxy issue


This 'seems' to be a modperl issue.

My configuration. I needed a 1.1 compliant reverse proxy in order to 
support Chunked encoding for an xml gateway.

Since only Apache 2.0 has a 1.1 compliant reverse proxy I replaced my 
Apache 1.3.14 standard apache wth an Apache 2.0.28 with the proxy 
support compiled in.

My modperl server on the backend is still running as 1.3.14.

The 2.0.28 proxy uses mod_rewrite. When it rewrites url's internally to 
go to a static apache server all works great!

However, when it rewrites to my modperl 1.3.14 server apache 2.0.28 
children start segfaulting left and right with a code 11. I can not find 
any reference to this on the 2.0 mailing lists/groups.

Does anyone know why Apache 2.0 running as a rewrite reverse proxy would 
die only when it talks to my modperl servers? This is destroying my 
development time and about  to kill me on some significant deadlines :(

John-



cvs commit: modperl-2.0/xs/APR/PerlIO apr_perlio.c

2002-01-04 Thread stas

stas02/01/04 01:29:50

  Modified:xs/APR/PerlIO apr_perlio.c
  Log:
  - now APR PerlIO read is buffered by PerlIOBuf layer.
  Attention: this requires at least bleadperl patch 13978,
  14042 seems to be fine too for me.
  
  Revision  ChangesPath
  1.8   +67 -42modperl-2.0/xs/APR/PerlIO/apr_perlio.c
  
  Index: apr_perlio.c
  ===
  RCS file: /home/cvs/modperl-2.0/xs/APR/PerlIO/apr_perlio.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- apr_perlio.c  20 Dec 2001 03:20:33 -  1.7
  +++ apr_perlio.c  4 Jan 2002 09:29:50 -   1.8
  @@ -4,7 +4,7 @@
   #include apr_perlio.h
   
   /* XXX: prerequisites to have things working
  - * pTHX_: perl 5.7.2 patch 13809 is required
  + * PerlIO_flush patch : perl 5.7.2 patch 13978 is required
* dup() : apr cvs date: 2001/12/06 13:43:45
*
* XXX: it's not enough to check for PERLIO_LAYERS, some functionality
  @@ -119,34 +119,16 @@
   return NULL;
   }
   
  -/* currrently read is very not-optimized, since in many cases the read
  - * process happens a char by char. Need to find a way to snoop on APR
  - * read buffer from PerlIO, or implement our own buffering layer here
  - */
  -static SSize_t PerlIOAPR_read(pTHX_ PerlIO *f, void *vbuf, Size_t count)
  -{
  -PerlIOAPR *st = PerlIOSelf(f, PerlIOAPR);
  -apr_status_t rc;
  -
  -/* fprintf(stderr, in  read: count %d, %s\n, 
  -   (int)count, (char*) vbuf); */
  -rc = apr_file_read(st-file, vbuf, count);
  -/* fprintf(stderr, out read: count %d, %s\n,
  -   (int)count, (char*) vbuf); */
  -if (rc == APR_SUCCESS) {
  -return (SSize_t) count;
  -}
  -
  -return (SSize_t) -1;
  -}
  -
   static SSize_t PerlIOAPR_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
   {
   PerlIOAPR *st = PerlIOSelf(f, PerlIOAPR);
   apr_status_t rc;
  +
  +#if 0
  + Perl_warn(aTHX_ in write: count %d, %s\n,
  +   (int)count, (char*) vbuf);
  +#endif
   
  -/* fprintf(stderr, in write: count %d, %s\n,
  -   (int)count, (char*) vbuf); */
   rc = apr_file_write(st-file, vbuf, count);
   if (rc == APR_SUCCESS) {
   return (SSize_t) count;
  @@ -160,13 +142,14 @@
   PerlIOAPR *st = PerlIOSelf(f, PerlIOAPR);
   apr_seek_where_t where;
   apr_status_t rc;
  +IV code;
   
  -/* XXX: must flush before seek? */
  -rc = apr_file_flush(st-file);
  -if (rc != APR_SUCCESS) {
  -return -1;
  +/* Flush the fill buffer */
  +code = PerlIOBuf_flush(aTHX_ f);
  +if (code != 0) {
  +return code;
   }
  -
  +
   switch(whence) {
 case 0:
   where = APR_SET;
  @@ -209,7 +192,7 @@
   
   const char *new_path;
   apr_file_name_get(new_path, st-file);
  -/* fprintf(stderr, closing file %s\n, new_path); */
  +/* Perl_warn(aTHX_ closing file %s\n, new_path); */
   
   rc = apr_file_flush(st-file);
   if (rc != APR_SUCCESS) {
  @@ -239,7 +222,46 @@
   
   static IV PerlIOAPR_fill(pTHX_ PerlIO *f)
   {
  -return -1;
  +PerlIOAPR *st = PerlIOSelf(f, PerlIOAPR);
  +apr_status_t rc;
  +SSize_t avail;
  +Size_t count = st-base.bufsiz;
  +
  +if (!st-base.buf) {
  +PerlIO_get_base(f);  /* allocate via vtable */
  +}
  +
  +#if 0
  + Perl_warn(aTHX_ ask to fill %d chars\n, count);
  +#endif
  +
  +rc = apr_file_read(st-file, st-base.ptr, count);
  +if (rc != APR_SUCCESS) {
  +/* XXX */
  +}
  +
  +#if 0
  + Perl_warn(aTHX_ got to fill %d chars\n, count);
  +#endif
  +
  +avail = count; /* apr_file_read() sets how many chars were read in count */
  +if (avail = 0) {
  +if (avail == 0) {
  +PerlIOBase(f)-flags |= PERLIO_F_EOF;
  +}
  +else {
  +PerlIOBase(f)-flags |= PERLIO_F_ERROR;
  +}
  +
  +return -1;
  +}
  +st-base.end = st-base.buf + avail;
  +
  +/* indicate that the buffer this layer currently holds unconsumed
  +   data read from layer below. */
  +PerlIOBase(f)-flags |= PERLIO_F_RDBUF;
  +
  +return 0;
   }
   
   static IV PerlIOAPR_eof(pTHX_ PerlIO *f)
  @@ -262,14 +284,14 @@
   static PerlIO_funcs PerlIO_APR = {
   APR,
   sizeof(PerlIOAPR),
  -PERLIO_K_BUFFERED | PERLIO_K_MULTIARG, /* XXX: document the flag in perliol.pod 
*/
  +PERLIO_K_BUFFERED | PERLIO_K_FASTGETS | PERLIO_K_MULTIARG,
   PerlIOBase_pushed,
   PerlIOAPR_popped,
   PerlIOAPR_open,
   NULL,  /* no getarg needed */
   PerlIOAPR_fileno,
   PerlIOAPR_dup,
  -PerlIOAPR_read,
  +PerlIOBuf_read,
   PerlIOBuf_unread,
   PerlIOAPR_write,
   PerlIOAPR_seek, 
  @@ -308,7 +330,10 @@
   char *mode;
   const char *layers = :APR;
   PerlIO *f = PerlIO_allocate(aTHX);
  -
  +if (!f) {
  +   

cvs commit: modperl-2.0/t/response/TestAPR perlio.pm

2002-01-04 Thread stas

stas02/01/04 01:30:45

  Modified:t/response/TestAPR perlio.pm
  Log:
  + extend PerlIO tests
  + cleanups
  
  Revision  ChangesPath
  1.6   +92 -28modperl-2.0/t/response/TestAPR/perlio.pm
  
  Index: perlio.pm
  ===
  RCS file: /home/cvs/modperl-2.0/t/response/TestAPR/perlio.pm,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- perlio.pm 18 Dec 2001 06:02:29 -  1.5
  +++ perlio.pm 4 Jan 2002 09:30:45 -   1.6
  @@ -23,74 +23,116 @@
   return Apache::OK;
   }
   
  -plan $r, tests = 9, have_perl 'iolayers';
  +plan $r, tests = 14, have_perl 'iolayers';
   
   my $vars = Apache::Test::config()-{vars};
   my $dir  = catfile $vars-{documentroot}, perlio;
   
   t_mkdir($dir);
   
  +my $sep = -- sep --\n;
  +my @lines = (This is a test: $$\n, test line --sep two\n);
  +my $expected = $lines[0];
  +my $expected_all = join $sep, @lines;
  +
   # write file
   my $file = catfile $dir, test;
  -t_debug open file $file;
  +t_debug open file $file for writing;
   my $foo = bar;
   open my $fh, :APR, $file, $r
   or die Cannot open $file for writing: $!;
   ok ref($fh) eq 'GLOB';
   
  -my $expected = This is a test: $$;
  -t_debug write to a file: $expected;
  -print $fh $expected;
  +t_debug write to a file:\n$expected;
  +print $fh $expected_all;
   close $fh;
   
  -# open() other tests
  +# open() failure test
   {
   # non-existant file
   my $file = /this/file/does/not/exist;
  -t_write_file(/tmp/testing, some stuff);
   if (open my $fh, :APR, $file, $r) {
   t_debug must not be able to open $file!;
   ok 0;
   close $fh;
   }
   else {
  -t_debug good! cannot open/doesn't exist: $!;
  -ok 1;
  +ok t_cmp('No such file or directory',
  + $!,
  + expected failure);
   }
   }
   
  -# read() test
  -{
  -open my $fh, :APR, $file, $r
  -or die Cannot open $file for reading: $!;
  -ok ref($fh) eq 'GLOB';
  -
  -my $received = $fh;
  -close $fh;
  -
  -ok t_cmp($expected,
  - $received,
  - read/write file);
  -}
  -
   # seek/tell() tests
   {
   open my $fh, :APR, $file, $r 
   or die Cannot open $file for reading: $!;
   
  -my $pos = 3;
  -seek $fh, $pos, Fcntl::SEEK_SET();
  +# read the whole file so we can test the buffer flushed
  +# correctly on seek.
  +my $dummy = join '', $fh;
   
  +# Fcntl::SEEK_SET()
  +my $pos = 3; # rewinds after reading 6 chars above
  +seek $fh, $pos, Fcntl::SEEK_SET();
   my $got = tell($fh);
   ok t_cmp($pos,
$got,
  - seek/tell the file);
  + seek/tell the file Fcntl::SEEK_SET);
  +
  +# Fcntl::SEEK_CUR()
  +my $step = 10;
  +$pos = tell($fh) + $step;
  +seek $fh, $step, Fcntl::SEEK_CUR();
  +$got = tell($fh);
  +ok t_cmp($pos,
  + $got,
  + seek/tell the file Fcntl::SEEK_CUR);
  +
  +# Fcntl::SEEK_END()
  +$pos = -s $file;
  +seek $fh, 0, Fcntl::SEEK_END();
  +$got = tell($fh);
  +ok t_cmp($pos,
  + $got,
  + seek/tell the file Fcntl::SEEK_END);
   
  -# XXX: test Fcntl::SEEK_CUR() Fcntl::SEEK_END()
   close $fh;
  +}
  +
  +# read() tests
  +{
  +open my $fh, :APR, $file, $r
  +or die Cannot open $file for reading: $!;
   
  +# basic open test
  +ok ref($fh) eq 'GLOB';
  +
  +# basic single line read
  +ok t_cmp($expected,
  + scalar($fh),
  + single line read);
  +
  +# slurp mode
  +seek $fh, 0, Fcntl::SEEK_SET(); # rewind to the start
  +local $/;
  +ok t_cmp($expected_all,
  + scalar($fh),
  + slurp file);
  +
  +# test ungetc (a long sep requires read ahead)
  +seek $fh, 0, Fcntl::SEEK_SET(); # rewind to the start
  +local $/ = $sep;
  +my @got_lines = $fh;
  +my @expect = ($lines[0] . $sep, $lines[1]);
  +ok t_cmp(\@expect,
  + \@got_lines,
  + adjusted input record sep read);
  +
  +close $fh;
   }
   
  +
   # eof() tests
   {
   open my $fh, :APR, $file, $r 
  @@ -103,6 +145,7 @@
   seek $fh, 0, Fcntl::SEEK_END();
   my $received = $fh;
   
  +t_debug($received);
   ok t_cmp(1,
eof($fh),
end of