- 博客(13)
- 收藏
- 关注
原创 nginx 源码学习笔记(十二)——基本容器——ngx_buf
ngx_buf.{c|h}分为两种类型,一种是file,一种是memory。因此这里会有文件的一些操作域。 typedef void * ngx_buf_tag_t; typedef struct ngx_buf_s ngx_buf_t; struct ngx_buf_s { u_char *pos; //已经执行的
2012-03-15 16:51:20 3492
原创 nginx 源码学习笔记(十一)——基本容器——ngx_list
ngx_list.{c|h}结构非常简单,如果你看过之前的array介绍,这一节可以一带而过: typedef struct ngx_list_part_s ngx_list_part_t; struct ngx_list_part_s { void *elts; //数据区域指针 ngx_uint_t nelts;
2012-03-15 16:47:00 2893
原创 nginx 源码学习笔记(十)——基本容器——ngx_hash
ngx_hash.{c|h}实现了nginx里面比较重要的一个hash结构,这个在模块配置解析里经常被用到。该hash结构是只读的,仅在初始创建时可以给出保存在其中的key-val对儿,然后就只能进行“增删改查”操作了。 先来看一下hash结构的内存布局: typedef struct { ngx_hash_t *hash; /
2012-03-15 16:43:19 4186
原创 nginx 源码学习笔记(九)——基本容器——queue
src/core/ngx_queue.{c|h}实现了一个队列的操作逻辑,队列的基本结构为一个双向队列 基础数据结构为: typedef struct ngx_queue_s ngx_queue_t; struct ngx_queue_s { ngx_queue_t *prev; ngx_queue_t *next; }; 根据数据结构可以发现,ng
2012-03-15 16:39:23 2901
原创 nginx 源码学习笔记(八)——基本容器——array数组
对应文件为core/ngx_array.{c|h} ngx_array是nginx内部封装的,使用ngx_pool_t对内存池进行分配的数组容器,其中的数据是在一整片内存区中连续存放的。更新数据时只能在尾部压入1个或多个元素。这里单纯的觉得和数组没有差别。 数组的实现结构为: struct ngx_array_s { void *elts; //具体的数据区域
2012-03-15 16:34:43 4359
原创 nginx 源码学习笔记(七)——内存分配相关源码分析
内存分配相关 1. 系统功能封装 内存相关的操作主要在os/unix/ngx_alloc.{h,c} 和 core/ngx_palloc.{h,c}中。 其中os/unix/ngx_alloc.{h,c}封装了最基本的内存分配函数,是对c原有的malloc/free/memalign等函数的封装,对应函数为: a.ngx_alloc:对malloc进行了简单的封装; voi
2012-03-15 14:06:54 4345 5
原创 nginx 源码学习笔记(六)——nginx基本数据结构
简单的数据类型 在core/ngx_confing.h中定义了基本的数据类型的映射,大部分都映射到c语言自身的数据类型: typedef intptr_t ngx_int_t; typedef uintptr_t ngx_uint_t; typedef intptr_t ngx_flag_t; 其中ngx_int_t,ngx_flag_t都映射为i
2012-03-15 14:00:49 7671 1
原创 nginx 源码学习笔记(五)——nginx精粹-模块
我们之前说过模块的上下文分别对应四种结构体分别是 ngx_core_module_t、 ngx_event_module_t、 ngx_http_module_t、 ngx_mail_module_t 分别对应四类模块 src/core/ngx_conf_file.h typedef struct { ngx_str_t name; void
2012-03-15 11:20:31 3109
原创 nginx 源码学习笔记(四)——nginx精粹-模块
接下来,继续理解helloworld模块中的指令。 helloworld中的代码 /* Commands */ static ngx_command_t ngx_http_hello_world_commands[] = { { ngx_string("hello_world"), NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, ngx_h
2012-03-15 10:54:00 6491
原创 nginx 源码学习笔记(三)——nginx精粹-模块
下面开始真正"nginx之旅",屏住呼吸吧! 首先找好入手点,对于nginx的入手点就是ngx_module_t结构,他的声明在src/core/ngx_conf_file.h中(我的版本nginx-1.0.13) #define NGX_MODULE_V1 0, 0, 0, 0, 0, 0, 1 #define NGX_MODULE_V1_PADDING 0, 0,
2012-03-14 17:48:04 4138
原创 nginx 源码学习笔记(二)——nginx精粹-模块
看了一点nginx的源码发现,nginx的模块思想确实吸引了我,也不得不佩服俄罗斯人的想问题方式,要分析nginx源码,首先要搞懂的就是nginx的模块思想以及相关的数据结构。 还记得我们上一次写的helloworld模块么?里面涉及最重要的数据就是ngx_module_t指针数组,这个指针数组包含了当前编译版本支持的所有模块,这个指针数组定义实在自动脚本生成的objs/ngx_modules.
2012-03-14 10:49:17 5071 12
原创 nginx 源码学习笔记(一)——初识nginx helloworld模块
最近看完一本书,而且还是跟我一个学校的人写的关于nginx的内容,个人觉得内容可以更充实点,包括整本书的后半本没有太大的价值,但是总体来说还是不错的哈哈!(是不有点自恋),不费话了,今天记录下我刚刚编写的nginx hello_world模块内容,网上也没有源代码,就完全手敲了,累呀! 1.nginx模块 首先nginx和apache最大的不同就是nginx的模块不能够动态添加,需要在编
2012-03-13 17:45:23 9411 7
原创 linux学习工作记录----配置基于ip的虚拟主机
查看自己的ip信息: [root@slave5 conf]# ifconfig eth0 Link encap:Ethernet HWaddr E0:CB:4E:D0:EC:B2 inet addr:192.168.30.149 Bcast:192.168.30.255 Mask:255.255.255.0 inet6 addr: fe
2012-03-08 10:57:41 1541
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人