perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Förtsch <>
Subject pnotes and pool cleanups
Date Fri, 04 Mar 2011 22:37:25 GMT

I had strange situation here today. I have added a $r->pool cleanup like:

	(sub {
	     my ($r)=@_;
	     use Data::Dumper;
	     warn Dumper $r->pnotes;
	 }, $r);

At that time there were no pnotes present.

Later I added pnotes the usual way $r->pnotes->{...}=...

Then I wondered why my pool cleanup function didn't show any notes.

After a few hours it occurred to me. The pnotes cleaner is also a pool 
cleanup. So it depends on the registration order. Well almost since elements 
in the cleanup queue can become invalid when a cleanup is killed. Later such 
elements can be reused. So generally a certain order cannot be assumed.

But in my case, adding a single pnotes() call *before* registering the cleanup 
solved the problem:

	(sub {
	     my ($r)=@_;
	     use Data::Dumper;
	     warn Dumper $r->pnotes;
	 }, $r);

Suddenly, the notes were shown.

Now, this seems like a bug to me.

Modern APR versions know about pre_cleanup functions that are run in the first 
place in apr_pool_clear.

Should we support them separately as APR::Pool->pre_cleanup_register or should 
we simply move our pool cleanups to the pre_cleanup stage?

I think the former is more appropriate.

In the mean time use $r->notes in such cases or perhaps

Torsten Förtsch

Need professional modperl support? Hire me! (

Like fantasy?

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message