summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/source.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/source.c b/tools/source.c
index 8a6b5f5..954405a 100644
--- a/tools/source.c
+++ b/tools/source.c
@@ -57,15 +57,20 @@ ssize_t cTBSource::Write(const void *Buffer, size_t Length) {
bool cTBSource::TimedWrite(const void *Buffer, size_t Length, uint TimeoutMs) {
cTBSelect sel;
int ms, offs;
-
cTimeMs starttime;
- ms = TimeoutMs;
+
offs = 0;
sel.Clear();
sel.Add(m_Filed, true);
while (Length > 0) {
int b;
+ ms = TimeoutMs - starttime.Elapsed();
+ if (ms <= 0) {
+ errno = ETIMEDOUT;
+ return false;
+ }
+
if (sel.Select(ms) == -1)
return false;
@@ -76,11 +81,6 @@ bool cTBSource::TimedWrite(const void *Buffer, size_t Length, uint TimeoutMs) {
Length -= b;
}
- ms = TimeoutMs - starttime.Elapsed();
- if (ms <= 0) {
- errno = ETIMEDOUT;
- return false;
- }
}
return true;
}