Properly implement BufferStream::read
The existing implementation did not advance the buffer at all.
This commit is contained in:
parent
7f749740f7
commit
fcdaa24fc5
@ -387,6 +387,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string buffer;
|
std::string buffer;
|
||||||
|
int position = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TaskQueue {
|
class TaskQueue {
|
||||||
@ -2750,10 +2751,12 @@ inline std::string SocketStream::get_remote_addr() const {
|
|||||||
// Buffer stream implementation
|
// Buffer stream implementation
|
||||||
inline int BufferStream::read(char *ptr, size_t size) {
|
inline int BufferStream::read(char *ptr, size_t size) {
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
return static_cast<int>(buffer._Copy_s(ptr, size, size));
|
int len_read = static_cast<int>(buffer._Copy_s(ptr, size, size, position));
|
||||||
#else
|
#else
|
||||||
return static_cast<int>(buffer.copy(ptr, size));
|
int len_read = static_cast<int>(buffer.copy(ptr, size, position));
|
||||||
#endif
|
#endif
|
||||||
|
position += len_read;
|
||||||
|
return len_read;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int BufferStream::write(const char *ptr, size_t size) {
|
inline int BufferStream::write(const char *ptr, size_t size) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user