From: | Mike Mascari <mascarm(at)mascari(dot)com> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
Cc: | Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Win32 rename()/unlink() questions |
Date: | 2002-09-20 15:54:52 |
Message-ID: | 3D8B44CC.6070802@mascari.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Stephan Szabo wrote:
> On Fri, 20 Sep 2002, Mike Mascari wrote:
>
>
>>I think that's a rather poor description. I think it just means
>>that if the file is opened once via CreateFile() with
>>FILE_SHARE_DELETE, then any subsequent CreateFile() calls will
>>fail unless they too have FILE_SHARE_DELETE. In other words, if
>>one of us can delete this file while its open, any of us can.
>
>
> The question is, what happens if two people have the file open
> and one goes and tries to delete it? Can the other still read
> from it?
Yes. I just tested it and it worked. I'll test Bruce's scenario
as well:
foo contains: "FOO"
bar contains: "BAR"
1. Process 1 opens "foo"
2. Process 2 opens "foo"
3. Process 1 calls MoveFile("foo", "foo2");
4. Process 3 opens "foo" <- Successful?
5. Process 1 calls MoveFile("bar", "foo");
6. Process 4 opens "foo" <- Successful?
7. Process 1 calls DeleteFile("foo2");
8. Process 1, 2, 3, 4 all read from their respective handles.
I think the thing to worry about is a race condition between the
two MoveFile() attempts. A very ugly hack would be to loop in a
CreateFile() in an attempt to open "foo", giving up if the error
is not a NOT EXISTS error code.
Mike Mascari
mascarm(at)mascari(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-09-20 15:56:02 | Re: Win32 rename()/unlink() questionst |
Previous Message | Justin Clift | 2002-09-20 15:52:18 | Re: Having no luck with getting pgbench to run multipletimes |