Getting rid of "benign blocking error" log spam.

For UDP sockets, instead of calling "recv" with "MSG_PEEK" to see if the socket
is alive, just check whether or not it's been closed. It seems that, at least
on some versions of Android, with some specific conditions involving loopback
sockets, calling "recv" with a buffer that's too small for a UDP packet causes
an EFAULT error.

BUG=webrtc:6715

Review-Url: https://codereview.webrtc.org/2678353006
Cr-Commit-Position: refs/heads/master@{#16522}
This commit is contained in:
deadbeef 2017-02-09 15:09:22 -08:00 committed by Commit bot
parent 22e39708c0
commit faedf7f942

View File

@ -689,6 +689,13 @@ int SocketDispatcher::GetDescriptor() {
}
bool SocketDispatcher::IsDescriptorClosed() {
if (udp_) {
// The MSG_PEEK trick doesn't work for UDP, since (at least in some
// circumstances) it requires reading an entire UDP packet, which would be
// bad for performance here. So, just check whether |s_| has been closed,
// which should be sufficient.
return s_ == INVALID_SOCKET;
}
// We don't have a reliable way of distinguishing end-of-stream
// from readability. So test on each readable call. Is this
// inefficient? Probably.
@ -707,6 +714,11 @@ bool SocketDispatcher::IsDescriptorClosed() {
// Returned during ungraceful peer shutdown.
case ECONNRESET:
return true;
// The normal blocking error; don't log anything.
case EWOULDBLOCK:
// Interrupted system call.
case EINTR:
return false;
default:
// Assume that all other errors are just blocking errors, meaning the
// connection is still good but we just can't read from it right now.