Skip to content

Commit 7d23189

Browse files
committed
Merge fix for ghc-8.4
2 parents 823e6ac + 21e87d9 commit 7d23189

File tree

4 files changed

+28
-20
lines changed

4 files changed

+28
-20
lines changed

.travis.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,15 @@ env:
1111
#- GHCVER=7.8.4 CABALVER=1.22 MONGO=2.6.12
1212
#- GHCVER=7.10.3 CABALVER=1.22 MONGO=2.6.12
1313
#- GHCVER=8.0.2 CABALVER=1.24 MONGO=2.6.12
14-
- GHCVER=7.8.4 CABALVER=1.22 MONGO=3.0
15-
- GHCVER=7.10.3 CABALVER=1.22 MONGO=3.0
16-
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0
17-
- GHCVER=7.8.4 CABALVER=1.22 MONGO=3.2
18-
- GHCVER=7.10.3 CABALVER=1.22 MONGO=3.2
19-
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2
20-
- GHCVER=7.8.4 CABALVER=1.22 MONGO=3.4
21-
- GHCVER=7.10.3 CABALVER=1.22 MONGO=3.4
22-
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4
23-
- GHCVER=7.8.4 CABALVER=1.22 MONGO=3.6
24-
- GHCVER=7.10.3 CABALVER=1.22 MONGO=3.6
25-
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6
14+
- GHCVER=8.4.2 CABALVER=2.2 MONGO=3.6 STACKAGE=nightly
15+
- GHCVER=8.2.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-11.6
16+
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.6 STACKAGE=lts-9.21
17+
- GHCVER=8.2.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-11.6
18+
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.0 STACKAGE=lts-9.21
19+
- GHCVER=8.2.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-11.6
20+
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.4 STACKAGE=lts-9.21
21+
- GHCVER=8.2.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-11.6
22+
- GHCVER=8.0.2 CABALVER=1.24 MONGO=3.2 STACKAGE=lts-9.21
2623

2724
before_install:
2825

@@ -56,6 +53,9 @@ install:
5653
# Install the combined dependencies for this package and all other packages
5754
# needed to reduce conflicts.
5855
- cabal sandbox init
56+
- wget https://www.stackage.org/$STACKAGE/cabal.config
57+
- sed -e '/mongoDB/d' cabal.config > cabal.config.new
58+
- mv cabal.config.new cabal.config
5959
- cabal install --only-dependencies --enable-tests --enable-benchmarks
6060

6161
script:

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Package Versioning Policy](https://wiki.haskell.org/Package_versioning_policy).
44

5+
## [Unreleased]
6+
7+
### Fixed
8+
- GHC 8.4 compatibility. isEmptyChan is not available in base 4.11 anymore.
9+
510
## [2.3.0.5] - 2018-03-15
611

712
### Fixed

Database/MongoDB/Internal/Protocol.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ import System.IO.Unsafe (unsafePerformIO)
4747
import Data.Maybe (maybeToList)
4848
import GHC.Conc (ThreadStatus(..), threadStatus)
4949
import Control.Monad (forever)
50-
import Control.Concurrent.Chan (Chan, newChan, readChan, writeChan, isEmptyChan)
50+
import Control.Monad.STM (atomically)
5151
import Control.Concurrent (ThreadId, killThread, forkFinally)
52+
import Control.Concurrent.STM.TChan (TChan, newTChan, readTChan, writeTChan, isEmptyTChan)
5253

5354
import Control.Exception.Lifted (onException, throwIO, try)
5455

@@ -87,7 +88,7 @@ mkWeakMVar = addMVarFinalizer
8788
-- | Thread-safe and pipelined connection
8889
data Pipeline = Pipeline
8990
{ vStream :: MVar Transport -- ^ Mutex on handle, so only one thread at a time can write to it
90-
, 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.
91+
, 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.
9192
, listenThread :: ThreadId
9293
, finished :: MVar ()
9394
, serverData :: ServerData
@@ -106,14 +107,14 @@ data ServerData = ServerData
106107
newPipeline :: ServerData -> Transport -> IO Pipeline
107108
newPipeline serverData stream = do
108109
vStream <- newMVar stream
109-
responseQueue <- newChan
110+
responseQueue <- atomically newTChan
110111
finished <- newEmptyMVar
111112
let drainReplies = do
112-
chanEmpty <- isEmptyChan responseQueue
113+
chanEmpty <- atomically $ isEmptyTChan responseQueue
113114
if chanEmpty
114115
then return ()
115116
else do
116-
var <- readChan responseQueue
117+
var <- atomically $ readTChan responseQueue
117118
putMVar var $ Left $ mkIOError
118119
doesNotExistErrorType
119120
"Handle has been closed"
@@ -159,7 +160,7 @@ listen Pipeline{..} = do
159160
stream <- readMVar vStream
160161
forever $ do
161162
e <- try $ readMessage stream
162-
var <- readChan responseQueue
163+
var <- atomically $ readTChan responseQueue
163164
putMVar var e
164165
case e of
165166
Left err -> Tr.close stream >> ioError err -- close and stop looping
@@ -182,7 +183,7 @@ pcall p@Pipeline{..} message = do
182183
doCall stream = do
183184
writeMessage stream message
184185
var <- newEmptyMVar
185-
liftIO $ writeChan responseQueue var
186+
liftIO $ atomically $ writeTChan responseQueue var
186187
return $ readMVar var >>= either throwIO return -- return promise
187188

188189
-- * Pipe

mongoDB.cabal

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ Library
4242
, monad-control >= 0.3.1
4343
, lifted-base >= 0.1.0.3
4444
, pureMD5
45+
, stm
4546
, tagged
46-
, tls >= 1.2.0
47+
, tls >= 1.3.0
4748
, time
4849
, data-default-class -any
4950
, transformers
@@ -106,6 +107,7 @@ Benchmark bench
106107
, cryptohash -any
107108
, network -any
108109
, nonce >= 1.0.5
110+
, stm
109111
, parsec -any
110112
, random -any
111113
, random-shuffle -any

0 commit comments

Comments
 (0)