First of all, thank you for this interresting point of view.
Ok with your comments, but :
1) apache is not supposed to run *only* on linux and freebsd
2) if checking memory allocation is really not a concern, should places
in httpd that checks for NULL be removed ?
For exemple, in /modules/proxy/ajp_msg.c
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
msg->buf = (apr_byte_t *)apr_palloc(pool, AJP_MSG_BUFFER_SZ);
/* XXX: This should never happen
* In case if the OS cannont allocate 8K of data
* we are in serious trouble
* No need to check the alloc return value, cause the
* core dump is probably the best solution anyhow.
*/
if (msg->buf == NULL) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL,
"ajp_msg_create(): can't allocate AJP message
memory");
return APR_ENOPOOL;
}
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
3) in some places, memory allocation can be delayed a bit, do you think
it could be interesting to dig futher in this direction and see if it could
be a win ?
For exemple, in /modules/generators/mod_status.c in function status_handler,
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
pid_buffer = apr_palloc(r->pool, server_limit * sizeof(pid_t));
stat_buffer = apr_palloc(r->pool, server_limit * thread_limit *
sizeof(char));
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
could be set moved around line 312 (instead of 257).
In this case,
- httpd would maybe not require at all this memory (if one of the
tests at the beginning fails)
- httpd would request for the memory (a bit) latter
CJ
"Paul Querna" <[EMAIL PROTECTED]> a écrit dans le message de
news:[EMAIL PROTECTED]
> Christophe Jaillet wrote:
> > When going thrue the code, looking at apr_palloc and friends, one can
see
> > that :
> > * in some places (few of them) , the returned pointer is checked
against
> > NULL
> > * in other places (most of them), it is not.
> >
> > I've always been told that checking return value is a good idea,
(especially
> > with memory allocation in order to avoid disasters) so should all the
> > apr_palloc (and friends) calls be checked or are they special reasons in
> > httpd not to care about short in memory situation ?
>
> Actually, on most operating systems, including Linux and FreeBSD, you
> will NEVER get returned NULL.
>
> Instead when your operating system is truly out of memory, it will kill
> your process, and you won't have any chance of handling it.
>
> Read a whole blog post about it:
> http://baus.net/memory-management
>
> -Paul
>