aboutsummaryrefslogtreecommitdiffstats
path: root/src/socket_util.h
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-09-19 08:10:13 -0500
committerMax Kellermann <max@duempel.org>2011-09-19 17:11:09 +0200
commit27946a981ff4192f064feb3117567463c137933f (patch)
tree1e03c0564a65c43ba98a29d8ed7938464e32d3f3 /src/socket_util.h
parent74617389c88ccf630b8cce4b54d9e2fa5afb2259 (diff)
downloadmpd-27946a981ff4192f064feb3117567463c137933f.tar.gz
mpd-27946a981ff4192f064feb3117567463c137933f.tar.xz
mpd-27946a981ff4192f064feb3117567463c137933f.zip
Set socket TCP keepalive option on incoming connections
If a connected host disappears without our knowledge, as can happen over wireless or a hibernating machine, we continue to hold the port open waiting for messages. Because we never try to send anything down this now-broken pipe, the connection will sit idle taking up a slot in our allowed incoming connections list. If enough of these happen, an unintended Denial of Service takes place, where all connection slots are filled with now-broken, never ending connections. Setting the TCP keepalive option at least allows these to time out after the default two hours, which is sufficient in the non-malicious case. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to '')
-rw-r--r--src/socket_util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/socket_util.h b/src/socket_util.h
index 3ebf4084c..f27751aa3 100644
--- a/src/socket_util.h
+++ b/src/socket_util.h
@@ -63,4 +63,7 @@ socket_bind_listen(int domain, int type, int protocol,
int backlog,
GError **error);
+int
+socket_keepalive(int fd);
+
#endif