Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/seastar/net/posix-stack.hh
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class posix_data_source_impl final : public data_source_impl {
size_t _buf_size;
public:
explicit posix_data_source_impl(lw_shared_ptr<pollable_fd> fd, compat::polymorphic_allocator<char>* allocator=memory::malloc_allocator,
size_t buf_size = 8192) : _buffer_allocator(allocator), _fd(std::move(fd)),
size_t buf_size = 1 << 13) : _buffer_allocator(allocator), _fd(std::move(fd)),
_buf(make_temporary_buffer<char>(_buffer_allocator, buf_size)), _buf_size(buf_size) {}
future<temporary_buffer<char>> get() override;
future<> close() override;
Expand Down
8 changes: 8 additions & 0 deletions src/net/posix-stack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,19 @@ posix_ap_server_socket_impl<Transport>::move_connected_socket(socket_address sa,
}
}

static constexpr size_t min_buf_size = 1 << 9;
static constexpr size_t max_buf_size = 1 << 19;

future<temporary_buffer<char>>
posix_data_source_impl::get() {
return _fd->read_some(_buf.get_write(), _buf_size).then([this] (size_t size) {
_buf.trim(size);
auto ret = std::move(_buf);
if (_buf_size == size) {
_buf_size = std::min(max_buf_size, _buf_size << 2);
} else if (size < (_buf_size >> 2)) {
_buf_size = std::max(min_buf_size, _buf_size >> 2);
}
_buf = make_temporary_buffer<char>(_buffer_allocator, _buf_size);
return make_ready_future<temporary_buffer<char>>(std::move(ret));
});
Expand Down