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 | |
parent | 07447744c6b3455c1703471b249bda89dba333f5 (diff) |
Big bug in Write / CopyJob...
-rw-r--r-- | include/CopyJob.h | 2 | ||||
-rw-r--r-- | lib/CopyJob.cc | 18 | ||||
-rw-r--r-- | lib/Handle.cc | 3 | ||||
-rw-r--r-- | src/Main.cc | 2 |
4 files changed, 17 insertions, 8 deletions
diff --git a/include/CopyJob.h b/include/CopyJob.h index 3afb098..4351570 100644 --- a/include/CopyJob.h +++ b/include/CopyJob.h @@ -19,7 +19,7 @@ class CopyJob : public Task { bool ds, dd; ssize_t siz, cursiz; char buffer[COPY_BUFSIZ + 1]; - int r; + int r, w, tw; }; #else 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); } diff --git a/lib/Handle.cc b/lib/Handle.cc index e98b2c7..9f6736d 100644 --- a/lib/Handle.cc +++ b/lib/Handle.cc @@ -56,6 +56,9 @@ ssize_t Handle::write(const void *buf, size_t count) throw (GeneralException) { throw IOException(GetName(), IO_WRITE, count); } } else if (((size_t) r) != count) { + if (nonblock) { + return r; + } full = done = false; ((char *)buf) += r; tr += r; diff --git a/src/Main.cc b/src/Main.cc index 4663a02..1436f84 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -138,7 +138,7 @@ int main(int argc, char ** argv) { try { HttpServ h(buildmenu(), port.to_int()); - IRC i("botalacon"); +// IRC i("botalacon"); // i.Connect(); // i.MainLoop(); TaskMan::MainLoop(); |