mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
Win32:
* Mostly, casting etc to remove compilation warnings in win32 only code. * main.c: set _IONBF to stdout/stderr under win32 (under win32, _IOLBF defaults to full buffering) * pg_resetxlog/Makefile: ensures dirmod.o gets cleaned (got bitten by this when, after "make clean"ing, switching compilation between Ming + Cygwin) Claudio Natoli
This commit is contained in:
@@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.74 2004/02/22 21:26:55 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/main/main.c,v 1.75 2004/03/05 01:11:04 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@@ -91,7 +91,14 @@ main(int argc, char *argv[])
|
|||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
{
|
{
|
||||||
WSADATA wsaData;
|
WSADATA wsaData;
|
||||||
int err = WSAStartup(MAKEWORD(2,2), &wsaData);
|
int err;
|
||||||
|
|
||||||
|
/* Make output streams unbuffered by default */
|
||||||
|
setvbuf(stdout,NULL,_IONBF,0);
|
||||||
|
setvbuf(stderr,NULL,_IONBF,0);
|
||||||
|
|
||||||
|
/* Prepare Winsock */
|
||||||
|
err = WSAStartup(MAKEWORD(2,2), &wsaData);
|
||||||
if (err != 0)
|
if (err != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: WSAStartup failed: %d\n",
|
fprintf(stderr, "%s: WSAStartup failed: %d\n",
|
||||||
@@ -99,6 +106,7 @@ main(int argc, char *argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Start our win32 signal implementation */
|
||||||
pgwin32_signal_initialize();
|
pgwin32_signal_initialize();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -8,4 +8,9 @@
|
|||||||
#define pg_dlclose dlclose
|
#define pg_dlclose dlclose
|
||||||
#define pg_dlerror dlerror
|
#define pg_dlerror dlerror
|
||||||
|
|
||||||
|
char* dlerror(void);
|
||||||
|
int dlclose(void *handle);
|
||||||
|
void* dlsym(void *handle, const char *symbol);
|
||||||
|
void* dlopen(const char *path, int mode);
|
||||||
|
|
||||||
#endif /* PORT_PROTOS_H */
|
#endif /* PORT_PROTOS_H */
|
||||||
|
@@ -37,7 +37,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.369 2004/02/25 19:41:22 momjian Exp $
|
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.370 2004/03/05 01:11:04 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
*
|
*
|
||||||
@@ -3525,29 +3525,29 @@ pid_t win32_forkexec(const char* path, char *argv[])
|
|||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
if (!CreateProcess(NULL,cmdLine,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
|
if (!CreateProcess(NULL,cmdLine,NULL,NULL,TRUE,0,NULL,NULL,&si,&pi))
|
||||||
{
|
{
|
||||||
elog(ERROR,"CreateProcess call failed (%d): %m",GetLastError());
|
elog(ERROR,"CreateProcess call failed (%i): %m",(int)GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
/* We are the Postmaster creating a child... */
|
/* We are the Postmaster creating a child... */
|
||||||
win32_AddChild(pi.dwProcessId,pi.hProcess);
|
win32_AddChild(pi.dwProcessId,pi.hProcess);
|
||||||
|
|
||||||
if (!DuplicateHandle(GetCurrentProcess(),
|
if (!DuplicateHandle(GetCurrentProcess(),
|
||||||
pi.hProcess,
|
pi.hProcess,
|
||||||
GetCurrentProcess(),
|
GetCurrentProcess(),
|
||||||
&childHandleCopy,
|
&childHandleCopy,
|
||||||
0,
|
0,
|
||||||
FALSE,
|
FALSE,
|
||||||
DUPLICATE_SAME_ACCESS))
|
DUPLICATE_SAME_ACCESS))
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg_internal("failed to duplicate child handle: %i",GetLastError())));
|
(errmsg_internal("failed to duplicate child handle: %i",(int)GetLastError())));
|
||||||
waiterThread = CreateThread(NULL, 64*1024, win32_sigchld_waiter, (LPVOID)childHandleCopy, 0, NULL);
|
waiterThread = CreateThread(NULL, 64*1024, win32_sigchld_waiter, (LPVOID)childHandleCopy, 0, NULL);
|
||||||
if (!waiterThread)
|
if (!waiterThread)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg_internal("failed to create sigchld waiter thread: %i",GetLastError())));
|
(errmsg_internal("failed to create sigchld waiter thread: %i",(int)GetLastError())));
|
||||||
CloseHandle(waiterThread);
|
CloseHandle(waiterThread);
|
||||||
|
|
||||||
if (IsUnderPostmaster)
|
if (IsUnderPostmaster)
|
||||||
CloseHandle(pi.hProcess);
|
CloseHandle(pi.hProcess);
|
||||||
CloseHandle(pi.hThread);
|
CloseHandle(pi.hThread);
|
||||||
@@ -3600,14 +3600,14 @@ static void win32_RemoveChild(pid_t pid)
|
|||||||
|
|
||||||
/* Something stronger than WARNING here? */
|
/* Something stronger than WARNING here? */
|
||||||
ereport(WARNING,
|
ereport(WARNING,
|
||||||
(errmsg_internal("unable to find child entry with pid %d",
|
(errmsg_internal("unable to find child entry with pid %lu",
|
||||||
pid)));
|
pid)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static pid_t win32_waitpid(int *exitstatus)
|
static pid_t win32_waitpid(int *exitstatus)
|
||||||
{
|
{
|
||||||
Assert(win32_childPIDArray && win32_childHNDArray);
|
Assert(win32_childPIDArray && win32_childHNDArray);
|
||||||
elog(DEBUG3,"waiting on %d children",win32_numChildren);
|
elog(DEBUG3,"waiting on %lu children",win32_numChildren);
|
||||||
|
|
||||||
if (win32_numChildren > 0)
|
if (win32_numChildren > 0)
|
||||||
{
|
{
|
||||||
@@ -3623,8 +3623,8 @@ static pid_t win32_waitpid(int *exitstatus)
|
|||||||
{
|
{
|
||||||
case WAIT_FAILED:
|
case WAIT_FAILED:
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errmsg_internal("failed to wait on %d children: %i",
|
(errmsg_internal("failed to wait on %lu children: %i",
|
||||||
win32_numChildren,GetLastError())));
|
win32_numChildren,(int)GetLastError())));
|
||||||
/* Fall through to WAIT_TIMEOUTs return */
|
/* Fall through to WAIT_TIMEOUTs return */
|
||||||
|
|
||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
@@ -3641,7 +3641,7 @@ static pid_t win32_waitpid(int *exitstatus)
|
|||||||
* No choice other than to assume a catastrophic failure.
|
* No choice other than to assume a catastrophic failure.
|
||||||
*/
|
*/
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
(errmsg_internal("failed to get exit code for child %d",
|
(errmsg_internal("failed to get exit code for child %lu",
|
||||||
win32_childPIDArray[index])));
|
win32_childPIDArray[index])));
|
||||||
*exitstatus = (int)exitCode;
|
*exitstatus = (int)exitCode;
|
||||||
return win32_childPIDArray[index];
|
return win32_childPIDArray[index];
|
||||||
@@ -3661,7 +3661,7 @@ static DWORD WINAPI win32_sigchld_waiter(LPVOID param) {
|
|||||||
if (r == WAIT_OBJECT_0)
|
if (r == WAIT_OBJECT_0)
|
||||||
pg_queue_signal(SIGCHLD);
|
pg_queue_signal(SIGCHLD);
|
||||||
else
|
else
|
||||||
fprintf(stderr,"ERROR: Failed to wait on child process handle: %i\n",GetLastError());
|
fprintf(stderr,"ERROR: Failed to wait on child process handle: %i\n",(int)GetLastError());
|
||||||
CloseHandle(procHandle);
|
CloseHandle(procHandle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
|
# Copyright (c) 1998-2002, PostgreSQL Global Development Group
|
||||||
#
|
#
|
||||||
# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.5 2004/02/10 23:24:13 tgl Exp $
|
# $PostgreSQL: pgsql/src/bin/pg_resetxlog/Makefile,v 1.6 2004/03/05 01:11:04 momjian Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -38,4 +38,4 @@ uninstall:
|
|||||||
rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
|
rm -f $(DESTDIR)$(bindir)/pg_resetxlog$(X)
|
||||||
|
|
||||||
clean distclean maintainer-clean:
|
clean distclean maintainer-clean:
|
||||||
rm -f pg_resetxlog$(X) pg_resetxlog.o pg_crc.o pg_crc.c dirmod.c
|
rm -f pg_resetxlog$(X) pg_crc.c dirmod.c $(OBJS)
|
||||||
|
Reference in New Issue
Block a user