pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Use atexit() in initdb and pg_basebackup
Date: Fri, 4 Jan 2019 16:35:51 -0300
Message-ID: <201901041935.aqi5ogzbyiak@alvherre.pgsql> (raw)
In-Reply-To: <ec4135ba-84e9-28bf-b584-0e78d47448d5@2ndquadrant.com>

On 2018-Dec-29, Peter Eisentraut wrote:

> @@ -387,6 +388,7 @@ StreamLog(void)
>  	if (!conn)
>  		/* Error message already written in GetConnection() */
>  		return;
> +	atexit(disconnect_atexit);
>  
>  	if (!CheckServerVersionForStreaming(conn))
>  	{

Seems you're registering the atexit cb twice here; you should only do so
in the first "!conn" block.

It would be nicer to be able to call atexit() in GetConnection() instead
of at each callsite, but that would require a place to save each conn
struct into, which is probably more work than warranted.

> @@ -3438,5 +3437,8 @@ main(int argc, char *argv[])
>  
>  	destroyPQExpBuffer(start_db_cmd);
>  
> +	/* prevent cleanup */
> +	made_new_pgdata = found_existing_pgdata = made_new_xlogdir = found_existing_xlogdir = false;
> +
>  	return 0;
>  }

This is a bit ugly, but meh.

Other than the first point, LGTM.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (6+ messages)  latest in thread

Message-ID: <201901041935.aqi5ogzbyiak@alvherre.pgsql>
Permalink:  ../201901041935.aqi5ogzbyiak@alvherre.pgsql/
Also on:    postgresql.org/message-id/201901041935.aqi5ogzbyiak@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, peter.eisentraut@2ndquadrant.com
  Subject: Re: Use atexit() in initdb and pg_basebackup
  In-Reply-To: <201901041935.aqi5ogzbyiak@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox