- 论坛徽章:
- 0
|
原帖由 smzgl 于 2008-11-11 01:44 发表 ![]()
看到这里,我忍不住要说上一说。大家都在讨论EPOLL的ET和LT模式,但是实际具体怎么运作,不知有多少人认真看了代码和做过试验看过效果的。
man说的没有错,但是会让你有个误会。
man说ET模式下,如果接收到 ...
哈哈,不是man没说清楚,是我没看仔细
Since even with the edge-triggered epoll multiple events can be gener-
ated upon receipt of multiple chunks of data, the caller has the option
to specify the EPOLLONESHOT flag, to tell epoll to disable the associ-
ated file descriptor after the receipt of an event with epoll_wait(2).
When the EPOLLONESHOT flag is specified, it is the caller's responsi-
bility to rearm the file descriptor using epoll_ctl(2) with
EPOLL_CTL_MOD.
所以多线程用et时,最好specify the EPOLLONESHOT flag,当读到EAGAIN时(或者返回读到的size小于要读的size时,但是楼主的实验这样会丢掉fin包,如果确实这样,那还是只能再次读出EAGAIN),rearm the file descriptor using epoll_ctl(2) with EPOLL_CTL_MOD
[ 本帖最后由 wishel 于 2008-11-11 09:09 编辑 ] |
|