You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ben Laurie <be...@algroup.co.uk> on 1999/09/11 12:25:18 UTC

APR cleanup status?

Why do cleanups return a status?

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: APR cleanup status?

Posted by Ben Hyde <bh...@pobox.com>.
Ben Laurie <be...@algroup.co.uk> writes:
> But what does an error mean during a cleanup?

:-) Presumably that the cleanup failed.  On windows where the cleanup
of a thread is your only chance after killing it to recovering the
locks was holding these failures can be useful as an indication that
the whole enterprise is probably toast.  In practise a cleanup should
rarely return an error - since pool cleanup can at best only return
the first error it notices.

 - ben

Re: APR cleanup status?

Posted by Ben Laurie <be...@algroup.co.uk>.
Ryan Bloom wrote:
> 
> > > That depends on the function.  If I am closing a file descriptor, I can at
> > > the very least get EBADF.  I think that is a relatively important error to
> > > acknowledge, because it most likely means that there is a bug in our code
> > > somewhere.
> >
> > I meant when it is being used as a cleanup, rather than to close/free
> > something.
> 
> I guess I was thinking that the error message is just as important if we
> are using the function as a cleanup.  Our cleanup routines should have the
> smarts required to output useful error messages, in time.  Same example, I
> am closing a file, because I am removing a context.  I get APR_EBADF.
> This should be reported somehow.  Put a line in the error log that says
> "Received APR_EBADF while executing cleanups."  Honestly, we should not be
> getting error codes during cleanups, and if we are, there is a bug
> somewhere.  I would personally like to know about it.

That sounds like a plan.

> > Because the cleanup may make slightly different assumptions (e.g. that
> > everything else is about to get cleaned up, too).
> >
> > It makes sense, but I'm not sure I think it is a good idea. I'd rather
> > have a third cleanup. I think.
> 
> No offense Ben, you say you aren't sure it's wise, it doesn't sit right
> with you, etc.  Everytime I say anything like that, I get hammered for
> hand waving over an issue.  :)  If you want to re-implement this, go
> ahead, I won't complain.  It is on the very bottom of my list right
> now, because there is just too much work to be done in APR.

:-) That's a fair comment. My specific concern is that the cleanup
functions are designed to clean up _when a pool is destroyed_.
Overloading that with releasing specific resources in the normal course
of events strikes me both as a risk, in the sense that we may find one
day that we really need all three semantics, and (potentially) an extra
porting problem for modules moving from 1.x.

Certainly it seems to me that there _are_ three different semantics, and
squeezing them into two function calls may be something we come to
regret.

Cheers,

Ben.

> 
> Ryan
> 
> _______________________________________________________________________
> Ryan Bloom              rbb@raleigh.ibm.com
> 4205 S Miami Blvd
> RTP, NC 27709           It's a beautiful sight to see good dancers
>                         doing simple steps.  It's a painful sight to
>                         see beginners doing complicated patterns.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: APR cleanup status?

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
> > That depends on the function.  If I am closing a file descriptor, I can at
> > the very least get EBADF.  I think that is a relatively important error to
> > acknowledge, because it most likely means that there is a bug in our code
> > somewhere.
> 
> I meant when it is being used as a cleanup, rather than to close/free
> something.

I guess I was thinking that the error message is just as important if we
are using the function as a cleanup.  Our cleanup routines should have the
smarts required to output useful error messages, in time.  Same example, I
am closing a file, because I am removing a context.  I get APR_EBADF.
This should be reported somehow.  Put a line in the error log that says 
"Received APR_EBADF while executing cleanups."  Honestly, we should not be
getting error codes during cleanups, and if we are, there is a bug
somewhere.  I would personally like to know about it.

> Because the cleanup may make slightly different assumptions (e.g. that
> everything else is about to get cleaned up, too).
> 
> It makes sense, but I'm not sure I think it is a good idea. I'd rather
> have a third cleanup. I think.

No offense Ben, you say you aren't sure it's wise, it doesn't sit right
with you, etc.  Everytime I say anything like that, I get hammered for
hand waving over an issue.  :)  If you want to re-implement this, go
ahead, I won't complain.  It is on the very bottom of my list right
now, because there is just too much work to be done in APR.

Ryan

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	



Re: APR cleanup status?

Posted by Ben Laurie <be...@algroup.co.uk>.
Ryan Bloom wrote:
> 
> > But what does an error mean during a cleanup?
> 
> That depends on the function.  If I am closing a file descriptor, I can at
> the very least get EBADF.  I think that is a relatively important error to
> acknowledge, because it most likely means that there is a bug in our code
> somewhere.

I meant when it is being used as a cleanup, rather than to close/free
something.

