TcpSocket: Fix TlsConnection SocketHandle
Changes the StreamSocket::socket_handle() method to return a const ref.
Will be used for integrating with NetworkWaiter, following nearly-done
CL: https://chromium-review.googlesource.com/c/openscreen/+/1791373
The above change requires that all socket_handles is recieves are const
refs rather than a new object created for each call. Because the rest
of StreamSocketPosix is not thread safe, changing from an atomic_int
to a standard int in SocketHandlePosix should have no thread safety
issues.
See for further context:
https://chromium-review.googlesource.com/c/openscreen/+/1814978
(thought Chromium Gerrit isn't correctly setting up CL hierarchy, so
you will need to wade through extra files)
Change-Id: I0f9bc21ba2bdb3059188141a2875740d0e416d18
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1816284
Reviewed-by: Max Yakimakha <yakimakha@chromium.org>
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Commit-Queue: Jordan Bayles <jophba@chromium.org>
diff --git a/platform/impl/stream_socket.h b/platform/impl/stream_socket.h
index 3fcade4..6128915 100644
--- a/platform/impl/stream_socket.h
+++ b/platform/impl/stream_socket.h
@@ -25,8 +25,12 @@
// asynchronous.
class StreamSocket {
public:
+ StreamSocket() = default;
+ StreamSocket(const StreamSocket& other) = delete;
virtual ~StreamSocket() = default;
+ StreamSocket& operator=(const StreamSocket& other) = delete;
+
// Used by passive/server sockets to accept connection requests
// from a client.
virtual ErrorOr<std::unique_ptr<StreamSocket>> Accept() = 0;
@@ -47,7 +51,7 @@
virtual Error Listen(int max_backlog_size) = 0;
// Returns the file descriptor (e.g. fd or HANDLE pointer) for this socket.
- virtual SocketHandle socket_handle() const = 0;
+ virtual const SocketHandle& socket_handle() const = 0;
// Returns the connected remote address, if socket is connected.
virtual absl::optional<IPEndpoint> remote_address() const = 0;