diff options
author | Andreas Kling <kling@serenityos.org> | 2021-09-07 15:11:49 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-09-07 15:11:49 +0200 |
commit | c69035c630178459e5a518fb6ef843eb01b8e661 (patch) | |
tree | 8f0788cf182d853b450337f837a4b1bc5adedb85 /Kernel/Net | |
parent | 308773ffda81601ef1a915f03eb4c71b7a28ec6f (diff) | |
download | serenity-c69035c630178459e5a518fb6ef843eb01b8e661.zip |
Kernel: TCPSocket always has a scratch buffer
Let's encode this in the constructor signature.
Diffstat (limited to 'Kernel/Net')
-rw-r--r-- | Kernel/Net/TCPSocket.cpp | 4 | ||||
-rw-r--r-- | Kernel/Net/TCPSocket.h | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Kernel/Net/TCPSocket.cpp b/Kernel/Net/TCPSocket.cpp index 9bc5d57fb8..a82d6bfcc9 100644 --- a/Kernel/Net/TCPSocket.cpp +++ b/Kernel/Net/TCPSocket.cpp @@ -130,7 +130,7 @@ void TCPSocket::release_for_accept(RefPtr<TCPSocket> socket) [[maybe_unused]] auto rc = queue_connection_from(*socket); } -TCPSocket::TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer, OwnPtr<KBuffer> scratch_buffer) +TCPSocket::TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer, NonnullOwnPtr<KBuffer> scratch_buffer) : IPv4Socket(SOCK_STREAM, protocol, move(receive_buffer), move(scratch_buffer)) { m_last_retransmit_time = kgettimeofday(); @@ -154,7 +154,7 @@ KResultOr<NonnullRefPtr<TCPSocket>> TCPSocket::try_create(int protocol, NonnullO if (!scratch_buffer) return ENOMEM; - return adopt_nonnull_ref_or_enomem(new (nothrow) TCPSocket(protocol, move(receive_buffer), move(scratch_buffer))); + return adopt_nonnull_ref_or_enomem(new (nothrow) TCPSocket(protocol, move(receive_buffer), scratch_buffer.release_nonnull())); } KResultOr<size_t> TCPSocket::protocol_receive(ReadonlyBytes raw_ipv4_packet, UserOrKernelBuffer& buffer, size_t buffer_size, [[maybe_unused]] int flags) diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index f588b77af4..ccbaf9922d 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -165,7 +165,7 @@ protected: void set_direction(Direction direction) { m_direction = direction; } private: - explicit TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer, OwnPtr<KBuffer> scratch_buffer); + explicit TCPSocket(int protocol, NonnullOwnPtr<DoubleBuffer> receive_buffer, NonnullOwnPtr<KBuffer> scratch_buffer); virtual StringView class_name() const override { return "TCPSocket"; } virtual void shut_down_for_writing() override; |