| 199 | } |
| 200 | |
| 201 | void ServicePool::RunThread() { |
| 202 | while (true) { |
| 203 | std::unique_ptr<InboundCall> incoming; |
| 204 | if (!service_queue_.BlockingGet(&incoming)) { |
| 205 | VLOG(1) << "ServicePool: messenger shutting down."; |
| 206 | return; |
| 207 | } |
| 208 | |
| 209 | incoming->RecordHandlingStarted(incoming_queue_time_.get()); |
| 210 | ADOPT_TRACE(incoming->trace()); |
| 211 | |
| 212 | if (PREDICT_FALSE(incoming->ClientTimedOut())) { |
| 213 | TRACE_TO(incoming->trace(), "Skipping call since client already timed out"); |
| 214 | rpcs_timed_out_in_queue_->Increment(); |
| 215 | |
| 216 | // Respond as a failure, even though the client will probably ignore |
| 217 | // the response anyway. |
| 218 | incoming->RespondFailure( |
| 219 | ErrorStatusPB::ERROR_SERVER_TOO_BUSY, |
| 220 | Status::TimedOut("Call waited in the queue past client deadline")); |
| 221 | |
| 222 | // Must release since RespondFailure above ends up taking ownership |
| 223 | // of the object. |
| 224 | ignore_result(incoming.release()); |
| 225 | continue; |
| 226 | } |
| 227 | |
| 228 | TRACE_TO(incoming->trace(), "Handling call"); |
| 229 | |
| 230 | // Release the InboundCall pointer -- when the call is responded to, |
| 231 | // it will get deleted at that point. |
| 232 | service_->Handle(incoming.release()); |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | const string& ServicePool::service_name() const { |
| 237 | return service_->service_name(); |
no test coverage detected