> > Is that wise? I suppose it makes sense, but which one do you call? And,
> > I presume you mean "I call the function that is registered as the
> > cleanup" when you say "I call the same function that is used for
> > registering the cleanup"?
> 
> Why wouldn't it be wise?  If I wrote the code to close a file and free the
> memory properly, why not use it everyplace I want to close the file and
> free the memory.

Because the cleanup may make slightly different assumptions (e.g. that
everything else is about to get cleaned up, too).

>  I call which ever function makes sense for what I am
> doing.  Most of the APR types only have one cleanup routine.  For those
> that have moer than one, I determine which cleanup to call based on why I
> am closing things.  I hope that makes sense.

It makes sense, but I'm not sure I think it is a good idea. I'd rather
have a third cleanup. I think.

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: APR cleanup status?

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
> But what does an error mean during a cleanup?

That depends on the function.  If I am closing a file descriptor, I can at
the very least get EBADF.  I think that is a relatively important error to
acknowledge, because it most likely means that there is a bug in our code
somewhere.

> Is that wise? I suppose it makes sense, but which one do you call? And,
> I presume you mean "I call the function that is registered as the
> cleanup" when you say "I call the same function that is used for
> registering the cleanup"?

Why wouldn't it be wise?  If I wrote the code to close a file and free the
memory properly, why not use it everyplace I want to close the file and
free the memory.  I call which ever function makes sense for what I am
doing.  Most of the APR types only have one cleanup routine.  For those
that have moer than one, I determine which cleanup to call based on why I
am closing things.  I hope that makes sense.

And yes, you interpreted my meaning properly.

Ryan

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	


Re: APR cleanup status?

Posted by Ben Laurie <be...@algroup.co.uk>.
Ryan Bloom wrote:
> 
> > If they return a value, then there needs to be some docco that says what
> > the values are, and what effect they have.
> 
> The values are ap_status_t's.  ie either an errno value, or APR_SUCCESS.
> The same as all the ap_status_t's used throughout the code.

But what does an error mean during a cleanup?

> > I don't know what you mean by "closing the data types".
> 
> For example, if I want to close an apr file entity, I call the same
> function that is used for registering the cleanup.  Because it is inside
> that function that the close call happens I need the status of the close.

Is that wise? I suppose it makes sense, but which one do you call? And,
I presume you mean "I call the function that is registered as the
cleanup" when you say "I call the same function that is used for
registering the cleanup"?

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: APR cleanup status?

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
> If they return a value, then there needs to be some docco that says what
> the values are, and what effect they have.

The values are ap_status_t's.  ie either an errno value, or APR_SUCCESS.
The same as all the ap_status_t's used throughout the code.

> 
> I don't know what you mean by "closing the data types".

For example, if I want to close an apr file entity, I call the same
function that is used for registering the cleanup.  Because it is inside
that function that the close call happens I need the status of the close.

Hope that helps.

Ryan

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.	


Re: APR cleanup status?

Posted by Ben Laurie <be...@algroup.co.uk>.
Ryan Bloom wrote:
> 
> There was a reason for this, but I don't remember what it was.  I think it
> was because I am using the same functions for cleanups as I am for
> actually closing the data types.  IF we really don't like this, I can
> change it, but I am actually using the the return code inside of APR.

If they return a value, then there needs to be some docco that says what
the values are, and what effect they have.

I don't know what you mean by "closing the data types".

Cheers,

Ben.

--
http://www.apache-ssl.org/ben.html

"My grandfather once told me that there are two kinds of people: those
who work and those who take the credit. He told me to try to be in the
first group; there was less competition there."
     - Indira Gandhi

Re: APR cleanup status?

Posted by Ryan Bloom <rb...@raleigh.ibm.com>.
There was a reason for this, but I don't remember what it was.  I think it
was because I am using the same functions for cleanups as I am for
actually closing the data types.  IF we really don't like this, I can
change it, but I am actually using the the return code inside of APR.

Ryan

On Sat, 11 Sep 1999, Ben Laurie wrote:

> Why do cleanups return a status?
> 
> Cheers,
> 
> Ben.
> 
> --
> http://www.apache-ssl.org/ben.html
> 
> "My grandfather once told me that there are two kinds of people: those
> who work and those who take the credit. He told me to try to be in the
> first group; there was less competition there."
>      - Indira Gandhi
> 

_______________________________________________________________________
Ryan Bloom		rbb@raleigh.ibm.com
4205 S Miami Blvd	
RTP, NC 27709		It's a beautiful sight to see good dancers 
			doing simple steps.  It's a painful sight to
			see beginners doing complicated patterns.