@@ -43,12 +43,7 @@ class ReflectionClient {
4343 file_descs->add_file ();
4444 file_desc->ParseFromString (bytes);
4545 }
46- } else {
47- return nullptr ;
4846 }
49- } else {
50- std::cerr << " Reflection failed" << std::endl;
51- return nullptr ;
5247 }
5348 stream->WritesDone ();
5449 grpc::Status status = stream->Finish ();
@@ -115,7 +110,8 @@ class grpcRequest : public NodeRequest {
115110 generic_stub.PrepareUnaryCall (&context, methodFullName, req_buf, &cq);
116111 grpc::Status status;
117112 call->StartCall ();
118- call->Finish (&resp_buf, &status, (void *)1 );
113+ int tag = 1 ;
114+ call->Finish (&resp_buf, &status, &tag);
119115 void *got_tag;
120116 bool ok = false ;
121117 cq.Next (&got_tag, &ok);
@@ -165,20 +161,21 @@ class grpcRequest : public NodeRequest {
165161 refl_client.GetFileDescriptor (gRPC_package + " ." + gRPC_service );
166162 bool server_reflection;
167163
168- // Check if server reflection complete
169- auto pool = std::make_unique<DescriptorPool>();
164+ // Make descriptor database
165+ SimpleDescriptorDatabase db;
166+ for (int i = 0 ; i < protos->file_size (); i++) {
167+ db.Add (protos->file (i));
168+ }
169+ auto pool = std::make_unique<DescriptorPool>(&db);
170170 const Descriptor *resp_desc;
171- if (!protos) {
171+ // Check if server reflection complete
172+ if (protos->file_size () == 0 ) {
172173 server_reflection = false ;
173174 req_buf = form_request ();
174175 } else {
175176 server_reflection = true ;
176- const FileDescriptor *file;
177- for (int i = protos->file_size () - 1 ; i >= 0 ; i--) {
178- const FileDescriptorProto &fd = protos->file (i);
179- file = pool->BuildFile (fd);
180- }
181- const ServiceDescriptor *svc = file->FindServiceByName (gRPC_service );
177+ const ServiceDescriptor *svc =
178+ pool->FindServiceByName (gRPC_package + " ." + gRPC_service );
182179 if (!svc) {
183180 throw Error (HTTP_STATUS_NOT_FOUND, nullptr , " gRPC service not found" );
184181 }
@@ -204,7 +201,8 @@ class grpcRequest : public NodeRequest {
204201 grpc::Status status;
205202
206203 call->StartCall ();
207- call->Finish (&resp_buf, &status, (void *)1 );
204+ int tag = 1 ;
205+ call->Finish (&resp_buf, &status, &tag);
208206 void *got_tag;
209207 bool ok = false ;
210208 cq.Next (&got_tag, &ok);
@@ -225,7 +223,6 @@ class grpcRequest : public NodeRequest {
225223 // Empty gRPC response
226224 if (recv_data.length () <= 0 ) {
227225 return new JsonResponse (session, HTTP_STATUS_OK, nullptr );
228- ;
229226 }
230227
231228 json_t *json_response;
0 commit comments