1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-12 05:01:15 +03:00

* Most changes are to fix warnings issued when compiling win32

* removed a few redundant defines
* get_user_name safe under win32
* rationalized pipe read EOF for win32 (UPDATED PATCH USED)
* changed all backend instances of sleep() to pg_usleep

    - except for the SLEEP_ON_ASSERT in assert.c, as it would exceed a
32-bit long [Note to patcher: If a SLEEP_ON_ASSERT of 2000 seconds is
acceptable, please replace with pg_usleep(2000000000L)]

I added a comment to that part of the code:

    /*
     *  It would be nice to use pg_usleep() here, but only does 2000 sec
     *  or 33 minutes, which seems too short.
     */
    sleep(1000000);

Claudio Natoli
This commit is contained in:
Bruce Momjian
2004-04-19 17:42:59 +00:00
parent 862b20b382
commit 31338352bd
29 changed files with 98 additions and 91 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.138 2004/03/22 04:16:57 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.139 2004/04/19 17:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2830,7 +2830,7 @@ StartupXLOG(void)
/* This is just to allow attaching to startup process with a debugger */
#ifdef XLOG_REPLAY_DELAY
if (ControlFile->state != DB_SHUTDOWNED)
sleep(60);
pg_usleep(60000000L);
#endif
/*
@@ -3360,7 +3360,7 @@ CreateCheckPoint(bool shutdown, bool force)
while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
{
CHECK_FOR_INTERRUPTS();
sleep(1);
pg_usleep(1000000L);
}
/*

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.131 2004/02/10 01:55:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.132 2004/04/19 17:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -64,7 +64,9 @@ createdb(const CreatedbStmt *stmt)
char *alt_loc;
char *target_dir;
char src_loc[MAXPGPATH];
#ifndef WIN32
char buf[2 * MAXPGPATH + 100];
#endif
Oid src_dboid;
AclId src_owner;
int src_encoding;

View File

@@ -14,7 +14,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.23 2004/03/24 03:44:58 momjian Exp $
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.24 2004/04/19 17:42:57 momjian Exp $
*/
@@ -33,9 +33,7 @@
#ifdef FRONTEND
#include "postgres_fe.h"
#ifndef WIN32
#include "libpq/crypt.h"
#endif /* WIN32 */
#endif /* FRONTEND */
#ifdef MD5_ODBC

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.77 2004/04/19 17:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -50,7 +50,9 @@ int
main(int argc, char *argv[])
{
int len;
#ifndef WIN32
struct passwd *pw;
#endif
char *pw_name_persist;
/*

View File

@@ -10,7 +10,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.32 2004/02/25 19:41:22 momjian Exp $
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.33 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -259,7 +259,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
PGSharedMemoryDetach();
UsedShmemSegAddr = origUsedShmemSegAddr;
#endif
elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
elog(DEBUG3,"Attaching to %p",UsedShmemSegAddr);
hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
if (hdr == NULL)
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.4 2004/02/12 20:37:34 momjian Exp $
* $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.5 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,7 +22,7 @@ static DWORD s_segsize = 0;
int
shmdt(const void *shmaddr)
{
if (UnmapViewOfFile(shmaddr))
if (UnmapViewOfFile((LPCVOID*)shmaddr))
return 0;
else
return -1;

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.1 2004/02/18 16:25:12 momjian Exp $
* $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.2 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,9 +43,9 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
timerHandle = CreateWaitableTimer(NULL, TRUE, NULL);
if (timerHandle == NULL)
ereport(FATAL,
(errmsg_internal("failed to create waitable timer: %i",GetLastError())));
(errmsg_internal("failed to create waitable timer: %i",(int)GetLastError())));
}
if (value->it_value.tv_sec == 0 &&
value->it_value.tv_usec == 0) {
/* Turn timer off */
@@ -55,11 +55,11 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
/* Negative time to SetWaitableTimer means relative time */
dueTime.QuadPart = -(value->it_value.tv_usec*10 + value->it_value.tv_sec*10000000L);
/* Turn timer on, or change timer */
if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
ereport(FATAL,
(errmsg_internal("failed to set waitable timer: %i",GetLastError())));
(errmsg_internal("failed to set waitable timer: %i",(int)GetLastError())));
return 0;
}

View File

