日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

nginx基本数据结构ngx_module_t,ngx_module_s

發(fā)布時(shí)間:2024/2/28 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx基本数据结构ngx_module_t,ngx_module_s 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

ngx_module_tnginx的模塊化架構(gòu)最基本的數(shù)據(jù)結(jié)構(gòu)。?
其結(jié)構(gòu)定義如下,其中的注釋為功能說明:?

struct ngx_module_s {

??? ngx_uint_t??????????? ctx_index;???

???????? /*分類的模塊計(jì)數(shù)器

???????? nginx模塊可以分為四種:core、event、http和mail

???????? 每個(gè)模塊都會各自計(jì)數(shù),ctx_index就是每個(gè)模塊在其所屬類組的計(jì)數(shù)*/

????????

??? ngx_uint_t??????????? index;??????????????

???????? /*一個(gè)模塊計(jì)數(shù)器,按照每個(gè)模塊在ngx_modules[]數(shù)組中的聲明順序,從0開始依次給每個(gè)模塊賦值*/

?

??? ngx_uint_t??????????? spare0;

??? ngx_uint_t??????????? spare1;

??? ngx_uint_t??????????? spare2;

??? ngx_uint_t??????????? spare3;

?

??? ngx_uint_t??????????? version;?????????? //nginx模塊版本

?

??? void???????????????? *ctx;??????????????????????????

???????? /*模塊的上下文,不同種類的模塊有不同的上下文,因此實(shí)現(xiàn)了四種結(jié)構(gòu)體*/

????????

??? ngx_command_t??????? *commands;

???????? /*命令定義地址

???????? 模塊的指令集

???????? 每一個(gè)指令在源碼中對應(yīng)著一個(gè)ngx_command_t結(jié)構(gòu)變量*/

????????

??? ngx_uint_t??????????? type;????????????????????????? //模塊類型,用于區(qū)分core eventhttp和mail

?

??? ngx_int_t?????????? (*init_master)(ngx_log_t *log);??????????????????????????? //初始化master時(shí)執(zhí)行

?

??? ngx_int_t?????????? (*init_module)(ngx_cycle_t *cycle);?????????? //初始化module時(shí)執(zhí)行

?

??? ngx_int_t?????????? (*init_process)(ngx_cycle_t *cycle); //初始化process時(shí)執(zhí)行

??? ngx_int_t?????????? (*init_thread)(ngx_cycle_t *cycle);???????????? //初始化thread時(shí)執(zhí)行

??? void??????????????? (*exit_thread)(ngx_cycle_t*cycle);????????? //退出thread時(shí)執(zhí)行

??? void??????????????? (*exit_process)(ngx_cycle_t*cycle);??????? //退出process時(shí)執(zhí)行

?

??? void??????????????? (*exit_master)(ngx_cycle_t*cycle);???????? ???????? //退出master時(shí)執(zhí)行

?

//以下功能不明

??? 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;

};

?

typedef struct ngx_module_s????? ngx_module_t;


nginx定義了很多模塊,每個(gè)模塊都有自己所屬的類型,可以定義一些屬于自己的操作函數(shù),通過把這些函數(shù)賦值為對應(yīng)類型結(jié)構(gòu)體中的函數(shù)指針,就可以注冊了不同的回調(diào)函數(shù)接口,以此實(shí)現(xiàn)不同的功能,有點(diǎn)c++多態(tài)的感覺!

總結(jié)

以上是生活随笔為你收集整理的nginx基本数据结构ngx_module_t,ngx_module_s的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。