Commit a28d04e6 authored by Bruce Momjian's avatar Bruce Momjian

This patch updates pgpipe() on win32 to log exactly which part of the

call fails when it does. (As it is now, there is no way to figure out
the point of error). Shouldn't be a problem since it's most defintily
not a performance-critical path (only called on pgstat startup ATM).

This should help us debug the pipe error message that's on the win32
status page (which I myself have never been able to reproduce, and thus
haven't figured out a better way to debug yet)

Magnus Hagander
parent 7643bed5
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* must be replaced with recv/send. * must be replaced with recv/send.
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/port/pipe.c,v 1.4 2004/05/18 20:18:59 momjian Exp $ * $PostgreSQL: pgsql/src/port/pipe.c,v 1.5 2004/06/11 03:48:35 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -28,24 +28,49 @@ pgpipe(int handles[2]) ...@@ -28,24 +28,49 @@ pgpipe(int handles[2])
handles[0] = handles[1] = INVALID_SOCKET; handles[0] = handles[1] = INVALID_SOCKET;
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{
ereport(LOG,(errmsg_internal("pgpipe failed to create socket: %ui",WSAGetLastError())));
return -1; return -1;
}
memset((void *) &serv_addr, 0, sizeof(serv_addr)); memset((void *) &serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
serv_addr.sin_port = htons(0); serv_addr.sin_port = htons(0);
serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR || if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
listen(s, 1) == SOCKET_ERROR || {
getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR || ereport(LOG,(errmsg_internal("pgpipe failed to bind: %ui",WSAGetLastError())));
(handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) closesocket(s);
return -1;
}
if (listen(s, 1) == SOCKET_ERROR)
{
ereport(LOG,(errmsg_internal("pgpipe failed to listen: %ui",WSAGetLastError())));
closesocket(s);
return -1;
}
if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
{
ereport(LOG,(errmsg_internal("pgpipe failed to getsockname: %ui",WSAGetLastError())));
closesocket(s);
return -1;
}
if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
{ {
ereport(LOG,(errmsg_internal("pgpipe failed to create socket 2: %ui",WSAGetLastError())));
closesocket(s); closesocket(s);
return -1; return -1;
} }
if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR || if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
(handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET) {
ereport(LOG,(errmsg_internal("pgpipe failed to connect socket: %ui",WSAGetLastError())));
closesocket(s);
return -1;
}
if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
{ {
ereport(LOG,(errmsg_internal("pgpipe failed to accept socket: %ui",WSAGetLastError())));
closesocket(handles[1]); closesocket(handles[1]);
handles[1] = INVALID_SOCKET; handles[1] = INVALID_SOCKET;
closesocket(s); closesocket(s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment