MCPcopy Create free account
hub / github.com/apache/brpc / SendRpcResponse

Function SendRpcResponse

src/brpc/policy/baidu_rpc_protocol.cpp:273–305  ·  view source on GitHub ↗

Used by UT, can't be static.

Source from the content-addressed store, hash-verified

271
272// Used by UT, can't be static.
273void SendRpcResponse(int64_t correlation_id, Controller* cntl,
274 RpcPBMessages* messages, const Server* server,
275 MethodStatus* method_status, int64_t received_us,
276 std::shared_ptr<Span> span) {
277 ControllerPrivateAccessor accessor(cntl);
278 if (span) {
279 span->set_start_send_us(butil::cpuwide_time_us());
280 }
281 Socket* sock = accessor.get_sending_socket();
282
283 const google::protobuf::Message* req = NULL == messages ? NULL : messages->Request();
284 const google::protobuf::Message* res = NULL == messages ? NULL : messages->Response();
285
286 // Recycle resources at the end of this function.
287 BRPC_SCOPE_EXIT {
288 {
289 // Remove concurrency and record latency at first.
290 ConcurrencyRemover concurrency_remover(method_status, cntl, received_us);
291 }
292
293 std::unique_ptr<Controller, LogErrorTextAndDelete> recycle_cntl(cntl);
294
295 if (NULL == messages) {
296 return;
297 }
298
299 cntl->CallAfterRpcResp(req, res);
300 if (NULL == server->options().baidu_master_service) {
301 server->options().rpc_pb_message_factory->Return(messages);
302 } else {
303 BaiduProxyPBMessages::Return(static_cast<BaiduProxyPBMessages*>(messages));
304 }
305 };
306
307 StreamIds response_stream_ids = accessor.response_streams();
308

Callers 1

ProcessRpcRequestFunction · 0.85

Calls 8

cpuwide_time_usFunction · 0.85
set_start_send_usMethod · 0.80
get_sending_socketMethod · 0.80
CallAfterRpcRespMethod · 0.80
optionsMethod · 0.80
RequestMethod · 0.45
ResponseMethod · 0.45
ReturnMethod · 0.45

Tested by

no test coverage detected