nginx/nginx
Data models
Field-level reference for the most commonly seen structs. For the in-depth narrative on each, see the primitives section.
ngx_str_t — src/core/ngx_string.h
typedef struct {
size_t len;
u_char *data;
} ngx_str_t;Length-prefixed, not NUL-terminated. See primitives/string.
ngx_buf_t — src/core/ngx_buf.h
struct ngx_buf_s {
u_char *pos, *last; /* in-memory bytes */
off_t file_pos, file_last;
u_char *start, *end; /* allocation bounds */
ngx_buf_tag_t tag; /* identifies the producer */
ngx_file_t *file;
ngx_buf_t *shadow;
/* flags */
unsigned temporary:1, memory:1, mmap:1, recycled:1;
unsigned in_file:1, flush:1, sync:1;
unsigned last_buf:1, last_in_chain:1;
unsigned last_shadow:1, temp_file:1;
int num;
};See primitives/buffer.
ngx_chain_t — src/core/ngx_buf.h
struct ngx_chain_s {
ngx_buf_t *buf;
ngx_chain_t *next;
};ngx_pool_t — src/core/ngx_palloc.h
typedef struct {
u_char *last, *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;
};See primitives/pool.
ngx_module_t — src/core/ngx_module.h
struct ngx_module_s {
ngx_uint_t ctx_index, index;
char *name;
ngx_uint_t spare0, spare1;
ngx_uint_t version;
const char *signature;
void *ctx; /* type-specific hook table */
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);
/* spare hooks */
};See primitives/module.
ngx_command_t — src/core/ngx_conf_file.h
struct ngx_command_s {
ngx_str_t name;
ngx_uint_t type;
char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
ngx_uint_t conf;
ngx_uint_t offset;
void *post;
};
ngx_cycle_t — src/core/ngx_cycle.h
(Abbreviated — full struct in primitives/cycle.)
struct ngx_cycle_s {
void ****conf_ctx;
ngx_pool_t *pool;
ngx_log_t *log;
ngx_connection_t *connections;
ngx_event_t *read_events, *write_events;
ngx_module_t **modules;
ngx_array_t listening;
ngx_list_t shared_memory;
ngx_str_t conf_file, prefix;
/* ... */
};ngx_connection_t — src/core/ngx_connection.h
(Abbreviated — full struct in primitives/connection.)
struct ngx_connection_s {
void *data;
ngx_event_t *read, *write;
ngx_socket_t fd;
ngx_recv_pt recv;
ngx_send_pt send;
ngx_recv_chain_pt recv_chain;
ngx_send_chain_pt send_chain;
ngx_listening_t *listening;
ngx_log_t *log;
ngx_pool_t *pool;
struct sockaddr *sockaddr;
ngx_str_t addr_text;
ngx_ssl_connection_t *ssl;
ngx_quic_stream_t *quic;
/* ... */
};ngx_event_t — src/event/ngx_event.h
struct ngx_event_s {
void *data;
unsigned write:1, accept:1, instance:1, active:1;
unsigned ready:1, oneshot:1, complete:1, eof:1;
unsigned timedout:1, timer_set:1, posted:1, /* ... */;
int available;
ngx_event_handler_pt handler;
ngx_uint_t index;
ngx_log_t *log;
ngx_rbtree_node_t timer;
ngx_queue_t queue;
};See systems/event-loop.
ngx_http_request_t — src/http/ngx_http_request.h
(Heavily abbreviated — full struct in primitives/request.)
struct ngx_http_request_s {
uint32_t signature;
ngx_connection_t *connection;
void **ctx;
void **main_conf, **srv_conf, **loc_conf;
ngx_http_event_handler_pt read_event_handler, write_event_handler;
ngx_http_upstream_t *upstream;
ngx_pool_t *pool;
ngx_buf_t *header_in;
ngx_http_headers_in_t headers_in;
ngx_http_headers_out_t headers_out;
ngx_http_request_body_t *request_body;
ngx_uint_t method;
ngx_str_t uri, args;
ngx_http_request_t *main, *parent;
ngx_int_t phase_handler;
ngx_http_handler_pt content_handler;
ngx_http_variable_value_t *variables;
ngx_http_cleanup_t *cleanup;
/* ... ~80 bit-fields ... */
};ngx_listening_t — src/core/ngx_connection.h
struct ngx_listening_s {
ngx_socket_t fd;
struct sockaddr *sockaddr;
socklen_t socklen;
ngx_str_t addr_text;
int type, protocol, backlog, rcvbuf, sndbuf;
ngx_connection_handler_pt handler;
void *servers; /* protocol-specific routing table */
ngx_log_t log;
size_t pool_size;
ngx_listening_t *previous;
ngx_connection_t *connection;
/* flags: open, remain, ignore, bound, inherited, reuseport, quic, ... */
};ngx_shm_zone_t — src/core/ngx_cycle.h
struct ngx_shm_zone_s {
void *data;
ngx_shm_t shm;
ngx_shm_zone_init_pt init;
void *tag;
void *sync;
ngx_uint_t noreuse;
};ngx_resolver_ctx_t — src/core/ngx_resolver.h
A pending DNS resolve. Caller fills the name/timeout/handler/data; the resolver fills addrs on success.
struct ngx_resolver_ctx_s {
ngx_resolver_ctx_t *next;
ngx_resolver_t *resolver;
ngx_str_t name;
ngx_msec_t timeout;
ngx_uint_t type; /* NGX_RESOLVE_A, AAAA, SRV, PTR */
ngx_resolver_addr_t *addrs;
ngx_uint_t naddrs;
ngx_resolver_handler_pt handler;
void *data;
ngx_int_t state;
/* ... */
};See systems/resolver.
Return code constants
#define NGX_OK 0
#define NGX_ERROR -1
#define NGX_AGAIN -2
#define NGX_BUSY -3
#define NGX_DONE -4
#define NGX_DECLINED -5
#define NGX_ABORT -6Defined in src/core/ngx_core.h. See how-to-contribute/patterns-and-conventions for usage conventions.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.