From 1ab3f478e7333620e3f8d424d27bd86e54886a3f Mon Sep 17 00:00:00 2001 From: Pixel Date: Sat, 22 Dec 2001 01:53:27 +0000 Subject: Big bug in Write / CopyJob... --- lib/CopyJob.cc | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/CopyJob.cc') 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); } -- cgit v1.2.3