diff options
author | Robert Haas <rhaas@postgresql.org> | 2010-07-06 21:14:25 +0000 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2010-07-06 21:14:25 +0000 |
commit | 5acd417c8f0f720418560360d9b3e543d593e4f0 (patch) | |
tree | fc0adb50cf0229f721c42a3f05e2a232bb97cc0a /src/interfaces/libpq/fe-connect.c | |
parent | 3f12653b73f8f2ffdfecfde3272caebdbdd4262f (diff) |
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.
Diffstat (limited to 'src/interfaces/libpq/fe-connect.c')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 2c8a0593471..5bb404fc27e 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -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; |