Skip to content

Commit

Permalink
fix(server): disable pooling when running multi-threaded
Browse files Browse the repository at this point in the history
  • Loading branch information
stakach committed Jul 24, 2023
1 parent afbb689 commit 19650c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: action-controller
version: 7.0.3
version: 7.0.4
crystal: ">= 1.9.0"

dependencies:
Expand Down
20 changes: 12 additions & 8 deletions src/action-controller/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 19650c1

Please sign in to comment.