apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bert Huijben" <b...@qqmail.nl>
Subject RE: [PATCH] apr_file_flush_locked and short writes
Date Mon, 21 Feb 2011 13:02:12 GMT


> -----Original Message-----
> From: Blair Zajac [mailto:blair@orcaware.com]
> Sent: zaterdag 5 februari 2011 0:33
> To: dev@apr.apache.org
> Subject: [PATCH] apr_file_flush_locked and short writes
> 
> Looking at apr_file_flush_locked(), it looks like it doesn't handle short
writes
> for buffered apr_file_t's, upon a short write the unwritten data will be
lost.
> 
> Here's a patch for this:
> 
> Index: file_io/unix/readwrite.c
> ==========================================================
> =========
> --- file_io/unix/readwrite.c	(revision 1067340)
> +++ file_io/unix/readwrite.c	(working copy)
> @@ -409,7 +409,11 @@
>              rv = errno;
>          } else {
>              thefile->filePtr += written;
> -            thefile->bufpos = 0;
> +            if (written != thefile->bufpos)
> +                memmove(thefile->buffer,
> +                        thefile->buffer + written,
> +                        thefile->bufpos - written);
> +            thefile->bufpos -= written;
>          }
>      }
> 
> 
> Beyond this, there's no a mechanism to report that all the buffered data
> didn't get into the file.  Perhaps apr_file_flush() should loop until the
entire
> buffer is written or it gets a non-EINTR error?

Pinging this two weeks old issue as I think it should be fixed for the next
release.

	Bert



Mime
View raw message