From e2b0ae39d065841f0b22d04be12512d88f5a5cb1 Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sat, 28 Apr 2018 11:12:19 -0700 Subject: [PATCH 1/6] Use lts stackage for builds --- .travis.yml | 23 +++++++++++------------ mongoDB.cabal | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5b3015a..4e72fbd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,18 +11,14 @@ env: #- GHCVER=7.8.4 CABALVER=1.22 MONGO=2.6.12 #- GHCVER=7.10.3 CABALVER=1.22 MONGO=2.6.12 #- GHCVER=8.0.2 CABALVER=1.24 MONGO=2.6.12 - - GHCVER=7.8.4 CABALVER=1.22 MONGO=3.0 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.0 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 - - GHCVER=7.8.4 CABALVER=1.22 MONGO=3.2 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.2 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 - - GHCVER=7.8.4 CABALVER=1.22 MONGO=3.4 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.4 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 - - GHCVER=7.8.4 CABALVER=1.22 MONGO=3.6 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.6 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 + - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.0 STACKAGE=6.35 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 STACKAGE=9.21 + - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.2 STACKAGE=6.35 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 STACKAGE=9.21 + - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.4 STACKAGE=6.35 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 STACKAGE=9.21 + - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.6 STACKAGE=6.35 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=9.21 before_install: @@ -56,6 +52,9 @@ install: # Install the combined dependencies for this package and all other packages # needed to reduce conflicts. - cabal sandbox init + - wget https://www.stackage.org/lts-$STACKAGE/cabal.config + - sed -e '/mongoDB/d' cabal.config > cabal.config.new + - mv cabal.config.new cabal.config - cabal install --only-dependencies --enable-tests --enable-benchmarks script: diff --git a/mongoDB.cabal b/mongoDB.cabal index 9cca031..2436a08 100644 --- a/mongoDB.cabal +++ b/mongoDB.cabal @@ -43,7 +43,7 @@ Library , lifted-base >= 0.1.0.3 , pureMD5 , tagged - , tls >= 1.2.0 + , tls >= 1.3.0 , time , data-default-class -any , transformers From 5e08f63f34d215d70d5b737abdf17381c6c6b20b Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sat, 28 Apr 2018 14:12:53 -0700 Subject: [PATCH 2/6] Add lts build --- .travis.yml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e72fbd..82e5b66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,14 +11,15 @@ env: #- GHCVER=7.8.4 CABALVER=1.22 MONGO=2.6.12 #- GHCVER=7.10.3 CABALVER=1.22 MONGO=2.6.12 #- GHCVER=8.0.2 CABALVER=1.24 MONGO=2.6.12 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.0 STACKAGE=6.35 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 STACKAGE=9.21 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.2 STACKAGE=6.35 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 STACKAGE=9.21 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.4 STACKAGE=6.35 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 STACKAGE=9.21 - - GHCVER=7.10.3 CABALVER=1.22 MONGO=3.6 STACKAGE=6.35 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=9.21 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-11.6 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts before_install: @@ -52,7 +53,7 @@ install: # Install the combined dependencies for this package and all other packages # needed to reduce conflicts. - cabal sandbox init - - wget https://www.stackage.org/lts-$STACKAGE/cabal.config + - wget https://www.stackage.org/$STACKAGE/cabal.config - sed -e '/mongoDB/d' cabal.config > cabal.config.new - mv cabal.config.new cabal.config - cabal install --only-dependencies --enable-tests --enable-benchmarks From b66318d5eac9b31e7967ab8460fa380cf3a0ea71 Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Fri, 16 Mar 2018 22:05:28 -0700 Subject: [PATCH 3/6] Add ghc 8.4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 82e5b66..d003a84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ env: - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-11.6 - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-9.21 - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-11.6 - - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts + - GHCVER=8.4.2 CABALVER=2.2.0.1 MONGO=3.6 STACKAGE=nightly before_install: From 9e0781dff5d6904cc2a4f36ba432a6ab240e4434 Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sat, 28 Apr 2018 15:14:30 -0700 Subject: [PATCH 4/6] Use stm channels --- .travis.yml | 2 +- Database/MongoDB/Internal/Protocol.hs | 15 ++++++++------- mongoDB.cabal | 2 ++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index d003a84..474e0cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ env: - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-11.6 - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-9.21 - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-11.6 - - GHCVER=8.4.2 CABALVER=2.2.0.1 MONGO=3.6 STACKAGE=nightly + - GHCVER=8.4.2 CABALVER=2.2 MONGO=3.6 STACKAGE=nightly before_install: diff --git a/Database/MongoDB/Internal/Protocol.hs b/Database/MongoDB/Internal/Protocol.hs index 384c82e..b2d9c03 100644 --- a/Database/MongoDB/Internal/Protocol.hs +++ b/Database/MongoDB/Internal/Protocol.hs @@ -47,8 +47,9 @@ import System.IO.Unsafe (unsafePerformIO) import Data.Maybe (maybeToList) import GHC.Conc (ThreadStatus(..), threadStatus) import Control.Monad (forever) -import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan, isEmptyChan) +import Control.Monad.STM (atomically) import Control.Concurrent (ThreadId, killThread, forkFinally) +import Control.Concurrent.STM.TChan (TChan, newTChan, readTChan, writeTChan, isEmptyTChan) import Control.Exception.Lifted (onException, throwIO, try) @@ -87,7 +88,7 @@ mkWeakMVar = addMVarFinalizer -- | Thread-safe and pipelined connection data Pipeline = Pipeline { vStream :: MVar Transport -- ^ Mutex on handle, so only one thread at a time can write to it - , responseQueue :: Chan (MVar (Either IOError Response)) -- ^ Queue of threads waiting for responses. Every time a response arrive we pop the next thread and give it the response. + , responseQueue :: TChan (MVar (Either IOError Response)) -- ^ Queue of threads waiting for responses. Every time a response arrive we pop the next thread and give it the response. , listenThread :: ThreadId , finished :: MVar () , serverData :: ServerData @@ -106,14 +107,14 @@ data ServerData = ServerData newPipeline :: ServerData -> Transport -> IO Pipeline newPipeline serverData stream = do vStream <- newMVar stream - responseQueue <- newChan + responseQueue <- atomically newTChan finished <- newEmptyMVar let drainReplies = do - chanEmpty <- isEmptyChan responseQueue + chanEmpty <- atomically $ isEmptyTChan responseQueue if chanEmpty then return () else do - var <- readChan responseQueue + var <- atomically $ readTChan responseQueue putMVar var $ Left $ mkIOError doesNotExistErrorType "Handle has been closed" @@ -159,7 +160,7 @@ listen Pipeline{..} = do stream <- readMVar vStream forever $ do e <- try $ readMessage stream - var <- readChan responseQueue + var <- atomically $ readTChan responseQueue putMVar var e case e of Left err -> Tr.close stream >> ioError err -- close and stop looping @@ -182,7 +183,7 @@ pcall p@Pipeline{..} message = do doCall stream = do writeMessage stream message var <- newEmptyMVar - liftIO $ writeChan responseQueue var + liftIO $ atomically $ writeTChan responseQueue var return $ readMVar var >>= either throwIO return -- return promise -- * Pipe diff --git a/mongoDB.cabal b/mongoDB.cabal index 2436a08..bf1c6e7 100644 --- a/mongoDB.cabal +++ b/mongoDB.cabal @@ -42,6 +42,7 @@ Library , monad-control >= 0.3.1 , lifted-base >= 0.1.0.3 , pureMD5 + , stm , tagged , tls >= 1.3.0 , time @@ -106,6 +107,7 @@ Benchmark bench , cryptohash -any , network -any , nonce >= 1.0.5 + , stm , parsec -any , random -any , random-shuffle -any From 3b526c035dc9c74ecdbc2f9f91680ea37e789dbc Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sat, 28 Apr 2018 16:27:05 -0700 Subject: [PATCH 5/6] Reverse build order --- .travis.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 474e0cf..5ba28d3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,15 +11,15 @@ env: #- GHCVER=7.8.4 CABALVER=1.22 MONGO=2.6.12 #- GHCVER=7.10.3 CABALVER=1.22 MONGO=2.6.12 #- GHCVER=8.0.2 CABALVER=1.24 MONGO=2.6.12 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-9.21 - - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-11.6 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-9.21 - - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-11.6 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-9.21 - - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-11.6 - - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-9.21 - - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-11.6 - GHCVER=8.4.2 CABALVER=2.2 MONGO=3.6 STACKAGE=nightly + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-9.21 + - GHCVER=8.2.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-11.6 + - GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-9.21 before_install: From 21e87d9e57eb5b5c1c1d2156a6ad14633d467aff Mon Sep 17 00:00:00 2001 From: Victor Denisov Date: Sun, 29 Apr 2018 13:16:03 -0700 Subject: [PATCH 6/6] Add a changelog entry --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7368ccf..7c35503 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Package Versioning Policy](https://wiki.haskell.org/Package_versioning_policy). +## [Unreleased] + +### Fixed +- GHC 8.4 compatibility. isEmptyChan is not available in base 4.11 anymore. + ## [2.3.0.5] - 2018-03-15 ### Fixed