Handle recvfrom() returning 0.
According to the Linux man page, recvfrom() can return 0 when the peer has performed an orderly shutdown. This also happens when other thread uses a shutdown function on a socket file descriptor.
libcore.io.Posix#recvfrom was treating this case as a success and
was trying to interpret unpopulated sockaddr structure, throwing
IllegalArgumentException in result.
DatagramChannel#receive in same case would return
last previously seen SocketAddress.
This change makes sure that libcore.io.Posix#recvfrom and
java.nio.channels.DatagramChannel handle this case correctly.
Bug: 27294715
Bug: 27233089
Change-Id: I1ec58327efbe9ea6b8d36716756a02987e3b9897
4 files changed