osrm-backend/src/server
Michael Bell f1a6056953 Immediately close bad connections to prevent file exhaustion
osrm-routed does not immediately clean up a keep-alive connection
when the client closes it. Instead it waits for five seconds
of inactivity before removing.

Given a setup with low file limits and clients opening and
closing a lot of keep-alive connections, it's possible for
osrm-routed to run out of file descriptors whilst it waits for
the clean-up to trigger.

Furthermore, this causes the connection acceptor loop to exit.
Even after the old connections are cleaned up, new ones
will not be created. Any new requests will block until the
server is restarted.

This commit improves the situation by:

- Immediately closing connections on error. This includes EOF errors
indicating that the client has closed the connection. This releases
resources early (including the open file) and doesn't wait for the
timer.

- Log when the acceptor loop exits. Whilst this means the behaviour
can still occur for reasons other than too many open files,
we will at least have visibility of the cause and can investigate further.
2021-09-04 01:55:36 +01:00
..
api Update src/server/api/url_parser.cpp 2021-09-03 10:55:53 +02:00
http Upgrade formatting to clang-format 10 (#5895) 2020-11-26 07:21:39 -08:00
service Upgrade formatting to clang-format 10 (#5895) 2020-11-26 07:21:39 -08:00
connection.cpp Immediately close bad connections to prevent file exhaustion 2021-09-04 01:55:36 +01:00
request_handler.cpp Upgrade formatting to clang-format 10 (#5895) 2020-11-26 07:21:39 -08:00
request_parser.cpp Upgrade formatting to clang-format 10 (#5895) 2020-11-26 07:21:39 -08:00
service_handler.cpp Upgrade formatting to clang-format 10 (#5895) 2020-11-26 07:21:39 -08:00