diff options
author | Pixel <pixel@nobis-crew.org> | 2008-10-08 09:31:07 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2008-10-08 09:31:07 -0700 |
commit | e771ca4231f7b7256cbff0eb3ac514267d7427ad (patch) | |
tree | 68faaa80c91edaa5963495405f81da418249bed7 /lib | |
parent | 2d57145f789c3e87cc950c3ceab76870cd98beff (diff) |
Fixing ReadJob to work better with partial input buffers.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ReadJob.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc index 6851f0e..33f78dd 100644 --- a/lib/ReadJob.cc +++ b/lib/ReadJob.cc @@ -34,22 +34,31 @@ ReadJob::ReadJob(Handle * as, Handle * ad, const Regex & aregex) : s(as), d(ad), ReadJob::~ReadJob() { } int ReadJob::Do() throw (GeneralException) { - String buff; - + String ubuff; + switch (current) { case 0: try { - *s >> buff; + if (buff.strlen() == 0) { + *s >> buff; + } else { + *s >> ubuff; + } } catch (IOAgain e) { + if (ubuff.strlen() != 0) + buff = buff + ubuff; WaitFor(s, W4_READING); Suspend(TASK_ON_HOLD); } + if (ubuff.strlen() != 0) + buff = buff + ubuff; case 1: try { *d << buff << "\n"; } catch (IOAgain e) { + /***TODO*** Potential bug here: if the write was partial, we'd need to restart at a later position. */ current = 1; WaitFor(d, W4_WRITING); Suspend(TASK_ON_HOLD); |