diff options
| -rw-r--r-- | include/Buffer.h | 1 | ||||
| -rw-r--r-- | include/Handle.h | 1 | ||||
| -rw-r--r-- | lib/Buffer.cc | 4 | ||||
| -rw-r--r-- | lib/CopyJob.cc | 4 | ||||
| -rw-r--r-- | lib/Handle.cc | 4 | ||||
| -rw-r--r-- | lib/ReadJob.cc | 4 | ||||
| -rw-r--r-- | lib/TaskMan.cc | 13 | 
7 files changed, 22 insertions, 9 deletions
| diff --git a/include/Buffer.h b/include/Buffer.h index 4971eb9..c2e78ec 100644 --- a/include/Buffer.h +++ b/include/Buffer.h @@ -19,6 +19,7 @@ class Buffer : public Handle {      virtual bool CanWrite();      virtual String GetName();      Buffer operator=(const Buffer &); +    virtual bool CanWatch();    private:      char * buffer; diff --git a/include/Handle.h b/include/Handle.h index 8d006ff..21d6780 100644 --- a/include/Handle.h +++ b/include/Handle.h @@ -43,6 +43,7 @@ class Handle : public Base {      virtual time_t GetModif();      void close();      int GetHandle(); +    virtual bool CanWatch();    protected:        Handle(int h); 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(); +		    }  		}  	    } | 
