File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,15 +232,17 @@ withServer =
232232 withResource createServer destroyServer
233233
234234-- | Get a unique port number that is not used by other tests. Needed since
235- -- all tests run in parallel.
235+ -- all tests run in parallel and we can't run Fencer on the same port in
236+ -- parallel.
236237getUniquePort :: IO Port
237- getUniquePort = atomicModifyIORef' next (\ port -> (succ port, port))
238- where
239- next :: IORef Port
240- next = unsafePerformIO (newIORef defaultGRPCPort)
241- {-# NOINLINE next #-}
238+ getUniquePort = atomicModifyIORef' nextUniquePortVar (\ port -> (succ port, port))
242239
243- {-# NOINLINE getUniquePort #-}
240+ -- | Top-level global variable used by 'getUniquePort'. For the explanation
241+ -- of @NOINLINE@, see
242+ -- <http://neilmitchell.blogspot.com/2014/10/hlint-now-spots-bad-unsafeperformio.html>.
243+ nextUniquePortVar :: IORef Port
244+ nextUniquePortVar = unsafePerformIO (newIORef defaultGRPCPort)
245+ {-# NOINLINE nextUniquePortVar #-}
244246
245247----------------------------------------------------------------------------
246248-- gRPC client
You can’t perform that action at this time.
0 commit comments