[PATCH V2] posix: insert seek between reads and writes on Solaris (issue4943)

Augie Fackler raf at durin42.com
Mon Nov 30 17:04:22 CST 2015


On Mon, Nov 30, 2015 at 04:23:25PM -0600, Matt Mackall 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?

Scares me less than the alternatives. Send a patch for stable?

> --
> Mathematics is the supreme nostalgia of our time.
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list