From 29770a9d660f28522a7ef69e60d1ab827781ef2e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 19 Oct 2020 10:46:24 +0200 Subject: Reimplement worker result manifest upload via temporary file This is part of the ongoing work to get rid of the intermittent broken pipe errors. --- bbot/worker/worker.cxx | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/bbot/worker/worker.cxx b/bbot/worker/worker.cxx index 2ad8947..5979ec6 100644 --- a/bbot/worker/worker.cxx +++ b/bbot/worker/worker.cxx @@ -353,10 +353,11 @@ static void upload_manifest (tracer& trace, const string& url, const T& m, - const char* what) + const string& what) { try { +#if 0 tftp_curl c (trace, path ("-"), nullfd, @@ -367,8 +368,35 @@ upload_manifest (tracer& trace, manifest_serializer s (c.out, url); m.serialize (s); - c.out.close (); +#else + auto_rmfile tmp; + try + { + tmp = auto_rmfile (path::temp_path (what + "-manifest")); + ofdstream ofs (tmp.path); + manifest_serializer s (ofs, tmp.path.string ()); + m.serialize (s); + ofs.close (); + } + catch (const io_error& e) // In case not derived from system_error. + { + fail << "unable to save " << what << " manifest: " << e; + } + catch (const system_error& e) + { + fail << "unable to save " << what << " manifest: " << e; + } + + tftp_curl c (trace, + tmp.path, + nullfd, + curl::put, + url, + "--tftp-blksize", tftp_blksize, + "--max-time", tftp_put_timeout); +#endif + if (!c.wait ()) throw_generic_ios_failure (EIO, "non-zero curl exit code"); } -- cgit v1.1