Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* modules/proxy/mod_proxy_fcgi.c (dispatch): Only allocate a heap
buffer if the configured size is greater than the stack-allocated buffer. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1917576 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
aa86530
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this modification?
aa86530
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because "Allocate a buffer if the configured size is larger than the stack buffer, otherwise use the stack buffer" to save an allocation?
aa86530
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is, before the modification, memory allocation was based on the size of
iobuf_size
. After the modification, ifiobuf_size
is not greater thanAP_IOBUFSIZE
, the default size will be used. This way, there won't be any memory waste, right?aa86530
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the default size that is being used when
iobuf_size <= AP_IOBUFSIZE
but the default buffer on the stack (char stack_iobuf[AP_IOBUFSIZE];
) which already has enough room.iobuf_size
will be set toiobuffersize
anyway if configured so the I/Os will use that size (orAP_IOBUFSIZE
by default).The point is that we don't need to allocate a new buffer on the heap if the one on the stack (already allocated) fits, even if it's not used to its full capacity.
aa86530
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand, thanks your reply