Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dePS6-0000ap-Vd for pgsql-bugs@arkaria.postgresql.org; Sun, 06 Aug 2017 17:34:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dePS5-00047L-Hk for pgsql-bugs@arkaria.postgresql.org; Sun, 06 Aug 2017 17:34:57 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dePS4-00046W-ID for pgsql-bugs@postgresql.org; Sun, 06 Aug 2017 17:34:56 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dePRx-00043u-DP for pgsql-bugs@postgresql.org; Sun, 06 Aug 2017 17:34:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v76HYg9p003827; Sun, 6 Aug 2017 13:34:42 -0400 From: Tom Lane To: Andres Freund cc: Noah Misch , "Augustine, Jobin" , pgsql-bugs@postgresql.org Subject: Re: Replication to Postgres 10 on Windows is broken In-reply-to: <20170806171436.ve646fu4bpagdrc2@alap3.anarazel.de> References: <20170806062634.GA3180536@rfd.leadboat.com> <3819.1502032677@sss.pgh.pa.us> <20170806155037.GD3179882@rfd.leadboat.com> <6525.1502036947@sss.pgh.pa.us> <20170806171436.ve646fu4bpagdrc2@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Sun, 06 Aug 2017 10:14:36 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3825.1502040882.1@sss.pgh.pa.us> Date: Sun, 06 Aug 2017 13:34:42 -0400 Message-ID: <3826.1502040882@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Andres Freund writes: > On 2017-08-06 12:29:07 -0400, Tom Lane wrote: >> This is problematic, because the APIs in between don't provide a way >> to report that we're still waiting for connect rather than for >> data-write-ready. Anybody have the stomach for extending PQconnectPoll's >> API with an extra PGRES_POLLING_CONNECTING state? > I'm a bit hesitant to do so at this phase of the release cycle, I'm pretty hesitant to do that at *any* phase of the release cycle, it's just too likely to break user code. However, there's always more than one way to skin the cat. What we need to know is whether PQconnectPoll's state machine is in CONNECTION_STARTED state, and PQstatus() does expose that, even though it claims it's an internal state that callers shouldn't rely on. So here's a sketch: * Invent a separate WL_SOCKET_CONNECTED flag for WaitLatchOrSocket. On Unix we can treat that the same as WL_SOCKET_WRITEABLE, on Windows it maps to FD_CONNECT. * In libpqwalreceiver, do something like io_flag = (status == PGRES_POLLING_READING ? WL_SOCKET_READABLE #ifdef WIN32 : PQstatus(conn->streamConn) == CONNECTION_STARTED ? WL_SOCKET_CONNECTED #endif : WL_SOCKET_WRITEABLE); The #ifdef's optional, but no reason to spend extra cycles if we don't have to. (Not sure if this is adequately parenthesized...) regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs