mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 17:30:38 +00:00
Kernel: Properly report receive window size in sent TCP packets
Instead of lying and claiming we always have space left in our receive buffer, actually report the available space. While this doesn't really affect network-bound workloads, it makes a world of difference in cpu/disk-bound ones, like git clones. Resulting in a considerable speed-up, and in some cases making them work at all. (instead of the sender side hanging up the connection due to timeouts)
This commit is contained in:
parent
69f88c9a64
commit
2c51ff763b
Notes:
sideshowbarker
2024-07-17 03:35:16 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/2c51ff763b Pull-request: https://github.com/SerenityOS/serenity/pull/22444
2 changed files with 3 additions and 1 deletions
|
@ -90,6 +90,8 @@ protected:
|
|||
static ErrorOr<NonnullOwnPtr<DoubleBuffer>> try_create_receive_buffer();
|
||||
void drop_receive_buffer();
|
||||
|
||||
size_t available_space_in_receive_buffer() const { return m_receive_buffer ? m_receive_buffer->space_for_writing() : 0; }
|
||||
|
||||
private:
|
||||
virtual bool is_ipv4() const override { return true; }
|
||||
|
||||
|
|
|
@ -260,7 +260,7 @@ ErrorOr<void> TCPSocket::send_tcp_packet(u16 flags, UserOrKernelBuffer const* pa
|
|||
VERIFY(local_port());
|
||||
tcp_packet.set_source_port(local_port());
|
||||
tcp_packet.set_destination_port(peer_port());
|
||||
tcp_packet.set_window_size(NumericLimits<u16>::max());
|
||||
tcp_packet.set_window_size(min(available_space_in_receive_buffer(), NumericLimits<u16>::max()));
|
||||
tcp_packet.set_sequence_number(m_sequence_number);
|
||||
tcp_packet.set_data_offset(tcp_header_size / sizeof(u32));
|
||||
tcp_packet.set_flags(flags);
|
||||
|
|
Loading…
Reference in a new issue