Esempio n. 1
0
ProxyRequestContext::~ProxyRequestContext() {
  if (recording_) {
    recordingState_.~unique_ptr<RecordingState>();
    return;
  }

  assert(replied_);
  if (reqComplete_) {
    fiber_local::runWithoutLocals([this]() {
      reqComplete_(*this);
    });
  }

  if (processing_) {
    --proxy_.numRequestsProcessing_;
    stat_decr(proxy_.stats, proxy_reqs_processing_stat, 1);
    proxy_.pump();
  }

  if (requester_) {
    if (requester_->maxOutstanding_ != 0) {
      counting_sem_post(&requester_->outstandingReqsSem_, 1);
    }
  }

  stat_decr_safe(proxy_.stats, proxy_request_num_outstanding_stat);
}
Esempio n. 2
0
void proxy_t::pump() {
  auto numPriorities = static_cast<int>(ProxyRequestPriority::kNumPriorities);
  for (int i = 0; i < numPriorities; ++i) {
    auto& queue = waitingRequests_[i];
    while (numRequestsProcessing_ < router_.opts().proxy_max_inflight_requests
           && !queue.empty()) {
      --numRequestsWaiting_;
      auto w = queue.popFront();
      stat_decr(stats, proxy_reqs_waiting_stat, 1);

      w->process(this);
    }
  }
}