Re: Use atexit() in initdb and pg_basebackup - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: Use atexit() in initdb and pg_basebackup
Date
Msg-id 201901041935.aqi5ogzbyiak@alvherre.pgsql
Whole thread Raw
In response to Use atexit() in initdb and pg_basebackup  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: Use atexit() in initdb and pg_basebackup  (Michael Paquier <michael@paquier.xyz>)
Re: Use atexit() in initdb and pg_basebackup  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Arrays of domain returned to client as non-builtin oiddescribing the array, not the base array type's oid
Next
From: Tom Lane
Date:
Subject: Re: "SELECT ... FROM DUAL" is not quite as silly as it appears