Does an operation on an fd affect the already collected but not yet reported events?
对一个描述符的操作会不会影响那些已经被收集但是还没上报的事件?
A8
You can do two operations on an existing fd. Remove would be meaningless for this case. Modify will re-read available I/O.
你能对已经存在的描述符做两种操作。移除对这种情况是没有什么意义的。修改将会重读有效的I/O。
Q9
Do I need to continuously read/write an fd until EAGAIN when using the
EPOLLET flag ( Edge Triggered behaviour ) ?
使用ET模式时需不需要连续地读或写一个文件描述符,直到收到EAGAIN?
A9
No you don't. Receiving an event from
epoll_wait(2) should suggest to you that such file descriptor is ready for the requested I/O operation. You have simply to consider it ready until you will receive the next EAGAIN. When and how you will use such file descriptor is entirely up to you. Also, the condition that the read/write I/O space is exhausted can be detected by checking the amount of data read/write from/to the target file descriptor. For example, if you call
read(2) by asking to read a certain amount of data and
read(2) returns a lower number of bytes, you can be sure to have exhausted the read I/O space for such file descriptor. Same is valid when writing using the
write(2) function.