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 1kWNVZ-0000Ub-9Q for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Oct 2020 17:39:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kWNVX-0008KI-Hj for pgsql-bugs@arkaria.postgresql.org; Sat, 24 Oct 2020 17:39:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kWNVX-0008KB-BZ for pgsql-bugs@lists.postgresql.org; Sat, 24 Oct 2020 17:39:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kWNVU-0003xX-MH for pgsql-bugs@lists.postgresql.org; Sat, 24 Oct 2020 17:39:10 +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 09OHd5M9383223; Sat, 24 Oct 2020 13:39:06 -0400 From: Tom Lane To: Alexander Lakhin cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16678: The ecpg connect/test5 test sometimes fails on Windows In-reply-to: References: <16678-253e48d34dc0c376@postgresql.org> <434311.1603135136@sss.pgh.pa.us> Comments: In-reply-to Alexander Lakhin message dated "Sat, 24 Oct 2020 13:00:00 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <383221.1603561145.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Sat, 24 Oct 2020 13:39:05 -0400 Message-ID: <383222.1603561145@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Alexander Lakhin writes: > So I've also tested on Windows the following version: >         secure_close(MyProcPort); >         shutdown(MyProcPort->sock, SD_SEND); >         for(;;) { >             char buffer[1000]; >             int res = recv(MyProcPort->sock, buffer, 1000, 0); >             if (res <= 0) >                 break; >         } >         closesocket(MyProcPort->sock); > And it works too. I'm afraid this cure is probably worse than the disease, because now the backend's exiting is held hostage by whether the client closes its socket (and the resulting FIN reaches us, which it might not if there's a network problem). It might be safe to do the shutdown() only, since Microsoft specifies that that doesn't block, but I have no idea if that would improve matters. regards, tom lane