|
33 | 33 | #include "co/Task.hxx" |
34 | 34 | #include "util/DeleteDisposer.hxx" |
35 | 35 | #include "util/StringCompare.hxx" |
| 36 | +#include "util/StringList.hxx" |
36 | 37 | #include "util/UTF8.hxx" |
37 | 38 | #include "AllocatorPtr.hxx" |
38 | 39 | #include "CgroupAccounting.hxx" |
@@ -87,6 +88,12 @@ WorkshopOperator::~WorkshopOperator() noexcept |
87 | 88 | children.clear_and_dispose(DeleteDisposer{}); |
88 | 89 | } |
89 | 90 |
|
| 91 | +bool |
| 92 | +WorkshopOperator::IsChildTag(std::string_view value) const noexcept |
| 93 | +{ |
| 94 | + return StringListContains(child_tag, '\0', value); |
| 95 | +} |
| 96 | + |
90 | 97 | inline UniqueFileDescriptor |
91 | 98 | WorkshopOperator::InitLog(std::size_t max_log_buffer, |
92 | 99 | bool enable_journal) |
@@ -240,6 +247,11 @@ WorkshopOperator::Start2(std::size_t max_log_buffer, |
240 | 247 | job.plan_name.c_str(), |
241 | 248 | "", nullptr, |
242 | 249 | job.args); |
| 250 | + |
| 251 | + if (translation.execute_options != nullptr && |
| 252 | + !translation.execute_options->child_options.tag.empty() && |
| 253 | + child_tag.empty()) |
| 254 | + child_tag = translation.execute_options->child_options.tag; |
243 | 255 | } |
244 | 256 |
|
245 | 257 | auto &spawn_service = workplace.GetSpawnService(); |
@@ -349,6 +361,17 @@ WorkshopOperator::Start2(std::size_t max_log_buffer, |
349 | 361 | } |
350 | 362 | } |
351 | 363 |
|
| 364 | +void |
| 365 | +WorkshopOperator::Cancel() noexcept |
| 366 | +{ |
| 367 | + logger(2, "cancel"); |
| 368 | + |
| 369 | + job.SetDone(-1, "Canceled"); |
| 370 | + |
| 371 | + /* we do not kill the process because this will be done |
| 372 | + implicitly by our destructor */ |
| 373 | +} |
| 374 | + |
352 | 375 | inline void |
353 | 376 | WorkshopOperator::OnTaskCompletion(std::exception_ptr &&error) noexcept |
354 | 377 | { |
@@ -594,6 +617,11 @@ WorkshopOperator::OnControlSpawn(const char *token, const char *param) |
594 | 617 | token, param, |
595 | 618 | {}); |
596 | 619 |
|
| 620 | + if (response.execute_options != nullptr && |
| 621 | + !response.execute_options->child_options.tag.empty() && |
| 622 | + child_tag.empty()) |
| 623 | + child_tag = response.execute_options->child_options.tag; |
| 624 | + |
597 | 625 | auto &spawn_service = workplace.GetSpawnService(); |
598 | 626 |
|
599 | 627 | co_await CoEnqueueSpawner{spawn_service}; |
|
0 commit comments