mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-26 20:48:24 +00:00
Serve connections without parking through KeepAliveConnection
Server::process_and_close_socket() repeated what KeepAliveConnection already does for keep-alive parking: make the stream, look up the addresses, run process_server_socket_core(), and close. Make it create the connection with new_keep_alive_connection() and resume() it once, with a flag that waits for the next request on the worker through keep_alive(), as before. The flag is checked first, ahead of the stop check, since keep_alive() serves a request that is already on the socket even when the server is stopping. detail::process_server_socket() and process_server_socket_ssl() are no longer called by the library, but overrides of process_and_close_socket() call them. Instantiate them in include_httplib.cc, which only the header build compiles, so that a change to process_server_socket_core() cannot break them unnoticed.
This commit is contained in:
1 parent
084b30055e
commit
daf46bd502
2 files changed
+24
-23
No files matched your search
@@ -3,3 +3,17 @@
|
||||
// when linked together with test.cc.
|
||||
|
||||
#include <httplib.h>
|
||||
|
||||
// The library no longer calls these, but subclasses that override
|
||||
// process_and_close_socket() do. Instantiating them here, where the split build
|
||||
// does not reach, keeps a change to process_server_socket_core() from breaking
|
||||
// them unnoticed.
|
||||
struct IncludeHttplibServeNothing {
|
||||
bool operator()(httplib::Stream &, bool, bool &) const { return false; }
|
||||
};
|
||||
auto include_httplib_process_server_socket =
|
||||
&httplib::detail::process_server_socket<IncludeHttplibServeNothing>;
|
||||
#ifdef CPPHTTPLIB_SSL_ENABLED
|
||||
auto include_httplib_process_server_socket_ssl =
|
||||
&httplib::detail::process_server_socket_ssl<IncludeHttplibServeNothing>;
|
||||
#endif
|
||||
Reference in new issue
Block a user