summaryrefslogtreecommitdiff
path: root/lib/CopyJob.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CopyJob.cc')
-rw-r--r--lib/CopyJob.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index fd31eff..5f348db 100644
--- a/lib/CopyJob.cc
+++ b/lib/CopyJob.cc
@@ -2,8 +2,9 @@
#include "General.h"
CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz, bool ads) : s(as), d(ad), ds(ads), siz(asiz), cursiz(0), r(0) {
- WaitFor(s, W4_STICKY | W4_READING);
- WaitFor(d, W4_STICKY | W4_WRITING);
+ s->SetNonBlock();
+ d->SetNonBlock();
+ WaitFor(s, W4_READING);
}
CopyJob::~CopyJob() { }
@@ -18,17 +19,19 @@ int CopyJob::Do() throw (GeneralException) {
r = s->read(buffer, MIN(COPY_BUFSIZ, tr));
}
catch (IOAgain e) {
+ WaitFor(s, W4_READING);
Suspend(TASK_ON_HOLD);
}
- case 1:
if (!r) {
return TASK_DONE;
}
+ case 1:
try {
d->write(buffer, r);
}
catch (IOAgain e) {
current = 1;
+ WaitFor(d, W4_WRITING);
Suspend(TASK_ON_HOLD);
}
current = 0;
@@ -36,7 +39,8 @@ int CopyJob::Do() throw (GeneralException) {
cursiz += r;
if (!s->IsClosed() && (siz != cursiz)) {
- throw TaskSwitch();
+ WaitFor(s, W4_READING);
+ Suspend(TASK_ON_HOLD);
}
if (ds) {