This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-server".
The branch, master has been updated
via 5cbf3b99c5e8fff269b8b846386e560a51c78564 (commit)
from 383b2f1a51656aea8d4c39230a3f99ae86e35077 (commit)
Summary of changes:
src/Snap/Internal/Http/Parser.hs | 5 +++--
src/Snap/Internal/Http/Server.hs | 16 ++++++++++++----
src/Snap/Internal/Http/Server/LibevBackend.hs | 15 ++++++++++-----
3 files changed, 25 insertions(+), 11 deletions(-)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 5cbf3b99c5e8fff269b8b846386e560a51c78564
Author: Gregory Collins <[email protected]>
Date: Sun May 30 00:22:06 2010 -0400
Get rid of unsafeBufferIteratee for now, it's causing firefox to hang
diff --git a/src/Snap/Internal/Http/Parser.hs b/src/Snap/Internal/Http/Parser.hs
index 7fcca6e..055cf64 100644
--- a/src/Snap/Internal/Http/Parser.hs
+++ b/src/Snap/Internal/Http/Parser.hs
@@ -113,9 +113,10 @@ toHex !i' = S.reverse s
writeChunkedTransferEncoding :: ForeignPtr CChar
-> Enumerator IO a
-> Enumerator IO a
-writeChunkedTransferEncoding buf enum it = do
+writeChunkedTransferEncoding _buf enum it = do
i' <- wrap it
- (i,_) <- unsafeBufferIterateeWithBuffer buf i'
+ --(i,_) <- unsafeBufferIterateeWithBuffer buf i'
+ i <- bufferIteratee i'
enum i
where
diff --git a/src/Snap/Internal/Http/Server.hs b/src/Snap/Internal/Http/Server.hs
index e734e58..f41f826 100644
--- a/src/Snap/Internal/Http/Server.hs
+++ b/src/Snap/Internal/Http/Server.hs
@@ -26,6 +26,7 @@ import Data.Monoid
import Data.Version
import Foreign.C.Types
import Foreign.ForeignPtr
+import Foreign.Ptr (nullPtr)
import GHC.Conc
import Prelude hiding (catch, show, Show)
import qualified Prelude
@@ -270,7 +271,8 @@ runHTTP lh lip lp rip rp alog elog
logPrefix = S.concat [ "[", rip, "]: error: " ]
go = do
- buf <- mkIterateeBuffer
+ --buf <- mkIterateeBuffer
+ buf <- newForeignPtr_ nullPtr
let iter = runServerMonad lh lip lp rip rp (logA alog) (logE elog) $
httpSession writeEnd buf onSendFile tickle
handler
@@ -302,10 +304,12 @@ httpSession :: Iteratee IO () -- ^ write end of
socket
-> ServerMonad ()
httpSession writeEnd' ibuf onSendFile tickle handler = do
- (writeEnd, cancelBuffering) <-
- liftIO $ I.unsafeBufferIterateeWithBuffer ibuf writeEnd'
+ -- (writeEnd, cancelBuffering) <-
+ -- liftIO $ I.unsafeBufferIterateeWithBuffer ibuf writeEnd'
+ -- let killBuffer = writeIORef cancelBuffering True
- let killBuffer = writeIORef cancelBuffering True
+ writeEnd <- liftIO $ I.bufferIteratee writeEnd'
+ let killBuffer = return ()
liftIO $ debug "Server.httpSession: entered"
mreq <- receiveRequest
@@ -314,6 +318,10 @@ httpSession writeEnd' ibuf onSendFile tickle handler = do
case mreq of
(Just req) -> do
+ liftIO $ debug $ "got request: " ++
+ Prelude.show (rqMethod req) ++
+ " " ++ SC.unpack (rqURI req) ++
+ " " ++ Prelude.show (rqVersion req)
logerr <- gets _logError
(req',rspOrig) <- lift $ handler logerr req
let rspTmp = rspOrig { rspHttpVersion = rqVersion req }
diff --git a/src/Snap/Internal/Http/Server/LibevBackend.hs
b/src/Snap/Internal/Http/Server/LibevBackend.hs
index 2045592..d53004f 100644
--- a/src/Snap/Internal/Http/Server/LibevBackend.hs
+++ b/src/Snap/Internal/Http/Server/LibevBackend.hs
@@ -110,14 +110,14 @@ sendFile c fp = do
withMVar lock $ \_ -> do
act <- readIORef $ _writeActive c
when act $ evIoStop loop io
+ writeIORef (_writeActive c) False
+ evAsyncSend loop asy
SF.sendFile s fp
withMVar lock $ \_ -> do
- tryPutMVar (_readAvailable c) ()
- tryPutMVar (_writeAvailable c) ()
- evIoStart loop io
- writeIORef (_writeActive c) True
+ tryTakeMVar $ _readAvailable c
+ tryTakeMVar $ _writeAvailable c
evAsyncSend loop asy
where
@@ -590,7 +590,10 @@ instance Show TimeoutException where
instance Exception TimeoutException
tickleTimeout :: Connection -> IO ()
-tickleTimeout conn = debug "Backend.tickleTimeout" >> evTimerAgain lp tmr
+tickleTimeout conn = do
+ debug "Backend.tickleTimeout"
+ withMVar (_loopLock bk) $ \_ -> evTimerAgain lp tmr
+
where
bk = _backend conn
lp = _evLoop bk
@@ -635,6 +638,7 @@ recvData conn n = do
then dbg "read watcher already active, skipping"
else do
dbg "starting watcher, sending async"
+ tryTakeMVar lock
evIoStart lp io
writeIORef active True
evAsyncSend lp async
@@ -687,6 +691,7 @@ sendData conn bs = do
then dbg "write watcher already running, skipping"
else do
dbg "starting watcher, sending async event"
+ tryTakeMVar lock
evIoStart lp io
writeIORef active True
evAsyncSend lp async
-----------------------------------------------------------------------
hooks/post-receive
--
snap-server
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap