| 413 | } |
| 414 | |
| 415 | static inline |
| 416 | void ProcessRequest( |
| 417 | HttpApiRequest& request, |
| 418 | HttpApiResponse& response, |
| 419 | const WaitGroup::Ptr& waitGroup, |
| 420 | std::chrono::steady_clock::duration& cpuBoundWorkTime, |
| 421 | boost::asio::yield_context& yc, |
| 422 | boost::asio::io_context::strand& strand |
| 423 | ) |
| 424 | { |
| 425 | try { |
| 426 | // Cache the elapsed time to acquire a CPU semaphore used to detect extremely heavy workloads. |
| 427 | auto start (std::chrono::steady_clock::now()); |
| 428 | response.StartCpuBoundWork(yc, strand); |
| 429 | cpuBoundWorkTime = std::chrono::steady_clock::now() - start; |
| 430 | |
| 431 | HttpHandler::ProcessRequest(waitGroup, request, response, yc); |
| 432 | response.body().Finish(); |
| 433 | } catch (const std::exception& ex) { |
| 434 | /* Since we don't know the state the stream is in, we can't send an error response and |
| 435 | * have to just cause a disconnect here. |
| 436 | */ |
| 437 | if (response.HasSerializationStarted()) { |
| 438 | throw; |
| 439 | } |
| 440 | |
| 441 | HttpUtility::SendJsonError(response, request.Params(), 500, "Unhandled exception", DiagnosticInformation(ex)); |
| 442 | } |
| 443 | |
| 444 | response.Flush(yc); |
| 445 | } |
| 446 | |
| 447 | void HttpServerConnection::ProcessMessages(boost::asio::yield_context yc) |
| 448 | { |
no test coverage detected