From 76b2e3c19278da49193aa1599a35197b279b4439 Mon Sep 17 00:00:00 2001 From: Pixel Date: Tue, 27 Nov 2001 15:10:33 +0000 Subject: Bug in taskman... --- lib/Buffer.cc | 4 ++++ lib/CopyJob.cc | 4 ++-- lib/Handle.cc | 4 ++++ lib/ReadJob.cc | 4 ++-- lib/TaskMan.cc | 13 ++++++++----- 5 files changed, 20 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/Buffer.cc b/lib/Buffer.cc index afbaa6f..2c2c955 100644 --- a/lib/Buffer.cc +++ b/lib/Buffer.cc @@ -71,3 +71,7 @@ Buffer Buffer::operator=(const Buffer & b) { } return *this; } + +bool Buffer::CanWatch() { + return false; +} diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc index a736e9d..fd31eff 100644 --- a/lib/CopyJob.cc +++ b/lib/CopyJob.cc @@ -18,7 +18,7 @@ int CopyJob::Do() throw (GeneralException) { r = s->read(buffer, MIN(COPY_BUFSIZ, tr)); } catch (IOAgain e) { - Suspend(); + Suspend(TASK_ON_HOLD); } case 1: if (!r) { @@ -29,7 +29,7 @@ int CopyJob::Do() throw (GeneralException) { } catch (IOAgain e) { current = 1; - Suspend(); + Suspend(TASK_ON_HOLD); } current = 0; } diff --git a/lib/Handle.cc b/lib/Handle.cc index e158511..4124231 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -155,3 +155,7 @@ off_t Handle::GetSize(void) { time_t Handle::GetModif(void) { return -1; } + +bool Handle::CanWatch(void) { + return true; +} \ No newline at end of file diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc index 6fab08b..3083040 100644 --- a/lib/ReadJob.cc +++ b/lib/ReadJob.cc @@ -17,7 +17,7 @@ int ReadJob::Do() throw (GeneralException) { *s >> buff; } catch (IOAgain e) { - throw TaskSwitch(); + Suspend(TASK_ON_HOLD); } case 1: try { @@ -32,7 +32,7 @@ int ReadJob::Do() throw (GeneralException) { } if (!s->IsClosed()) { - throw TaskSwitch(); + Suspend(TASK_ON_HOLD); } return TASK_DONE; diff --git a/lib/TaskMan.cc b/lib/TaskMan.cc index 218ce2f..546bbc6 100644 --- a/lib/TaskMan.cc +++ b/lib/TaskMan.cc @@ -92,9 +92,7 @@ void TaskMan::RemoveFromWatches(Task * t) { } void TaskMan::WaitFor(Handle * h, Task * t, int flags) { - if (h->GetHandle() >= 0) { - w4ha.push_back(w4ha_t(h, flags, t)); - } + w4ha.push_back(w4ha_t(h, flags, t)); } void TaskMan::WaitFor(pid_t p, Task * t) { @@ -174,8 +172,13 @@ void TaskMan::MainLoop() throw (GeneralException) { q->events = 0; } else { cerr << "==== TaskMan: adding watch over handle \"" << p->ha->GetName() << "\" for task \"" << p->T->GetName() << "\"\n"; - q->fd = p->ha->GetHandle(); - q->events = (p->flags & W4_READING ? POLLIN : 0) | (p->flags & W4_WRITING ? POLLOUT : 0); + if (p->ha->CanWatch() { + q->fd = p->ha->GetHandle(); + q->events = (p->flags & W4_READING ? POLLIN : 0) | (p->flags & W4_WRITING ? POLLOUT : 0); + } else { + cerr << "==== TaskMan: handle can't watch, switching task to burst.\n"; + p->T->SetBurst(); + } } } -- cgit v1.2.3