Skip to content

Commit

Permalink
Fix HTTP server example when closing listening socket fails.
Browse files Browse the repository at this point in the history
Currently the example ignores the failure and tries to re-open the
listening socket, running into an infinite loop. This is not meaningful,
if we cannot close the listening socket we better stop since we will
never be able to re-bind onto the server port anymore.

Signed-off-by: Hugo Lefeuvre <[email protected]>
  • Loading branch information
hlef committed Dec 6, 2024
1 parent 0941483 commit b02a101
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions examples/05.HTTP_SERVER/http_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,11 @@ void __cheri_compartment("http_server_example") example()
if (retries == 0)
{
Debug::log("Failed to close the listening socket.");

// We have to stop now - if we cannot close the
// listening socket, we will not be able to bind onto
// the server port anymore. This is bad!
break;
}
}

Expand Down

0 comments on commit b02a101

Please sign in to comment.