Skip to content

Commit 3133835

Browse files
committed
* 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
1 parent 862b20b commit 3133835

File tree

29 files changed

+98
-91
lines changed

29 files changed

+98
-91
lines changed

src/backend/access/transam/xlog.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.138 2004/03/22 04:16:57 momjian Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.139 2004/04/19 17:42:57 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2830,7 +2830,7 @@ StartupXLOG(void)
28302830
/* This is just to allow attaching to startup process with a debugger */
28312831
#ifdef XLOG_REPLAY_DELAY
28322832
if (ControlFile->state != DB_SHUTDOWNED)
2833-
sleep(60);
2833+
pg_usleep(60000000L);
28342834
#endif
28352835

28362836
/*
@@ -3360,7 +3360,7 @@ CreateCheckPoint(bool shutdown, bool force)
33603360
while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
33613361
{
33623362
CHECK_FOR_INTERRUPTS();
3363-
sleep(1);
3363+
pg_usleep(1000000L);
33643364
}
33653365

33663366
/*

src/backend/commands/dbcommands.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.131 2004/02/10 01:55:25 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.132 2004/04/19 17:42:57 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -64,7 +64,9 @@ createdb(const CreatedbStmt *stmt)
6464
char *alt_loc;
6565
char *target_dir;
6666
char src_loc[MAXPGPATH];
67+
#ifndef WIN32
6768
char buf[2 * MAXPGPATH + 100];
69+
#endif
6870
Oid src_dboid;
6971
AclId src_owner;
7072
int src_encoding;

src/backend/libpq/md5.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Portions Copyright (c) 1994, Regents of the University of California
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.23 2004/03/24 03:44:58 momjian Exp $
17+
* $PostgreSQL: pgsql/src/backend/libpq/md5.c,v 1.24 2004/04/19 17:42:57 momjian Exp $
1818
*/
1919

2020

@@ -33,9 +33,7 @@
3333

3434
#ifdef FRONTEND
3535
#include "postgres_fe.h"
36-
#ifndef WIN32
3736
#include "libpq/crypt.h"
38-
#endif /* WIN32 */
3937
#endif /* FRONTEND */
4038

4139
#ifdef MD5_ODBC

src/backend/main/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.76 2004/03/15 16:14:26 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.77 2004/04/19 17:42:57 momjian Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -50,7 +50,9 @@ int
5050
main(int argc, char *argv[])
5151
{
5252
int len;
53+
#ifndef WIN32
5354
struct passwd *pw;
55+
#endif
5456
char *pw_name_persist;
5557

5658
/*

src/backend/port/sysv_shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.32 2004/02/25 19:41:22 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/port/sysv_shmem.c,v 1.33 2004/04/19 17:42:58 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -259,7 +259,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port)
259259
PGSharedMemoryDetach();
260260
UsedShmemSegAddr = origUsedShmemSegAddr;
261261
#endif
262-
elog(DEBUG3,"Attaching to %x",UsedShmemSegAddr);
262+
elog(DEBUG3,"Attaching to %p",UsedShmemSegAddr);
263263
hdr = PGSharedMemoryAttach((IpcMemoryKey) UsedShmemSegID, &shmid);
264264
if (hdr == NULL)
265265
elog(FATAL, "could not attach to proper memory at fixed address: shmget(key=%d, addr=%p) failed: %m",

src/backend/port/win32/shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.4 2004/02/12 20:37:34 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/shmem.c,v 1.5 2004/04/19 17:42:58 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -22,7 +22,7 @@ static DWORD s_segsize = 0;
2222
int
2323
shmdt(const void *shmaddr)
2424
{
25-
if (UnmapViewOfFile(shmaddr))
25+
if (UnmapViewOfFile((LPCVOID*)shmaddr))
2626
return 0;
2727
else
2828
return -1;

src/backend/port/win32/timer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
*
88
* IDENTIFICATION
9-
* $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.1 2004/02/18 16:25:12 momjian Exp $
9+
* $PostgreSQL: pgsql/src/backend/port/win32/timer.c,v 1.2 2004/04/19 17:42:58 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -43,9 +43,9 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
4343
timerHandle = CreateWaitableTimer(NULL, TRUE, NULL);
4444
if (timerHandle == NULL)
4545
ereport(FATAL,
46-
(errmsg_internal("failed to create waitable timer: %i",GetLastError())));
46+
(errmsg_internal("failed to create waitable timer: %i",(int)GetLastError())));
4747
}
48-
48+
4949
if (value->it_value.tv_sec == 0 &&
5050
value->it_value.tv_usec == 0) {
5151
/* Turn timer off */
@@ -55,11 +55,11 @@ int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue
5555

5656
/* Negative time to SetWaitableTimer means relative time */
5757
dueTime.QuadPart = -(value->it_value.tv_usec*10 + value->it_value.tv_sec*10000000L);
58-
58+
5959
/* Turn timer on, or change timer */
60-
if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
60+
if (!SetWaitableTimer(timerHandle, &dueTime, 0, timer_completion, NULL, FALSE))
6161
ereport(FATAL,
62-
(errmsg_internal("failed to set waitable timer: %i",GetLastError())));
62+
(errmsg_internal("failed to set waitable timer: %i",(int)GetLastError())));
6363

6464
return 0;
6565
}

src/backend/postmaster/pgstat.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
1515
*
16-
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.66 2004/04/12 16:19:18 momjian Exp $
16+
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.67 2004/04/19 17:42:58 momjian Exp $
1717
* ----------
1818
*/
1919
#include "postgres.h"
@@ -1730,13 +1730,6 @@ pgstat_mainChild(PGSTAT_FORK_ARGS)
17301730
{
17311731
if (errno == EINTR)
17321732
continue;
1733-
#ifdef WIN32
1734-
if (WSAGetLastError() == WSAECONNRESET) /* EOF on the pipe! (win32 socket based implementation) */
1735-
{
1736-
pipeEOF = true;
1737-
break;
1738-
}
1739-
#endif
17401733
ereport(LOG,
17411734
(errcode_for_socket_access(),
17421735
errmsg("could not read from statistics collector pipe: %m")));

src/backend/postmaster/postmaster.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.380 2004/04/12 16:19:18 momjian Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.381 2004/04/19 17:42:58 momjian Exp $
4141
*
4242
* NOTES
4343
*
@@ -314,8 +314,6 @@ static unsigned long tmpBackendFileNum = 0;
314314
void read_backend_variables(unsigned long id, Port *port);
315315
static bool write_backend_variables(Port *port);
316316

317-
size_t ShmemBackendArraySize(void);
318-
void ShmemBackendArrayAllocation(void);
319317
static void ShmemBackendArrayAdd(Backend *bn);
320318
static void ShmemBackendArrayRemove(pid_t pid);
321319
#endif
@@ -2561,7 +2559,7 @@ BackendRun(Port *port)
25612559
* PGOPTIONS, but it is not honored until after authentication.)
25622560
*/
25632561
if (PreAuthDelay > 0)
2564-
sleep(PreAuthDelay);
2562+
pg_usleep(PreAuthDelay*1000000L);
25652563

25662564
/* Will exit on failure */
25672565
BackendInit(port);
@@ -3455,8 +3453,8 @@ static void ShmemBackendArrayAdd(Backend *bn)
34553453
}
34563454
}
34573455

3458-
/* FIXME: [fork/exec] some sort of error */
3459-
abort();
3456+
ereport(FATAL,
3457+
(errmsg_internal("unable to add backend entry")));
34603458
}
34613459

34623460
static void ShmemBackendArrayRemove(pid_t pid)
@@ -3472,7 +3470,6 @@ static void ShmemBackendArrayRemove(pid_t pid)
34723470
}
34733471
}
34743472

3475-
/* Something stronger than WARNING here? */
34763473
ereport(WARNING,
34773474
(errmsg_internal("unable to find backend entry with pid %d",
34783475
pid)));
@@ -3565,8 +3562,9 @@ static void win32_AddChild(pid_t pid, HANDLE handle)
35653562
++win32_numChildren;
35663563
}
35673564
else
3568-
/* FIXME: [fork/exec] some sort of error */
3569-
abort();
3565+
ereport(FATAL,
3566+
(errmsg_internal("unable to add child entry with pid %lu",
3567+
pid)));
35703568
}
35713569

35723570
static void win32_RemoveChild(pid_t pid)
@@ -3588,7 +3586,6 @@ static void win32_RemoveChild(pid_t pid)
35883586
}
35893587
}
35903588

3591-
/* Something stronger than WARNING here? */
35923589
ereport(WARNING,
35933590
(errmsg_internal("unable to find child entry with pid %lu",
35943591
pid)));

src/backend/storage/smgr/md.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.103 2004/02/11 22:55:25 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/smgr/md.c,v 1.104 2004/04/19 17:42:58 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -607,7 +607,7 @@ mdsync(void)
607607
{
608608
sync();
609609
if (IsUnderPostmaster)
610-
sleep(2);
610+
pg_usleep(2000000L);
611611
sync();
612612
return true;
613613
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy