aboutsummaryrefslogtreecommitdiff
path: root/bbot
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2023-05-11 08:19:44 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2023-05-11 08:19:44 +0200
commitd6594fffcb4ccbfd16f4bb260daad667273cb065 (patch)
tree85db26f1525557a53b143a3179b63be41fc43da9 /bbot
parentf45e240682302d4d67c35292ff18408858e3c3e7 (diff)
Do not assume bootstrapped machines and task request machines are parallel
This is the ground work for the task priority/interrupt support.
Diffstat (limited to 'bbot')
-rw-r--r--bbot/agent/agent.cxx49
1 files changed, 28 insertions, 21 deletions
diff --git a/bbot/agent/agent.cxx b/bbot/agent/agent.cxx
index 16cec19..09d520f 100644
--- a/bbot/agent/agent.cxx
+++ b/bbot/agent/agent.cxx
@@ -1728,7 +1728,7 @@ try
machine_header_manifests {}
};
- // Note: below we assume tq.size () == ms.size ().
+ // Note: do not assume tq.machines.size () == ms.size ().
//
for (const bootstrapped_machine& m: ms)
tq.machines.emplace_back (m.manifest.machine.id,
@@ -1885,30 +1885,40 @@ try
// We have a build task.
//
- // First find the index of the machine we were asked to use (and verify it
- // is one of those we sent). Also unlock all the other machines as well as
- // the global toolchain lock.
+ task_manifest& t (*tr.task);
+
+ // First verify the requested machine is one of those we sent in tq. Then
+ // find the corresponding bootstrapped_machine instance in ms. Also unlock
+ // all the other machines as well as the global toolchain lock.
//
- size_t i (ms.size ());
- for (size_t j (0); j != ms.size (); ++j)
+ bootstrapped_machine* pm (nullptr);
+ for (const machine_header_manifest& mh: tq.machines)
{
- if (tq.machines[j].name == tr.task->machine)
+ if (mh.name == t.machine) // Yes, comparing names, not ids.
{
- if (!ops.fake_machine_specified ())
- ms[j].lock.write (tl, 1234 /* prio */);
+ for (bootstrapped_machine& m: ms)
+ {
+ if (mh.id == m.manifest.machine.id)
+ {
+ if (!ops.fake_machine_specified ())
+ m.lock.write (tl, 1234 /* prio */);
+
+ pm = &m;
+ }
+ else
+ m.lock.unlock ();
+ }
- i = j;
+ assert (pm != nullptr);
+ break;
}
- else
- ms[j].lock.unlock ();
}
tl.unlock ();
- if (i == ms.size ())
+ if (pm == nullptr)
{
- error << "task from " << url << " for unknown machine "
- << tr.task->machine;
+ error << "task from " << url << " for unknown machine " << t.machine;
if (ops.dump_task ())
return 0;
@@ -1916,7 +1926,7 @@ try
continue;
}
- task_manifest& t (*tr.task);
+ bootstrapped_machine& m (*pm);
if (ops.dump_task ())
{
@@ -1939,12 +1949,9 @@ try
if (!tr.agent_checksum || *tr.agent_checksum != agent_checksum)
t.worker_checksum = nullopt;
- const dir_path& d (); // The -<toolchain> directory.
- const bootstrapped_machine_manifest& m ();
-
- result_manifest r (perform_task (ms[i].path, ms[i].manifest, t));
+ result_manifest r (perform_task (m.path, m.manifest, t));
- ms[i].lock.unlock (); // No need to hold the lock any longer.
+ m.lock.unlock (); // No need to hold the lock any longer.
if (ops.dump_result ())
{