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  97c5b867d43af6ebbd0071af2e064286a1f2537d (commit)
       via  f0db75b019241eb3892d5d01cca79b762a17bfe9 (commit)
       via  fef060f889d234d136c0796066e52213d36e96a0 (commit)
      from  b2b0a3ff472d5e0d8ac30113ce42c3f98714be44 (commit)


Summary of changes:
 snap-server.cabal                              |    2 +-
 src/Snap/Internal/Http/Server.hs               |    5 +-
 src/Snap/Internal/Http/Server/LibevBackend.hs  |   51 +++++++++++-------------
 src/Snap/Internal/Http/Server/SimpleBackend.hs |   17 +------
 test/snap-server-testsuite.cabal               |    2 +-
 5 files changed, 31 insertions(+), 46 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 97c5b867d43af6ebbd0071af2e064286a1f2537d
Merge: f0db75b fef060f
Author: Gregory Collins <[email protected]>
Date:   Wed May 26 21:31:39 2010 -0400

    Merge branch 'master' of http://github.com/jystic/snap-server

commit f0db75b019241eb3892d5d01cca79b762a17bfe9
Author: Gregory Collins <[email protected]>
Date:   Wed May 26 21:14:48 2010 -0400

    Strictify some libev backend stuff, remove dodgy timeout stuff from 
SimpleBackend

diff --git a/src/Snap/Internal/Http/Server/LibevBackend.hs 
b/src/Snap/Internal/Http/Server/LibevBackend.hs
index 398e4d3..1064fd1 100644
--- a/src/Snap/Internal/Http/Server/LibevBackend.hs
+++ b/src/Snap/Internal/Http/Server/LibevBackend.hs
@@ -72,34 +72,32 @@ data Backend = Backend
     , _loopLock          :: MVar ()
     , _asyncCb           :: FunPtr AsyncCallback
     , _asyncObj          :: EvAsyncPtr
-    , _killCb           :: FunPtr AsyncCallback
-    , _killObj          :: EvAsyncPtr
+    , _killCb            :: FunPtr AsyncCallback
+    , _killObj           :: EvAsyncPtr
     , _connectionThreads :: MVar (Set ThreadId)
     , _backendCPU        :: Int
     }
 
 
 data Connection = Connection
