Re: Use atexit() in initdb and pg_basebackup

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use atexit() in initdb and pg_basebackup
Date: 2019-01-04 19:35:51
Message-ID: 201901041935.aqi5ogzbyiak@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2019-01-04 19:48:57 Re: "SELECT ... FROM DUAL" is not quite as silly as it appears
Previous Message Alvaro Herrera 2019-01-04 19:24:15 Re: Arrays of domain returned to client as non-builtin oid describing the array, not the base array type's oid