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

Function ProcessRedisResponse

src/brpc/policy/redis_protocol.cpp:226–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224}
225
226void ProcessRedisResponse(InputMessageBase* msg_base) {
227 const int64_t start_parse_us = butil::cpuwide_time_us();
228 DestroyingPtr<InputResponse> msg(static_cast<InputResponse*>(msg_base));
229
230 const bthread_id_t cid = msg->id_wait;
231 Controller* cntl = NULL;
232 const int rc = bthread_id_lock(cid, (void**)&cntl);
233 if (rc != 0) {
234 LOG_IF(ERROR, rc != EINVAL && rc != EPERM)
235 << "Fail to lock correlation_id=" << cid << ": " << berror(rc);
236 return;
237 }
238
239 ControllerPrivateAccessor accessor(cntl);
240 if (auto span = accessor.span()) {
241 span->set_base_real_us(msg->base_real_us());
242 span->set_received_us(msg->received_us());
243 span->set_response_size(msg->response.ByteSize());
244 span->set_start_parse_us(start_parse_us);
245 }
246 const int saved_error = cntl->ErrorCode();
247 if (cntl->response() != NULL) {
248 if (cntl->response()->GetDescriptor() != RedisResponse::descriptor()) {
249 cntl->SetFailed(ERESPONSE, "Must be RedisResponse");
250 } else {
251 // We work around ParseFrom of pb which is just a placeholder.
252 if (msg->response.reply_size() != (int)accessor.pipelined_count()) {
253 cntl->SetFailed(ERESPONSE, "pipelined_count=%d of response does "
254 "not equal request's=%d",
255 msg->response.reply_size(), accessor.pipelined_count());
256 }
257 ((RedisResponse*)cntl->response())->Swap(&msg->response);
258 if (FLAGS_redis_verbose) {
259 LOG(INFO) << "\n[REDIS RESPONSE] "
260 << *((RedisResponse*)cntl->response());
261 }
262 }
263 } // silently ignore the response.
264
265 // Unlocks correlation_id inside. Revert controller's
266 // error code if it version check of `cid' fails
267 msg.reset(); // optional, just release resource ASAP
268 accessor.OnResponse(cid, saved_error);
269}
270
271void ProcessRedisRequest(InputMessageBase* msg_base) { }
272

Callers

nothing calls this directly

Calls 15

cpuwide_time_usFunction · 0.85
berrorFunction · 0.85
spanMethod · 0.80
set_base_real_usMethod · 0.80
base_real_usMethod · 0.80
set_response_sizeMethod · 0.80
set_start_parse_usMethod · 0.80
ErrorCodeMethod · 0.80
responseMethod · 0.80
reply_sizeMethod · 0.80
OnResponseMethod · 0.80
set_received_usMethod · 0.45

Tested by

no test coverage detected