Skip to content

Commit

Permalink
check always if reader dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
ademar committed Sep 20, 2024
1 parent 34607b6 commit 445fec8
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Suave/ConnectionFacade.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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))
Expand Down

0 comments on commit 445fec8

Please sign in to comment.