Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1014)

Unified Diff: media/cast/net/udp_transport.cc

Issue 967723002: Cast: Fix crash in udp_transport (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missed one thing... Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/net/udp_transport.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/net/udp_transport.cc
diff --git a/media/cast/net/udp_transport.cc b/media/cast/net/udp_transport.cc
index f36b03444dbf59dca08e0b6e8d2d85b5c687b85d..95a8997b22b6c595ae07890baca2eb5c046f1979 100644
--- a/media/cast/net/udp_transport.cc
+++ b/media/cast/net/udp_transport.cc
@@ -75,6 +75,7 @@ void UdpTransport::StartReceiving(
udp_socket_->AllowAddressReuse() < 0 ||
udp_socket_->Bind(local_addr_) < 0) {
udp_socket_->Close();
+ udp_socket_.reset();
status_callback_.Run(TRANSPORT_SOCKET_ERROR);
LOG(ERROR) << "Failed to bind local address.";
return;
@@ -84,6 +85,7 @@ void UdpTransport::StartReceiving(
udp_socket_->AllowAddressReuse() < 0 ||
udp_socket_->Connect(remote_addr_) < 0) {
udp_socket_->Close();
+ udp_socket_.reset();
status_callback_.Run(TRANSPORT_SOCKET_ERROR);
LOG(ERROR) << "Failed to connect to remote address.";
return;
@@ -113,6 +115,8 @@ void UdpTransport::SetDscp(net::DiffServCodePoint dscp) {
#if defined(OS_WIN)
void UdpTransport::UseNonBlockingIO() {
DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
+ if (!udp_socket_)
+ return;
udp_socket_->UseNonBlockingIO();
}
#endif
@@ -133,6 +137,8 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) {
if (packet_receiver_.is_null())
return;
+ if (!udp_socket_)
+ return;
// Loop while UdpSocket is delivering data synchronously. When it responds
// with a "pending" status, break and expect this method to be called back in
@@ -189,6 +195,8 @@ void UdpTransport::ReceiveNextPacket(int length_or_status) {
bool UdpTransport::SendPacket(PacketRef packet, const base::Closure& cb) {
DCHECK(io_thread_proxy_->RunsTasksOnCurrentThread());
+ if (!udp_socket_)
+ return true;
// Increase byte count no matter the packet was sent or dropped.
bytes_sent_ += packet->data.size();
« no previous file with comments | « media/cast/net/udp_transport.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698