Tom Lane wrote:
> Alvaro Herrera <alvhe...@commandprompt.com> writes:
> > Tom Lane wrote:
> >> I guess I need to point out that those ereport calls already pose a far
> >> more substantial risk of palloc failure than the DLNewElem represents.
> 
> > Hmm, do they?  I mean, don't they use ErrorContext, which is supposed to
> > be preallocated?
> 
> Well, we'd like to think that they pose an insignificant risk, but it's
> hard to credit that DLNewElem isn't insignificant as well.

Yeah, actually as I said earlier, I haven't ever seen this.

> If you're really intent on doing something about this, my inclination
> would be to get rid of the dependence on DLNewElem altogether.  Add
> a Dlelem field to the Backend struct and use DLInitElem (compare
> the way catcache uses that module).

Hmm, yeah, I had seen that code.  So it looks like this instead.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
Index: src/backend/postmaster/postmaster.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/postmaster/postmaster.c,v
retrieving revision 1.551.2.1
diff -c -p -r1.551.2.1 postmaster.c
*** src/backend/postmaster/postmaster.c	27 Jun 2008 01:53:31 -0000	1.551.2.1
--- src/backend/postmaster/postmaster.c	7 Apr 2009 02:25:51 -0000
*************** typedef struct bkend
*** 142,147 ****
--- 142,148 ----
  	long		cancel_key;		/* cancel key for cancels for this backend */
  	bool		is_autovacuum;	/* is it an autovacuum process? */
  	bool		dead_end;		/* is it going to send an error and quit? */
+ 	Dlelem		elem;			/* self pointer into BackendList */
  } Backend;
  
  static Dllist *BackendList;
*************** CleanupBackend(int pid,
*** 2343,2349 ****
  #endif
  			DLRemove(curr);
  			free(bp);
- 			DLFreeElem(curr);
  			break;
  		}
  	}
--- 2344,2349 ----
*************** HandleChildCrash(int pid, int exitstatus
*** 2390,2396 ****
  #endif
  			DLRemove(curr);
  			free(bp);
- 			DLFreeElem(curr);
  			/* Keep looping so we can signal remaining backends */
  		}
  		else
--- 2390,2395 ----
*************** BackendStartup(Port *port)
*** 2857,2863 ****
  	bn->cancel_key = MyCancelKey;
  	bn->is_autovacuum = false;
  	bn->dead_end = (port->canAcceptConnections != CAC_OK);
! 	DLAddHead(BackendList, DLNewElem(bn));
  #ifdef EXEC_BACKEND
  	if (!bn->dead_end)
  		ShmemBackendArrayAdd(bn);
--- 2856,2864 ----
  	bn->cancel_key = MyCancelKey;
  	bn->is_autovacuum = false;
  	bn->dead_end = (port->canAcceptConnections != CAC_OK);
! 
! 	DLInitElem(&bn->elem, bn);
! 	DLAddHead(BackendList, &bn->elem);
  #ifdef EXEC_BACKEND
  	if (!bn->dead_end)
  		ShmemBackendArrayAdd(bn);
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to