Skip to content

Commit 4550096

Browse files
committed
StreamConnection() mustn't call elog().
1 parent b1134e3 commit 4550096

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* Copyright (c) 1994, Regents of the University of California
3030
*
31-
* $Id: pqcomm.c,v 1.82 1999/08/31 04:26:37 tgl Exp $
31+
* $Id: pqcomm.c,v 1.83 1999/09/08 22:57:12 tgl Exp $
3232
*
3333
*-------------------------------------------------------------------------
3434
*/
@@ -335,6 +335,10 @@ StreamServerPort(char *hostName, unsigned short portName, int *fdP)
335335
* the Postmaster uses select() to tell when the server master
336336
* socket is ready for accept().
337337
*
338+
* NB: this can NOT call elog() because it is invoked in the postmaster,
339+
* not in standard backend context. If we get an error, the best we can do
340+
* is log it to stderr.
341+
*
338342
* RETURNS: STATUS_OK or STATUS_ERROR
339343
*/
340344
int
@@ -348,7 +352,7 @@ StreamConnection(int server_fd, Port *port)
348352
(struct sockaddr *) & port->raddr,
349353
&addrlen)) < 0)
350354
{
351-
elog(ERROR, "postmaster: StreamConnection: accept: %m");
355+
perror("postmaster: StreamConnection: accept");
352356
return STATUS_ERROR;
353357
}
354358

@@ -357,7 +361,7 @@ StreamConnection(int server_fd, Port *port)
357361
if (getsockname(port->sock, (struct sockaddr *) & port->laddr,
358362
&addrlen) < 0)
359363
{
360-
elog(ERROR, "postmaster: StreamConnection: getsockname: %m");
364+
perror("postmaster: StreamConnection: getsockname");
361365
return STATUS_ERROR;
362366
}
363367

@@ -370,13 +374,13 @@ StreamConnection(int server_fd, Port *port)
370374
pe = getprotobyname("TCP");
371375
if (pe == NULL)
372376
{
373-
elog(ERROR, "postmaster: getprotobyname failed");
377+
perror("postmaster: StreamConnection: getprotobyname");
374378
return STATUS_ERROR;
375379
}
376380
if (setsockopt(port->sock, pe->p_proto, TCP_NODELAY,
377381
&on, sizeof(on)) < 0)
378382
{
379-
elog(ERROR, "postmaster: setsockopt failed: %m");
383+
perror("postmaster: StreamConnection: setsockopt");
380384
return STATUS_ERROR;
381385
}
382386
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy