From 19650c1d8d16072a4dc9716a092a51ab50e88c6e Mon Sep 17 00:00:00 2001 From: Stephen von Takach Date: Mon, 24 Jul 2023 22:47:38 +1000 Subject: [PATCH] fix(server): disable pooling when running multi-threaded --- shard.yml | 2 +- src/action-controller/server.cr | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/shard.yml b/shard.yml index 72c2f84..d05220b 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: action-controller -version: 7.0.3 +version: 7.0.4 crystal: ">= 1.9.0" dependencies: diff --git a/src/action-controller/server.cr b/src/action-controller/server.cr index 9fff38f..618862b 100644 --- a/src/action-controller/server.cr +++ b/src/action-controller/server.cr @@ -12,16 +12,20 @@ class ActionController::Server # :nodoc: private class HTTPServer < HTTP::Server - @worker : WorkerPool = WorkerPool.new(100) + {% if flag?(:preview_mt) %} + # worker pooling is single threaded + {% else %} + @worker : WorkerPool = WorkerPool.new(100) - protected def dispatch(io) - @worker.perform { handle_client(io) } - end + protected def dispatch(io) + @worker.perform { handle_client(io) } + end - def close - super - @worker.close - end + def close + super + @worker.close + end + {% end %} end # handlers to run before your application code, see: [handlers](https://crystal-lang.org/api/latest/HTTP/Handler.html)