diff --git a/docs/nodejs/api.md b/docs/nodejs/api.md index ddc58964e..faaf83d64 100644 --- a/docs/nodejs/api.md +++ b/docs/nodejs/api.md @@ -40,7 +40,6 @@ var osrm = new OSRM('network.osrm'); - `options.max_results_nearest` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. results supported in nearest query (default: unlimited). - `options.max_alternatives` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Max. number of alternatives supported in alternative routes query (default: 3). - `options.default_radius` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Default radius for queries (default: unlimited). - - `options.keepalive_timeout` **[Number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Seconds used as the server-side keepalive_timeout (default: 5). ### route diff --git a/include/server/connection.hpp b/include/server/connection.hpp index ad0b43df1..3f98d4ed1 100644 --- a/include/server/connection.hpp +++ b/include/server/connection.hpp @@ -35,7 +35,9 @@ class RequestHandler; class Connection : public std::enable_shared_from_this { public: - explicit Connection(boost::asio::io_context &io_context, RequestHandler &handler, short keepalive_timeout); + explicit Connection(boost::asio::io_context &io_context, + RequestHandler &handler, + short keepalive_timeout); Connection(const Connection &) = delete; Connection &operator=(const Connection &) = delete; diff --git a/include/server/server.hpp b/include/server/server.hpp index 321d6d3d3..34b8982e6 100644 --- a/include/server/server.hpp +++ b/include/server/server.hpp @@ -31,8 +31,10 @@ class Server { public: // Note: returns a shared instead of a unique ptr as it is captured in a lambda somewhere else - static std::shared_ptr - CreateServer(std::string &ip_address, int ip_port, unsigned requested_num_threads, short keepalive_timeout) + static std::shared_ptr CreateServer(std::string &ip_address, + int ip_port, + unsigned requested_num_threads, + short keepalive_timeout) { util::Log() << "http 1.1 compression handled by zlib version " << zlibVersion(); const unsigned hardware_threads = std::max(1u, std::thread::hardware_concurrency()); @@ -40,9 +42,13 @@ class Server return std::make_shared(ip_address, ip_port, real_num_threads, keepalive_timeout); } - explicit Server(const std::string &address, const int port, const unsigned thread_pool_size, const short keepalive_timeout) - : thread_pool_size(thread_pool_size), keepalive_timeout(keepalive_timeout), acceptor(io_context), - new_connection(std::make_shared(io_context, request_handler, keepalive_timeout)) + explicit Server(const std::string &address, + const int port, + const unsigned thread_pool_size, + const short keepalive_timeout) + : thread_pool_size(thread_pool_size), keepalive_timeout(keepalive_timeout), + acceptor(io_context), new_connection(std::make_shared( + io_context, request_handler, keepalive_timeout)) { const auto port_string = std::to_string(port); @@ -94,7 +100,8 @@ class Server if (!e) { new_connection->start(); - new_connection = std::make_shared(io_context, request_handler, keepalive_timeout); + new_connection = + std::make_shared(io_context, request_handler, keepalive_timeout); acceptor.async_accept( new_connection->socket(), boost::bind(&Server::HandleAccept, this, boost::asio::placeholders::error)); diff --git a/src/server/connection.cpp b/src/server/connection.cpp index 75b24c243..c3c07a340 100644 --- a/src/server/connection.cpp +++ b/src/server/connection.cpp @@ -7,13 +7,15 @@ #include #include -#include #include +#include namespace osrm::server { -Connection::Connection(boost::asio::io_context &io_context, RequestHandler &handler, short keepalive_timeout) +Connection::Connection(boost::asio::io_context &io_context, + RequestHandler &handler, + short keepalive_timeout) : strand(boost::asio::make_strand(io_context)), TCP_socket(strand), timer(strand), request_handler(handler), keepalive_timeout(keepalive_timeout) { @@ -89,7 +91,9 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t { keep_alive = true; current_reply.headers.emplace_back("Connection", "keep-alive"); - current_reply.headers.emplace_back("Keep-Alive", "timeout="+ fmt::to_string(keepalive_timeout) + ", max=" + fmt::to_string(processed_requests)); + current_reply.headers.emplace_back("Keep-Alive", + "timeout=" + fmt::to_string(keepalive_timeout) + + ", max=" + fmt::to_string(processed_requests)); } // compress the result w/ gzip/deflate if requested diff --git a/src/tools/routed.cpp b/src/tools/routed.cpp index 4846e9f6f..1e6a9c266 100644 --- a/src/tools/routed.cpp +++ b/src/tools/routed.cpp @@ -271,8 +271,15 @@ try int requested_thread_num = 1; short keepalive_timeout = 5; - const unsigned init_result = generateServerProgramOptions( - argc, argv, base_path, ip_address, ip_port, trial_run, config, requested_thread_num, keepalive_timeout); + const unsigned init_result = generateServerProgramOptions(argc, + argv, + base_path, + ip_address, + ip_port, + trial_run, + config, + requested_thread_num, + keepalive_timeout); if (init_result == INIT_OK_DO_NOT_START_ENGINE) { return EXIT_SUCCESS; @@ -325,7 +332,8 @@ try #endif auto service_handler = std::make_unique(config); - auto routing_server = server::Server::CreateServer(ip_address, ip_port, requested_thread_num, keepalive_timeout); + auto routing_server = + server::Server::CreateServer(ip_address, ip_port, requested_thread_num, keepalive_timeout); routing_server->RegisterServiceHandler(std::move(service_handler));