[ubuntu/jaunty] conntrack 1:0.9.7-1.1ubuntu1 (Accepted)

Steve Langasek steve.langasek at ubuntu.com
Mon Nov 24 11:56:39 GMT 2008


On Mon, Nov 24, 2008 at 01:02:49AM +0000, James Westby wrote:
> I have attacked a couple of these failures recently, and the thing I
> always find hard is knowing what to do with an error condition. Without
> knowing the code it is hard to know how an error should be handled.
> For instance today I was looking at an ircd that wasn't checking the
> return code on a write call, writing to its log file. I don't think
> an error should abort, but in many cases that will be the only sensible
> thing to do.

This is the obvious conclusion, and the one I mistakenly reached at first,
too.  But the main reason it's a programming error to not check the return
code on a write call is *not* because you need to always handle errors, but
because you should handle *successes* in the form of partial writes:

       If  a  write()  is interrupted by a signal handler before any bytes are
       written, then the call fails with the error EINTR; if it is interrupted
       after  at  least  one  byte  has  been  written, the call succeeds, and
       returns the number of bytes written.

write(2)

So using write() means you should always have retry handling in place.

-- 
Steve Langasek                   Give me a lever long enough and a Free OS
Debian Developer                   to set it on, and I can move the world.
Ubuntu Developer                                    http://www.debian.org/
slangasek at ubuntu.com                                     vorlon at debian.org



More information about the ubuntu-devel mailing list