chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Fix #819 by marking file-mkstemp as unimpl


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Fix #819 by marking file-mkstemp as unimplemented on Windows
Date: Sun, 3 Aug 2014 15:32:15 +0200
User-agent: Mutt/1.4.2.3i

On Sun, Aug 03, 2014 at 11:04:21AM +0200, Michele La Monaca wrote:
> On Sun, Aug 3, 2014 at 3:01 AM, Mario Domenech Goulart
> <address@hidden> wrote:
> > ...
> > If I understand correctly, at this point the code is subject to race
> > conditions, which is one of the things mkstemp prevents.
> 
> Yes, actually a stupid one which can be avoided, I think. Attached a
> revisited patch which should avoid the problem. I also added a few
> sanity checks (some more may be needed). Unfortunately, I can't
> thoroughly test the code right now as I said.

Thanks for your patch!  I've taken it and improved it a little bit:
- Changed file's permission to use 600 instead of 777.
- Converted functional string concatenation code to imperative mutation
   of a copied string to reduce pressure on the GC.
- Considering that the standard says mkstemp returns an error in case
   the file doesn't end in "XXXXXX", I decided to simplify the handling
   of invalid templates by assuming a template with no trailing Xs is
   also invalid.  This also allows us to remove the special case of when
   the template is empty (in which case first-x is also 0).  I've checked
   NetBSD's libc and GNU libc.  NetBSD allows templates with no Xs, but
   GNU libc disallows them (resulting in an error in CHICKEN), so erroring
   on this in Windows too should improve portability of CHICKEN code.
- Various other small cleanups to make the code more compact.
- Made use of fixnum procedures where possible (not terribly important,
   but it improves consistency with the rest of the code)

I've also tested the code on Windows.  Here's the new version.

Cheers,
Peter
-- 
http://www.more-magic.net

Attachment: 0001-Fix-file-mkstemp-behaviour-on-Windows-819.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]