X-Original-To: pgsql-hackers-win32-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AE2A1D80DF; Thu, 8 Sep 2005 20:33:14 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 60301-02; Thu, 8 Sep 2005 23:33:11 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id A4795D6F0D; Thu, 8 Sep 2005 20:33:11 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EDVtA-0000Z2-D6; Fri, 09 Sep 2005 11:33:12 +1200 Message-ID: <4320CA2E.1000104@opencloud.com> Date: Fri, 09 Sep 2005 11:33:02 +1200 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050324) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane Cc: Merlin Moncure , pgsql-patches@postgresql.org, pgsql-hackers-win32@postgresql.org Subject: Re: [PATCHES] Implement support for TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL References: <6EE64EF3AB31D5448D0007DD34EEB3417DD2C6@Herge.rcsinc.local> <4320C4BE.7010306@opencloud.com> <26590.1126221622@sss.pgh.pa.us> In-Reply-To: <26590.1126221622@sss.pgh.pa.us> X-Enigmail-Version: 0.90.2.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.008 required=5 tests=[AWL=0.008] X-Spam-Level: X-Archive-Number: 200509/11 X-Sequence-Number: 3377 Tom Lane wrote: > Oliver Jowett writes: > >>Merlin Moncure wrote: >> >>>Even better would be a stronger test to make sure o/s supports this >>>feature. > > >>Well, the code assumes that if the TCP_* constants are present then they >>can be used. It seems a bit stupid if Windows defines them but doesn't >>support them at all. > In short, if you were assuming that then you'd better fix the code. Sorry, to clarify: If the TCP_* constants are provided, *and* you configure the backend to try to use non-default values, then the code will try the appropriate setsockopt(). If that fails, then the connection gets dropped. If you don't change the defaults, it doesn't use setsockopt() at all. The assumption I'm making is that if the TCP_* values are present at compile time, then you can make a setsockopt() call and get a sane error code back if there's no support -- rather than a segfault, or having the OS spontaneously do weird things to the connection, or anything like that. Is that a reasonable thing to assume? ... There doesn't seem any clean way to test if a particular set of values specified at runtime is going to work or not -- the only way is to try. I suppose we could set up a dummy TCP connection on postmaster start and try that, but.. We could potentially do better in the "no TCP_* support" case, detecting it on postmaster startup (move the check for NULL port down into the pqcomm code, and complain about non-zero values even in that case if there's no support); but that doesn't help the other cases. If I specify out-of-range values on my Linux box, I get this: > oliver@extrashiny ~ $ pg/8.1-beta1/bin/psql -h localhost template1 > psql: server closed the connection unexpectedly > This probably means the server terminated abnormally > before or while processing the request. and in the logs: > LOG: setsockopt(TCP_KEEPIDLE) failed: Invalid argument I'd expect to see something similar in the "TCP_* present but no real support" case. -O