[Haskell-cafe] File locked unnecessarily

Vyacheslav Akhmechet coffeemug at gmail.com
Sun Dec 3 14:45:01 EST 2006


Are you using hGetContents? If you are, take a closer look at the
documentation. The function creates a lazy stream and until you finish
reading from it the file will be in the "semi-closed" state (which
means it will be locked).

On 12/3/06, Arie Peterson <ariep at xs4all.nl> wrote:
> Hi,
>
>
> After a partial rewrite of my webserver, it is suffering from locked files:
>
>   /path/to/file: openBinaryFile: resource busy (file is locked)
>
> The file in question really shouldn't be locked:
>   - Only my server knows of the file's existence.
>   - Only one thread accesses the file.
>   - The thread accesses the file multiple times in quick succession,
> opening and closing it each time, but debugging statements show that it
> is properly closed before it is reopened.
>
> I tried opening, reading/writing and closing a file continuously for some
> time in an isolated environment, and that works without problems.
>
> Also, my server did not have this file locking problem before the rewrite,
> and the rewrite did not touch the part of the code that accesses the file.
>
> This suggests that the locking is somehow triggered by the specific access
> pattern of my code, if that is even possible.
>
>
> Does anyone know what could cause this locking and/or how to prevent it?
>
> I'm using ghc 6.4 on gentoo linux (amd64).
>
>
> Thanks and greetings,
>
>
> Arie
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list