[PATCH] don't ignore write failures

Pete Zaitcev zaitcev at redhat.com
Mon Oct 4 22:16:40 UTC 2010


On Mon, 04 Oct 2010 16:59:48 -0400
Jeff Darcy <jdarcy at redhat.com> wrote:

> >  	n = fwrite(ptr,size,nmemb,stream);
> > -	fflush(stream);
> > +	if (n != nmemb)
> > +		error(0, 0, "warning: write failed");
> > +	if (fflush(stream))
> > +		error(0, 0, "warning: write failed");
> >  	DPRINTF("in %s(%zu,%zu) => %zu\n",__func__,size,nmemb,n);

> Pete, is this going to conflict with your pending changes to implement
> the same sort of error-termination handshake for other back ends that
> you already did for the S3 back end?

Actually I implemented it everywhere, including fs, because unfortunately
the wait was inserted into a common path, so fs back-end hung with my
early patch. I thought you noticed that and that was why you told me
pay attention to back-ends other than S3.

I need to check this though. I don't even remember a function called
"junk_writer", maybe I missed a piece of code that needed chaning.

> > -		fflush(stdout);
> > +		if (!!ferror(stdout) + !!fflush(stdout))
> > +			error(EXIT_FAILURE, 0, "write failed");
> 
> Also, I can't wait to see the reaction to !! from the guy who
> gave me grief about !0 in some other code.  ;)

I was unhappy all right but fortunately the unacceptable semantics
of the plus gave me a better excuse to nitpick the bike shed without
being a total douche.

-- Pete


More information about the iwhd-devel mailing list