*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.585 2009/07/24 20:12:42 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.586 2009/08/06 09:50:22 mha Exp $
*
* NOTES
*
* mess with the half-started process
*/
if (!TerminateProcess(pi.hProcess, 255))
- ereport(ERROR,
+ ereport(LOG,
(errmsg_internal("could not terminate unstarted process: error code %d",
(int) GetLastError())));
CloseHandle(pi.hProcess);
* process and give up.
*/
if (!TerminateProcess(pi.hProcess, 255))
- ereport(ERROR,
+ ereport(LOG,
(errmsg_internal("could not terminate process that failed to reserve memory: error code %d",
(int) GetLastError())));
CloseHandle(pi.hProcess);
{
if (!TerminateProcess(pi.hProcess, 255))
{
- ereport(ERROR,
+ ereport(LOG,
(errmsg_internal("could not terminate unstartable process: error code %d",
(int) GetLastError())));
CloseHandle(pi.hProcess);
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
- ereport(ERROR,
+ ereport(LOG,
(errmsg_internal("could not resume thread of unstarted process: error code %d",
(int) GetLastError())));
return -1;
#define write_inheritable_socket(dest, src, childpid) (*(dest) = (src))
#define read_inheritable_socket(dest, src) (*(dest) = *(src))
#else
-static void write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE child);
-static void write_inheritable_socket(InheritableSocket *dest, SOCKET src,
+static bool write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE child);
+static bool write_inheritable_socket(InheritableSocket *dest, SOCKET src,
pid_t childPid);
static void read_inheritable_socket(SOCKET *dest, InheritableSocket *src);
#endif
#endif
{
memcpy(¶m->port, port, sizeof(Port));
- write_inheritable_socket(¶m->portsocket, port->sock, childPid);
+ if (!write_inheritable_socket(¶m->portsocket, port->sock, childPid))
+ return false;
strlcpy(param->DataDir, DataDir, MAXPGPATH);
param->ProcGlobal = ProcGlobal;
param->AuxiliaryProcs = AuxiliaryProcs;
param->PMSignalState = PMSignalState;
- write_inheritable_socket(¶m->pgStatSock, pgStatSock, childPid);
+ if (!write_inheritable_socket(¶m->pgStatSock, pgStatSock, childPid))
+ return false;
param->PostmasterPid = PostmasterPid;
param->PgStartTime = PgStartTime;
#ifdef WIN32
param->PostmasterHandle = PostmasterHandle;
- write_duplicated_handle(¶m->initial_signal_pipe,
+ if (!write_duplicated_handle(¶m->initial_signal_pipe,
pgwin32_create_signal_listener(childPid),
- childProcess);
+ childProcess))
+ return false;
#endif
memcpy(¶m->syslogPipe, &syslogPipe, sizeof(syslogPipe));
* Duplicate a handle for usage in a child process, and write the child
* process instance of the handle to the parameter file.
*/
-static void
+static bool
write_duplicated_handle(HANDLE *dest, HANDLE src, HANDLE childProcess)
{
HANDLE hChild = INVALID_HANDLE_VALUE;
0,
TRUE,
DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS))
- ereport(ERROR,
+ {
+ ereport(LOG,
(errmsg_internal("could not duplicate handle to be written to backend parameter file: error code %d",
(int) GetLastError())));
+ return false;
+ }
*dest = hChild;
+ return true;
}
/*
* common on Windows (antivirus, firewalls, download managers etc) break
* straight socket inheritance.
*/
-static void
+static bool
write_inheritable_socket(InheritableSocket *dest, SOCKET src, pid_t childpid)
{
dest->origsocket = src;
{
/* Actual socket */
if (WSADuplicateSocket(src, childpid, &dest->wsainfo) != 0)
- ereport(ERROR,
+ {
+ ereport(LOG,
(errmsg("could not duplicate socket %d for use in backend: error code %d",
src, WSAGetLastError())));
+ return false;
+ }
}
+ return true;
}
/*