【问题标题】:grpc c++ called CompletionQueue shutdown but CompletionQueue.next blocked forever when there is pending eventgrpc c++ 调用 CompletionQueue 关闭但 CompletionQueue.next 在有挂起事件时永远阻塞
【发布时间】:2017-09-29 12:25:10
【问题描述】:

有两个线程,一个在CompletionQueue上调用shutdown

    debug_log("cq shutdown start\n");
    cq.Shutdown();
    debug_log("cq shutdown success\n");

在另一个线程中,cq.next 永远被阻止。

我可以看到 cq 中有一个待处理的事件, 但是从文档中我希望一旦我调用shutdown,cq.next 将开始返回false。

我不知道这里出了什么问题。

这是 cq.next 的调用堆栈

grpc_iocp_work(grpc_exec_ctx * exec_ctx, gpr_timespec deadline) Line 83 C
grpc_pollset_work(grpc_exec_ctx * exec_ctx, grpc_pollset * pollset, grpc_pollset_worker * * worker_hdl, gpr_timespec now, gpr_timespec deadline) Line 143   C
cq_next(grpc_completion_queue * cc, gpr_timespec deadline, void * reserved) Line 844    C
grpc_completion_queue_next(grpc_completion_queue * cc, gpr_timespec deadline, void * reserved) Line 873 C
grpc::CompletionQueue::AsyncNextInternal(void * * tag, bool * ok, gpr_timespec deadline) Line 71    C++
grpc::CompletionQueue::Next(void * * tag, bool * ok) Line 151   C++

【问题讨论】:

    标签: c++ grpc


    【解决方案1】:

    API 表示 cq.Next 将在您耗尽 cq 后返回 false。我不确定您所说的有一个待处理事件是什么意思,但如果它不是关闭事件,您的 cq.Next 仍将等待该事件返回,然后返回 false(在下一次调用中)。

    【讨论】:

      猜你喜欢
      • 2014-09-13
      • 2018-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-08
      • 1970-01-01
      相关资源
      最近更新 更多