Skip to content
Commit 0e601d41 authored by Robert Lubos's avatar Robert Lubos Committed by Anas Nashif
Browse files

net: lib: http_server: Add restart delay



In case there were active connections when restarting the server, it
can't be re-initialized immediately, as binding to the server port will
fail. We need to wait for the TCP connection teardown, as even with
REUSEADDR socket option set, binding will fail if the sockets are not in
TCP TIMED_WAIT state (i. e. connections are active).

Because of this, add a configurable delay when restarting the server.
Additionally, make server initialization failures non-fatal, i. e. try
to restart the server again after the delay if the initialization fails.
It's been observed with Chromium, that it tends to keep connections open
even after closing them on the server side (socket lingers in FIN_WAIT_2
state), so the server re-initialization may fail even with delay, so
it's beneficial in  such case to keep retrying the server
re-initialization.

Signed-off-by: default avatarRobert Lubos <robert.lubos@nordicsemi.no>
parent fc10a946
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment