Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dQDOd-000402-Es for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Jun 2017 13:52:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dQDOd-0003NX-1a for pgsql-bugs@arkaria.postgresql.org; Wed, 28 Jun 2017 13:52:43 +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 1dQDOb-0003Fz-SX for pgsql-bugs@postgresql.org; Wed, 28 Jun 2017 13:52:42 +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 1dQDOZ-0005VJ-Ed for pgsql-bugs@postgresql.org; Wed, 28 Jun 2017 13:52:40 +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 v5SDqaud008595; Wed, 28 Jun 2017 09:52:36 -0400 From: Tom Lane To: Alvaro Herrera cc: lizenko79@gmail.com, Michael Paquier , pgsql-bugs@postgresql.org Subject: Re: BUG #14720: getsockopt(TCP_KEEPALIVE) failed: Option not supported by protocol In-reply-to: <1982.1498602401@sss.pgh.pa.us> References: <20170627191732.bqh677xgt5bbdo7t@alvherre.pgsql> <20527.1498594613@sss.pgh.pa.us> <1982.1498602401@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Tue, 27 Jun 2017 18:26:41 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8593.1498657956.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 28 Jun 2017 09:52:36 -0400 Message-ID: <8594.1498657956@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 I wrote: > Concretely, something like the attached. I have no way to test this > locally, so I'm thinking of just pushing it and seeing what the buildfarm > says. So that didn't work: castoroides is still showing [5953a7e1.1fff:13] LOG: getsockopt(TCP_KEEPALIVE) failed: Option not suppo= rted by protocol [5953a7e1.1fff:14] STATEMENT: select name, setting from pg_settings where = name like 'enable%'; which implies that TCP_KEEPALIVE_THRESHOLD doesn't exist on Solaris 10. Evidently, the logic here needs to be along the lines of #if defined(TCP_KEEPIDLE) ... #elif defined(TCP_KEEPALIVE_THRESHOLD) ... #elif defined(TCP_KEEPALIVE) && defined(__darwin__) ... Or we could make the last test be !defined(__solaris__), but I'm not sure that's better. Anybody have an opinion? As long as I have to touch this code again anyway, I'm also going to look into Michael's thought of trying to reduce code duplication. I was unhappy yesterday about how to handle the error messages, but we could do it like this: #if defined(TCP_KEEPIDLE) #define PG_TCP_KEEPALIVE TCP_KEEPIDLE #define PG_TCP_KEEPALIVE_STR "TCP_KEEPIDLE" #elif ... #ifdef PG_TCP_KEEPALIVE if (setsockopt(port->sock, IPPROTO_TCP, PG_TCP_KEEPALIVE, (char *) &idle, sizeof(idle)) < 0) { elog(LOG, "setsockopt(%s) failed: %m", PG_TCP_KEEPALIVE_STR); which doesn't seem too painful. regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs