summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorlordjaxom <lordjaxom>2005-02-08 13:59:16 +0000
committerlordjaxom <lordjaxom>2005-02-08 13:59:16 +0000
commit8e4556b0a982dab75d8ba3bb388965ecf47fa0b0 (patch)
treecda6583f76af5967c634fffe454b003052baf521 /tools
parent04a5985dcc0a24a1ff7b8debd5e88d4de46bb989 (diff)
downloadvdr-plugin-streamdev-8e4556b0a982dab75d8ba3bb388965ecf47fa0b0.tar.gz
vdr-plugin-streamdev-8e4556b0a982dab75d8ba3bb388965ecf47fa0b0.tar.bz2
- first adoptions (transfer-commit)
Diffstat (limited to 'tools')
-rw-r--r--tools/select.c7
-rw-r--r--tools/source.c10
2 files changed, 6 insertions, 11 deletions
diff --git a/tools/select.c b/tools/select.c
index 77229c8..0ab5f9b 100644
--- a/tools/select.c
+++ b/tools/select.c
@@ -16,7 +16,6 @@ cTBSelect::~cTBSelect() {
int cTBSelect::Select(uint TimeoutMs) {
struct timeval tv;
- time_t st, et;
ssize_t res;
int ms;
@@ -26,15 +25,13 @@ int cTBSelect::Select(uint TimeoutMs) {
if (TimeoutMs == 0)
return ::select(m_MaxFiled + 1, &m_Rfds, &m_Wfds, NULL, &tv);
- st = time_ms();
+ cTimeMs starttime;
ms = TimeoutMs;
while (ms > 0 && (res = ::select(m_MaxFiled + 1, &m_Rfds, &m_Wfds, NULL,
&tv)) == -1 && errno == EINTR) {
- et = time_ms();
- ms -= et - st;
+ ms = TimeoutMs - starttime.Elapsed();
tv.tv_usec = (ms % 1000) * 1000;
tv.tv_sec = ms / 1000;
- st = et;
}
if (ms <= 0) {
errno = ETIMEDOUT;
diff --git a/tools/source.c b/tools/source.c
index 91c36c8..e882583 100644
--- a/tools/source.c
+++ b/tools/source.c
@@ -56,10 +56,9 @@ ssize_t cTBSource::Write(const void *Buffer, size_t Length) {
bool cTBSource::TimedWrite(const void *Buffer, size_t Length, uint TimeoutMs) {
cTBSelect sel;
- time_t st;
int ms, offs;
- st = time_ms();
+ cTimeMs starttime;
ms = TimeoutMs;
offs = 0;
while (Length > 0) {
@@ -77,7 +76,7 @@ bool cTBSource::TimedWrite(const void *Buffer, size_t Length, uint TimeoutMs) {
Length -= b;
}
- ms -= time_ms() - st;
+ ms = TimeoutMs - starttime.Elapsed();
if (ms <= 0) {
errno = ETIMEDOUT;
return false;
@@ -89,7 +88,6 @@ bool cTBSource::TimedWrite(const void *Buffer, size_t Length, uint TimeoutMs) {
ssize_t cTBSource::ReadUntil(void *Buffer, size_t Length, const char *Seq,
uint TimeoutMs) {
char *offs;
- time_t st;
int seqlen, ms;
size_t olen;
cTBSelect sel;
@@ -108,7 +106,7 @@ ssize_t cTBSource::ReadUntil(void *Buffer, size_t Length, const char *Seq,
return olen;
}
- st = time_ms();
+ cTimeMs starttime;
ms = TimeoutMs;
while (m_LineBuffer.Length() < BUFSIZ) {
int b;
@@ -142,7 +140,7 @@ ssize_t cTBSource::ReadUntil(void *Buffer, size_t Length, const char *Seq,
}
}
- ms -= time_ms() - st;
+ ms = TimeoutMs - starttime.Elapsed();
if (ms <= 0) {
errno = ETIMEDOUT;
return -1;