From 445fec8aff0a53d295eaddf256046c2681bb8596 Mon Sep 17 00:00:00 2001 From: Ademar Gonzalez Date: Fri, 20 Sep 2024 14:56:21 -0400 Subject: [PATCH] check always if reader dirty --- src/Suave/ConnectionFacade.fs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Suave/ConnectionFacade.fs b/src/Suave/ConnectionFacade.fs index 2f299e1b..ad41f4b1 100644 --- a/src/Suave/ConnectionFacade.fs +++ b/src/Suave/ConnectionFacade.fs @@ -322,8 +322,7 @@ type ConnectionFacade(connection: Connection, runtime: HttpRuntime, connectionPo | Result.Error e -> flag := false result := Result.Error e - reader.stop() - return result + return result.Value } member this.accept(binding) = task{ @@ -334,13 +333,15 @@ type ConnectionFacade(connection: Connection, runtime: HttpRuntime, connectionPo connection.socketBinding <- binding try let task = Task.Factory.StartNew(reader.readLoop,cancellationToken) - let! a = this.requestLoop() - () + match! this.requestLoop() with + | Ok () -> () + | Result.Error err -> + do Console.WriteLine(sprintf "Error: %A" err) with | ex -> - if reader.isDirty then - reader.stop() do Console.WriteLine("Error: " + ex.Message) + if reader.isDirty then + reader.stop() Interlocked.Decrement(Globals.numberOfClients) |> ignore if Globals.verbose then do Console.WriteLine("Disconnected {0}. {1} connected.", clientIp,(!Globals.numberOfClients))