diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2022-07-19 13:36:53 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-07-20 19:42:20 +0100 |
commit | 23d8501adcc6ed092ca407c12315e4c88d1a86ed (patch) | |
tree | d5cc9a99c4c0aed5af0b53816a87ab5ca9028d7f /bitbake/lib/bb/asyncrpc | |
parent | 33ff9b7d139c2ff87b0e5e49b08417e6cd86659f (diff) | |
download | poky-23d8501adcc6ed092ca407c12315e4c88d1a86ed.tar.gz |
bitbake: asyncrpc: Add TCP Keep Alives
Adds TCP Keep Alive support to the async RPC server. This should help
prevent file descriptor exhaustion on the server when client connections
are interrupted and the socket never closes (e.g. no FIN is sent from
the client).
A keep alive is sent after 30 seconds of inactivity, then every 15
seconds after that up to a maximum of 2 minutes.
(Bitbake rev: 68f4ce662cad28fed739900addbdee949ad3c1e8)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/asyncrpc')
-rw-r--r-- | bitbake/lib/bb/asyncrpc/serv.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bitbake/lib/bb/asyncrpc/serv.py b/bitbake/lib/bb/asyncrpc/serv.py index b4cffff213..585bc121da 100644 --- a/bitbake/lib/bb/asyncrpc/serv.py +++ b/bitbake/lib/bb/asyncrpc/serv.py | |||
@@ -151,6 +151,13 @@ class AsyncServer(object): | |||
151 | s.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1) | 151 | s.setsockopt(socket.SOL_TCP, socket.TCP_NODELAY, 1) |
152 | s.setsockopt(socket.SOL_TCP, socket.TCP_QUICKACK, 1) | 152 | s.setsockopt(socket.SOL_TCP, socket.TCP_QUICKACK, 1) |
153 | 153 | ||
154 | # Enable keep alives. This prevents broken client connections | ||
155 | # from persisting on the server for long periods of time. | ||
156 | s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) | ||
157 | s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 30) | ||
158 | s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 15) | ||
159 | s.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 4) | ||
160 | |||
154 | name = self.server.sockets[0].getsockname() | 161 | name = self.server.sockets[0].getsockname() |
155 | if self.server.sockets[0].family == socket.AF_INET6: | 162 | if self.server.sockets[0].family == socket.AF_INET6: |
156 | self.address = "[%s]:%d" % (name[0], name[1]) | 163 | self.address = "[%s]:%d" % (name[0], name[1]) |