Re: Possible problem with zero-copy TCP and sendfile()

Jan Kasprzak
2001-04-18T06:10:10Z

Wolfgang Rohdewald wrote:
: On Tuesday 17 April 2001 22:36, Jan Kasprzak wrote:
: > +    if (len == -1 || len > 0 && len < count) {
:
: are you sure there are no missing () ?
:
: if ((len == -1) || (len > 0) && (len < count)) {
:
: assumig that && has precedence over || (I believe so)

Yes, but the precedence of ==, <, and > is even higher.
However, I've found a problem with the previous patch: The first chunk should
read:

- if((len = sendfile(session.d->outf->fd, retr_fd, offset, count)) == -1) {
+ len = sendfile(session.d->outf->fd, retr_fd, offset, count);
+ if (len == -1 || len > 0 && len < count) {
+ if (len != -1)
+ errno = EINTR;

i.e. we should not overwrite errno, when it is valid.

-Yenya

PS.: You can find the C operators precedence for example at
http://www.howstuffworks.com/c14.htm (found by Google).

--
\ Jan "Yenya" Kasprzak <kas at fi.muni.cz> http://www.fi.muni.cz/~kas/
\\ PGP: finger kas at aisa.fi.muni.cz 0D99A7FB206605D7 8B35FCDE05B18A5E //
\\\ Czech Linux Homepage: http://www.linux.cz/ ///
Mantra: "everything is a stream of bytes". Repeat until enlightened. --Linus