aboutsummaryrefslogtreecommitdiff
path: root/bbot/agent.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-04-22 18:32:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-04-22 18:32:46 +0200
commit16143f324c030579d447679d5741b63796a4ac9b (patch)
tree887fa63758205ab24fae5395ac2e4244a2e51067 /bbot/agent.cxx
parent1fef20e94bd9960da1b2ea0b2a41b94a79f8abc5 (diff)
Make HTTP soft error handling more robust
Diffstat (limited to 'bbot/agent.cxx')
-rw-r--r--bbot/agent.cxx38
1 files changed, 32 insertions, 6 deletions
diff --git a/bbot/agent.cxx b/bbot/agent.cxx
index 683bd73..0840739 100644
--- a/bbot/agent.cxx
+++ b/bbot/agent.cxx
@@ -873,14 +873,30 @@ try
"--header", "Content-Type: text/manifest",
"--max-time", ops.request_timeout ());
- serialize_manifest (tq, c.out, u, "task request");
+ // This is tricky/hairy: we may fail hard parsing the output before
+ // seeing that curl exited with an error and failing softly.
+ //
+ bool f (false);
+
+ try
+ {
+ serialize_manifest (tq, c.out, u, "task request", false);
+ }
+ catch (const failed&) {f = true;}
+
c.out.close ();
- tr = parse_manifest<task_response_manifest> (
- c.in, u, "task response");
+ if (!f)
+ try
+ {
+ tr = parse_manifest<task_response_manifest> (
+ c.in, u, "task response", false);
+ }
+ catch (const failed&) {f = true;}
+
c.in.close ();
- if (!c.wait ())
+ if (!c.wait () || f)
throw_generic_error (EIO);
}
catch (const system_error& e)
@@ -971,10 +987,20 @@ try
"--header", "Content-Type: text/manifest",
"--max-time", ops.request_timeout ());
- serialize_manifest (rq, c.out, u, "task request");
+ // This is tricky/hairy: we may fail hard writing the input before
+ // seeing that curl exited with an error and failing softly.
+ //
+ bool f (false);
+
+ try
+ {
+ serialize_manifest (rq, c.out, u, "task request");
+ }
+ catch (const failed&) {f = true;}
+
c.out.close ();
- if (!c.wait ())
+ if (!c.wait () || f)
throw_generic_error (EIO);
}
catch (const system_error& e)