Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a28d04e

Browse files
committed
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
1 parent 7643bed commit a28d04e

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

src/port/pipe.c

+32-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* must be replaced with recv/send.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/port/pipe.c,v 1.4 2004/05/18 20:18:59 momjian Exp $
13+
* $PostgreSQL: pgsql/src/port/pipe.c,v 1.5 2004/06/11 03:48:35 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -28,24 +28,49 @@ pgpipe(int handles[2])
2828
handles[0] = handles[1] = INVALID_SOCKET;
2929

3030
if ((s = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
31+
{
32+
ereport(LOG,(errmsg_internal("pgpipe failed to create socket: %ui",WSAGetLastError())));
3133
return -1;
34+
}
3235

3336
memset((void *) &serv_addr, 0, sizeof(serv_addr));
3437
serv_addr.sin_family = AF_INET;
3538
serv_addr.sin_port = htons(0);
3639
serv_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
37-
if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR ||
38-
listen(s, 1) == SOCKET_ERROR ||
39-
getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR ||
40-
(handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
40+
if (bind(s, (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
41+
{
42+
ereport(LOG,(errmsg_internal("pgpipe failed to bind: %ui",WSAGetLastError())));
43+
closesocket(s);
44+
return -1;
45+
}
46+
if (listen(s, 1) == SOCKET_ERROR)
47+
{
48+
ereport(LOG,(errmsg_internal("pgpipe failed to listen: %ui",WSAGetLastError())));
49+
closesocket(s);
50+
return -1;
51+
}
52+
if (getsockname(s, (SOCKADDR *) & serv_addr, &len) == SOCKET_ERROR)
53+
{
54+
ereport(LOG,(errmsg_internal("pgpipe failed to getsockname: %ui",WSAGetLastError())));
55+
closesocket(s);
56+
return -1;
57+
}
58+
if ((handles[1] = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET)
4159
{
60+
ereport(LOG,(errmsg_internal("pgpipe failed to create socket 2: %ui",WSAGetLastError())));
4261
closesocket(s);
4362
return -1;
4463
}
4564

46-
if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR ||
47-
(handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
65+
if (connect(handles[1], (SOCKADDR *) & serv_addr, len) == SOCKET_ERROR)
66+
{
67+
ereport(LOG,(errmsg_internal("pgpipe failed to connect socket: %ui",WSAGetLastError())));
68+
closesocket(s);
69+
return -1;
70+
}
71+
if ((handles[0] = accept(s, (SOCKADDR *) & serv_addr, &len)) == INVALID_SOCKET)
4872
{
73+
ereport(LOG,(errmsg_internal("pgpipe failed to accept socket: %ui",WSAGetLastError())));
4974
closesocket(handles[1]);
5075
handles[1] = INVALID_SOCKET;
5176
closesocket(s);

0 commit comments

Comments
 (0)