Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Commit

Permalink
Ignore closed FastCGI stream.
Browse files Browse the repository at this point in the history
With Apache Benchmark, it is possible to elicit an exception:

    ab -n 5000 -c 100 -t 60 'http://...'

Would result in:

    user error (FCGX_PutStr failed with error code: -1)

I have experienced this merely with a lighttpd and nginx FastCGI web site not even under particularly heavy load.

So it's a problem that this isn't handled. FCGX_PutStr returns an error if you try to write to a closed stream.

So we now handle that case by discontinuing the response as there is nothing to respond to, and going about our business.
  • Loading branch information
chrisdone committed Jun 22, 2010
1 parent 132e833 commit de8d303
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Network/FastCGI.hsc
Expand Up @@ -224,7 +224,9 @@ peekEnvp = (#peek FCGX_Request, envp)

sPutStr :: StreamPtr -> Lazy.ByteString -> IO ()
sPutStr h str =
mapM_ (flip BSB.unsafeUseAsCStringLen (fcgxPutCStringLen h)) (Lazy.toChunks str)
mapM_ (flip BSB.unsafeUseAsCStringLen (fcgxPutCStringLen h))
(Lazy.toChunks str)
`catch` \(_ :: IOException) -> return ()

fcgxPutCStringLen :: StreamPtr -> CStringLen -> IO ()
fcgxPutCStringLen h (cs,len) =
Expand Down

0 comments on commit de8d303

Please sign in to comment.