lin
2015-01-15 07:52:06 UTC
I read the unbound remote control code, I know that unbound use pipe in the remote control logic.However, I am confused, I summary the steps as follows.
Firstly,Unbound add pipe read side into I/O event list,so if the pipe has data, the select (epoll_wait) function return, andexecute the callback function.
Secondly,unbound receive user command,such as unbound-control stub_add ***,and then the main thread first write the command type such as "worker_cmd_remote" into all pipe write side via function worker_send_cmd,and then call functiontube_write_msg write the command string to the pipe.
Thirdly,because pipe has data to read,so the event callback function would be executed,and read the command type such as "worker_cmd_remote" from the pipe, and then call function tube_read_msg to read the command string,and then call function execute_cmd to exucte the command.
So my question is that why unbound distinguish between the command type & command string,I think we can send the command string to the child thread directly,and do not need send the command type firstly.â
------------------
Best wishes for youFrom Sure Ning
Mail:***@foxmail.com
Address:Beijing ChinaïŒäžåœ å京ïŒ
Firstly,Unbound add pipe read side into I/O event list,so if the pipe has data, the select (epoll_wait) function return, andexecute the callback function.
Secondly,unbound receive user command,such as unbound-control stub_add ***,and then the main thread first write the command type such as "worker_cmd_remote" into all pipe write side via function worker_send_cmd,and then call functiontube_write_msg write the command string to the pipe.
Thirdly,because pipe has data to read,so the event callback function would be executed,and read the command type such as "worker_cmd_remote" from the pipe, and then call function tube_read_msg to read the command string,and then call function execute_cmd to exucte the command.
So my question is that why unbound distinguish between the command type & command string,I think we can send the command string to the child thread directly,and do not need send the command type firstly.â
------------------
Best wishes for youFrom Sure Ning
Mail:***@foxmail.com
Address:Beijing ChinaïŒäžåœ å京ïŒ