grpc c ++称为CompletionQueue shutdown,但当有挂起事件时,CompletionQueue.next将永久阻止

时间:2017-09-29 12:25:10

标签: c++ grpc

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

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

在另一个theads中,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++

1 个答案:

答案 0 :(得分:0)

The API means cq.Next will return false once you have drained the cq. I am not sure what you meant by having one pending event, but if it is not the shutdown event, your cq.Next will still wait for that event to return before returning false (in the next call).

相关问题