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  01ec4881b5ba554edd24533e57810f968ca178ee (commit)
       via  d4c2f38d41fb22b4704704cf8276b8231099a00d (commit)
      from  82f636b2263e0093e036817db35e7dcb81cdb8a5 (commit)


Summary of changes:
 snap-server.cabal                         |    4 +-
 src/Snap/Internal/Http/Server/Backend.hs  |    3 +-
 src/Snap/Internal/Http/Server/HttpPort.hs |   34 +++++++++++++++-------------
 3 files changed, 21 insertions(+), 20 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 01ec4881b5ba554edd24533e57810f968ca178ee
Author: Gregory Collins <[email protected]>
Date:   Wed Feb 16 09:27:57 2011 -0800

    Bump snap-core dep

diff --git a/snap-server.cabal b/snap-server.cabal
index 5f05594..6639ff3 100644
--- a/snap-server.cabal
+++ b/snap-server.cabal
@@ -118,7 +118,7 @@ Library
     murmur-hash >= 0.1 && < 0.2,
     network >= 2.3 && <2.4,
     old-locale,
-    snap-core >= 0.4.0.2 && <0.5,
+    snap-core >= 0.4.0.3 && <0.5,
     template-haskell,
     time,
     transformers,
commit d4c2f38d41fb22b4704704cf8276b8231099a00d
Author: Gregory Collins <[email protected]>
Date:   Wed Feb 16 08:32:06 2011 -0800

    Eliminate unnecessary buffer copy in the server

diff --git a/snap-server.cabal b/snap-server.cabal
index 89ec82b..5f05594 100644
--- a/snap-server.cabal
+++ b/snap-server.cabal
@@ -1,5 +1,5 @@
 name:           snap-server
-version:        0.4.0.2
+version:        0.4.0.3
 synopsis:       A fast, iteratee-based, epoll-enabled web server for the Snap 
Framework
 description:
   This is the first developer prerelease of the Snap framework.  Snap is a
diff --git a/src/Snap/Internal/Http/Server/Backend.hs 
b/src/Snap/Internal/Http/Server/Backend.hs
index 1364eb3..f3c2b2b 100644
--- a/src/Snap/Internal/Http/Server/Backend.hs
+++ b/src/Snap/Internal/Http/Server/Backend.hs
@@ -92,6 +92,5 @@ instance Show ListenSocket where
 data NetworkSession = NetworkSession
   { _socket     :: CInt
   , _session    :: Ptr Word
-  , _recvBuffer :: Ptr CChar
-  , _recvLen    :: CSize
+  , _recvLen    :: Int
   }
diff --git a/src/Snap/Internal/Http/Server/HttpPort.hs 
b/src/Snap/Internal/Http/Server/HttpPort.hs
index 0afe39f..e5e128d 100644
--- a/src/Snap/Internal/Http/Server/HttpPort.hs
+++ b/src/Snap/Internal/Http/Server/HttpPort.hs
@@ -22,8 +22,8 @@ import           Network.Socket hiding (recv, send)
 #ifdef PORTABLE
 import qualified Network.Socket.ByteString as SB
 #else
-import           Control.Monad (liftM)
-import           Data.ByteString.Unsafe (unsafeUseAsCStringLen)
+import qualified Data.ByteString.Internal as BI
+import qualified Data.ByteString.Unsafe as BI
 #endif
 
 import           Snap.Internal.Debug
@@ -56,14 +56,13 @@ getHostAddr p s = do
 
 ------------------------------------------------------------------------------
 createSession :: Int -> CInt -> IO () -> IO NetworkSession
-createSession buffSize s _ = do
-    buffer <- mallocBytes $ fromIntegral buffSize
-    return $ NetworkSession s nullPtr buffer $ fromIntegral buffSize
+createSession buffSize s _ =
+    return $ NetworkSession s nullPtr $ fromIntegral buffSize
 
 
 ------------------------------------------------------------------------------
 endSession :: NetworkSession -> IO ()
-endSession (NetworkSession {_recvBuffer = buff}) = free buff
+endSession _ = return ()
 
 #ifdef PORTABLE
 
@@ -84,24 +83,27 @@ send sock tickle _ _ bs = SB.sendAll sock bs >> tickle
 
 ------------------------------------------------------------------------------
 recv :: IO () -> NetworkSession -> IO (Maybe ByteString)
-recv onBlock (NetworkSession s _ buff buffSize) = do
-    sz <- throwErrnoIfMinus1RetryMayBlock
-              "recv"
-              (c_read s buff buffSize)
-              onBlock
+recv onBlock (NetworkSession s _ buffSize) = do
+    fp <- BI.mallocByteString $ fromEnum buffSize
+    sz <- withForeignPtr fp $ \p ->
+              throwErrnoIfMinus1RetryMayBlock
+                  "recv"
+                  (c_read s p $ toEnum buffSize)
+                  onBlock
+
     if sz == 0
-        then return Nothing
-        else liftM Just $ B.packCStringLen (buff, fromIntegral sz)
+      then return Nothing
+      else return $ Just $ BI.fromForeignPtr fp 0 $ fromEnum sz
 
 
 ------------------------------------------------------------------------------
 send :: IO () -> IO () -> NetworkSession -> ByteString -> IO ()
-send tickleTimeout onBlock (NetworkSession s _ _ _) bs =
-    unsafeUseAsCStringLen bs $ uncurry loop
+send tickleTimeout onBlock (NetworkSession s _ _) bs =
+    BI.unsafeUseAsCStringLen bs $ uncurry loop
   where loop ptr len = do
           sent <- throwErrnoIfMinus1RetryMayBlock
                     "send"
-                    (c_write s ptr $ fromIntegral len)
+                    (c_write s ptr $ toEnum len)
                     onBlock
 
           let sent' = fromIntegral sent
-----------------------------------------------------------------------


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

Reply via email to