| 319 | ::google::protobuf::Closure* done); |
| 320 | |
| 321 | void ProcessSofaRequest(InputMessageBase* msg_base) { |
| 322 | const int64_t start_parse_us = butil::cpuwide_time_us(); |
| 323 | DestroyingPtr<MostCommonMessage> msg(static_cast<MostCommonMessage*>(msg_base)); |
| 324 | SocketUniquePtr socket_guard(msg->ReleaseSocket()); |
| 325 | Socket* socket = socket_guard.get(); |
| 326 | const Server* server = static_cast<const Server*>(msg_base->arg()); |
| 327 | ScopedNonServiceError non_service_error(server); |
| 328 | |
| 329 | SofaRpcMeta meta; |
| 330 | if (!ParsePbFromIOBuf(&meta, msg->meta)) { |
| 331 | LOG(WARNING) << "Fail to parse SofaRpcMeta from " << *socket; |
| 332 | socket->SetFailed(EREQUEST, "Fail to parse SofaRpcMeta from %s", |
| 333 | socket->description().c_str()); |
| 334 | return; |
| 335 | } |
| 336 | const CompressType req_cmp_type = Sofa2CompressType(meta.compress_type()); |
| 337 | |
| 338 | SampledRequest* sample = AskToBeSampled(); |
| 339 | if (sample) { |
| 340 | sample->meta.set_method_name(meta.method()); |
| 341 | sample->meta.set_compress_type(req_cmp_type); |
| 342 | sample->meta.set_protocol_type(PROTOCOL_SOFA_PBRPC); |
| 343 | sample->request = msg->payload; |
| 344 | sample->submit(start_parse_us); |
| 345 | } |
| 346 | |
| 347 | std::unique_ptr<Controller> cntl(new (std::nothrow) Controller); |
| 348 | if (NULL == cntl.get()) { |
| 349 | LOG(WARNING) << "Fail to new Controller"; |
| 350 | return; |
| 351 | } |
| 352 | std::unique_ptr<google::protobuf::Message> req; |
| 353 | std::unique_ptr<google::protobuf::Message> res; |
| 354 | |
| 355 | ControllerPrivateAccessor accessor(cntl.get()); |
| 356 | ServerPrivateAccessor server_accessor(server); |
| 357 | const int64_t correlation_id = meta.sequence_id(); |
| 358 | const bool security_mode = server->options().security_mode() && |
| 359 | socket->user() == server_accessor.acceptor(); |
| 360 | |
| 361 | cntl->set_request_compress_type(req_cmp_type); |
| 362 | accessor.set_server(server) |
| 363 | .set_security_mode(security_mode) |
| 364 | .set_peer_id(socket->id()) |
| 365 | .set_remote_side(socket->remote_side()) |
| 366 | .set_local_side(socket->local_side()) |
| 367 | .set_auth_context(socket->auth_context()) |
| 368 | .set_request_protocol(PROTOCOL_SOFA_PBRPC) |
| 369 | .set_begin_time_us(msg->received_us()) |
| 370 | .move_in_server_receiving_sock(socket_guard); |
| 371 | |
| 372 | // Tag the bthread with this server's key for thread_local_data(). |
| 373 | if (server->thread_local_options().thread_local_data_factory) { |
| 374 | bthread_assign_data((void*)&server->thread_local_options()); |
| 375 | } |
| 376 | |
| 377 | std::shared_ptr<Span> span; |
| 378 | if (IsTraceable(false)) { |
nothing calls this directly
no test coverage detected