summaryrefslogtreecommitdiff
path: root/lib/CopyJob.cc
diff options
context:
space:
mode:
authorPixel <Pixel>2001-11-25 23:50:14 +0000
committerPixel <Pixel>2001-11-25 23:50:14 +0000
commit9707409e4d15eadac9b3c752c3c6877788943a58 (patch)
tree58a8ef3851967415fd21674648f02c42e8eab4cd /lib/CopyJob.cc
parent8b6b771ca421f4f08f58debbf5459b020cf1bef7 (diff)
Wow, everything almost work!!! Amazing!!!
Diffstat (limited to 'lib/CopyJob.cc')
-rw-r--r--lib/CopyJob.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index 3b01092..7b4694a 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);
- WaitFor(d, W4_STICKY);
+ WaitFor(s, W4_STICKY | W4_READING);
+ WaitFor(d, W4_STICKY | W4_WRITING);
+ cerr << "Creating a copyjob from " << s->GetName() << " to " << d->GetName() << " of " << siz << " bytes.\n";
}
CopyJob::~CopyJob() { }
@@ -11,13 +12,18 @@ CopyJob::~CopyJob() { }
int CopyJob::Do() throw (GeneralException) {
int tr;
+ cerr << GetName() << " running...\n";
+
switch (current) {
case 0:
tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ;
+ cerr << "Reading " << tr << " bytes.\n";
try {
r = s->read(buffer, MIN(COPY_BUFSIZ, tr));
+ cerr << "Got " << r << " bytes.\n";
}
catch (IOAgain e) {
+ cerr << "Not enough bytes. Suspending.\n";
Suspend();
}
case 1:
@@ -25,17 +31,19 @@ int CopyJob::Do() throw (GeneralException) {
return TASK_DONE;
}
try {
+ cerr << "Writing " << r << " bytes.\n";
d->write(buffer, r);
}
catch (IOAgain e) {
current = 1;
+ cerr << "No more byte in the output. Suspending.\n";
Suspend();
}
current = 0;
}
cursiz += r;
- if (!s->IsClosed() || (siz != cursiz)) {
+ if (!s->IsClosed() && (siz != cursiz)) {
throw TaskSwitch();
}