caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* file mapped bigarray and Unix.unlink
@ 2009-07-02  8:10 Matthieu Dubuget
  2009-07-02  8:54 ` [Caml-list] " Matthieu Dubuget
  2009-07-02 12:48 ` Florian Hars
  0 siblings, 2 replies; 6+ messages in thread
From: Matthieu Dubuget @ 2009-07-02  8:10 UTC (permalink / raw)
  To: caml-list

Hello,

I have difficulties to delete one file (name: fn, file descriptor:
fdesc) with "Unix.unlink fn".

I suspect that this is because I have a bigarray ba mapped with fdesc.
Is it a possible reason?

At some point, I want to delete fn because the saving operation was
cancelled by the user.

I assure that the binding to ba is lost.

Then, I close the file handle with
"Unix.close fdesc;"

At this point,
"Unix.rename fn g;" works, but
 
"Unix.unlink fn;" fails with : Permission denied error.


following my idea that this can be due to the fact that fn is mapped in
memory, I tried to insert a Gc.compact, in order for ba to be erased:

Unix.close fdesc;
Gc.compact ();
Unix.unlink fn;

but got the same error message.

Any idea?

Salutations

Matt




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] file mapped bigarray and Unix.unlink
  2009-07-02  8:10 file mapped bigarray and Unix.unlink Matthieu Dubuget
@ 2009-07-02  8:54 ` Matthieu Dubuget
  2009-07-02  9:49   ` David MENTRE
  2009-07-02 12:48 ` Florian Hars
  1 sibling, 1 reply; 6+ messages in thread
From: Matthieu Dubuget @ 2009-07-02  8:54 UTC (permalink / raw)
  To: caml-list

Solved! Sorry for the noise.

The operating systems takes time to free the file descriptor.
The strategy I adopted is to spawn a recursive thread that
periodically try to erase the file until success.

Salutations


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] file mapped bigarray and Unix.unlink
  2009-07-02  8:54 ` [Caml-list] " Matthieu Dubuget
@ 2009-07-02  9:49   ` David MENTRE
  2009-07-02 10:15     ` Matthieu Dubuget
  0 siblings, 1 reply; 6+ messages in thread
From: David MENTRE @ 2009-07-02  9:49 UTC (permalink / raw)
  To: matthieu.dubuget; +Cc: caml-list

Hello Mathieu,

2009/7/2 Matthieu Dubuget <matthieu.dubuget@gmail.com>:
> The strategy I adopted is to spawn a recursive thread that
> periodically try to erase the file until success.

That seems the wrong solution to me. The unlink syscall should work
immediately or you have another reason why it only works after a
certain time.

Yours,
david


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] file mapped bigarray and Unix.unlink
  2009-07-02  9:49   ` David MENTRE
@ 2009-07-02 10:15     ` Matthieu Dubuget
  0 siblings, 0 replies; 6+ messages in thread
From: Matthieu Dubuget @ 2009-07-02 10:15 UTC (permalink / raw)
  To: caml-list

| Sujet : « Re: [Caml-list] file mapped bigarray and Unix.unlink »
| Pour : « matthieu.dubuget@gmail.com »
| De : « David MENTRE <dmentre@linux-france.org> »
| Le  Thu Jul 02 2009 11:49:33 GMT+0200 (CEST)
> Hello Mathieu,
>
> 2009/7/2 Matthieu Dubuget <matthieu.dubuget@gmail.com>:
>   
>> The strategy I adopted is to spawn a recursive thread that
>> periodically try to erase the file until success.
>>     
>
> That seems the wrong solution to me. The unlink syscall should work
> immediately or you have another reason why it only works after a
> certain time.
>
> Yours,
> david
>   

I agree… but:
- I'm already late (I know, that's a bad reason)
- I don't know what could be the reason(s) for this delay

Thanks

Matt


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] file mapped bigarray and Unix.unlink
  2009-07-02  8:10 file mapped bigarray and Unix.unlink Matthieu Dubuget
  2009-07-02  8:54 ` [Caml-list] " Matthieu Dubuget
@ 2009-07-02 12:48 ` Florian Hars
  1 sibling, 0 replies; 6+ messages in thread
From: Florian Hars @ 2009-07-02 12:48 UTC (permalink / raw)
  To: matthieu.dubuget; +Cc: caml-list

Matthieu Dubuget schrieb:
> Any idea?

You are probably using windows, which is a bit weird about operations
on open files.

- Florian.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] file mapped bigarray and Unix.unlink
@ 2009-07-02 12:43 Dario Teixeira
  0 siblings, 0 replies; 6+ messages in thread
From: Dario Teixeira @ 2009-07-02 12:43 UTC (permalink / raw)
  To: matthieu.dubuget, David MENTRE; +Cc: caml-list


Hi,

> > The strategy I adopted is to spawn a recursive thread that
> > periodically try to erase the file until success.
> 
> That seems the wrong solution to me. The unlink syscall should work
> immediately or you have another reason why it only works after a
> certain time.

I second David's discomfort.  Have you considered issuing a sync after
the unlink?  For efficiency reasons the OS may not actually be deleting
the file immediately after the unlink; the sync should force it to do it.

Cheers,
Dario Teixeira






^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-07-02 12:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-02  8:10 file mapped bigarray and Unix.unlink Matthieu Dubuget
2009-07-02  8:54 ` [Caml-list] " Matthieu Dubuget
2009-07-02  9:49   ` David MENTRE
2009-07-02 10:15     ` Matthieu Dubuget
2009-07-02 12:48 ` Florian Hars
2009-07-02 12:43 Dario Teixeira

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).