forked from lix-project/lix
Merge pull request #2173 from dtzWill/fix/serialise-read-unbuffered
serialise: fix buffer size used, hide method for internal use only
This commit is contained in:
commit
9064dd2f4d
|
@ -133,7 +133,7 @@ size_t FdSource::readUnbuffered(unsigned char * data, size_t len)
|
||||||
ssize_t n;
|
ssize_t n;
|
||||||
do {
|
do {
|
||||||
checkInterrupt();
|
checkInterrupt();
|
||||||
n = ::read(fd, (char *) data, bufSize);
|
n = ::read(fd, (char *) data, len);
|
||||||
} while (n == -1 && errno == EINTR);
|
} while (n == -1 && errno == EINTR);
|
||||||
if (n == -1) { _good = false; throw SysError("reading from file"); }
|
if (n == -1) { _good = false; throw SysError("reading from file"); }
|
||||||
if (n == 0) { _good = false; throw EndOfFile("unexpected end-of-file"); }
|
if (n == 0) { _good = false; throw EndOfFile("unexpected end-of-file"); }
|
||||||
|
|
|
@ -77,10 +77,12 @@ struct BufferedSource : Source
|
||||||
|
|
||||||
size_t read(unsigned char * data, size_t len) override;
|
size_t read(unsigned char * data, size_t len) override;
|
||||||
|
|
||||||
/* Underlying read call, to be overridden. */
|
|
||||||
virtual size_t readUnbuffered(unsigned char * data, size_t len) = 0;
|
|
||||||
|
|
||||||
bool hasData();
|
bool hasData();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/* Underlying read call, to be overridden. */
|
||||||
|
virtual size_t readUnbuffered(unsigned char * data, size_t len) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -134,8 +136,9 @@ struct FdSource : BufferedSource
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t readUnbuffered(unsigned char * data, size_t len) override;
|
|
||||||
bool good() override;
|
bool good() override;
|
||||||
|
protected:
|
||||||
|
size_t readUnbuffered(unsigned char * data, size_t len) override;
|
||||||
private:
|
private:
|
||||||
bool _good = true;
|
bool _good = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -197,7 +197,8 @@ struct TunnelSource : BufferedSource
|
||||||
{
|
{
|
||||||
Source & from;
|
Source & from;
|
||||||
TunnelSource(Source & from) : from(from) { }
|
TunnelSource(Source & from) : from(from) { }
|
||||||
size_t readUnbuffered(unsigned char * data, size_t len)
|
protected:
|
||||||
|
size_t readUnbuffered(unsigned char * data, size_t len) override
|
||||||
{
|
{
|
||||||
to << STDERR_READ << len;
|
to << STDERR_READ << len;
|
||||||
to.flush();
|
to.flush();
|
||||||
|
|
Loading…
Reference in a new issue