Re: Man page correction: epoll (7)
On Sun, 1 Jul 2007, Heikki Orsila wrote: > So, the Q9 should be changed: > > Q9Do I need to continuously read/write an fd until EAGAIN when > using the EPOLLET flag ( Edge Triggered behaviour ) ? > > A9As a general rule, yes. However, there are exceptions. > With some types of fds it is enough to wait until > read returns less bytes than was requested by the read call. > > Are there any fd types where such behavior is guaranteed by the Linux > kernel (for the future)? I.e. one can assume that edge-triggered fds > will behave properly if > > x = read(fd, data, count) and x < count ? > > Regular files? Sockets? What? Basically, any "streaming" file. That is, any file that tends to fill up the buffer you supply to the call in full (till they have data in their buffers, that is). Packet/token oriented files would be the ones you cannot apply the rule to, since data is returned in multiple of tokens. - Davide - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Man page correction: epoll (7)
Here's a bit of email I exchanged with Davide Libenzi on epoll (7) man page. There is an error in answer 9: Davide Libenzi wrote: > On Mon, 25 Jun 2007, Heikki Orsila wrote: >> >From epoll man page: >> >>Q9 Do I need to continuously read/write an fd until EAGAIN when >> using the EPOLLET flag ( Edge Triggered behaviour ) ? >> >>A9 No you don't. >> ... >> 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. >> ... >> >> This doesn't seem very true in the general case. Afaik, terminal >> devices can be configured to return only one line per read(). For >> example, >> >> read(terminal_fd, buf, 4096) >> >> will return 34 (the length of the line) but obviously the IO space would >> not be exhausted if _two_ lines arrived into terminal fd during IO wait. >> And thus, arrival of the second line went unnoticed. >> >> Teaching to optimise nonblocking reads will likely cause more bugs. >> >> I'm I correct? If yes, that number should be removed from the question >> list. > > Yes, you are correct. Although the above is true for the majority of > stream files, so it better be fixed with the few counter-examples > instead of being removed. > > - Davide and Davide Libenzi wrote: > Heikki Orsila wrote: >> Maybe so that we say that as a general rule one must read until EAGAIN, >> but mention specific cases where one only needs to wait for "short" >> reads? > > Yes, that's fine with me. So, the Q9 should be changed: Q9 Do I need to continuously read/write an fd until EAGAIN when using the EPOLLET flag ( Edge Triggered behaviour ) ? A9 As a general rule, yes. However, there are exceptions. With some types of fds it is enough to wait until read returns less bytes than was requested by the read call. Are there any fd types where such behavior is guaranteed by the Linux kernel (for the future)? I.e. one can assume that edge-triggered fds will behave properly if x = read(fd, data, count) and x < count ? Regular files? Sockets? What? -- Heikki Orsila Barbie's law: [EMAIL PROTECTED] "Math is hard, let's go shopping!" http://www.iki.fi/shd - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Man page correction: epoll (7)
Here's a bit of email I exchanged with Davide Libenzi on epoll (7) man page. There is an error in answer 9: Davide Libenzi wrote: On Mon, 25 Jun 2007, Heikki Orsila wrote: From epoll man page: Q9 Do I need to continuously read/write an fd until EAGAIN when using the EPOLLET flag ( Edge Triggered behaviour ) ? A9 No you don't. ... 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. ... This doesn't seem very true in the general case. Afaik, terminal devices can be configured to return only one line per read(). For example, read(terminal_fd, buf, 4096) will return 34 (the length of the line) but obviously the IO space would not be exhausted if _two_ lines arrived into terminal fd during IO wait. And thus, arrival of the second line went unnoticed. Teaching to optimise nonblocking reads will likely cause more bugs. I'm I correct? If yes, that number should be removed from the question list. Yes, you are correct. Although the above is true for the majority of stream files, so it better be fixed with the few counter-examples instead of being removed. - Davide and Davide Libenzi wrote: Heikki Orsila wrote: Maybe so that we say that as a general rule one must read until EAGAIN, but mention specific cases where one only needs to wait for short reads? Yes, that's fine with me. So, the Q9 should be changed: Q9 Do I need to continuously read/write an fd until EAGAIN when using the EPOLLET flag ( Edge Triggered behaviour ) ? A9 As a general rule, yes. However, there are exceptions. With some types of fds it is enough to wait until read returns less bytes than was requested by the read call. Are there any fd types where such behavior is guaranteed by the Linux kernel (for the future)? I.e. one can assume that edge-triggered fds will behave properly if x = read(fd, data, count) and x count ? Regular files? Sockets? What? -- Heikki Orsila Barbie's law: [EMAIL PROTECTED] Math is hard, let's go shopping! http://www.iki.fi/shd - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: Man page correction: epoll (7)
On Sun, 1 Jul 2007, Heikki Orsila wrote: So, the Q9 should be changed: Q9Do I need to continuously read/write an fd until EAGAIN when using the EPOLLET flag ( Edge Triggered behaviour ) ? A9As a general rule, yes. However, there are exceptions. With some types of fds it is enough to wait until read returns less bytes than was requested by the read call. Are there any fd types where such behavior is guaranteed by the Linux kernel (for the future)? I.e. one can assume that edge-triggered fds will behave properly if x = read(fd, data, count) and x count ? Regular files? Sockets? What? Basically, any streaming file. That is, any file that tends to fill up the buffer you supply to the call in full (till they have data in their buffers, that is). Packet/token oriented files would be the ones you cannot apply the rule to, since data is returned in multiple of tokens. - Davide - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/