       statusDetails <- B.packCString =<< C.peek ptrPtrStatusStr
       let status = RpcStatus trailingMd statusCode statusDetails
       writeIORef value status
-      writeIORef statusFromServer (Just status)
+      putMVar statusFromServer status
       free
     free = do
       freeMetadataArray trailingMetadataArrPtr

    Left err -> return (RpcError err)
    Right a -> return (RpcOk a)

initialMetadata :: Rpc req resp [Metadata]
initialMetadata = do
  crw <- askCrw
  joinReply =<< liftIO (clientWaitForInitialMetadata crw)

waitForStatus :: Rpc req resp RpcStatus
waitForStatus = do
  crw <- askCrw
  joinReply =<< liftIO (clientWaitForStatus crw)

receiveMessage :: Rpc req resp (Maybe resp)
receiveMessage = do
  crw <- askCrw
  msg <- joinReply =<< liftIO (clientRead crw)
  case msg of
    Nothing -> return Nothing
    Just x -> do

  go []

sendMessage :: req -> Rpc req resp ()
sendMessage req = do
  abortIfStatus
  encoder <- askEncoder
  bs <- joinReply =<< liftIO (encoder req)
  joinClientRWOp (\crw -> clientWrite crw bs)

sendHalfClose :: Rpc req resp ()
sendHalfClose = do
  abortIfStatus
  joinClientRWOp clientSendHalfClose

closeCall :: Rpc req resp ()
closeCall =
  clientRWOp clientClose

data RpcReply a
  = RpcOk a
