1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Adjust rename on Win32 to only link to temp name while holding lock,

then release locks and loop over renaming to active file name.
This commit is contained in:
Bruce Momjian
2004-02-02 00:17:23 +00:00
parent e5e5a323ca
commit d9d2ca8e8e
5 changed files with 67 additions and 27 deletions

View File

@ -10,7 +10,7 @@
* Win32 (NT, Win2k, XP). replace() doesn't work on Win95/98/Me.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.8 2003/11/29 19:52:13 pgsql Exp $
* $PostgreSQL: pgsql/src/port/dirmod.c,v 1.9 2004/02/02 00:17:23 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -27,9 +27,19 @@ pgrename(const char *from, const char *to)
{
int loops = 0;
#ifdef WIN32
while (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING))
#endif
#ifdef CYGWIN
while (rename(from, to) < 0)
#endif
{
#ifdef WIN32
if (GetLastError() != ERROR_ACCESS_DENIED)
#endif
#ifdef CYGWIN
if (errno != EACCES)
#endif
/* set errno? */
return -1;
Sleep(100); /* ms */