Esempio n. 1
0
void ProxyRequestContext::sendReply(McReply newReply) {
  if (recording_) {
    return;
  }

  if (replied_) {
    return;
  }
  reply_ = std::move(newReply);
  replied_ = true;

  if (LIKELY(enqueueReply_ != nullptr)) {
    fiber_local::runWithoutLocals([this]() {
      enqueueReply_(*this);
    });
  }

  stat_incr(proxy_.stats, request_replied_stat, 1);
  stat_incr(proxy_.stats, request_replied_count_stat, 1);
  if (mc_res_is_err(reply_->result())) {
    stat_incr(proxy_.stats, request_error_stat, 1);
    stat_incr(proxy_.stats, request_error_count_stat, 1);
  } else {
    stat_incr(proxy_.stats, request_success_stat, 1);
    stat_incr(proxy_.stats, request_success_count_stat, 1);
  }
}
Esempio n. 2
0
void DestinationClient::onReply(McReply reply, mc_op_t op, void* req_ctx,
                                std::weak_ptr<ProxyDestination> pdstn) {
  auto pdstnPtr = pdstn.lock();
  // ProxyDestination is already dead, just return.
  if (!pdstnPtr) {
    return;
  }
  auto proxy = pdstnPtr->proxy;

  if (reply.result() == mc_res_local_error) {
    update_send_stats(proxy, op, PROXY_SEND_LOCAL_ERROR);
  } else {
    stat_incr(proxy->stats, sum_server_queue_length_stat, 1);
    update_send_stats(proxy, op, PROXY_SEND_OK);
  }

  pdstnPtr->on_reply(std::move(reply),
                     req_ctx);
}