packages feed

simple-sendfile 0.2.8 → 0.2.9

raw patch · 6 files changed

+47/−13 lines, 6 filesdep ~basedep ~network

Dependency ranges changed: base, network

Files

Network/Sendfile/BSD.hsc view
@@ -74,7 +74,9 @@         if errno `elem` [eAGAIN, eINTR] then do             sent <- peek sentp             hook-            threadWaitWrite dst+            -- Parallel IO manager use edge-trigger mode.+            -- So, calling threadWaitWrite only when errnor is eAGAIN.+            when (errno == eAGAIN) $ threadWaitWrite dst             let newoff = off + sent                 newlen = if len == entire then entire else len - sent             sendloop dst src newoff newlen sentp hook@@ -163,7 +165,9 @@                   else                     return $ Just (newoff, len - sent)               else do-                threadWaitWrite dst+                -- Parallel IO manager use edge-trigger mode.+                -- So, calling threadWaitWrite only when errnor is eAGAIN.+                when (errno == eAGAIN) $ threadWaitWrite dst                 let newlen = if len == entire then entire else len - sent                     newhdr = remainingChunks (fromIntegral sent) hdr                     newhlen = hlen - sent
Network/Sendfile/Linux.hsc view
@@ -102,7 +102,9 @@     loop 0    = return ()     loop left = do         hook-        threadWaitWrite dst+        -- Parallel IO manager use edge-trigger mode.+        -- So, calling threadWaitWrite only when errnor is eAGAIN.+        when (errno == eAGAIN) $ threadWaitWrite dst         sendloop dst src offp left hook  -- Dst Src in order. take care
simple-sendfile.cabal view
@@ -1,5 +1,5 @@ Name:                   simple-sendfile-Version:                0.2.8+Version:                0.2.9 Author:                 Kazu Yamamoto <kazu@iij.ad.jp> Maintainer:             Kazu Yamamoto <kazu@iij.ad.jp> License:                BSD3@@ -11,7 +11,6 @@ Category:               Network Cabal-Version:          >= 1.10 Build-Type:             Simple-Extra-Source-Files:     test/setup.sh  Library   Default-Language:     Haskell2010@@ -47,9 +46,8 @@   Type:                 exitcode-stdio-1.0   Default-Language:     Haskell2010   Hs-Source-Dirs:       test-  Main-Is:              Spec.hs+  Main-Is:              SendfileSpec.hs   GHC-Options:          -Wall-  Other-Modules:        SendfileSpec   Build-Depends:        base                       , HUnit                       , bytestring
test/SendfileSpec.hs view
@@ -1,11 +1,12 @@ {-# LANGUAGE OverloadedStrings #-} -module SendfileSpec where+module Main where  import Control.Concurrent import Control.Exception import Control.Monad-import Data.ByteString.Char8 as BS+import Data.ByteString (ByteString)+import qualified Data.ByteString.Char8 as BS import Data.Conduit import Data.Conduit.Binary as CB import Data.Conduit.List as CL@@ -23,10 +24,16 @@  ---------------------------------------------------------------- +main :: IO ()+main = do+    setup0+    hspec spec+ spec :: Spec spec = do     describe "sendfile" $ do         it "sends an entire file" $ do+            setup0             sendFile EntireFile `shouldReturn` ExitSuccess         it "sends a part of file" $ do             sendFile (PartOfFile 2000 1000000) `shouldReturn` ExitSuccess@@ -215,3 +222,30 @@                   => FilePath                   -> Sink ByteString m () sinkAppendFile fp = sinkIOHandle (openBinaryFile fp AppendMode)++----------------------------------------------------------------++srcFile :: String+srcFile = "/usr/share/dict/words"++dstFile :: String+dstFile = "test/inputFile"++setup0 :: IO ()+setup0 = do+    dst <- doesFileExist dstFile+    unless dst $ do+        src <- doesFileExist srcFile+        if src then do+            size <- getFileSize srcFile+            if size >= 1000000 then+                copyFile srcFile dstFile+              else+                failure+          else+            failure+  where+    getFileSize file = bracket (openFile file ReadMode) hClose hFileSize+    failure = do+        hPutStrLn stderr "You must copy a large file (> 1000000 bytes) to \"test/inputFile\"."+        exitFailure
− test/Spec.hs
@@ -1,1 +0,0 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
− test/setup.sh
@@ -1,3 +0,0 @@-#! /bin/sh--ln -s /usr/share/dict/words inputFile