mirror of
https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git
synced 2023-10-10 17:16:51 +00:00
make sure TimedWrite(...) doesn't return failure after a slow but successful
write operation (refs #2045)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user