4.1.2.1 MASTER_SERV结构体
2016-04-07 10:24
281 查看
/* *Server processes that provide the same service share a common"listen" *socket to accept connection requests, and share a common pipe to the *master process to send status reports. Server processes die voluntarily *when idle for a configurable amount of time, or after servicing a *configurable number of requests; the master process spawns new processes *on demand up to a configurable concurrency limit and/or periodically. * *The canonical service name is what we use internally, so that we correctly *handle a request to "reload" after someone changes "smtp"into "25". * *We use the external service name from master.cf when reporting problems, so *that the user can figure out what we are talking about. Of course we also *include the canonical service name so that the UNIX-domain smtp service *can be distinguished from the Internet smtp service. */ /master/master.h typedef struct MASTER_SERV { int flags; /* status, features, etc. */ char *ext_name; /* service endpointname (master.cf) */ char *name; /* service endpointname (canonical) */ int type; /* UNIX-domain, INET, etc.*/ time_t busy_warn_time; /* limit "all serversbusy" warning */ int wakeup_time; /* wakeup interval */ int *listen_fd; /* incoming requests */ int listen_fd_count; /* nr of descriptors */ union { struct{ char *port; /* inet listen port*/ struct INET_ADDR_LIST *addr;/* inet listenaddress */ } inet_ep; #define MASTER_INET_ADDRLIST(s) ((s)->endpoint.inet_ep.addr) #define MASTER_INET_PORT(s) ((s)->endpoint.inet_ep.port) } endpoint; int max_proc; /* upper bound on # processes*/ char *path; /* command pathname*/ struct ARGV *args; /*argument vector */ char *stress_param_val; /* stress value: "yes" orempty */ time_t stress_expire_time; /* stress pulse stretcher */ int avail_proc; /* idle processes */ int total_proc; /* number ofprocesses */ int throttle_delay; /* failure recovery parameter */ int status_fd[2]; /* child status reports */ struct BINHASH *children; /*linkage */ struct MASTER_SERV *next; /*linkage */ } MASTER_SERV;
flags 状态标志。
ext_name master.cf中记录的模块名。
name 服务名。
type 模块服务类型,即inet,fifo,或unix。与master.cf中定义的一致。
busy_warn_time:繁忙警告时间。
wakeup_time:唤醒时间,即master.cf中的唤醒时间。
listen_fd:监听的文件描述符数组指针。
listen_fd_count:listen_fd个数,在MASTER_SERV结构体初始化时候确定,对于unix域协议和fifo管道为1,对于inet由master.cf配置文件中的配置决定。
max_proc:最大进程数,即master.cf中的最大进程数。
path:启动服务的命令路径,即master.cf中的command选项。
args:参数数组指针,即master.cf中的args选项。
stress_param_val:表示模块是否满负荷运行,其值为“yes”或空。
业务模块满负荷运转时,master模块重启该模块,并加上“stress=yes”命令行选项,此时stress_param_val为yes。非满负荷运转stress_param_val为空。
avail_proc:可用进程数。
total_proc:当前总进程数。
throttle_delay:当模块当前无法创建子进程时,flags会设置MASTER_FLAG_THROTTLE标志,throttle_delay就是这个标志的保留时间:
serv->flags |= MASTER_FLAG_THROTTLE;
status_fd:汇报子进程状态的管道。master模块要用到3组管道,这里的status_fd用来汇报子进程状态。在/master/master_status.c/master_status_init中构建,另外的两组管道是master_sig_pipe和master_flow_pipe,分别用来报告信号和收信速度。在/master/master_sig.c/master_sigsetup函数
和/master/master_flow.c/master_flow_init函数中被初始化。
children: 用BINHASH哈希链表来记录和管理各个子进程信息。
next:组织MASTER_SERV链表。
相关文章推荐
- 虚幻4 小笔记
- 仿京东导航
- Android 性能典范:拯救计划
- 在BackGroundWorker中使用ArcGIS组件
- MyBatis 配置sql语句输出
- Shiro学习(7)与Web整合
- Spring如何加载XSD文件(org.xml.sax.SAXParseException: Failed to read schema document错误的解决方法)
- SSH中的error解决
- C与C++中的常用提高程序效率的方法
- 4.1.1 master.c:master模块主程序--master.cf配置文件
- 4.1.2 MASTER_SERV和MASTER_PROC结构体:描述模块和其子进程结构
- 训练自己的harr-like特征分类器并识别物体
- Gson基本操作,JsonObject,JsonArray,String,JavaBean,List互转
- 微信开发教程① 公众平台的介绍与注册
- 关于HTML控件作为服务器控件后ID会变化解决办法
- “上帝的算法”在高斯混合分布中的应用
- HDU 1866 A + B forever!
- Android 高清加载巨图方案 拒绝压缩图片
- android TextView设置中文字体加粗实现方法
- java修炼之道