lkml.org 
[lkml]   [2012]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: autofs: make the autofsv5 packet file descriptor use a packetized pipe
On Sun, Apr 29, 2012 at 5:28 PM, H. Peter Anvin <hpa@zytor.com> wrote:
>
>  do {
>    i = read(fd, buf, bytes);
>
>    if (i <= 0)
>      break;
>
>    buf = (char *)buf + i;
>    bytes -= i;
>  } while (bytes);
>
>  return bytes;

Ok, that should be fine. It will always get the full packet in one
read, so the short read case will never actually happen.

In fact, automount has this exact same pattern, except it calls the
function "fullread()".

The problem is only if it starts out by reading just the header of the
packet, and then reads the rest of the packet as a second read. *THAT*
won't work with the packetized pipe approach, because reading the
header of the packet will then discard the rest of it, and the second
read would try to read the *next* packet (which under many normal
loads won't even exist, of course).

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-04-30 02:41    [W:0.094 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site