-    { _backend             :: Backend
-    , _socket              :: Socket
-    , _socketFd            :: CInt
-    , _remoteAddr          :: ByteString
-    , _remotePort          :: Int
-    , _localAddr           :: ByteString
-    , _localPort           :: Int
-    , _readAvailable       :: MVar ()
-    , _writeAvailable      :: MVar ()
-    , _timerObj            :: EvTimerPtr
-    , _timerCallback       :: FunPtr TimerCallback
-    , _openingTime         :: CDouble
-    , _lastActivity        :: IORef CDouble
-    , _readActive          :: IORef Bool
-    , _writeActive         :: IORef Bool
-    , _connReadIOObj       :: EvIoPtr
-    , _connReadIOCallback  :: FunPtr IoCallback
-    , _connWriteIOObj      :: EvIoPtr
-    , _connWriteIOCallback :: FunPtr IoCallback
-    , _connThread          :: MVar ThreadId
+    { _backend             :: !Backend
+    , _socket              :: !Socket
+    , _socketFd            :: !CInt
+    , _remoteAddr          :: !ByteString
+    , _remotePort          :: !Int
+    , _localAddr           :: !ByteString
+    , _localPort           :: !Int
+    , _readAvailable       :: !(MVar ())
+    , _writeAvailable      :: !(MVar ())
+    , _timerObj            :: !EvTimerPtr
+    , _timerCallback       :: !(FunPtr TimerCallback)
+    , _readActive          :: !(IORef Bool)
+    , _writeActive         :: !(IORef Bool)
+    , _connReadIOObj       :: !EvIoPtr
+    , _connReadIOCallback  :: !(FunPtr IoCallback)
+    , _connWriteIOObj      :: !EvIoPtr
+    , _connWriteIOCallback :: !(FunPtr IoCallback)
+    , _connThread          :: !(MVar ThreadId)
     }
 
 {-# INLINE name #-}
@@ -367,7 +365,9 @@ freeConnection conn = ignoreException $ do
 
         -- remove the thread id from the backend set
         tid <- readMVar threadMVar
-        modifyMVar_ tsetMVar $ return . Set.delete tid
+        modifyMVar_ tsetMVar $ \s -> do
+            let !s' = Set.delete tid s
+            return $! s'
 
         -- wake up the event loop so it can be apprised of the changes
         evAsyncSend loop asyncObj
@@ -464,9 +464,6 @@ withConnection backend cpu proc = go
 
         let lp = _evLoop backend
 
-        now        <- evNow lp
-        lastActRef <- newIORef now
-
         -- makes sense to assume the socket is read/write available when
         -- opened; worst-case is we get EWOULDBLOCK
         ra    <- newMVar ()
@@ -510,8 +507,6 @@ withConnection backend cpu proc = go
                               wa
                               tmr
                               tcb
-                              now
-                              lastActRef
                               readActive
                               writeActive
                               evioRead
diff --git a/src/Snap/Internal/Http/Server/SimpleBackend.hs 
b/src/Snap/Internal/Http/Server/SimpleBackend.hs
index 40599df..3ef28bc 100644
--- a/src/Snap/Internal/Http/Server/SimpleBackend.hs
+++ b/src/Snap/Internal/Http/Server/SimpleBackend.hs
@@ -28,13 +28,11 @@ module Snap.Internal.Http.Server.SimpleBackend
 ------------------------------------------------------------------------------
 import           Control.Concurrent
 import           Control.Exception
-import           Control.Monad (when)
 import           Control.Monad.Trans
 import           Data.ByteString (ByteString)
 import           Data.ByteString.Internal (c2w, w2c)
 import qualified Data.ByteString as B
 import           Data.Iteratee.WrappedByteString
-import           Data.Maybe (isNothing)
 import           Data.Typeable
 import           Foreign hiding (new)
 import           GHC.Conc (labelThread, forkOnIO)
@@ -42,7 +40,6 @@ import           Network.Socket
 import qualified Network.Socket.ByteString as SB
 import qualified Network.Socket.SendFile as SF
 import           Prelude hiding (catch)
-import           System.Timeout (timeout)
 ------------------------------------------------------------------------------
 import           Snap.Internal.Debug
 import           Snap.Iteratee
@@ -101,6 +98,7 @@ stop :: Backend -> IO ()
 stop (Backend s) = do
     debug $ "Backend.stop"
     sClose s
+    myThreadId >>= killThread
 
 
 data AddressNotSupportedException = AddressNotSupportedException String
@@ -207,26 +205,17 @@ instance Exception TimeoutException
 tickleTimeout :: Connection -> IO ()
 tickleTimeout = const $ return ()
 
--- FIXME: fixed 30 seconds
-dEFAULT_TIMEOUT :: Int
-dEFAULT_TIMEOUT = 30000000
-
 
 timeoutRecv :: Connection -> Int -> IO ByteString
 timeoutRecv conn n = do
     let sock = _socket conn
-    m <- timeout dEFAULT_TIMEOUT $ SB.recv sock n
-
-    maybe (throwIO TimeoutException)
-          return
-          m
+    SB.recv sock n
 
 
 timeoutSend :: Connection -> ByteString -> IO ()
 timeoutSend conn s = do
     let sock = _socket conn
-    m <- timeout dEFAULT_TIMEOUT $ SB.sendAll sock s
-    when (isNothing m) $ throwIO TimeoutException
+    SB.sendAll sock s
 
 
 bLOCKSIZE :: Int
commit fef060f889d234d136c0796066e52213d36e96a0
Author: Jacob Stanley <[email protected]>
Date:   Mon May 24 03:39:36 2010 +0800

    Compiles and runs all tests successfully on Windows
    
    Changed from using the 'unix' library to 'unit-compat'. This caused
    some compile error related to FileOffset that I suppressed by hiding
    the FileOffset that was exported from Snap.Iteratee. I'm not sure if
    this was the right thing to do or not but snap-server now compiles
    and the test suite runs successfully.

diff --git a/snap-server.cabal b/snap-server.cabal
index 4dafb23..0efd488 100644
--- a/snap-server.cabal
+++ b/snap-server.cabal
@@ -108,7 +108,7 @@ Library
     snap-core >= 0.2.1 && <0.3,
     time,
     transformers,
-    unix,
+    unix-compat,
     vector >= 0.6 && <0.7
 
   if flag(libev)
diff --git a/src/Snap/Internal/Http/Server.hs b/src/Snap/Internal/Http/Server.hs
index 215d120..5b253ac 100644
--- a/src/Snap/Internal/Http/Server.hs
+++ b/src/Snap/Internal/Http/Server.hs
@@ -27,13 +27,14 @@ import           Data.Version
 import           GHC.Conc
 import           Prelude hiding (catch, show, Show)
 import qualified Prelude
-import           System.Posix.Files hiding (setFileSize)
+import           System.PosixCompat.Files hiding (setFileSize)
+import           System.Posix.Types (FileOffset)
 import           Text.Show.ByteString hiding (runPut)
 ------------------------------------------------------------------------------
 import           System.FastLogger
 import           Snap.Internal.Http.Types hiding (Enumerator)
 import           Snap.Internal.Http.Parser
-import           Snap.Iteratee hiding (foldl', head, take)
+import           Snap.Iteratee hiding (foldl', head, take, FileOffset)
 import qualified Snap.Iteratee as I
 
 #ifdef LIBEV
diff --git a/test/snap-server-testsuite.cabal b/test/snap-server-testsuite.cabal
index 77e7169..19c119a 100644
--- a/test/snap-server-testsuite.cabal
+++ b/test/snap-server-testsuite.cabal
@@ -84,7 +84,7 @@ Executable pongserver
      snap-core >= 0.2.1 && <0.3,
      time,
      transformers,
-     unix,
+     unix-compat,
      vector >= 0.6.0.1 && < 0.7
 
    if flag(libev)
-----------------------------------------------------------------------


hooks/post-receive
-- 
snap-server
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to