9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] read9pmsg usage
@ 2015-08-10 14:11 Giacomo Tesio
  2015-08-10 14:22 ` erik quanstrom
  2015-08-11 15:48 ` Charles Forsyth
  0 siblings, 2 replies; 12+ messages in thread
From: Giacomo Tesio @ 2015-08-10 14:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 1335 bytes --]

Hi, I've a probably naive question that I can't figure out.
I've just noticed that fcall(2) states

> Read9pmsg calls read(2) multiple times, if necessary, to
> read an entire 9P message into buf.  The return value is 0
> for end of file, or -1 for error; it does not return partial
> messages.
>
>
but I've noticed that a few client does not interpret a 0 return value as a
EOF, eg

https://github.com/brho/plan9/blob/master/sys/src/cmd/usb/lib/fs.c#L604-L606
https://github.com/brho/plan9/blob/master/sys/src/cmd/usb/audio/audiofs.c#L889-L891
https://github.com/brho/plan9/blob/master/sys/src/cmd/aux/searchfs.c#L613-L615
https://github.com/brho/plan9/blob/master/sys/src/cmd/lnfs.c#L547-L551
https://github.com/brho/plan9/blob/master/sys/src/cmd/telco/telco.c#L935-L937

The comment there states that

/*
 * reading from a pipe or a network device
 * will give an error after a few eof reads.
 * however, we cannot tell the difference
 * between a zero-length read and an interrupt
 * on the processes writing to us,
 * so we wait for the error.
 */

However many other fs just handle errors and eof together, for example here:
https://github.com/brho/plan9/blob/master/sys/src/cmd/ip/ftpfs/ftpfs.c#L273-L279

I'm a bit confused about this. What's the proper use of the 0 return value?


Giacomo

[-- Attachment #2: Type: text/html, Size: 2165 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2015-08-12 17:17 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-10 14:11 [9fans] read9pmsg usage Giacomo Tesio
2015-08-10 14:22 ` erik quanstrom
2015-08-10 14:35   ` Giacomo Tesio
2015-08-10 14:54     ` Charles Forsyth
2015-08-10 15:40       ` Charles Forsyth
2015-08-10 20:17       ` Giacomo Tesio
2015-08-10 20:33         ` Charles Forsyth
2015-08-11 15:48 ` Charles Forsyth
2015-08-12  0:21   ` Giacomo Tesio
2015-08-12  7:25     ` David du Colombier
2015-08-12  9:18       ` Giacomo Tesio
2015-08-12 17:17         ` Charles Forsyth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).