Skip to content

Commit

Permalink
Fix a silly file descriptor leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
bos committed Mar 17, 2010
1 parent b63cad4 commit f269f3e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions benchmarks/StaticHttp.hs
Expand Up @@ -65,7 +65,7 @@ client sock = (`finally` sClose sock) loop
loop = do
(bs, ereq) <- parseM (recv sock 4096) request
case ereq of
Right (req,hdrs) | requestMethod req == "GET" ->
Right (req,hdrs) | requestMethod req == "GET" -> do
bracket (openFd (B.unpack (requestUri req)) ReadOnly Nothing
defaultFileFlags{nonBlock=True}) closeFd $ \fd -> do
st <- getFdStatus fd
Expand All @@ -81,6 +81,6 @@ client sock = (`finally` sClose sock) loop
fix $ \sendLoop -> do
s <- F.read fd 16384
unless (B.null s) $ sendAll sock s >> sendLoop
unless (requestProtocol req == "1.0") loop
_ | B.null bs -> return ()
| otherwise -> sendAll sock "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n"
unless (requestVersion req == "1.0") loop
err | B.null bs -> return ()
| otherwise -> print err >> sendAll sock "HTTP/1.1 400 Bad Request\r\nConnection: close\r\n\r\n"

0 comments on commit f269f3e

Please sign in to comment.