[PATCH] don't ignore write failures

Jeff Darcy jdarcy at redhat.com
Mon Oct 4 20:59:48 UTC 2010


On 10/04/2010 04:50 PM, Jim Meyering wrote:
> --- a/proxy.c
> +++ b/proxy.c
> @@ -271,7 +271,10 @@ junk_writer (void *ptr, size_t size, size_t nmemb, void *stream)
>  	size_t	n;
> 
>  	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);
> 
>  	return 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?

> diff --git a/rest.c b/rest.c
> index c808d1a..3d54f79 100644
> --- a/rest.c
> +++ b/rest.c
> @@ -1793,7 +1793,8 @@ args_done:
>  		printf("db is at %s:%u\n",db_host,db_port);
>  		printf("will listen on port %u\n",my_port);
>  		printf("my location is \"%s\"\n",me);
> -		fflush(stdout);
> +		if (!!ferror(stdout) + !!fflush(stdout))
> +			error(EXIT_FAILURE, 0, "write failed");
>  	}
> 
>  	backend_init();

Checking for errors on debug output?  Somehow if I think things are so
screwed up that we hit this then the "write failed" will get eaten too,
but fine.  Also, I can't wait to see the reaction to !! from the guy who
gave me grief about !0 in some other code.  ;)

I'm not NAKing, but I'm not ACKing either until we find out whether the
important part conflicts with Pete.


More information about the iwhd-devel mailing list