Forum: NGINX Bug in ngx_slab.c ?

Posted by double (Guest)
on 2010-02-06 20:21
(Received via mailing list)
Hello,

In "ngx_slab.c":


static ngx_uint_t  ngx_slab_max_size;
[...]
void ngx_slab_init(ngx_slab_pool_t *pool)
{
    if (ngx_slab_max_size == 0) {


Could one be sure, that "ngx_slab_max_size" is always "0"?
Maybe better:


static ngx_uint_t  ngx_slab_max_size = 0;


Thanks
Marcus

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,51479,51479#msg-51479
Posted by Maxim Dounin (Guest)
on 2010-02-06 22:45
(Received via mailing list)
Hello!

On Sat, Feb 06, 2010 at 02:20:36PM -0500, double wrote:

> 
> 
> Could one be sure, that "ngx_slab_max_size" is always "0"?
> Maybe better:
> 
> 
> static ngx_uint_t  ngx_slab_max_size = 0;

Here is the explication from ISO C standard (6.7.8 Initialization):

% 10. If an object that has automatic storage duration is not 
initialized
% explicitly, its value is indeterminate. If an object that has static 
storage
% duration is not initialized explicitly, then:
%
% — if it has pointer type, it is initialized to a null pointer;
% — if it has arithmetic type, it is initialized to (positive or 
unsigned)
%   zero;
% — if it is an aggregate, every member is initialized (recursively) 
according
%   to these rules;
% — if it is a union, the first named member is initialized 
(recursively)
%   according to these rules.

Guess which storage duration ngx_slab_max_size has?  If in doubt,
refer to "6.2.4 Storage durations of objects" chapter of the same
standard.

Maxim Dounin
Posted by double (Guest)
on 2010-02-07 09:41
(Received via mailing list)
Thanks for pointing out!
Didn't know that.
Marcus

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,51479,51631#msg-51631
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.