Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ The release run heads these entries with the version and opens a fresh

## Unreleased

- HTTP server shutdown avoids user logging callbacks, so logging failures
cannot interrupt cleanup or terminate the process during destruction.

- `DecodedFile::file_meta`, `identify`, and position `to_string` methods no
longer promise `noexcept`; allocation failures can propagate instead of
terminating the process.
Expand Down
6 changes: 1 addition & 5 deletions src/odr/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,6 @@ class HttpServer::Impl : public std::enable_shared_from_this<Impl> {
return;
}

ODR_VERBOSE(m_logger, "Stopping HTTP server...");

// rejects requests in flight, and any listen() that has not started yet
m_stopping.store(true, std::memory_order_release);
m_bound = false;
Expand All @@ -298,11 +296,9 @@ class HttpServer::Impl : public std::enable_shared_from_this<Impl> {
// the accept loop stands on the server and on what the handlers capture,
// so neither may go before listen() has returned
m_listen_done.wait(lock, [this] { return m_listening == 0; });
m_content.clear();
}

// nothing is serving any more
clear();

// ~server here, which joins the thread pool
}

Expand Down
18 changes: 18 additions & 0 deletions test/src/http_server_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ class ListenGuard {

} // namespace

TEST(HttpServer, cleanup_does_not_call_user_loggers) {
class ThrowingLogger final : public ILogger {
public:
bool will_log(LogLevel) const override {
throw std::runtime_error("logging failed");
}
void log(Time, LogLevel, const std::string &,
const std::source_location &) override {}
void flush() override {}
};
const Logger logger(std::make_shared<ThrowingLogger>());
{
const HttpServer server({}, logger);
EXPECT_NO_THROW(server.stop());
}
EXPECT_NO_THROW({ const HttpServer server({}, logger); });
}

TEST(HttpServer, bind_reports_the_port_it_got) {
const HttpServer server;

Expand Down
Loading