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

Unified Diff: net/dns/mdns_client_impl.cc

Issue 2684113002: [ON HOLD] Deallocate read buffer in MDnsClientImpl::SocketHandler if done reading (Closed)
Patch Set: Created 3 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 | « net/dns/mdns_client_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/mdns_client_impl.cc
diff --git a/net/dns/mdns_client_impl.cc b/net/dns/mdns_client_impl.cc
index 8dbd6d3277e26611be3c7a2b12198d37d6993a65..693f518c151c9ecc7dd5f90dcf92478b1bc76441 100644
--- a/net/dns/mdns_client_impl.cc
+++ b/net/dns/mdns_client_impl.cc
@@ -61,7 +61,7 @@ MDnsConnection::SocketHandler::SocketHandler(
MDnsConnection* connection)
: socket_(std::move(socket)),
connection_(connection),
- response_(dns_protocol::kMaxMulticastSize),
+ response_(new DnsResponse(dns_protocol::kMaxMulticastSize)),
send_in_progress_(false) {}
MDnsConnection::SocketHandler::~SocketHandler() {
@@ -75,32 +75,35 @@ int MDnsConnection::SocketHandler::Start() {
DCHECK(end_point.GetFamily() == ADDRESS_FAMILY_IPV4 ||
end_point.GetFamily() == ADDRESS_FAMILY_IPV6);
multicast_addr_ = GetMDnsIPEndPoint(end_point.GetFamily());
- return DoLoop(0);
+ return DoRead(0);
}
-int MDnsConnection::SocketHandler::DoLoop(int rv) {
+int MDnsConnection::SocketHandler::DoRead(int rv) {
+ DCHECK(response_);
do {
if (rv > 0)
- connection_->OnDatagramReceived(&response_, recv_addr_, rv);
+ connection_->OnDatagramReceived(response_.get(), recv_addr_, rv);
rv = socket_->RecvFrom(
- response_.io_buffer(), response_.io_buffer()->size(), &recv_addr_,
+ response_->io_buffer(), response_->io_buffer()->size(), &recv_addr_,
base::Bind(&MDnsConnection::SocketHandler::OnDatagramReceived,
base::Unretained(this)));
} while (rv > 0);
- if (rv != ERR_IO_PENDING)
- return rv;
-
- return OK;
+ if (rv == ERR_IO_PENDING)
+ return OK;
+ response_.reset();
+ return rv;
}
void MDnsConnection::SocketHandler::OnDatagramReceived(int rv) {
if (rv >= OK)
- rv = DoLoop(rv);
+ rv = DoRead(rv);
- if (rv != OK)
+ if (rv != OK) {
+ response_.reset();
connection_->PostOnError(this, rv);
+ }
}
void MDnsConnection::SocketHandler::Send(const scoped_refptr<IOBuffer>& buffer,
« no previous file with comments | « net/dns/mdns_client_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698