diff options
author | Pixel <Pixel> | 2001-12-22 01:53:27 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2001-12-22 01:53:27 +0000 |
commit | 1ab3f478e7333620e3f8d424d27bd86e54886a3f (patch) | |
tree | 795ba70046b47c94ecc86e363a9c0351f0a01285 /lib/CopyJob.cc | |
parent | 07447744c6b3455c1703471b249bda89dba333f5 (diff) |
Big bug in Write / CopyJob...
Diffstat (limited to 'lib/CopyJob.cc')
-rw-r--r-- | lib/CopyJob.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/CopyJob.cc b/lib/CopyJob.cc index 524a52c..7acc7c5 100644 --- a/lib/CopyJob.cc +++ b/lib/CopyJob.cc @@ -2,7 +2,7 @@ #include "General.h" #include "config.h" -CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz, bool ads, bool add) : s(as), d(ad), ds(ads), dd(add), siz(asiz), cursiz(0), r(0) { +CopyJob::CopyJob(Handle * as, Handle * ad, ssize_t asiz, bool ads, bool add) : s(as), d(ad), ds(ads), dd(add), siz(asiz), cursiz(0), r(0), w(0), tw(0) { s->SetNonBlock(); d->SetNonBlock(); WaitFor(s, W4_READING); @@ -26,9 +26,7 @@ int CopyJob::Do() throw (GeneralException) { tr = siz >= 0 ? siz - cursiz : COPY_BUFSIZ; try { r = s->read(buffer, MIN(COPY_BUFSIZ, tr)); -// cerr << "CopyJob: read " << r << " bytes: " << endl; -// buffer[r] = 0; -// cerr << buffer << endl; +// cerr << "CopyJob: read " << r << " bytes." << endl; } catch (IOAgain e) { WaitFor(s, W4_READING); @@ -37,12 +35,20 @@ int CopyJob::Do() throw (GeneralException) { if (!r) { return TASK_DONE; } + tw = 0; case 1: + current = 1; try { - d->write(buffer, r); + w = d->write(buffer + tw, r - tw); } catch (IOAgain e) { - current = 1; + WaitFor(d, W4_WRITING); + Suspend(TASK_ON_HOLD); + } +// cerr << "CopyJob: wrote " << w << " bytes." << endl; + tw += w; + if (r != tw) { +// cerr << "CopyJob: We did expect to write a total of " << r << " bytes and we achieved " << tw << " bytes so far.\n"; WaitFor(d, W4_WRITING); Suspend(TASK_ON_HOLD); } |