on edee978 help sign in
3 files changed+12−19
since splitsnapshots
unifiedsplit
cabal.project+1−1 curryer-rpc.cabal → curryer.cabal+2−3 src/Network/RPC/Curryer/Server.hs+9−15
cabal.project+1−1
@@ -3,4 +3,4 @@ packages: .
33source-repository-package
44 type: git
55 location: https://github.com/composewell/streamly.git
6− tag: 4e48b52e8709390a47e99c107ebed2d1c9420076
6+ tag: ac3af8749194f1788704dda8667d0b3807075cc2
curryer-rpc.cabal → curryer.cabalrenamed+2−3
@@ -11,7 +11,7 @@ Maintainer: agentm@themactionfaction.com
1111Cabal-Version: >= 1.10
1212Synopsis: Fast, Haskell RPC
1313Description: Haskell-to-Haskell RPC using Winery serialization.
14−Extra-Source-Files: Changelog.markdown README.markdown cabal.project
14+Extra-Source-Files: Changelog.markdown README.markdown
1515
1616Source-Repository head
1717 Type: git
@@ -65,8 +65,7 @@ Benchmark perf
6565
6666 Main-Is: Basic.hs
6767 Type: exitcode-stdio-1.0
68− GHC-Options: -Wall -threaded -rtsopts
69− -- -fprof-auto
68+ GHC-Options: -Wall -threaded -rtsopts -fprof-auto
7069 HS-Source-Dirs: ./bench
7170
7271Executable SimpleKeyValueServer
src/Network/RPC/Curryer/Server.hs+9−15
@@ -1,4 +1,4 @@
1−{-# LANGUAGE DerivingVia, DeriveGeneric, RankNTypes, ScopedTypeVariables, MultiParamTypeClasses, OverloadedStrings, GeneralizedNewtypeDeriving, CPP, ExistentialQuantification, StandaloneDeriving, GADTs, RecordWildCards #-}
1+{-# LANGUAGE DerivingVia, DeriveGeneric, RankNTypes, ScopedTypeVariables, MultiParamTypeClasses, OverloadedStrings, GeneralizedNewtypeDeriving, CPP, ExistentialQuantification, StandaloneDeriving, GADTs #-}
22{-# OPTIONS_GHC -fno-warn-orphans #-}
33{- HLINT ignore "Use lambda-case" -}
44module Network.RPC.Curryer.Server where
@@ -35,13 +35,13 @@ import Data.Hashable
3535import System.Timeout
3636import qualified Network.ByteOrder as BO
3737
38−
3938-- for toArrayS conversion
40−import qualified Data.ByteString.Internal as BSI
41−import qualified Streamly.Internal.Data.Array.Storable.Foreign.Types as Arr
39+{-import qualified Data.ByteString.Internal as BSI
40+import qualified Streamly.Internal.Data.Array.Storable.Foreign.Types as SA
41+import Foreign.ForeignPtr (plusForeignPtr)
4242import Foreign.ForeignPtr.Unsafe (unsafeForeignPtrToPtr)
43−import GHC.Ptr (minusPtr)
44−
43+import GHC.Ptr (plusPtr)
44+-}
4545-- define CURRYER_SHOW_BYTES 1
4646#if CURRYER_SHOW_BYTES == 1
4747import Debug.Trace
@@ -159,7 +159,8 @@ localHostAddr = (127,0,0,1)
159159-- Each message is length-prefixed by a 32-bit unsigned length.
160160envelopeP :: Parser IO Word8 Envelope
161161envelopeP = do
162− let msgTypeP = (P.satisfy (== 0) *>
162+ let s = FL.toList
163+ msgTypeP = (P.satisfy (== 0) *>
163164 (RequestMessage . fromIntegral <$> word32P)) `P.alt`
164165 (P.satisfy (== 1) $> ResponseMessage) `P.alt`
165166 (P.satisfy (== 2) $> TimeoutResponseMessage) `P.alt`
@@ -170,7 +171,7 @@ envelopeP = do
170171 if c == 0 then
171172 pure BS.empty
172173 else
173− fromArray <$> P.takeEQ c (Arr.writeN c)
174+ BS.pack <$> P.takeEQ c s
174175 Envelope <$> fingerprintP <*> msgTypeP <*> uuidP <*> lenPrefixedByteStringP
175176
176177encodeEnvelope :: Envelope -> BS.ByteString
@@ -333,10 +334,3 @@ sendEnvelope envelope sockLock = do
333334fingerprint :: Typeable a => a -> Fingerprint
334335fingerprint = typeRepFingerprint . typeOf
335336
336−fromArray :: Arr.Array Word8 -> BSI.ByteString
337−fromArray Arr.Array {..}
338− | aLen == 0 = mempty
339− | otherwise = BSI.PS aStart 0 aLen
340− where
341− aStartPtr = unsafeForeignPtrToPtr aStart
342− aLen = aEnd `minusPtr` aStartPtr