nginx代码学习wiki-基本数据结构

来源:互联网 发布:abap 修改内表数据 编辑:程序博客网 时间:2024/05/21 11:14

1、ngx_str_t

typedef struct {    size_t      len;    u_char     *data;} ngx_str_t;

2、ngx_conf_s(ngx_conf_t)

struct ngx_conf_s {    char                 *name;    ngx_array_t          *args;    ngx_cycle_t          *cycle;    ngx_pool_t           *pool;    ngx_pool_t           *temp_pool;    ngx_conf_file_t      *conf_file;    ngx_log_t            *log;    void                 *ctx;    ngx_uint_t            module_type;    ngx_uint_t            cmd_type;    ngx_conf_handler_pt   handler;    char                 *handler_conf;};typedef struct {    ngx_file_t            file;    ngx_buf_t            *buffer;    ngx_buf_t            *dump;    ngx_uint_t            line;} ngx_conf_file_t;struct ngx_file_s {    ngx_fd_t                   fd;    ngx_str_t                  name;    ngx_file_info_t            info;    off_t                      offset;    off_t                      sys_offset;    ngx_log_t                 *log;#if (NGX_THREADS || NGX_COMPAT)    ngx_int_t                (*thread_handler)(ngx_thread_task_t *task,                                               ngx_file_t *file);    void                      *thread_ctx;    ngx_thread_task_t         *thread_task;#endif#if (NGX_HAVE_FILE_AIO || NGX_COMPAT)    ngx_event_aio_t           *aio;#endif    unsigned                   valid_info:1;    unsigned                   directio:1;}; 

3、ngx_log_s(ngx_log_t)

typedef u_char *(*ngx_log_handler_pt) (ngx_log_t *log, u_char *buf, size_t len);typedef void (*ngx_log_writer_pt) (ngx_log_t *log, ngx_uint_t level,    u_char *buf, size_t len);struct ngx_log_s {    ngx_uint_t           log_level;    ngx_open_file_t     *file;    ngx_atomic_uint_t    connection;    time_t               disk_full_time;    ngx_log_handler_pt   handler;    void                *data;    ngx_log_writer_pt    writer;    void                *wdata;    /*     * we declare "action" as "char *" because the actions are usually     * the static strings and in the "u_char *" case we have to override     * their types all the time     */    char                *action;    ngx_log_t           *next;};

4、ngx_cycle_s(ngx_cycle_t)

struct ngx_cycle_s {    void                  ****conf_ctx;    ngx_pool_t               *pool;    ngx_log_t                *log;    ngx_log_t                 new_log;    ngx_uint_t                log_use_stderr;  /* unsigned  log_use_stderr:1; */    ngx_connection_t        **files;    ngx_connection_t         *free_connections;    ngx_uint_t                free_connection_n;    ngx_module_t            **modules;    ngx_uint_t                modules_n;    ngx_uint_t                modules_used;    /* unsigned  modules_used:1; */    ngx_queue_t               reusable_connections_queue;    ngx_array_t               listening;    ngx_array_t               paths;    ngx_array_t               config_dump;    ngx_rbtree_t              config_dump_rbtree;    ngx_rbtree_node_t         config_dump_sentinel;    ngx_list_t                open_files;    ngx_list_t                shared_memory;    ngx_uint_t                connection_n;    ngx_uint_t                files_n;    ngx_connection_t         *connections;    ngx_event_t              *read_events;    ngx_event_t              *write_events;    ngx_cycle_t              *old_cycle;    ngx_str_t                 conf_file;    ngx_str_t                 conf_param;    ngx_str_t                 conf_prefix;    ngx_str_t                 prefix;    ngx_str_t                 lock_file;    ngx_str_t                 hostname;};

5、ngx_pool_s(ngx_pool_t)

typedef void (*ngx_pool_cleanup_pt)(void *data);typedef struct ngx_pool_cleanup_s  ngx_pool_cleanup_t;struct ngx_pool_cleanup_s {    ngx_pool_cleanup_pt   handler;    void                 *data;    ngx_pool_cleanup_t   *next;};typedef struct ngx_pool_large_s  ngx_pool_large_t;struct ngx_pool_large_s {    ngx_pool_large_t     *next;    void                 *alloc;};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;};typedef struct {    ngx_fd_t              fd;    u_char               *name;    ngx_log_t            *log;} ngx_pool_cleanup_file_t;

7、ngx_array_t
typedef struct {    void        *elts;    ngx_uint_t   nelts;    size_t       size;    ngx_uint_t   nalloc;    ngx_pool_t  *pool;} ngx_array_t;

8、ngx_list_t

typedef struct ngx_list_part_s  ngx_list_part_t;struct ngx_list_part_s {    void             *elts;    ngx_uint_t        nelts;    ngx_list_part_t  *next;};typedef struct {    ngx_list_part_t  *last;    ngx_list_part_t   part;    size_t            size;    ngx_uint_t        nalloc;    ngx_pool_t       *pool;} ngx_list_t;

9、ngx_module_s(ngx_module_t)

struct ngx_module_s {    ngx_uint_t            ctx_index;    ngx_uint_t            index;    char                 *name;    ngx_uint_t            spare0;    ngx_uint_t            spare1;    ngx_uint_t            version;    const char           *signature;    void                 *ctx;    ngx_command_t        *commands;    ngx_uint_t            type;    ngx_int_t           (*init_master)(ngx_log_t *log);    ngx_int_t           (*init_module)(ngx_cycle_t *cycle);    ngx_int_t           (*init_process)(ngx_cycle_t *cycle);    ngx_int_t           (*init_thread)(ngx_cycle_t *cycle);    void                (*exit_thread)(ngx_cycle_t *cycle);    void                (*exit_process)(ngx_cycle_t *cycle);    void                (*exit_master)(ngx_cycle_t *cycle);    uintptr_t             spare_hook0;    uintptr_t             spare_hook1;    uintptr_t             spare_hook2;    uintptr_t             spare_hook3;    uintptr_t             spare_hook4;    uintptr_t             spare_hook5;    uintptr_t             spare_hook6;    uintptr_t             spare_hook7;};

10、ngx_core_conf_t

typedef struct {    ngx_flag_t                daemon;    ngx_flag_t                master;    ngx_msec_t                timer_resolution;    ngx_int_t                 worker_processes;    ngx_int_t                 debug_points;    ngx_int_t                 rlimit_nofile;    off_t                     rlimit_core;    int                       priority;    ngx_uint_t                cpu_affinity_auto;    ngx_uint_t                cpu_affinity_n;    ngx_cpuset_t             *cpu_affinity;    char                     *username;    ngx_uid_t                 user;    ngx_gid_t                 group;    ngx_str_t                 working_directory;    ngx_str_t                 lock_file;    ngx_str_t                 pid;    ngx_str_t                 oldpid;    ngx_array_t               env;    char                    **environment;} ngx_core_conf_t;



0 0
原创粉丝点击