[PATCH V2] posix: insert seek between reads and writes on Solaris (issue4943)
Gregory Szorc
gregory.szorc at gmail.com
Mon Nov 30 17:28:55 CST 2015
On Mon, Nov 30, 2015 at 2:23 PM, Matt Mackall <mpm at selenic.com> wrote:
> On Thu, 2015-11-26 at 18:10 -0800, Gregory Szorc wrote:
> > # HG changeset patch
> > # User Gregory Szorc <gregory.szorc at gmail.com>
> > # Date 1447625312 28800
> > # Sun Nov 15 14:08:32 2015 -0800
> > # Branch stable
> > # Node ID a7d5be598b347ae2c26566aa2bcdcf5cb1acb30b
> > # Parent 6979fe2a6d75105affcacd9e298262a92641cb98
> > posix: insert seek between reads and writes on Solaris (issue4943)
> >
> > At least some versions of Solaris fail to properly write to file
> > descriptors opened for both reading and writing. When the descriptor
> > is seeked and read, subsequent writes effectively disappear into a
> > black hole.
>
> A quick check of all the "a+" users suggests this is restricted to
> revlog writing. So I think it'd be much simpler to do:
>
> diff -r 61fbf5dc12b2 mercurial/scmutil.py
> --- a/mercurial/scmutil.py Tue Nov 24 21:41:12 2015 +0000
> +++ b/mercurial/scmutil.py Mon Nov 30 16:21:33 2015 -0600
> @@ -516,6 +516,12 @@
> fp = util.posixfile(f, mode)
> if nlink == 0:
> self._fixfilemode(f)
> +
> + # The position when opening in append mode is implementation
> defined, so
> + # make it consistent across platforms by positioning at EOF
> + if mode in ('a', 'a+'):
> + fp.seek(0, os.SEEK_END)
> +
> return fp
>
> def symlink(self, src, dst):
> diff -r 61fbf5dc12b2 mercurial/windows.py
> --- a/mercurial/windows.py Tue Nov 24 21:41:12 2015 +0000
> +++ b/mercurial/windows.py Mon Nov 30 16:21:33 2015 -0600
> @@ -99,12 +99,6 @@
> '''Open a file with even more POSIX-like semantics'''
> try:
> fp = osutil.posixfile(name, mode, buffering) # may raise
> WindowsError
> -
> - # The position when opening in append mode is implementation
> defined, so
> - # make it consistent with other platforms, which position at EOF.
> - if 'a' in mode:
> - fp.seek(0, os.SEEK_END)
> -
> if '+' in mode:
> return mixedfilemodewrapper(fp)
>
> Thoughts?
My patch is about inserting extra seeks between reads and writes: yours is
about seeking when opening in append mode. Apples and oranges.
Did you intend to suggest inserting the seek to EOF on every write() to a
file opened in append mode? That will blow up the number of system calls
during writing. It probably doesn't matter. But it feels wasteful on the
platforms where it isn't necessary.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20151130/60bd875b/attachment.html>
More information about the Mercurial-devel
mailing list