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.
4 files changed