Re: [PATCHES] Implement support for TCP_KEEPCNT, TCP_KEEPIDLE, TCP_KEEPINTVL

Oliver Jowett <[email protected]> Mon, 12 Sep 2005 12:59:46 +1200
Newsgroups gmane.comp.db.postgresql.devel.win32,gmane.comp.db.postgresql.devel.patches
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------020807010000040500060901
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Tom Lane wrote:
> So the postmaster-log message may be the best we can do ...
> but I don't think we should drop the connection.

Here's a patch to do that; it appears to work as intended on my Linux
system.

-O

--------------020807010000040500060901
Content-Type: text/plain;
 name="pgsql-keepalives-noerror.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="pgsql-keepalives-noerror.txt"

Index: src/backend/libpq/pqcomm.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/libpq/pqcomm.c,v
retrieving revision 1.178
diff -c -r1.178 pqcomm.c
*** src/backend/libpq/pqcomm.c	30 Jul 2005 20:28:20 -0000	1.178
--- src/backend/libpq/pqcomm.c	12 Sep 2005 00:58:15 -0000
***************
*** 595,612 ****
  			return STATUS_ERROR;
  		}
  
! 		/* Set default keepalive parameters. This should also catch
! 		 * misconfigurations (non-zero values when socket options aren't
! 		 * supported)
  		 */
! 		if (pq_setkeepalivesidle(tcp_keepalives_idle, port) != STATUS_OK)
! 			return STATUS_ERROR;
! 
! 		if (pq_setkeepalivesinterval(tcp_keepalives_interval, port) != STATUS_OK)
! 			return STATUS_ERROR;
! 
! 		if (pq_setkeepalivescount(tcp_keepalives_count, port) != STATUS_OK)
! 			return STATUS_ERROR;
  	}
  
  	return STATUS_OK;
--- 595,607 ----
  			return STATUS_ERROR;
  		}
  
! 		/* Set default keepalive parameters. We ignore misconfigurations
! 		 * that cause errors -- they will be logged, but won't kill the
! 		 * connection.
  		 */
! 		pq_setkeepalivesidle(tcp_keepalives_idle, port);
! 		pq_setkeepalivesinterval(tcp_keepalives_interval, port);
! 		pq_setkeepalivescount(tcp_keepalives_count, port);
  	}
  
  	return STATUS_OK;

--------------020807010000040500060901
Content-Type: text/plain
Content-Disposition: inline
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

               http://archives.postgresql.org

--------------020807010000040500060901--