mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
Support setting the keepalive idle time on MacOS X.
MacOS X uses TCP_KEEPALIVE rather than TCP_KEEPIDLE for this purpose. Thanks to Fujii Masao for the review.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.395 2010/07/06 19:19:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.396 2010/07/06 21:14:25 rhaas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -1008,6 +1008,20 @@ setKeepalivesIdle(PGconn *conn)
|
||||
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#ifdef TCP_KEEPALIVE
|
||||
/* Darwin uses TCP_KEEPALIVE rather than TCP_KEEPIDLE */
|
||||
if (setsockopt(conn->sock, IPPROTO_TCP, TCP_KEEPALIVE,
|
||||
(char *) &idle, sizeof(idle)) < 0)
|
||||
{
|
||||
char sebuf[256];
|
||||
|
||||
appendPQExpBuffer(&conn->errorMessage,
|
||||
libpq_gettext("setsockopt(TCP_KEEPALIVE) failed: %s\n"),
|
||||
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user