httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@gmail.com>
Subject Re: rational behind not checking the return value of apr_palloc and apr_pcalloc
Date Wed, 01 Sep 2010 12:08:34 GMT
On Wed, Sep 1, 2010 at 6:37 AM, Graham Dumpleton <graham.dumpleton@gmail.com
> wrote:

> On 1 September 2010 20:15, Graham Leggett <minfrin@sharp.fm> wrote:
> > On 01 Sep 2010, at 6:07 AM, dave b wrote:
> >
> >> What is the rational behind not checking the return value of
> >> apr_palloc and apr_pcalloc?
> >
> > The rationale is to not be forced to check for and handle hundreds of
> > potential failure cases when you're probably doomed anyway.
> >
> > The APR pools API gives you the apr_pool_abort_set() function, which
> > specifies a function to call if the memory allocation fails. In the case
> of
> > httpd, a function is registered which gracefully shuts down that
> particular
> > server process if the allocation fails, and apr_palloc() is in the
> process
> > guaranteed to never return NULL.
>
> Noting that apr_pool_abort_set() is only setup in Apache 2.3 and not
> in Apache 2.2.16 or earlier. Not being in 2.X explains why I couldn't
> find it before.
>
> Any reason why setting up apr_pool_abort_set() wasn't back ported to Apache
> 2.2?
>

dunno, but here's the commit and original discussion in case anyone wants to
read

http://svn.apache.org/viewvc?view=revision&revision=406953 (dunno if it was
subsequently fixed)
http://www.mail-archive.com/dev@httpd.apache.org/msg32257.html


>
> Graham
>
> > Obviously if you're not using APR from httpd, or if you're writing a
> library
> > that depends on APR, and you haven't set an abort function, NULL will
> > potentially be returned and you should check for and handle that case.
> >
> > Regards,
> > Graham
> > --
> >
> >
>



-- 
Born in Roswell... married an alien...

Mime
View raw message