Skip to content
Snippets Groups Projects
Commit 45500964 authored by Tom Lane's avatar Tom Lane
Browse files

StreamConnection() mustn't call elog().

parent b1134e36
No related branches found
No related tags found
No related merge requests found
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: pqcomm.c,v 1.82 1999/08/31 04:26:37 tgl Exp $ * $Id: pqcomm.c,v 1.83 1999/09/08 22:57:12 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -335,6 +335,10 @@ StreamServerPort(char *hostName, unsigned short portName, int *fdP) ...@@ -335,6 +335,10 @@ StreamServerPort(char *hostName, unsigned short portName, int *fdP)
* the Postmaster uses select() to tell when the server master * the Postmaster uses select() to tell when the server master
* socket is ready for accept(). * socket is ready for accept().
* *
* NB: this can NOT call elog() because it is invoked in the postmaster,
* not in standard backend context. If we get an error, the best we can do
* is log it to stderr.
*
* RETURNS: STATUS_OK or STATUS_ERROR * RETURNS: STATUS_OK or STATUS_ERROR
*/ */
int int
...@@ -348,7 +352,7 @@ StreamConnection(int server_fd, Port *port) ...@@ -348,7 +352,7 @@ StreamConnection(int server_fd, Port *port)
(struct sockaddr *) & port->raddr, (struct sockaddr *) & port->raddr,
&addrlen)) < 0) &addrlen)) < 0)
{ {
elog(ERROR, "postmaster: StreamConnection: accept: %m"); perror("postmaster: StreamConnection: accept");
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -357,7 +361,7 @@ StreamConnection(int server_fd, Port *port) ...@@ -357,7 +361,7 @@ StreamConnection(int server_fd, Port *port)
if (getsockname(port->sock, (struct sockaddr *) & port->laddr, if (getsockname(port->sock, (struct sockaddr *) & port->laddr,
&addrlen) < 0) &addrlen) < 0)
{ {
elog(ERROR, "postmaster: StreamConnection: getsockname: %m"); perror("postmaster: StreamConnection: getsockname");
return STATUS_ERROR; return STATUS_ERROR;
} }
...@@ -370,13 +374,13 @@ StreamConnection(int server_fd, Port *port) ...@@ -370,13 +374,13 @@ StreamConnection(int server_fd, Port *port)
pe = getprotobyname("TCP"); pe = getprotobyname("TCP");
if (pe == NULL) if (pe == NULL)
{ {
elog(ERROR, "postmaster: getprotobyname failed"); perror("postmaster: StreamConnection: getprotobyname");
return STATUS_ERROR; return STATUS_ERROR;
} }
if (setsockopt(port->sock, pe->p_proto, TCP_NODELAY, if (setsockopt(port->sock, pe->p_proto, TCP_NODELAY,
&on, sizeof(on)) < 0) &on, sizeof(on)) < 0)
{ {
elog(ERROR, "postmaster: setsockopt failed: %m"); perror("postmaster: StreamConnection: setsockopt");
return STATUS_ERROR; return STATUS_ERROR;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment