summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2008-10-08 09:31:07 -0700
committerPixel <pixel@nobis-crew.org>2008-10-08 09:31:07 -0700
commite771ca4231f7b7256cbff0eb3ac514267d7427ad (patch)
tree68faaa80c91edaa5963495405f81da418249bed7
parent2d57145f789c3e87cc950c3ceab76870cd98beff (diff)
Fixing ReadJob to work better with partial input buffers.
-rw-r--r--include/ReadJob.h1
-rw-r--r--lib/ReadJob.cc15
2 files changed, 13 insertions, 3 deletions
diff --git a/include/ReadJob.h b/include/ReadJob.h
index fb2fa32..c7843d5 100644
--- a/include/ReadJob.h
+++ b/include/ReadJob.h
@@ -34,6 +34,7 @@ class ReadJob : public Task {
private:
Handle * s, * d;
const Regex * regex;
+ String buff;
};
#endif
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);