mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
IPv4: Only buffer payload bytes for SOCK_STREAM sockets
Since stream sockets don't actually need to deliver packets-at-a-time data in recvfrom(), they can just buffer the payload bytes instead. This avoids keeping one KBuffer per incoming packet in the receive queue, which was a big performance issue in ProtocolServer. This code is definitely not perfect and is something we should keep improving over time.
This commit is contained in:
parent
4d406d5c6d
commit
77cb5594b0
2 changed files with 74 additions and 9 deletions
|
@ -53,6 +53,12 @@ public:
|
|||
|
||||
u8 ttl() const { return m_ttl; }
|
||||
|
||||
enum class BufferMode {
|
||||
Packets,
|
||||
Bytes,
|
||||
};
|
||||
BufferMode buffer_mode() const { return m_buffer_mode; }
|
||||
|
||||
protected:
|
||||
IPv4Socket(int type, int protocol);
|
||||
virtual const char* class_name() const override { return "IPv4Socket"; }
|
||||
|
@ -84,6 +90,8 @@ private:
|
|||
|
||||
SinglyLinkedList<ReceivedPacket> m_receive_queue;
|
||||
|
||||
DoubleBuffer m_receive_buffer;
|
||||
|
||||
u16 m_local_port { 0 };
|
||||
u16 m_peer_port { 0 };
|
||||
|
||||
|
@ -92,4 +100,8 @@ private:
|
|||
u8 m_ttl { 64 };
|
||||
|
||||
bool m_can_read { false };
|
||||
|
||||
BufferMode m_buffer_mode { BufferMode::Packets };
|
||||
|
||||
Optional<KBuffer> m_scratch_buffer;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue