diff options
Diffstat (limited to 'bbot/agent.cxx')
-rw-r--r-- | bbot/agent.cxx | 38 |
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) |