From a03ed4fa08bc9a276a8c52f3ca17aad29bad65ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Fri, 1 May 2020 23:53:19 +0200 Subject: [PATCH] udp: set is_connected flag on our socket once connected. Change-Id: Ie5fcc5152af813d74d33c20ed7c3e81f9e828518 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2548 Reviewed-by: waddlesplash --- src/add-ons/kernel/network/protocols/udp/udp.cpp | 5 ++++- src/add-ons/kernel/network/stack/net_socket.cpp | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/network/protocols/udp/udp.cpp b/src/add-ons/kernel/network/protocols/udp/udp.cpp index 9be6d767bb..8d74e7c6fc 100644 --- a/src/add-ons/kernel/network/protocols/udp/udp.cpp +++ b/src/add-ons/kernel/network/protocols/udp/udp.cpp @@ -384,7 +384,10 @@ UdpDomainSupport::ConnectEndpoint(UdpEndpoint *endpoint, // we need to activate no matter whether or not we have just disconnected, // as calling connect() always triggers an implicit bind(): - return _BindEndpoint(endpoint, *endpoint->LocalAddress()); + status_t status = _BindEndpoint(endpoint, *endpoint->LocalAddress()); + if (status == B_OK) + gSocketModule->set_connected(endpoint->Socket()); + return status; } diff --git a/src/add-ons/kernel/network/stack/net_socket.cpp b/src/add-ons/kernel/network/stack/net_socket.cpp index 414acc5e2c..4ca9ebbf20 100644 --- a/src/add-ons/kernel/network/stack/net_socket.cpp +++ b/src/add-ons/kernel/network/stack/net_socket.cpp @@ -829,6 +829,11 @@ socket_connected(net_socket* _socket) TRACE("socket_connected(%p)\n", socket); + if (socket->parent == NULL) { + socket->is_connected = true; + return B_OK; + } + BReference parent = socket->parent.GetReference(); if (parent.Get() == NULL) return B_BAD_VALUE;