4.3.3.2 master_notify函数:子进程写status_fd管道
来源:互联网 发布:python3网络编程 pdf 编辑:程序博客网 时间:2024/05/29 11:43
对status_fd管道的读在master_status_event回调函数中执行。对它的写被放在一个专门的c文件中:master_proto.c
/master/ master_proto.c/* DESCRIPTION/* Themaster process provides a standard environment for its/* childprocesses. Part of this environment is a pair of file/* descriptorsthat the master process shares with all child/* processesthat provide the same service./* .IP MASTER_LISTEN_FD/* Theshared file descriptor for accepting client connection/* requests.The master process listens on this socket or FIFO/* whenall child processes are busy./* .IP MASTER_STATUS_FD/* Theshared file descriptor for sending child status updates to/* themaster process./* .PP/* Achild process uses master_notify() to send a status notification/* messageto the master process./* .IP MASTER_STAT_AVAIL/* Thechild process is ready to accept client connections./* .IP MASTER_STAT_TAKEN/* Untilfurther notice, the child process is unavailable for/* acceptingclient connections./* .PP/* Whena child process terminates without sending a status update,/* themaster process will figure out that the child is no longer/* available.65 int master_notify(int pid, unsigned generation, int status) 66 { 67 const char *myname = "master_notify"; 68 MASTER_STATUS stat; 69 70 /* 71 * We use a simple binary protocol to minimize security risks. Since this 72 * is local IPC, there are no byte order or word length issues. The 73 * server treats this information as gossip, sosending a bad PID or a 74 * bad status code will only have amusement value. 75 */ 76 stat.pid = pid; 77 stat.gen = generation; 78 stat.avail = status; 79 80 if (write(MASTER_STATUS_FD, (void *) &stat, sizeof(stat)) !=sizeof(stat)) { 81 if (msg_verbose) 82 msg_info("%s: status %d: %m", myname, status); 83 return (-1); 84 }else { 85 if (msg_verbose) 86 msg_info("%s: status %d",myname, status); 87 return (0); 88 } 89 }
master_notify在single_server.c,multi_server.c,trigger_server.c,event_server.c中被调用,一旦运行模板准备为业务模块提供服务了,就通知父进程该子进程将进入工作状态,让父进程将相关MASTER_PROC结构体的avail字段设为MASTER_STAT_TAKEN。
0 0
- 4.3.3.2 master_notify函数:子进程写status_fd管道
- 4.3.3.3 master_status_event函数:父进程读status_fd管道,更新其记录的子进程状态
- 4.3.3.1 master_status.c:报告子进程状态--master_status_init函数:建立status_fd管道
- 管道 子进程
- 匿名管道与子进程
- 用管道写守护进程
- 通过管道与子进程通信
- perl exec管道和子进程
- Python subprocess.Popen子进程管道阻塞
- Linux下父进程与两子进程管道通信
- CreateProcess主进程与子进程管道通信的封装
- 创建子进程函数
- 管道-pipe函数 进程间通信
- Day29、加载子进程、Vfork创建子进程、进程间通讯(管道)
- Linux c 匿名管道实例—创建两个子进程与父进程进行管道通信
- Python的subprocess子进程和管道进行交互
- Python的subprocess子进程和管道进行交互
- Python的subprocess子进程和管道进行交互
- PowerDesigner(七)-数据库的生成和修改
- Java中int与String互转
- memadmin监控memcached
- c++第三次上级实验
- 最近公共祖先离线加在线倍增
- 4.3.3.2 master_notify函数:子进程写status_fd管道
- 【BLE】CC2541之添加自定义任务
- Mac 下AppRTCDemo xcode 工程搭建和webrtc源码下载
- c++实验3-个人所得税计算器
- 纪律
- android wifi组播发送开发日常问题汇总
- Openstack Horizon开发资料与案例
- 加载缩略图类
- 移动端报表JS开发示例