Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfVGE-0000gW-O3 for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jan 2019 19:36:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gfVGD-0005bN-BR for pgsql-hackers@arkaria.postgresql.org; Fri, 04 Jan 2019 19:36:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfVGD-0005bG-0E for pgsql-hackers@lists.postgresql.org; Fri, 04 Jan 2019 19:36:01 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gfVGA-0005NN-4P for pgsql-hackers@postgresql.org; Fri, 04 Jan 2019 19:36:00 +0000 Received: by mail-qt1-x842.google.com with SMTP id n32so41451860qte.11 for ; Fri, 04 Jan 2019 11:35:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=zsniZYx0vvyVtb4BjLHbg9Hv8gCPpLvyeEwqaOX7pto=; b=mIDMIOtBB3Nr8K+2iD1lkVFUo0nLl9Yhw4ndxyFApDQr5mdjfGuKzp+V6cdiBuHkJ0 h5cBn2WlCbSgd5UWhlGcUtgg/TrbwzGGZb9HI4CKq8B2siMqLJ0kLWiJkqYP8Rln5PRi aiaDoUBznJbAwTHBI4ryHIXlQ08Kf9/pQJSUNsiliGXZ60ii8ew7kXoMVm0djfLYC6AF ZyG1yprFZ54+RyBvPOtJk9KD/KIEvWRQZ8Ob2j72O8Cv05rSUIv1ek1tHCS4e0xAaYl3 0VmGT99c47sruWV6xkRVvlIMiq0OJX4fvm8xGokqT1m4fyIAMrvTQVd59MBtlCAx7qIT 4Q1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=zsniZYx0vvyVtb4BjLHbg9Hv8gCPpLvyeEwqaOX7pto=; b=RgV71ikhJBHe/wTTjVLPx4lprR8C1LJS/l94Na0ZTD+xXnTbgQkw917KlJJKoSU1cu do2MH6IROJNZ4W9UWJgJJk4gpoQoosAioioHcOzC4CqFuWKKBkf4TWPuit89KGtz2+8Z cMDt6KzuVkCk9SbNpujV68j4r2iqzhMbnXsbt7EbXAL4sBnVhhWA/FuTQU2bNUkWzyXK 748qD16c+5pmo3zlI0Prn0BKHp+1u33sntBm/qZjWPOBVOFPj5L3LiNtucGLflgcGu3+ 7F5Bmt1sIAm00lp/bx1g0a04BH+/zhlAE/7LLDR9lRxzqK3kO7UfsZLyAV7NvUJnGxJl lAYg== X-Gm-Message-State: AA+aEWagjdKB4VCXcZj3KLaBnYGOY3pWaf+8YYXzLxtnIbZeUdOYw03T TnfpPnidpeH3TtCSuxWeeLPzQgG/FSE= X-Google-Smtp-Source: AFSGD/WbUFTrsW5zeEQzzAxdfsrrfQ7IQOdRlEjvbEhk0XnoMZ4rNsw1Po77ymUAJw3mODCt2LCmhA== X-Received: by 2002:aed:2539:: with SMTP id v54mr50637018qtc.211.1546630555106; Fri, 04 Jan 2019 11:35:55 -0800 (PST) Received: from alvin.alvh.no-ip.org ([190.217.219.6]) by smtp.gmail.com with ESMTPSA id 46sm35194610qtv.22.2019.01.04.11.35.54 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 Jan 2019 11:35:54 -0800 (PST) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 505DC9F8; Fri, 4 Jan 2019 16:35:51 -0300 (-03) Date: Fri, 4 Jan 2019 16:35:51 -0300 From: Alvaro Herrera To: Peter Eisentraut Cc: pgsql-hackers Subject: Re: Use atexit() in initdb and pg_basebackup Message-ID: <201901041935.aqi5ogzbyiak@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716-1013-2c1e88 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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