摘要:关于:nginx_http_push_module模块致力成为一个成熟的http推送和comet服务,它能够处理好全部链接,并且仅通过http请求,可以完成广播消息到所有客户端,这让你写异步web应用程序时得心应手,并且在代码中完全不必理会延时请求。本文为翻译文章,有部分原创转载请注明地址:http://blog.csdn.net/lengzijian/article/details/7638088为什么选择此模块:当你要写一个实时更新的模块时,例如某些聊天室、多人在线flash游戏等。无论哪种方式,我们都要避免更新请求时刷新页面或者每隔几秒轮训服务器,这样的代码丑陋无比(也许是我翻译错误)。
阅读全文
摘要:我们之前说过模块的上下文分别对应四种结构体分别是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 *(*create_conf)(ngx_cycle_t *cycle); char *(*init_conf)(ngx_cycle_t *cycle, void ...
阅读全文
摘要:接下来,继续理解helloworld模块中的指令。helloworld中的代码
/* Commands */
static ngx_command_t ngx_http_hello_world_commands[] = { { ngx_string("hello_world"), NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, ngx_http_hello_world, 0, 0, NULL }, ngx_null_command
};
有代码可以看出模块的指令在源码中ngx_command_t...
阅读全文
摘要:下面开始真正"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, 0, 0, 0, 0, 0, 0 struct ngx_module_s { ngx_uint_t ctx_index; ngx_uint_t ind...
阅读全文
摘要:看了一点nginx的源码发现,nginx的模块思想确实吸引了我,也不得不佩服俄罗斯人的想问题方式,要分析nginx源码,首先要搞懂的就是nginx的模块思想以及相关的数据结构。还记得我们上一次写的helloworld模块么?里面涉及最重要的数据就是ngx_module_t指针数组,这个指针数组包含了当前编译版本支持的所有模块,这个指针数组定义实在自动脚本生成的objs/ngx_modules.c中,如下:extern ngx_module_t ngx_core_module;
extern ngx_module_t ngx_errlog_module;
extern ngx_module_..
阅读全文