packages feed

ngx-export 0.7.0.1 → 0.8.0.0

raw patch · 3 files changed

+48/−32 lines, 3 filesdep +monad-loopsPVP ok

version bump matches the API change (PVP)

Dependencies added: monad-loops

API changes (from Hackage documentation)

Files

Changelog.md view
@@ -1,3 +1,9 @@+### 0.8.0.0++- Implemented shared services using waitToSetLock to get exclusive access for+  servicing.+- New dependency on package *monad-loops* (>= 0.4.2).+ ### 0.7.0.0  Further optimizations.
NgxExport.hs view
@@ -48,8 +48,10 @@ import           System.IO.Error import           System.Posix.IO import           Control.Monad+import           Control.Monad.Loops import           Control.Exception hiding (Handler) import           GHC.IO.Exception (ioe_errno)+import           GHC.IO.Device (SeekMode (..)) import           Control.Concurrent.Async import qualified Data.ByteString as B import qualified Data.ByteString.Unsafe as B@@ -209,9 +211,9 @@ ngxExportAsyncIOYY :: Name -> Q [Dec] ngxExportAsyncIOYY =     ngxExportC 'IOYY 'asyncIOYY-    [t|CString -> CInt -> CInt -> CUInt -> CUInt ->-       Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr CUInt ->-       Ptr (StablePtr L.ByteString) -> IO ()|]+    [t|CString -> CInt -> CInt -> CInt -> CUInt -> CUInt ->+       Ptr (Ptr NgxStrType) -> Ptr CInt ->+       Ptr CUInt -> Ptr (StablePtr L.ByteString) -> IO ()|]  -- | Exports a function of type -- /'L.ByteString' -> 'B.ByteString' -> 'IO' 'L.ByteString'/@@ -223,8 +225,8 @@ ngxExportAsyncOnReqBody =     ngxExport 'IOYYY 'asyncIOYYY     [t|Ptr NgxStrType -> CInt -> CString -> CInt -> CInt -> CUInt ->-       Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr CUInt ->-       Ptr (StablePtr L.ByteString) -> IO ()|]+       Ptr (Ptr NgxStrType) -> Ptr CInt ->+       Ptr CUInt -> Ptr (StablePtr L.ByteString) -> IO ()|]  -- | Exports a function of type -- /'B.ByteString' -> 'Bool' -> 'IO' 'L.ByteString'/@@ -235,9 +237,9 @@ ngxExportServiceIOYY :: Name -> Q [Dec] ngxExportServiceIOYY =     ngxExport 'IOYY 'asyncIOYY-    [t|CString -> CInt -> CInt -> CUInt -> CUInt ->-       Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr CUInt ->-       Ptr (StablePtr L.ByteString) -> IO ()|]+    [t|CString -> CInt -> CInt -> CInt -> CUInt -> CUInt ->+       Ptr (Ptr NgxStrType) -> Ptr CInt ->+       Ptr CUInt -> Ptr (StablePtr L.ByteString) -> IO ()|]  -- | Exports a function of type -- /'B.ByteString' -> ('L.ByteString', 'String', 'Int')/@@ -367,6 +369,10 @@     return (C8L.pack $ show (e :: SomeException), 1) {-# INLINE safeYYHandler #-} +isEINTR :: IOError -> Bool+isEINTR = (Just ((\(Errno i) -> i) eINTR) ==) . ioe_errno+{-# INLINE isEINTR #-}+ sS :: SS -> CString -> CInt ->     Ptr CString -> Ptr CInt -> IO CUInt sS f x (I n) p pl =@@ -421,8 +427,8 @@ asyncIOFlag8b = L.toStrict $ runPut $ putInt64host 1  asyncIOCommon :: IO C8L.ByteString ->-    CInt -> Bool -> Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr CUInt ->-    Ptr (StablePtr L.ByteString) -> IO ()+    CInt -> Bool -> Ptr (Ptr NgxStrType) -> Ptr CInt ->+    Ptr CUInt -> Ptr (StablePtr L.ByteString) -> IO () asyncIOCommon a (I fd) efd p pl pr spd = void . async $ do     (s, r) <- safeYYHandler $ do         s <- a@@ -433,30 +439,33 @@         if efd             then writeFlag8b             else writeFlag1b >> closeFd fd `catchIOError` const (return ())-    where writeBufN n s w-              | w < n = (w +) <$>+    where writeBufN n s = iterateUntilM (>= n)+              (\w -> (w +) <$>                   fdWriteBuf fd (plusPtr s $ fromIntegral w) (n - w)-                  `catchIOError`-                  (\e -> return $-                       if ioe_errno e == Just ((\(Errno i) -> i) eINTR)-                           then 0-                           else n-                  ) >>= writeBufN n s-              | otherwise = return w-          writeFlag1b = void $-              B.unsafeUseAsCString asyncIOFlag1b $ flip (writeBufN 1) 0-          writeFlag8b = void $-              B.unsafeUseAsCString asyncIOFlag8b $ flip (writeBufN 8) 0+                  `catchIOError` (\e -> return $ if isEINTR e+                                                     then 0+                                                     else n+                                 )+              ) 0+          writeFlag1b = void $ B.unsafeUseAsCString asyncIOFlag1b $ writeBufN 1+          writeFlag8b = void $ B.unsafeUseAsCString asyncIOFlag8b $ writeBufN 8  asyncIOYY :: IOYY -> CString -> CInt ->-    CInt -> CUInt -> CUInt -> Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr CUInt ->-    Ptr (StablePtr L.ByteString) -> IO ()-asyncIOYY f x (I n) fd (ToBool efd) (ToBool fstRun) =-    asyncIOCommon (B.unsafePackCStringLen (x, n) >>= flip f fstRun) fd efd+    CInt -> CInt -> CUInt -> CUInt -> Ptr (Ptr NgxStrType) -> Ptr CInt ->+    Ptr CUInt -> Ptr (StablePtr L.ByteString) -> IO ()+asyncIOYY f x (I n) fd (I fdlk) (ToBool efd) (ToBool fstRun) =+    asyncIOCommon+    (do+        when (fstRun && fdlk /= -1) $ void $ iterateUntil (== True) $+            (waitToSetLock fdlk (WriteLock, AbsoluteSeek, 0, 0) >> return True)+            `catchIOError` (return . not . isEINTR)+        x' <- B.unsafePackCStringLen (x, n)+        f x' fstRun+    ) fd efd  asyncIOYYY :: IOYYY -> Ptr NgxStrType -> CInt -> CString -> CInt ->-    CInt -> CUInt -> Ptr (Ptr NgxStrType) -> Ptr CInt -> Ptr CUInt ->-    Ptr (StablePtr L.ByteString) -> IO ()+    CInt -> CUInt -> Ptr (Ptr NgxStrType) -> Ptr CInt ->+    Ptr CUInt -> Ptr (StablePtr L.ByteString) -> IO () asyncIOYYY f b (I m) x (I n) fd (ToBool efd) =     asyncIOCommon     (do
ngx-export.cabal view
@@ -1,5 +1,5 @@ name:                ngx-export-version:             0.7.0.1+version:             0.8.0.0 synopsis:            Helper module for Nginx haskell module description:         Helper module for         <http://github.com/lyokha/nginx-haskell-module Nginx haskell module>@@ -19,9 +19,10 @@   build-depends:       base >= 4.8 && < 5                      , template-haskell >= 2.11.0.0                      , bytestring >= 0.10.0.0-                     , unix-                     , async >= 2.0+                     , monad-loops >= 0.4.2                      , binary >= 0.8.1.0+                     , async >= 2.0+                     , unix   exposed-modules:     NgxExport   other-modules:       Paths_ngx_export   ghc-options:         -Wall -Wno-unrecognised-pragmas