[darcs-users] darcs patch: add suggested fix to readFile policy war... (and 1 more)

Eric Kow kowey at darcs.net
Fri Feb 13 16:58:48 UTC 2009


On Thu, Feb 12, 2009 at 21:14:52 +0100, Petr Rockai wrote:
> The problem with Prelude readFile is that it's based on hGetContents, which is
> lazy by definition. This also means that unless you force consumption of the
> produced list, it will keep an fd open for the file, possibly
> indefinitely. This is called a fd leak. Other than being annoying and if done
> often, leading to fd exhaustion and failure to open any new files (which is
> usually fatal), it also prevents the file to be unlinked (deleted) on win32.
> 
> On the other hand, *strict* bytestring version of readFile will read the whole
> file into a contiguous buffer, *close the fd* and return. This is perfectly
> safe with regards to fd leaks. Btw., this is *not* the case with lazy
> bytestring variant of readFile, so that one is unsafe.

Oh, so Simon's suggestion really is the right thing to do then?  Ok,
I'll apply the patch, thanks!

PS:
> Let me explain then. In return, I'd be grateful if you could file this
> somewhere where people find it the next time this comes around.

Excellent request for increasing darcs hacking efficiency.  I'll put
these into the comments of haskell_policy because I figure that's a
reasonable place to look when it complains.

-- 
Eric Kow <http://www.nltg.brighton.ac.uk/home/Eric.Kow>
PGP Key ID: 08AC04F9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.osuosl.org/pipermail/darcs-users/attachments/20090213/1004eb67/attachment-0001.pgp>


More information about the darcs-users mailing list