diff options
author | Robert Hensing <robert@roberthensing.nl> | 2020-09-17 22:01:35 +0200 |
---|---|---|
committer | Robert Hensing <robert@roberthensing.nl> | 2020-09-21 07:55:47 +0200 |
commit | 8279178b078103f816bf85f5a153a4845d30cc83 (patch) | |
tree | db0ae65fa87e37ca47b86ad0bcef6c5977394bd9 /src/libstore/remote-store.cc | |
parent | ecc8088cb7e91e4c45787f290c8ff61547fb838a (diff) |
Move FramedSink next to FramedSource
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r-- | src/libstore/remote-store.cc | 35 |
1 files changed, 1 insertions, 34 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 95e6a3291..cfbf23ac4 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -957,39 +957,6 @@ std::exception_ptr RemoteStore::Connection::processStderr(Sink * sink, Source * return nullptr; } - -struct FramedSink : nix::BufferedSink -{ - ConnectionHandle & conn; - std::exception_ptr & ex; - - FramedSink(ConnectionHandle & conn, std::exception_ptr & ex) : conn(conn), ex(ex) - { } - - ~FramedSink() - { - try { - conn->to << 0; - conn->to.flush(); - } catch (...) { - ignoreException(); - } - } - - void write(const unsigned char * data, size_t len) override - { - /* Don't send more data if the remote has - encountered an error. */ - if (ex) { - auto ex2 = ex; - ex = nullptr; - std::rethrow_exception(ex2); - } - conn->to << len; - conn->to(data, len); - }; -}; - void ConnectionHandle::withFramedSink(std::function<void(Sink &sink)> fun) { (*this)->to.flush(); @@ -1022,7 +989,7 @@ ConnectionHandle::withFramedSink(std::function<void(Sink &sink)> fun) { }); { - FramedSink sink(*this, ex); + FramedSink sink((*this)->to, ex); fun(sink); sink.flush(); } |