aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/misc/guc.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-09-12 02:26:33 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-09-12 02:26:33 +0000
commitcc3bda37f704dffb641a19d17d447e0eeb1a6c6c (patch)
tree9144b085be25ef1a613cb4e1fb6cf494a73f0f29 /src/backend/utils/misc/guc.c
parentf7a5f90c464cc68d70255923a8bd5046e0baba37 (diff)
downloadpostgresql-cc3bda37f704dffb641a19d17d447e0eeb1a6c6c.tar.gz
postgresql-cc3bda37f704dffb641a19d17d447e0eeb1a6c6c.zip
Tweak TCP-keepalive code so that an invalid setting doesn't cause us
to drop connections unceremoniously. Also some other marginal cleanups: don't query getsockopt() repeatedly if it fails, and avoid having the apparent definition of struct Port depend on which system headers you might have included or not. Oliver Jowett and Tom Lane.
Diffstat (limited to 'src/backend/utils/misc/guc.c')
-rw-r--r--src/backend/utils/misc/guc.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index b9e8ff3122e..1c44b0d2f77 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.287 2005/08/29 21:38:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.288 2005/09/12 02:26:32 tgl Exp $
*
*--------------------------------------------------------------------
*/
@@ -5884,10 +5884,8 @@ assign_canonical_path(const char *newval, bool doit, GucSource source)
static bool
assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
{
- if (doit && MyProcPort != NULL)
- {
+ if (doit)
return (pq_setkeepalivesidle(newval, MyProcPort) == STATUS_OK);
- }
return true;
}
@@ -5895,18 +5893,17 @@ assign_tcp_keepalives_idle(int newval, bool doit, GucSource source)
static const char *
show_tcp_keepalives_idle(void)
{
- static char nbuf[32];
- snprintf(nbuf, sizeof(nbuf), "%d", MyProcPort == NULL ? 0 : pq_getkeepalivesidle(MyProcPort));
+ static char nbuf[16];
+
+ snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesidle(MyProcPort));
return nbuf;
}
static bool
assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
{
- if (doit && MyProcPort != NULL)
- {
+ if (doit)
return (pq_setkeepalivesinterval(newval, MyProcPort) == STATUS_OK);
- }
return true;
}
@@ -5914,18 +5911,17 @@ assign_tcp_keepalives_interval(int newval, bool doit, GucSource source)
static const char *
show_tcp_keepalives_interval(void)
{
- static char nbuf[32];
- snprintf(nbuf, sizeof(nbuf), "%d", MyProcPort == NULL ? 0 : pq_getkeepalivesinterval(MyProcPort));
+ static char nbuf[16];
+
+ snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivesinterval(MyProcPort));
return nbuf;
}
static bool
assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
{
- if (doit && MyProcPort != NULL)
- {
+ if (doit)
return (pq_setkeepalivescount(newval, MyProcPort) == STATUS_OK);
- }
return true;
}
@@ -5933,9 +5929,11 @@ assign_tcp_keepalives_count(int newval, bool doit, GucSource source)
static const char *
show_tcp_keepalives_count(void)
{
- static char nbuf[32];
- snprintf(nbuf, sizeof(nbuf), "%d", MyProcPort == NULL ? 0 : pq_getkeepalivescount(MyProcPort));
+ static char nbuf[16];
+
+ snprintf(nbuf, sizeof(nbuf), "%d", pq_getkeepalivescount(MyProcPort));
return nbuf;
}
+
#include "guc-file.c"