mirror of
https://github.com/unclechu/gRPC-haskell.git
synced 2024-11-27 05:29:43 +01:00
72160cea89
pluckers) would register a CQ notification via grpc_server_request_registered_call prior to obtaining pluck permission, block on acquiring such permission, and thus miss notification of the server call. The bug can could be witnessed with particular interleavings by ensuring that GRPC_MAX_COMPLETION_QUEUE_PLUCKERS server threads are blocked on their own server call notifications, and then using the (GRPC_MAX_COMPLETION_QUEUE_PLUCKERS+1)th server thread to attempt to block on a notification for an additional server call. In order to fix this, we simply extended the pluck permission held window for serverRequestCall, and created a variant of pluck (called pluck') which assumes permission to pluck is already held by the calling thread.
21 lines
797 B
Haskell
21 lines
797 B
Haskell
{-# LANGUAGE LambdaCase #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
|
|
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
|
|
|
|
import Control.Monad
|
|
import Network.GRPC.LowLevel
|
|
import Network.GRPC.LowLevel.Call
|
|
import qualified Network.GRPC.LowLevel.Client.Unregistered as U
|
|
import System.Environment
|
|
|
|
echoMethod = MethodName "/echo.Echo/DoEcho"
|
|
|
|
_unregistered c = U.clientRequest c echoMethod 1 "hi" mempty
|
|
|
|
main = withGRPC $ \g ->
|
|
withClient g (ClientConfig "localhost" 50051 []) $ \c -> do
|
|
rm <- clientRegisterMethod c echoMethod Normal
|
|
replicateM_ 100000 $ clientRequest c rm 5 "hi" mempty >>= \case
|
|
Left e -> error $ "Got client error: " ++ show e
|
|
_ -> return ()
|