Skip to content

Commit 9a94629

Browse files
committed
Don't dump core if pq_comm_reset() is called before pq_init().
This can happen if an error occurs in a standalone backend. This bug was introduced by commit 2bd9e41. Reported by Álvaro Herrera.
1 parent 5ede3a3 commit 9a94629

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/backend/libpq/pqcomm.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ char *Unix_socket_group;
105105
/* Where the Unix socket files are (list of palloc'd strings) */
106106
static List *sock_paths = NIL;
107107

108-
PQcommMethods *PqCommMethods;
109-
110-
111108
/*
112109
* Buffers for low-level I/O.
113110
*
@@ -154,8 +151,6 @@ static int Lock_AF_UNIX(char *unixSocketDir, char *unixSocketPath);
154151
static int Setup_AF_UNIX(char *sock_path);
155152
#endif /* HAVE_UNIX_SOCKETS */
156153

157-
PQcommMethods PQcommSocketMethods;
158-
159154
static PQcommMethods PqCommSocketMethods = {
160155
socket_comm_reset,
161156
socket_flush,
@@ -167,6 +162,9 @@ static PQcommMethods PqCommSocketMethods = {
167162
socket_endcopyout
168163
};
169164

165+
PQcommMethods *PqCommMethods = &PqCommSocketMethods;
166+
167+
170168

171169
/* --------------------------------
172170
* pq_init - initialize libpq at backend startup
@@ -175,7 +173,6 @@ static PQcommMethods PqCommSocketMethods = {
175173
void
176174
pq_init(void)
177175
{
178-
PqCommMethods = &PqCommSocketMethods;
179176
PqSendBufferSize = PQ_SEND_BUFFER_SIZE;
180177
PqSendBuffer = MemoryContextAlloc(TopMemoryContext, PqSendBufferSize);
181178
PqSendPointer = PqSendStart = PqRecvPointer = PqRecvLength = 0;

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