aboutsummaryrefslogtreecommitdiff
path: root/bbot/tftp.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-06-14 17:04:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-06-14 17:04:57 +0200
commitf58adbc887abd4f467b483be953ecce7794255fc (patch)
tree975fba131e4f61ddf654524d65354aee377d9e57 /bbot/tftp.cxx
parente66023e394db72e81bc88e4747325380db7c96d0 (diff)
Periodically recheck for manifest upload
There seems to be some obscure race, perhaps related to tmpfs?
Diffstat (limited to 'bbot/tftp.cxx')
-rw-r--r--bbot/tftp.cxx15
1 files changed, 10 insertions, 5 deletions
diff --git a/bbot/tftp.cxx b/bbot/tftp.cxx
index 70cc85d..0da6c24 100644
--- a/bbot/tftp.cxx
+++ b/bbot/tftp.cxx
@@ -67,15 +67,18 @@ namespace bbot
}
bool tftp_server::
- serve (size_t& sec)
+ serve (size_t& sec, size_t inc)
{
tracer trace ("tftp_server::serve");
+ if (inc == 0 || inc > sec)
+ inc = sec;
+
int fd (fd_.get ());
// Note: Linux updates the timeout value which we rely upon.
//
- timeval timeout {static_cast<long> (sec), 0};
+ timeval timeout {static_cast<long> (inc), 0};
fd_set rd;
FD_ZERO (&rd);
@@ -95,7 +98,7 @@ namespace bbot
}
else if (r == 0) // Timeout.
{
- sec = 0;
+ sec -= inc;
return false;
}
@@ -122,9 +125,11 @@ namespace bbot
"--secure", // Chroot to data directory.
ops.tftp ());
- // @@ This is not really accurate.
+ // This is not really accurate since tftpd will, for example, serve
+ // an upload request until it is complete. But it's close anough for
+ // our needs.
//
- sec = static_cast<size_t> (timeout.tv_sec);
+ sec -= (inc - static_cast<size_t> (timeout.tv_sec));
return true;
}
}