Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kToU3-00076u-QN for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Oct 2020 15:51:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kToU2-0002nj-D9 for pgsql-hackers@arkaria.postgresql.org; Sat, 17 Oct 2020 15:51:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kToU2-0002nb-6S for pgsql-hackers@lists.postgresql.org; Sat, 17 Oct 2020 15:51:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kToTz-0000cb-Up for pgsql-hackers@lists.postgresql.org; Sat, 17 Oct 2020 15:51:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 09HFov8Y117920; Sat, 17 Oct 2020 11:50:57 -0400 From: Tom Lane To: Alexander Lakhin cc: Victor Spirin , pgsql-hackers@lists.postgresql.org Subject: Re: Sometimes the output to the stdout in Windows disappears In-reply-to: References: <4124040.1598898684@sss.pgh.pa.us> <855416.1600022228@sss.pgh.pa.us> <4156857.1602865112@sss.pgh.pa.us> Comments: In-reply-to Alexander Lakhin message dated "Sat, 17 Oct 2020 11:00:02 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <117918.1602949857.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 17 Oct 2020 11:50:57 -0400 Message-ID: <117919.1602949857@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Lakhin writes: > 16.10.2020 19:18, Tom Lane wrote: >> What if we arranged to call WSAStartup just once, during the first >> libpq connection-open in a process, and then never did WSACleanup? >> Surely the OS can cope with that, and it eliminates any risk that >> WSACleanup breaks something. > What bothers me is: > There must be a call to *WSACleanup* for each successful call to > WSAStartup > . Yeah, that is a very odd statement. Surely, the Windows kernel manages to cope if a program crashes without having done that. So what exactly is the downside of intentionally not doing it? There's no reason to care if the Winsock DLL stays loaded until program exit rather than getting unloaded a bit earlier. (If anything, the current code causes an unload/reload cycle for each connection when the application makes a series of PG connections; who could think that's a great idea?) regards, tom lane