爱亚搏 > October 9th Friday

October 9th Friday

标签: structure,struct,os,file  |  作者: lu_ming 相关  |  发布日期 : 2014-07-18  |  热度 : 485°

yabo88亚博体育app下载地址  The long holiday past.  From today I begin studying the nginx.  In a month, I have to master the key of nginx.  I have not more time to study.  But it is not a happy thing to read the sources.

 

  Let's decompress the tar file of the nginx.  There are several folders in the main folder.

 

  core    event    http    mail    misc    os

 

  core:      the core sources; including core modules.

  event:    the event logic in the nginx.

  http:       http core modules.

  mail:       mail core modules.

  os:          the sources on various OS.

  misc:       utility sources.

 

Firstly, let's take a look the structure of ngx_pool.  The structure is revised.  In the newest version is as follow.

 

typedef struct {
    u_char                  *last;
    u_char                  *end;
    ngx_pool_t           *next;
    ngx_uint_t            failed;
} ngx_pool_data_t;


struct ngx_pool_s {
    ngx_pool_data_t        d;
    size_t                          max;
    ngx_pool_t                 *current;
    ngx_chain_t                *chain;
    ngx_pool_large_t        *large;
    ngx_pool_cleanup_t    *cleanup;
    ngx_log_t                    *log;
};

 

The old version structure is here.

 

struct ngx_pool_s {
    u_char                        *last;
    u_char                        *end;
    ngx_pool_t                 *current;
    ngx_chain_t               *chain;
    ngx_pool_t                 *next;
    ngx_pool_large_t       *large;
    ngx_pool_cleanup_t   *cleanup;
    ngx_log_t                   *log;
};

 

The members last, end, and next in the old structure is replaced ngx_pool_data_t.  The member failed is added newly.

I sought two figures on the pool structures in the nginx.   They can help us understand the logic structure of the pool.