aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-02-07 12:57:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-02-07 12:57:58 +0200
commit9f8391e292f6e4ffd72437fcfb86afb42af33654 (patch)
treed2268bc40f91bbdd2e54a04353db00efab05df0f
parentb0ccf83f965e5fa64fea984a1e5e56528bff5ddd (diff)
Fix race in machine check
-rw-r--r--bbot/agent/agent.cxx22
1 files changed, 15 insertions, 7 deletions
diff --git a/bbot/agent/agent.cxx b/bbot/agent/agent.cxx
index be3b706..83db6d7 100644
--- a/bbot/agent/agent.cxx
+++ b/bbot/agent/agent.cxx
@@ -263,7 +263,7 @@ bootstrap_machine (const dir_path& md,
break;
if (!check_machine ())
- return r;
+ return nullopt;
}
// This can mean two things: machine mis-configuration or what we
@@ -301,6 +301,14 @@ bootstrap_machine (const dir_path& md,
if (tftpd.serve (to, 2))
continue;
+ if (!check_machine ())
+ {
+ // The exit/upload is racy so we re-check.
+ //
+ if (!(file_not_empty (mf) || file_not_empty (mfo)))
+ return nullopt;
+ }
+
bool old (false);
if (file_not_empty (mf) || (old = file_not_empty (mfo)))
{
@@ -313,9 +321,6 @@ bootstrap_machine (const dir_path& md,
if (!tftpd.serve (to, 5))
break;
}
-
- if (!check_machine ())
- return nullopt;
}
if (to == 0)
@@ -981,14 +986,17 @@ try
if (tftpd.serve (to, 2))
continue;
+ if (!check_machine ())
+ {
+ if (!file_not_empty (rf))
+ return r;
+ }
+
if (file_not_empty (rf))
{
if (!tftpd.serve (to, 5))
break;
}
-
- if (!check_machine ())
- return r;
}
if (to == 0)