diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-11-27T19·49-0500 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-11-27T20·08+0000 |
commit | 39f96c4d9f5799aad1c064ef80c6fb1aed45f4e3 (patch) | |
tree | 9a832e3c0e6c62a40291785545e235f338ad7232 /third_party/nix/src/nix-daemon/nix-daemon-proto.cc | |
parent | afdf08ead56370efabd6e9e9e154fe013a428419 (diff) |
fix(txix): Override overflow in BuildLogStreambuf r/1941
Subclasses of std::streambuf are expected to override overflow in addition to xsputn, as it's called in certain cases by the non-virtual methods. In our case, this was preventing endlines from getting sent over the log stream. Change-Id: I70d00f0c7cb8f8cf2f744f58974c21e7a70a715b Reviewed-on: https://cl.tvl.fyi/c/depot/+/2172 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/nix-daemon/nix-daemon-proto.cc')
-rw-r--r-- | third_party/nix/src/nix-daemon/nix-daemon-proto.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc index b6a5fe358a96..eab10e9572aa 100644 --- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc +++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc @@ -99,6 +99,7 @@ class BuildLogStreambuf final : public std::streambuf { using Writer = grpc::ServerWriter<nix::proto::BuildEvent>; explicit BuildLogStreambuf(Writer* writer) : writer_(writer) {} + // TODO(grfn): buffer with a timeout so we don't have too many messages std::streamsize xsputn(const char_type* s, std::streamsize n) override { nix::proto::BuildEvent event; event.mutable_build_log()->set_line(s, n); @@ -106,6 +107,15 @@ class BuildLogStreambuf final : public std::streambuf { return n; } + int_type overflow(int_type ch) override { + if (ch != traits_type::eof()) { + nix::proto::BuildEvent event; + event.mutable_build_log()->set_line(std::string(1, ch)); + writer_->Write(event); + } + return ch; + } + private: Writer* writer_{}; }; |