Prevent busy loop
On an intermittent basis, NsdManager.resolveService() never returns with
a callback. The only way to recover from this condition is to force-kill
the app process.
From logcat output, it is clear that MDnsSdListener::Monitor has entered
a polling loop, in which it continually finds data but does not appear
to process it.
The condition is caused when an old request is closed, then reallocated
at the exact same memory location before a rescan can occur. If data
or POLLNVAL arrives on the old socket, it is improperly matched up with
the newly allocated DNSServiceRef, and DNSServiceProcessResult() is
called for it when nothing actually happened, causing undefined behavior
such as the busy poll() loop.
Clearing mRef at deallocation time prevents this effect because the
DNSServiceProcessResult ignores a NULL DNSServiceRef.
More details in https://issuetracker.google.com/issues/37127704
Test: Repeated use of NsdManager include resolve with devices in range
Change-Id: If0f21ffc8b0f003f06e04dbc6bc2b1aac55a5443
Signed-off-by: Glade Diviney <mopriadevteam@gmail.com>
1 file changed