1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 09:11:47 +02:00

Rename and protect BufferedSink::write

The `write` name is ambiguous and could lead to some funny bugs like
https://github.com/NixOS/nix/pull/8173#issuecomment-1500009480. So
rename it to the more explicit `writeUnbuffered`.
Besides, this method shouldn't be (and isn't) used outside of the class
implementation, so mark it `protected`.

This makes it more symetrical to `BufferedSource` which uses a
`protected readUnbuffered` method.
This commit is contained in:
Théophane Hufschmitt 2023-04-07 09:16:40 +02:00
parent 9185639631
commit 214f1d6791
6 changed files with 14 additions and 12 deletions

View file

@ -53,7 +53,9 @@ struct BufferedSink : virtual Sink
void flush();
virtual void write(std::string_view data) = 0;
protected:
virtual void writeUnbuffered(std::string_view data) = 0;
};
@ -133,7 +135,7 @@ struct FdSink : BufferedSink
~FdSink();
void write(std::string_view data) override;
void writeUnbuffered(std::string_view data) override;
bool good() override;
@ -520,7 +522,7 @@ struct FramedSink : nix::BufferedSink
}
}
void write(std::string_view data) override
void writeUnbuffered(std::string_view data) override
{
/* Don't send more data if the remote has
encountered an error. */