summaryrefslogtreecommitdiff
path: root/lib/ReadJob.cc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ReadJob.cc')
-rw-r--r--lib/ReadJob.cc55
1 files changed, 30 insertions, 25 deletions
diff --git a/lib/ReadJob.cc b/lib/ReadJob.cc
index 6640d82..9f037d9 100644
--- a/lib/ReadJob.cc
+++ b/lib/ReadJob.cc
@@ -1,7 +1,10 @@
#include "ReadJob.h"
#include "HttpServ.h"
-ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) { }
+ReadJob::ReadJob(Handle * as, Handle * ad) : s(as), d(ad) {
+ WaitFor(s);
+ WaitFor(d);
+}
ReadJob::~ReadJob() { }
@@ -10,31 +13,33 @@ int ReadJob::Do() throw (GeneralException) {
cerr << "ReadJob running...\n";
- while (!s->IsClosed()) {
- switch (current) {
- case 0:
- try {
- cerr << "Trying to read...\n";
- *s >> buff;
- }
- catch (IOAgain e) {
- cerr << "Suspending ReadJob to wait for reading...\n";
- throw TaskSwitch();
- }
- cerr << "Read some bytes...\n";
- case 1:
- try {
- *d << buff << endnl;
- }
- catch (IOAgain e) {
- cerr << "Suspending ReadJob to wait for writing...\n";
- current = 1;
- throw TaskSwitch();
- }
- current = 0;
- cerr << "Wrote some bytes...\n";
- if (buff == "") return TASK_DONE;
+ switch (current) {
+ case 0:
+ try {
+ cerr << "Trying to read...\n";
+ *s >> buff;
+ }
+ catch (IOAgain e) {
+ cerr << "Suspending ReadJob to wait for reading...\n";
+ throw TaskSwitch();
+ }
+ cerr << "Read some bytes...\n";
+ case 1:
+ try {
+ *d << buff << endnl;
}
+ catch (IOAgain e) {
+ cerr << "Suspending ReadJob to wait for writing...\n";
+ current = 1;
+ throw TaskSwitch();
+ }
+ current = 0;
+ cerr << "Wrote some bytes...\n";
+ if (buff == "") return TASK_DONE;
+ }
+
+ if (!s->IsClosed()) {
+ throw TaskSwitch();
}
return TASK_DONE;