In addition to what Vijay Said, I wanted to address the following you mentioned:
* >> If I do nothing in this case, CallData exhaust after a while and the program hang at the 3rd line (the start of the while loop).* By the way, I am assuming you are using the grpc async server example from here <https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc>. If ok==false, you still need to do *'service_->*RequestMethodName()' to let grpc know that it should accept a new method like here <https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L106> for example. Otherwise, the server will not be able to accept any new incoming method that it doesn't know about - and this is the reason why cq->next() doesn't return (NOTE: If ok == true, things are working well because I am sure your code is also doing soemthing similar to what is done in the example. i.e cd->proceed() is called with status_ == PROCESS and the first thing it does is to create a new CallData <https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L112> object whose constructor calls Proceed() <https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L93> - which ends up calling service_->RequestSayHello() <https://github.com/grpc/grpc/blob/master/examples/cpp/helloworld/greeter_async_server.cc#L106> ) thanks, Sree On Mon, Jan 23, 2017 at 11:16 AM, 'Vijay Pai' via grpc.io < [email protected]> wrote: > Hello there, > Thanks for the detailed question and feedback! The ok parameter indicates > whether or not the operation completed "normally". When it is false, it > means that no more operations on that side of the RPC (Read-side or > Write-side) will ever return true in the future (e.g., a server Read will > never return true again after the client has done a WritesDone). In some > cases, it might mean that operations on both sides of the RPC will never > return true in the future (e.g., if the RPC was cancelled or had its > deadline exceeded). The way to handle it will typically be to mark some > information in your class to indicate that type of progress has occurred. > That said, the only conclusive way of knowing the RPC status is with a call > to Finish. The ok parameter just tells you explicitly about one side of the > RPC. > > - Vijay > > On Mon, Jan 16, 2017 at 12:47 AM <[email protected]> wrote: > >> CallData* cd = NULL; >> bool ok = false; >> while( cq->Next(reinterpret_cast<void**>(&cd), &ok) ) { >> if( ok ) { >> cd->Proceed(); >> } else { >> // what to do here? >> } >> } >> >> In my grpc server, I found the 2nd parameter >> of ServerCompletionQueue::Next sometimes returns false. >> >> If I do nothing in this case, CallData exhaust after a while and the >> program hang at the 3rd line (the start of the while loop). >> >> but from the examples, I didn't find a correct way to handle this. >> >> Is there an example for this, thanks. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "grpc.io" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/grpc-io. >> To view this discussion on the web visit https://groups.google.com/d/ >> msgid/grpc-io/87b2b09a-c825-4ea6-ae3a-ffcecec5b1eb%40googlegroups.com >> <https://groups.google.com/d/msgid/grpc-io/87b2b09a-c825-4ea6-ae3a-ffcecec5b1eb%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/grpc-io. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/grpc-io/CADEy0h0oJTQpAw_zxEoCHnY0_CqUk%2B-8CGLg0ngvh6% > 3Dwf5r9QQ%40mail.gmail.com > <https://groups.google.com/d/msgid/grpc-io/CADEy0h0oJTQpAw_zxEoCHnY0_CqUk%2B-8CGLg0ngvh6%3Dwf5r9QQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/grpc-io. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CALRi9QcPGFBcKop-ah-5%2BWLBDmayCh082fP2cVQaQW-Edr_Gpg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
