Skip site navigation (1) Skip section navigation (2)

Re: TCP keepalive support for libpq

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Euler Taveira de Oliveira <euler(at)timbira(dot)com>, Marko Kreen <markokr(at)gmail(dot)com>, Tollef Fog Heen <tollef(dot)fog(dot)heen(at)collabora(dot)co(dot)uk>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: TCP keepalive support for libpq
Date: 2010-06-23 04:20:02
Message-ID: AANLkTimK2cNU2lJVTFTKZulRGsmzXBXS7QOtFZ-qEFRb@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Wed, Jun 23, 2010 at 5:32 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> On Tue, Jun 22, 2010 at 3:45 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>> On Tue, Jun 22, 2010 at 3:28 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>>> Either I'm doing something wrong,
>>
>> I think it's this one.  Stand by.
>
> OK, here's a new version with several fewer bugs.

Since valid values for keepalives parameter are 0 and 1, its field size should
be 1 rather than 10.

diff --git a/src/interfaces/libpq/fe-connect.c
b/src/interfaces/libpq/fe-connect.c
index 8240404..f0085ab 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -184,7 +184,7 @@ static const PQconninfoOption PQconninfoOptions[] = {
        "Fallback-Application-Name", "", 64},

        {"keepalives", NULL, NULL, NULL,
-       "TCP-Keepalives", "", 10}, /* strlen(INT32_MAX) == 10 */
+       "TCP-Keepalives", "", 1},

        {"keepalives_idle", NULL, NULL, NULL,
        "TCP-Keepalives-Idle", "", 10}, /* strlen(INT32_MAX) == 10 */

In this case, you can check the value of keepalives parameter by seeing
conn->keepalives[0] instead of using strtol() in useKeepalives().

Regards,

-- 
Fujii Masao
NIPPON TELEGRAPH AND TELEPHONE CORPORATION
NTT Open Source Software Center

In response to

Responses

pgsql-hackers by date

Next:From: Sander, Ingo (NSN - DE/Munich)Date: 2010-06-23 08:48:01
Subject: Streaming Replication: sql error on standby
Previous:From: Dann CorbitDate: 2010-06-23 03:58:26
Subject: Re: Implementation of Date/Time Input Interpretation

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group