From 40e4eddbbd13ad46f7aec51ba0043026a20fea93 Mon Sep 17 00:00:00 2001 From: Harald Wolff-Thobaben Date: Fri, 27 May 2022 22:12:13 +0200 Subject: [PATCH] Fixed singlethread HTTPServer.Connection() blocking listeners from accepting more connections --- ln.http/HTTPServer.cs | 7 +++++-- ln.http/ln.http.csproj | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ln.http/HTTPServer.cs b/ln.http/HTTPServer.cs index c1c2fe8..f60efe5 100644 --- a/ln.http/HTTPServer.cs +++ b/ln.http/HTTPServer.cs @@ -4,6 +4,7 @@ using ln.logging; using ln.http.exceptions; using System.IO; using System.Text; +using System.Threading; using ln.protocols.helper; namespace ln.http @@ -35,8 +36,10 @@ namespace ln.http public void RemoveRouter(HttpRouter httpRouter) => RemoveRouter(httpRouter.Route); public void RemoveRouter(HttpRouterDelegate routerDelegate) => _routerDelegates.Remove(routerDelegate); - - public void Connection(HttpConnection httpConnection) + + public void Connection(HttpConnection httpConnection) => + ThreadPool.QueueUserWorkItem((state => ConnectionWorker(httpConnection))); + public void ConnectionWorker(HttpConnection httpConnection) { try { diff --git a/ln.http/ln.http.csproj b/ln.http/ln.http.csproj index 7936a67..dac0389 100644 --- a/ln.http/ln.http.csproj +++ b/ln.http/ln.http.csproj @@ -10,7 +10,7 @@ (c) 2020 Harald Wolff-Thobaben http server 9 - 0.5.3 + 0.6.1