LWN.net Logo

Quotes of the week

Quotes of the week

Posted May 28, 2009 16:11 UTC (Thu) by iabervon (subscriber, #722)
In reply to: Quotes of the week by elanthis
Parent article: Quotes of the week

You can't depend on short writes alone to keep your multiplexed server from stalling, because write() can only report a short write of at least one byte (and select is not perfectly reliable); you need to use O_NONBLOCK to make conditions that are expected to clear with time errors.

The more general thing is that an error may occur, and it may be permanent or may be transient, and it may not be possible for the kernel to know which. If it occurs for the first byte, the kernel can just report it and nothing else, but if the kernel sends some of the data and then gets an error, it has to be able to report that some of the data was transferred successfully and some of it was not, in order that userspace be able to try to resolve the problem and then send the data that wasn't transferred. Once there's the possibility of userspace needing to do something other than wait in order to resolve the error, neither blocking nor failing completely is sufficient.


(Log in to post comments)

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds