libco测试实例分析
29 Mar 2017
|
服务端测试例子 example_echosvr
./example_echosvr 127.0.0.1 8889 1 1
客户端连接测试例子
./client.pl 127.0.0.1 8889
日志
(myenv)root@gavin-VirtualBox:/media/sf_share/libco# ./example_echosvr 127.0.0.1 8889 1 2
listen 3 127.0.0.1:8889
[7630] co_create readwrite_routine. -- 创建业务协程
[7630] co_resume readwrite_routine -- 恢复业务协程
[7630] readwrite_routine start -- 业务协程执行
[7630] g_readwrite.push(co) -- 业务协程空闲入队列
[7630] co_yield_ct() readwrite_routine -- 业务协程挂起
[7630] co_create accept_routine. -- 创建接入协程
[7630] co_resume accept_routine. -- 恢复接入协程
[7630] accept_routine start -- 接入协程执行
[7630] co_eventloop.pid -- 事件驱动
[7629] co_create readwrite_routine.
[7629] co_resume readwrite_routine
[7629] readwrite_routine start
[7629] g_readwrite.push(co)
[7629] co_yield_ct() readwrite_routine
[7629] co_create accept_routine.
[7629] co_resume accept_routine.
[7629] accept_routine start
[7629] co_eventloop.pid
(myenv)root@gavin-VirtualBox:/media/sf_share/libco# p example
root 7628 1 0 15:26 ? 00:00:00 ./example_echosvr 127.0.0.1 8889 1 2
root 7629 7628 1 15:26 ? 00:00:00 ./example_echosvr 127.0.0.1 8889 1 2
root 7630 7628 1 15:26 ? 00:00:00 ./example_echosvr 127.0.0.1 8889 1 2
[7630] g_readwrite.pop() fd = 5 -- 弹栈业务协程处理新连接
[7630] co_resume g_readwrite.top -- 恢复业务协程
[7630] continue readwrite_routine
[7630] co_poll co_get_epoll_ct readwrite_routine fd[5] -- 业务协程处理业务请求
[7630] accept_routine g_readwrite.empty -- 暂无可以业务协程处理新连接
[7630] recv:hello srv
[7630] send:hello srv
[7630] co_poll co_get_epoll_ct readwrite_routine fd[5] -- 业务协程处理业务请求
[7630] recv:hello srv
[7630] send:hello srv
[7630] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7630] recv:hello srv
[7630] send:hello srv
[7630] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7630] recv:hello srv
[7630] send:hello srv
[7630] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7630] recv:hello srv
[7630] g_readwrite.push(co) -- 连接业务处理完毕入栈
[7630] co_yield_ct() readwrite_routine -- 挂起业务协程
[7629] g_readwrite.pop() fd = 5
[7629] co_resume g_readwrite.top
[7629] continue readwrite_routine
[7629] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7629] accept_routine g_readwrite.empty
[7629] recv:hello srv
[7629] send:hello srv
[7629] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7629] recv:hello srv
[7629] send:hello srv
[7629] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7629] recv:hello srv
[7629] send:hello srv
[7629] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7629] recv:hello srv
[7629] send:hello srv
[7629] co_poll co_get_epoll_ct readwrite_routine fd[5]
[7629] recv:hello srv
[7629] g_readwrite.push(co)
[7629] co_yield_ct() readwrite_routine