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 33e83a54fb288f2771fcb42782c4c1f3bdfdb6c9 (commit)
from 6737c7d5102c573296a1ca7a8b2560e6e081f259 (commit)
Summary of changes:
snap-server.cabal | 19 ++++++++----
src/Snap/Internal/Http/Server.hs | 36 +++++++++++++++++++++++-
src/Snap/Internal/Http/Server/LibevBackend.hs | 4 ++
src/Snap/Internal/Http/Server/SimpleBackend.hs | 4 ++
src/System/SendFile.hs | 8 +----
5 files changed, 57 insertions(+), 14 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 33e83a54fb288f2771fcb42782c4c1f3bdfdb6c9
Author: Shu-yu Guo <[email protected]>
Date: Sun Jun 6 19:06:13 2010 -0700
Fix compilation issues with sendfile... I hope
diff --git a/snap-server.cabal b/snap-server.cabal
index 0bf847d..d730ab9 100644
--- a/snap-server.cabal
+++ b/snap-server.cabal
@@ -93,7 +93,6 @@ Library
Snap.Internal.Http.Parser,
Snap.Internal.Http.Server,
Snap.Internal.Http.Server.Date
- System.SendFile
build-depends:
array >= 0.2 && <0.4,
@@ -133,17 +132,23 @@ Library
other-modules: Snap.Internal.Http.Server.SimpleBackend
- if os(linux)
+ if os(linux) && !flag(portable)
cpp-options: -DLINUX -DHAS_SENDFILE
- other-modules: System.SendFile.Linux
+ other-modules:
+ System.SendFile,
+ System.SendFile.Linux
- if os(darwin)
+ if os(darwin) && !flag(portable)
cpp-options: -DOSX -DHAS_SENDFILE
- other-modules: System.SendFile.Darwin
+ other-modules:
+ System.SendFile,
+ System.SendFile.Darwin
- if os(freebsd)
+ if os(freebsd) && !flag(portable)
cpp-options: -DFREEBSD -DHAS_SENDFILE
- other-modules: System.SendFile.FreeBSD
+ other-modules:
+ System.SendFile,
+ System.SendFile.FreeBSD
ghc-prof-options: -prof -auto-all
diff --git a/src/Snap/Internal/Http/Server.hs b/src/Snap/Internal/Http/Server.hs
index 03f233f..e553a9d 100644
--- a/src/Snap/Internal/Http/Server.hs
+++ b/src/Snap/Internal/Http/Server.hs
@@ -176,7 +176,9 @@ httpServe bindAddress bindPort localHostname alogPath
elogPath handler =
runHTTP localHostname laddr lport raddr rport
alog elog readEnd writeEnd
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
(Backend.sendFile conn)
+#endif
(Backend.tickleTimeout conn) handler
debug "Server.httpServe.runHTTP: finished"
@@ -252,12 +254,18 @@ runHTTP :: ByteString -- ^ local host
name
-> Maybe Logger -- ^ error logger
-> Enumerator IO () -- ^ read end of socket
-> Iteratee IO () -- ^ write end of socket
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
-> (FilePath -> Int -> IO ()) -- ^ sendfile end
+#endif
-> IO () -- ^ timeout tickler
-> ServerHandler -- ^ handler procedure
-> IO ()
runHTTP lh lip lp rip rp alog elog
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
readEnd writeEnd onSendFile tickle handler =
+#else
+ readEnd writeEnd tickle handler =
+#endif
go `catches` [ Handler $ \(e :: AsyncException) -> do
throwIO e
@@ -272,7 +280,11 @@ runHTTP lh lip lp rip rp alog elog
go = do
buf <- mkIterateeBuffer
let iter = runServerMonad lh lip lp rip rp (logA alog) (logE elog) $
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
httpSession writeEnd buf onSendFile tickle
+#else
+ httpSession writeEnd buf tickle
+#endif
handler
readEnd iter >>= run
@@ -296,11 +308,17 @@ logError s = gets _logError >>= (\l -> liftIO $ l s)
-- | Runs an HTTP session.
httpSession :: Iteratee IO () -- ^ write end of socket
-> ForeignPtr CChar -- ^ iteratee buffer
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
-> (FilePath -> Int -> IO ()) -- ^ sendfile continuation
+#endif
-> IO () -- ^ timeout tickler
-> ServerHandler -- ^ handler procedure
-> ServerMonad ()
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
httpSession writeEnd' ibuf onSendFile tickle handler = do
+#else
+httpSession writeEnd' ibuf tickle handler = do
+#endif
(writeEnd, cancelBuffering) <-
liftIO $ I.unsafeBufferIterateeWithBuffer ibuf writeEnd'
@@ -340,7 +358,11 @@ httpSession writeEnd' ibuf onSendFile tickle handler = do
date <- liftIO getDateString
let ins = (Map.insert "Date" [date] . Map.insert "Server"
sERVER_HEADER)
let rsp' = updateHeaders ins rsp
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
(bytesSent,_) <- sendResponse rsp' writeEnd ibuf killBuffer
onSendFile
+#else
+ (bytesSent,_) <- sendResponse rsp' writeEnd ibuf killBuffer
+#endif
liftIO . debug $ "Server.httpSession: sent " ++
(Prelude.show bytesSent) ++ " bytes"
@@ -351,7 +373,11 @@ httpSession writeEnd' ibuf onSendFile tickle handler = do
if cc
then return ()
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
else httpSession writeEnd' ibuf onSendFile tickle handler
+#else
+ else httpSession writeEnd' ibuf tickle handler
+#endif
Nothing -> return ()
@@ -510,15 +536,21 @@ sendResponse :: Response
-> Iteratee IO a
-> ForeignPtr CChar
-> IO ()
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
-> (FilePath -> Int -> IO a)
+#endif
-> ServerMonad (Int, a)
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
sendResponse rsp' writeEnd ibuf killBuffering onSendFile = do
+#else
+sendResponse rsp' writeEnd ibuf killBuffering = do
+#endif
rsp <- fixupResponse rsp'
let !headerString = mkHeaderString rsp
(!x,!bs) <- case (rspBody rsp) of
(Enum e) -> liftIO $ whenEnum headerString e
-#if defined(HAS_SENDFILE)
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
(SendFile f) -> liftIO $ whenSendFile headerString rsp f
#else
(SendFile f) -> liftIO $ whenEnum headerString
@@ -536,6 +568,7 @@ sendResponse rsp' writeEnd ibuf killBuffering onSendFile =
do
return (x, bs-hl)
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
whenSendFile hs r f = do
-- guaranteed to have a content length here.
enumBS hs writeEnd >>= run
@@ -543,6 +576,7 @@ sendResponse rsp' writeEnd ibuf killBuffering onSendFile =
do
let !cl = fromJust $ rspContentLength r
x <- onSendFile f cl
return (x, cl)
+#endif
(major,minor) = rspHttpVersion rsp'
diff --git a/src/Snap/Internal/Http/Server/LibevBackend.hs
b/src/Snap/Internal/Http/Server/LibevBackend.hs
index f3ba2bb..177f51f 100644
--- a/src/Snap/Internal/Http/Server/LibevBackend.hs
+++ b/src/Snap/Internal/Http/Server/LibevBackend.hs
@@ -18,7 +18,9 @@ module Snap.Internal.Http.Server.LibevBackend
, new
, stop
, withConnection
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
, sendFile
+#endif
, tickleTimeout
, getReadEnd
, getWriteEnd
@@ -115,6 +117,7 @@ name :: ByteString
name = "libev"
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
sendFile :: Connection -> FilePath -> Int -> IO ()
sendFile c fp total = do
withMVar lock $ \_ -> do
@@ -146,6 +149,7 @@ sendFile c fp total = do
loop = _evLoop b
lock = _loopLock b
asy = _asyncObj b
+#endif
bindIt :: ByteString -- ^ bind address, or \"*\" for all
diff --git a/src/Snap/Internal/Http/Server/SimpleBackend.hs
b/src/Snap/Internal/Http/Server/SimpleBackend.hs
index 657c946..41a7cdd 100644
--- a/src/Snap/Internal/Http/Server/SimpleBackend.hs
+++ b/src/Snap/Internal/Http/Server/SimpleBackend.hs
@@ -18,7 +18,9 @@ module Snap.Internal.Http.Server.SimpleBackend
, new
, stop
, withConnection
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
, sendFile
+#endif
, tickleTimeout
, getReadEnd
, getWriteEnd
@@ -91,6 +93,7 @@ name :: ByteString
name = "simple"
+#if defined(HAS_SENDFILE) && !defined(PORTABLE)
sendFile :: Connection -> FilePath -> Int -> IO ()
sendFile c fp sz = do
fd <- openFd fp ReadOnly Nothing defaultFileFlags
@@ -105,6 +108,7 @@ sendFile c fp sz = do
else return ()
sfd = Fd . fdSocket $ _socket c
+#endif
bindIt :: ByteString -- ^ bind address, or \"*\" for all
diff --git a/src/System/SendFile.hs b/src/System/SendFile.hs
index 2810232..04784e7 100644
--- a/src/System/SendFile.hs
+++ b/src/System/SendFile.hs
@@ -13,16 +13,12 @@ import System.SendFile.Linux (sendFile)
sendFileMode :: String
sendFileMode = "LINUX_SENDFILE"
-#endif
-
-#if defined(FREEBSD)
+#elif defined(FREEBSD)
import System.SendFile.FreeBSD (sendFile)
sendFileMode :: String
sendFileMode = "FREEBSD_SENDFILE"
-#endif
-
-#if defined(OSX)
+#elif defined(OSX)
import System.SendFile.Darwin (sendFile)
sendFileMode :: String
-----------------------------------------------------------------------
hooks/post-receive
--
snap-server
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap