mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-05 10:49:42 +01:00
make serverLoop blocking again (#59)
This commit is contained in:
parent
0d70a6c960
commit
5a23c9ae90
1 changed files with 4 additions and 2 deletions
|
@ -9,6 +9,7 @@
|
|||
module Network.GRPC.HighLevel.Server.Unregistered where
|
||||
|
||||
import Control.Concurrent
|
||||
import Control.Concurrent.Async (async, wait)
|
||||
import Control.Arrow
|
||||
import qualified Control.Exception as CE
|
||||
import Control.Monad
|
||||
|
@ -81,10 +82,10 @@ dispatchLoop server meta hN hC hS hB =
|
|||
U.serverRW server call meta (convertServerRWHandler h)
|
||||
|
||||
serverLoop :: ServerOptions -> IO ()
|
||||
serverLoop ServerOptions{..} =
|
||||
serverLoop ServerOptions{..} = do
|
||||
-- We run the loop in a new thread so that we can kill the serverLoop thread.
|
||||
-- Without this fork, we block on a foreign call, which can't be interrupted.
|
||||
void $ forkIO $ withGRPC $ \grpc ->
|
||||
tid <- async $ withGRPC $ \grpc ->
|
||||
withServer grpc config $ \server -> do
|
||||
dispatchLoop server
|
||||
optInitialMetadata
|
||||
|
@ -92,6 +93,7 @@ serverLoop ServerOptions{..} =
|
|||
optClientStreamHandlers
|
||||
optServerStreamHandlers
|
||||
optBiDiStreamHandlers
|
||||
wait tid
|
||||
where
|
||||
config =
|
||||
ServerConfig
|
||||
|
|
Loading…
Reference in a new issue