aboutsummaryrefslogtreecommitdiff
path: root/bbot/tftp.cxx
diff options
context:
space:
mode:
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;
}
}