diff options
author | Ryan Keane <rwkeane@google.com> | 2019-08-23 14:54:38 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-23 22:02:34 +0000 |
commit | 83e6832daffbb8244d5b24496014ae904b22983c (patch) | |
tree | e8d6c49572cd81fef135da671f424b392ca51d5c /osp | |
parent | 7267c15b3999a7dac7861ef6f4dccf2b16939654 (diff) | |
download | openscreen-83e6832daffbb8244d5b24496014ae904b22983c.tar.gz |
UdpSocket: Update Bind call
Updates bind to use the new Callback mechanism instead of the current
return value approach
Change-Id: I07d3048658046a7ff56c1851716f8a9bd4b91bfb
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1761387
Commit-Queue: Ryan Keane <rwkeane@google.com>
Reviewed-by: mark a. foltz <mfoltz@chromium.org>
Reviewed-by: Max Yakimakha <yakimakha@chromium.org>
Diffstat (limited to 'osp')
-rw-r--r-- | osp/impl/discovery/mdns/embedder_demo.cc | 12 | ||||
-rw-r--r-- | osp/impl/internal_services.cc | 10 | ||||
-rw-r--r-- | osp/impl/quic/quic_connection_factory_impl.cc | 9 |
3 files changed, 10 insertions, 21 deletions
diff --git a/osp/impl/discovery/mdns/embedder_demo.cc b/osp/impl/discovery/mdns/embedder_demo.cc index 2cbbf9e2..04823157 100644 --- a/osp/impl/discovery/mdns/embedder_demo.cc +++ b/osp/impl/discovery/mdns/embedder_demo.cc @@ -52,8 +52,11 @@ struct Service { }; class DemoSocketClient : public platform::UdpSocket::Client { + public: void OnError(platform::UdpSocket* socket, Error error) override { - OSP_UNIMPLEMENTED(); + // TODO(issue/66): Change to OSP_LOG_FATAL. + OSP_LOG_ERROR << "configuration failed for interface " << error.message(); + OSP_CHECK(false); } void OnSendError(platform::UdpSocket* socket, Error error) override { @@ -143,12 +146,7 @@ std::vector<platform::UdpSocketUniquePtr> SetUpMulticastSockets( continue; } - result = socket->Bind(); - if (!result.ok()) { - OSP_LOG_ERROR << "bind failed for interface " << ifindex << ": " - << result.message(); - continue; - } + socket->Bind(); OSP_LOG << "listening on interface " << ifindex; sockets.emplace_back(std::move(socket)); diff --git a/osp/impl/internal_services.cc b/osp/impl/internal_services.cc index 61bbffa9..b4c1b601 100644 --- a/osp/impl/internal_services.cc +++ b/osp/impl/internal_services.cc @@ -55,12 +55,7 @@ Error SetUpMulticastSocket(platform::UdpSocket* socket, return result; } - result = socket->Bind(); - if (!result.ok()) { - OSP_LOG_ERROR << "bind failed for interface " << ifindex << ": " - << result.message(); - return result; - } + socket->Bind(); return Error::None(); } @@ -226,7 +221,8 @@ void InternalServices::DereferenceSingleton(void* instance) { } void InternalServices::OnError(platform::UdpSocket* socket, Error error) { - OSP_UNIMPLEMENTED(); + OSP_LOG_ERROR << "failed to configure socket " << error.message(); + this->DeregisterMdnsSocket(socket); } void InternalServices::OnSendError(platform::UdpSocket* socket, Error error) { diff --git a/osp/impl/quic/quic_connection_factory_impl.cc b/osp/impl/quic/quic_connection_factory_impl.cc index 8e455e70..da072eec 100644 --- a/osp/impl/quic/quic_connection_factory_impl.cc +++ b/osp/impl/quic/quic_connection_factory_impl.cc @@ -96,12 +96,7 @@ void QuicConnectionFactoryImpl::SetServerDelegate( continue; } platform::UdpSocketUniquePtr server_socket = create_result.MoveValue(); - Error bind_result = server_socket->Bind(); - if (!bind_result.ok()) { - OSP_LOG_ERROR << "failed to bind socket (for " << endpoint - << "): " << bind_result.message(); - continue; - } + server_socket->Bind(); network_runner_->ReadRepeatedly(server_socket.get(), this); sockets_.emplace_back(std::move(server_socket)); } @@ -214,7 +209,7 @@ void QuicConnectionFactoryImpl::OnConnectionClosed(QuicConnection* connection) { void QuicConnectionFactoryImpl::OnError(platform::UdpSocket* socket, Error error) { - OSP_UNIMPLEMENTED(); + OSP_LOG_ERROR << "failed to configure socket " << error.message(); } void QuicConnectionFactoryImpl::OnSendError(platform::UdpSocket* socket, |