| 550 | } |
| 551 | |
| 552 | CancellationCode QueryStatus::cancelQuery(bool kill, bool internal) |
| 553 | { |
| 554 | UInt8 kill_flag = internal ? INTERNAL_KILL_BIT : EXTERNAL_KILL_BIT; |
| 555 | { |
| 556 | std::lock_guard lock(executors_mutex); |
| 557 | if (!executors.empty()) |
| 558 | { |
| 559 | if (is_killed.load()) |
| 560 | return CancellationCode::CancelSent; |
| 561 | |
| 562 | is_killed.store(kill_flag); |
| 563 | |
| 564 | for (auto * e : executors) |
| 565 | e->cancel(); |
| 566 | |
| 567 | return CancellationCode::CancelSent; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | /// Streams are destroyed, and ProcessListElement will be deleted from ProcessList soon. We need wait a little bit |
| 572 | if (streamsAreReleased()) |
| 573 | return CancellationCode::CancelSent; |
| 574 | |
| 575 | BlockInputStreamPtr input_stream; |
| 576 | BlockOutputStreamPtr output_stream; |
| 577 | |
| 578 | if (tryGetQueryStreams(input_stream, output_stream)) |
| 579 | { |
| 580 | if (input_stream) |
| 581 | { |
| 582 | input_stream->cancel(kill); |
| 583 | return CancellationCode::CancelSent; |
| 584 | } |
| 585 | return CancellationCode::CancelCannotBeSent; |
| 586 | } |
| 587 | /// Query is not even started |
| 588 | is_killed.store(kill_flag); |
| 589 | return CancellationCode::CancelSent; |
| 590 | } |
| 591 | |
| 592 | void QueryStatus::addPipelineExecutor(PipelineExecutor * e) |
| 593 | { |
no test coverage detected