From 1420a219ee69434e5f131bfe317e78f063094788 Mon Sep 17 00:00:00 2001 From: nekobit Date: Mon, 31 Oct 2022 03:49:37 +0000 Subject: [PATCH] Add thread pool size to config FossilOrigin-Name: e7a3187b94e5a277a7bb0126e6e599f5a788ec695e428440dc755aac71376081 --- config.sample.yaml | 1 + src/config/config_http.cpp | 1 + src/config/config_http.h | 1 + src/http/microhttpd_server.cpp | 3 +++ 4 files changed, 6 insertions(+) diff --git a/config.sample.yaml b/config.sample.yaml index 90fd029..d49c8de 100644 --- a/config.sample.yaml +++ b/config.sample.yaml @@ -9,6 +9,7 @@ instance: http: port: 4050 + thread_pool_size: 12 database: db_type: "sqlite" diff --git a/src/config/config_http.cpp b/src/config/config_http.cpp index 9c5ddc6..7fcc46f 100644 --- a/src/config/config_http.cpp +++ b/src/config/config_http.cpp @@ -22,6 +22,7 @@ void Config::load_http(Config::HTTP& cfg, YAML::Node& node) try { cfg.port = node["http"]["port"].as(); + cfg.pool_size = node["http"]["thread_pool_size"].as(); } catch(const YAML::BadConversion& err) {} diff --git a/src/config/config_http.h b/src/config/config_http.h index b6b73cc..9f208a1 100644 --- a/src/config/config_http.h +++ b/src/config/config_http.h @@ -27,6 +27,7 @@ namespace Config struct HTTP { uint16_t port{8080}; + uint16_t pool_size{8}; }; void load_http(Config::HTTP& cfg, YAML::Node& node); diff --git a/src/http/microhttpd_server.cpp b/src/http/microhttpd_server.cpp index ba7fc8d..0f9d743 100644 --- a/src/http/microhttpd_server.cpp +++ b/src/http/microhttpd_server.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "config/config_loader.h" #include "logger.h" #include "microhttpd_server.h" #include "http/mime.h" @@ -183,6 +184,8 @@ void MicroHttpdServer::start() MHD_OPTION_NOTIFY_CONNECTION, request_completed, this, + MHD_OPTION_THREAD_POOL_SIZE, + Config::instance().config.http.pool_size, MHD_OPTION_END); if (!dm) {