@@ -13,7 +13,7 @@
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.66 2004/04/12 16:19:18 momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.67 2004/04/19 17:42:58 momjian Exp $
* ----------
*/
#include "postgres.h"
@@ -1730,13 +1730,6 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
{
if (errno == EINTR)
continue;
#ifdef WIN32
if (WSAGetLastError() == WSAECONNRESET) /* EOF on the pipe! (win32 socket based implementation) */
{
pipeEOF = true;
break;
}
#endif
ereport(LOG,
(errcode_for_socket_access(),
errmsg("could not read from statistics collector pipe: %m")));

View File

@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.380 2004/04/12 16:19:18 momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.381 2004/04/19 17:42:58 momjian Exp $
*
* NOTES
*
@@ -314,8 +314,6 @@ static unsigned long tmpBackendFileNum = 0;
void read_backend_variables(unsigned long id, Port *port);
static bool write_backend_variables(Port *port);
size_t ShmemBackendArraySize(void);
void ShmemBackendArrayAllocation(void);
static void ShmemBackendArrayAdd(Backend *bn);
static void ShmemBackendArrayRemove(pid_t pid);
#endif
@@ -2561,7 +2559,7 @@ BackendRun(Port *port)
* PGOPTIONS, but it is not honored until after authentication.)
*/
if (PreAuthDelay > 0)
sleep(PreAuthDelay);
pg_usleep(PreAuthDelay*1000000L);
/* Will exit on failure */
BackendInit(port);
@@ -3455,8 +3453,8 @@ static void ShmemBackendArrayAdd(Backend *bn)
}
}
/* FIXME: [fork/exec] some sort of error */
abort();
ereport(FATAL,
(errmsg_internal("unable to add backend entry")));
}
static void ShmemBackendArrayRemove(pid_t pid)
@@ -3472,7 +3470,6 @@ static void ShmemBackendArrayRemove(pid_t pid)
}
}
/* Something stronger than WARNING here? */
ereport(WARNING,
(errmsg_internal("unable to find backend entry with pid %d",
pid)));
@@ -3565,8 +3562,9 @@ static void win32_AddChild(pid_t pid, HANDLE handle)
++win32_numChildren;
}
else
/* FIXME: [fork/exec] some sort of error */
abort();
ereport(FATAL,
(errmsg_internal("unable to add child entry with pid %lu",
pid)));
}
static void win32_RemoveChild(pid_t pid)
@@ -3588,7 +3586,6 @@ static void win32_RemoveChild(pid_t pid)
}
}
/* Something stronger than WARNING here? */
ereport(WARNING,
(errmsg_internal("unable to find child entry with pid %lu",
pid)));

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.103 2004/02/11 22:55:25 tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.104 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -607,7 +607,7 @@ mdsync(void)
{
sync();
if (IsUnderPostmaster)
sleep(2);
pg_usleep(2000000L);
sync();
return true;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.399 2004/04/11 00:54:44 momjian Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.400 2004/04/19 17:42:58 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -2456,7 +2456,7 @@ PostgresMain(int argc, char *argv[], const char *username)
/*
* wait N seconds to allow attach from a debugger
*/
sleep(atoi(optarg));
pg_usleep(atoi(optarg)*1000000L);
break;
case 'x':

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.25 2003/11/29 19:52:01 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/utils/error/assert.c,v 1.26 2004/04/19 17:42:58 momjian Exp $
*
* NOTE
* This should eventually work with elog()
@@ -40,7 +40,11 @@ ExceptionalCondition(char *conditionName,
}
#ifdef SLEEP_ON_ASSERT
sleep(1000000);
/*
* It would be nice to use pg_usleep() here, but only does 2000 sec
* or 33 minutes, which seems too short.
*/
sleep(1000000);
#endif
abort();

View File

@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.50 2003/12/29 23:54:22 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/hash/dynahash.c,v 1.51 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -85,6 +85,7 @@ DynaHashAlloc(Size size)
}
#define MEM_ALLOC DynaHashAlloc
#undef MEM_FREE /* already in windows header files */
#define MEM_FREE pfree

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.123 2004/02/10 01:55:26 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.124 2004/04/19 17:42:58 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -213,11 +213,11 @@ SetDataDir(const char *dir)
* generating funny-looking paths to individual files.
*/
newlen = strlen(new);
if (newlen > 1 && new[newlen - 1] == '/'
if (newlen > 1 && (new[newlen - 1] == '/'
#ifdef WIN32
|| new[newlen - 1] == '\\'
#endif
)
))
new[newlen - 1] = '\0';
if (DataDir)