summaryrefslogtreecommitdiff
path: root/databases/pgbouncer/files/patch-keepalive
blob: 5da439c89796d44464e7ca90d02a3c0055d4bb45 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
--- src/util.c.orig	2011-12-07 15:04:13.000000000 +0400
+++ src/util.c	2011-12-07 15:04:07.000000000 +0400
@@ -126,7 +126,7 @@
 		res = setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
 		if (res < 0)
 			goto fail;
-#ifdef __linux__
+#ifdef TCP_KEEPCNT
 		/* set count of keepalive packets */
 		if (cf_tcp_keepcnt > 0) {
 			val = cf_tcp_keepcnt;
@@ -134,6 +134,8 @@
 			if (res < 0)
 				goto fail;
 		}
+#endif
+#ifdef TCP_KEEPIDLE
 		/* how long the connection can stay idle before sending keepalive pkts */
 		if (cf_tcp_keepidle) {
 			val = cf_tcp_keepidle;
@@ -141,6 +143,8 @@
 			if (res < 0)
 				goto fail;
 		}
+#endif
+#ifdef TCP_KEEPINTVL
 		/* time between packets */
 		if (cf_tcp_keepintvl) {
 			val = cf_tcp_keepintvl;
@@ -148,7 +152,7 @@
 			if (res < 0)
 				goto fail;
 		}
-#else
+#endif
 #ifdef TCP_KEEPALIVE
 		if (cf_tcp_keepidle) {
 			val = cf_tcp_keepidle;
@@ -157,7 +161,6 @@
 				goto fail;
 		}
 #endif
-#endif
 	}
 
 	/* set in-kernel socket buffer size */