Skip to content

Commit a1e1ef4

Browse files
committed
Avoid a memory allocation in the backend startup code, to avoid having to check
whether it failed. Modelled after catcache.c's usage of DlList, per suggestion from Tom.
1 parent d85c688 commit a1e1ef4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.578 2009/05/02 22:02:37 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.579 2009/05/04 02:24:17 alvherre Exp $
4141
*
4242
* NOTES
4343
*
@@ -143,6 +143,7 @@ typedef struct bkend
143143
long cancel_key; /* cancel key for cancels for this backend */
144144
bool is_autovacuum; /* is it an autovacuum process? */
145145
bool dead_end; /* is it going to send an error and quit? */
146+
Dlelem elem; /* self pointer into BackendList */
146147
} Backend;
147148

148149
static Dllist *BackendList;
@@ -2459,7 +2460,6 @@ CleanupBackend(int pid,
24592460
#endif
24602461
DLRemove(curr);
24612462
free(bp);
2462-
DLFreeElem(curr);
24632463
break;
24642464
}
24652465
}
@@ -2506,7 +2506,6 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
25062506
#endif
25072507
DLRemove(curr);
25082508
free(bp);
2509-
DLFreeElem(curr);
25102509
/* Keep looping so we can signal remaining backends */
25112510
}
25122511
else
@@ -3014,7 +3013,8 @@ BackendStartup(Port *port)
30143013
bn->is_autovacuum = false;
30153014
bn->dead_end = (port->canAcceptConnections != CAC_OK &&
30163015
port->canAcceptConnections != CAC_WAITBACKUP);
3017-
DLAddHead(BackendList, DLNewElem(bn));
3016+
DLInitElem(&bn->elem, bn);
3017+
DLAddHead(BackendList, &bn->elem);
30183018
#ifdef EXEC_BACKEND
30193019
if (!bn->dead_end)
30203020
ShmemBackendArrayAdd(bn);

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