summaryrefslogtreecommitdiff
path: root/lib/CopyJob.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CopyJob.cc')
-rw-r--r--lib/CopyJob.cc22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc
index f1d3310..e46e3da 100644
--- a/lib/CopyJob.cc
+++ b/lib/CopyJob.cc
@@ -5,27 +5,29 @@ CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz) : s(as), d(ad), siz(asi
CopyJob::~CopyJob() { }
-int CopyJob::Do() {
+int CopyJob::Do() throw (GeneralException) {
int r, tr;
while (!s->IsClosed() || (siz != cursiz)) {
- if (!current) {
+ switch (current) {
+ case 0:
tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ;
try {
r = s->read(buffer, MIN(COPY_BUFSIZ, tr));
}
catch (IOAgain e) {
- return TASK_ON_HOLD;
+ throw TaskSwitch();
+ }
+ case 1:
+ try {
+ d->write(buffer, r);
+ }
+ catch (IOAgain e) {
+ current = 1;
+ throw TaskSwitch();
}
current = 0;
}
- try {
- d->write(buffer, r);
- }
- catch (IOAgain e) {
- current = 1;
- return TASK_ON_HOLD;
- }
cursiz += r;
}
}