
Nginx
hz5034
这个作者很懒,什么都没留下…
展开
-
Nginx源码阅读(ngx_pool_t)
// src/core/ngx_palloc.hstruct ngx_pool_s { ngx_pool_data_t d; size_t max; /* 全部可使用内存的大小,包含已使用和未使用内存。 区别小块和大块内存的标准,小于等于max为小块内存,大于max为大块内存原创 2017-01-21 20:51:15 · 455 阅读 · 0 评论 -
Nginx源码阅读(ngx_http_init_connection)
ngx_http_init_connection()voidngx_http_init_connection(ngx_connection_t *c){ ngx_uint_t i; ngx_event_t *rev; struct sockaddr_in *sin; ngx_http_port_t ...原创 2018-07-15 17:43:21 · 1191 阅读 · 0 评论 -
Nginx源码阅读(事件/连接/请求)
在nginx中,ngx_connection_t是对TCP连接的封装,包括已连接套接字、读事件、写事件表示一个事件的数据结构struct ngx_event_s { void *data; // 通常指向ngx_connection_t unsigned write:1; // 位域,表示事件可写 unsigned ...原创 2018-07-15 17:27:05 · 583 阅读 · 0 评论 -
Nginx源码阅读(ngx_event_accept)
static ngx_int_tngx_event_process_init(ngx_cycle_t *cycle){ ngx_uint_t m, i; ngx_event_t *rev, *wev; ngx_listening_t *ls; ngx_connection_t *c, *next, *old; ...原创 2018-04-02 21:47:51 · 1035 阅读 · 0 评论 -
Nginx源码阅读(Hello World程序)
来源于深入理解Nginx第3章在nginx-1.10.2目录下新建mytest目录,把config文件和ngx_http_mytest_module.c文件放在mytest目录下修改配置文件// 在/usr/local/nginx/conf/nginx.conf中增加以下配置location /test { mytest;}编写config文件ngx...原创 2018-04-02 21:32:09 · 733 阅读 · 0 评论 -
Nginx源码阅读(main)
/* src/core/nginx.c */int ngx_cdecl // #define ngx_cdecl,一个空的define,跨平台支持main(int argc, char *const *argv){ ngx_buf_t *b; ngx_log_t *log; ngx_uint_t i; ngx_原创 2017-01-20 14:07:31 · 3226 阅读 · 1 评论 -
Nginx源码阅读(模块)
每个nginx模块,都是一个ngx_module_t类型的变量。根据ngx_module_t的type,所有nginx模块可以分为5种类型: type ctx指向的数据结构 commands指向的数据结构 具体模块 NGX_CORE_MODULE ngx_core_module_t ngx_command_t ngx_core_module、ngx_e...原创 2017-01-21 20:28:28 · 706 阅读 · 0 评论 -
Nginx源码阅读(IPC)
共享内存/* src/os/unix/ngx_shmem.h */typedef struct { u_char *addr; // 共享内存的地址 size_t size; // 共享内存的长度 ngx_str_t name; // 共享内存的名称 ngx_log_t *log; ngx_uint_t exists;原创 2017-01-21 21:18:36 · 685 阅读 · 0 评论 -
Nginx源码阅读(ngx_master_process_cycle)
ngx_master_process_cycle()/* src/os/unix/ngx_process_cycle.c */voidngx_master_process_cycle(ngx_cycle_t *cycle){ char *title; u_char *p; size_t size;原创 2017-08-18 11:16:16 · 533 阅读 · 0 评论 -
Nginx源码阅读(ngx_worker_process_cycle)
ngx_worker_process_cycle()static voidngx_worker_process_cycle(ngx_cycle_t *cycle, void *data){ ngx_int_t worker = (intptr_t) data; ngx_process = NGX_PROCESS_WORKER; ngx_worker = worker;原创 2017-08-18 11:43:41 · 1005 阅读 · 0 评论 -
Nginx源码阅读(worker进程处理http请求流程)
worker进程循环执行以下步骤,其中第5步是nginx真正处理http请求的过程1、抢锁(非阻塞,没抢到锁就只处理旧连接上的http请求,不接收新连接)抢到锁: 若上次抢到锁,意味着监听套接字已经在epoll中了,do nothing若上次没抢到锁,意味着监听套接字不在epoll中,需要将监听套接字添加到epoll中没抢到锁: 若上次抢到锁,意味着监听套接字还在epoll中,需...原创 2017-12-06 18:34:07 · 1434 阅读 · 0 评论 -
Nginx源码阅读(ngx_hash_t)
/* src/core/ngx_hash.h */typedef struct { void *value; // value的首地址 u_short len; // key的长度 u_char name[1]; // key的首地址,一个柔性数组} ngx_hash_elt_t;typedef struc原创 2017-01-21 21:13:41 · 533 阅读 · 0 评论 -
Nginx源码阅读(ngx_cycle_t)
/* src/core/ngx_cycle.h */struct ngx_cycle_s { void ****conf_ctx; ngx_pool_t *pool; ngx_log_t *log; ngx_log_t new_log; ng原创 2017-01-21 21:11:00 · 616 阅读 · 0 评论 -
Nginx源码阅读(ngx_array_t)
/* src/core/ngx_array.h */typedef struct { void *elts; // 数组的首地址 ngx_uint_t nelts; // 数组中已经使用的元素个数 size_t size; // 每个数组元素占用的字节数 ngx_uint_t nalloc; // 数组中能够容纳的最大元素个数原创 2017-01-21 21:08:40 · 411 阅读 · 0 评论 -
Nginx源码阅读(ngx_list_t)
/* src/core/ngx_list.h */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原创 2017-01-21 21:06:21 · 526 阅读 · 0 评论 -
Nginx源码阅读(ngx_queue_t)
/* src/core/ngx_queue.h */typedef struct ngx_queue_s ngx_queue_t;/* 一个以容器为哨兵的双向链表。 对于容器而言,prev指向最后一个元素,next指向第一个元素。当容器为空(容器中没有元素)时,prev和next都指向容器。 对于元素而言,prev指向前一个元素,next指向后一个元素。第一个元素的prev指向容器,最原创 2017-01-21 21:03:09 · 452 阅读 · 0 评论 -
Nginx源码阅读(ngx_http_process_request_line)
ngx_http_process_request_line()static voidngx_http_process_request_line(ngx_event_t *rev){ ssize_t n; ngx_int_t rc, rv; ngx_str_t host; ngx_con...原创 2018-07-15 17:45:34 · 1090 阅读 · 0 评论