> also i forgot to mention that this version of qread can
> potentially cut the number of reads on tcp channels by up
> to 1/2. one might as well completely satisfy the read,
> if possible.
This looks like a good idea for tcp. But there are other
users of qread, with stricter assumptions. Aren't you in danger
of breaking the contract of pipe(3) which uses qwrite/qread:
Writes are atomic up to a certain size, typically 32768
bytes, that is, each write will be delivered in a single
read by the recipient, provided the receiving buffer is
large enough.
To preserve the atomicity of qread/qwrite, maybe tcp should be
coalescing the blocks itself by multiple calls to qread.