fb34431c917d206542a3eeb42338f8fb42fc40a9 |
|
30-Mar-2016 |
Przemyslaw Szczepaniak <pszczepaniak@google.com> |
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 (cherry picked from commit 6e888e9390649a9ab2557da5b28bb75be39e1b74)
|
396f2361ba82cce530a4ff8aa9ac0780af8d4d56 |
|
06-Aug-2015 |
Narayan Kamath <narayan@google.com> |
Fix DatagramChannel tests. - Add native implementation. - Minor behavioural change : receive from a null address must not attempt to bind. Change-Id: I308cacf4f03bad8e6062ee9e83b5e3e0fa7a6310
|
0aff1dd0b4be1b8d8cb45b59079ca883a1b3205a |
|
17-Jun-2014 |
Elliott Hughes <enh@google.com> |
Remove. (cherry-pick of 63744c884dd4b4f4307f2b021fb894af164972af.) Change-Id: Ibf79a402e1bad98a262e380fcee3d35c127ae6d5
|
63744c884dd4b4f4307f2b021fb894af164972af |
|
17-Jun-2014 |
Elliott Hughes <enh@google.com> |
Remove. Change-Id: Ibf79a402e1bad98a262e380fcee3d35c127ae6d5
|
47ae0b5a1d96c8030e0963ccc5b44c3ee66aaec3 |
|
20-Jan-2014 |
Neil Fuller <nfuller@google.com> |
Implementing bind() and getLocalAddress() for NIO2. This change introduces NetworkChannel, but only bind() and getLocalAddress() methods. To avoid breaking existing Android applications that extend ServerSocketChannel, DatagramChannel and SocketChannel the methods have been added with concrete implementations that throw exceptions rather than leaving them abstract. In channel tests, usages of channel.socket().bind() and channel.socket().getLocalSocketAddress() have been changed to channel.bind() and channel.getLocalAddress(), since the behavior is close enough and the tests should be written against the channel APIs as much as possible. Tests have been added for new methods. Removed further overriding in DatagramChannelImpl.DatagramSocketAdapter and SocketChannelImpl.SocketAdapter which revealed some bugs and lack of clarity in the docs for the socket methods: Improved the documentation for DatagramSocket.getLocalAddress(), DatagramSocket.getLocalSocketAddress(), ServerSocket.getInetAddress(), ServerSocket.getLocalPort(), ServerSocket.getLocalSocketAddress(), Socket.getLocalAddress(), Socket.getLocalPort(), Socket.getLocalSocketAddress(). These methods treat special cases differently. Fixed a bug in DatagramSocket.getLocalSocketAddress() where it would incorrect throw an exception if the socket has been closed, which contradicts the (updated) documentation and the RI. It now returns null. Added tests. Fixed a bug in Socket.close(): a closed socket would still report as being connected. Added tests. Fixed a bug in Socket.startupSocket() - the socket was recording it was being bound, but was not updating the cached local address. This method is called during ServerSocketChannel.accept() and would cause the socket to report its local address as being the wildcard address, when it is not. Added a test. Change-Id: Ibec8527e1c72597e268d23e6c1f03eb16e46cdc4 Bug: 12464155
|
933fbbf606268eec9fc430632b8bca7002a833b3 |
|
14-Jan-2014 |
Neil Fuller <nfuller@google.com> |
Refactoring in preparation for NIO2 changes. Making the various Socket/Channel classes more consistent with each other for synchronizing state between the Channel, Socket and the OS. This is in preparation for NetworkChannel.bind(). Synchronizing state revealed a test that relied upon a Socket from a channel not reporting isConnected() properly after a connect(). Tests have been updated. Reading the local address back from the OS revealed that Android is using IPv6 and reports the string equivalent of IPv4's 0.0.0.0 as "::". Updated a test that was relying on the string form. Calling connect() twice on a DatagramSocket appears inconsistent with itself and Channel and other Sockets. A pure DatagramSocket switches over to the new remote address. I have changed the Channel-backed DatagramSocket to throw an IllegalStateException exception, and have created a bug to discuss making the calls more consistent. Socket has been modified to avoid using the address field to store the local address after a bind(). This field is documented as holding the remote address, not the local. Changed implementation of SocketChannelImpl.socket().getInputStream() and SocketChannelImpl.socket().getOutputStream() to use the one that is implemented by Socket and not a custom NIO-based implementation. The use of NIO provided two parallel implementations for the same thing. This change alters behavior when attempting to read zero bytes and when a Channel is in non-blocking mode: now it throws IllegalBlockingModeException rather than ArrayIndexOutOfBoundsException. The tests have been updated. Various tidying up changes to introduce @Override, remove unnecessarily initialized local variables, fields, semi-colons, javadocs and imports. Added close() calls for objects during tests that were cluttering the logs. Modified IoBridge.connect() to be void. Adjusted SocketChannelImpl accordingly and tidied up impossible cases. Modified SocketChannel.connect() so that it always returns false in non-blocking mode. This looks like an existing bug: it would previously have returned true, even though the connection was potentially still pending. Tests have been added. Also tidied up SocketChannelImpl.finishConnect() - it was potentially resetting the isBound state. Change-Id: Ic7943615b4b763f77e74397e0e91a62edc7d7017 bug: 12464155
|
82c642531ba3c9ad29cb3125f7547a226b661b11 |
|
02-Jan-2014 |
Narayan Kamath <narayan@google.com> |
Delete Support_PortManager & OldDatagramSocketTest Support_PortManager didn't really work, so rewrite all tests that use it. Also, dedup OldDatagramSocketTest with the harmony DatagramSocketTest. Fix various broken test cases and terribly written tests. bug: 11689863 Change-Id: I4efb9e02eb88517273fff50a0dec1d0262feafb2
|
e5fea3d504609d22337a5311d3ce0e72314bceee |
|
15-Nov-2013 |
Narayan Kamath <narayan@google.com> |
Use a consistent package path for harmony tests. Harmony was never consistent about where they put their tests. There's no reason we have to be the same. Also, there's no need to have separate subtrees for nio, nio_char etc. etc. This change makes all existing apache harmony tests subpackages of "org.apache.harmony.tests" and put them under libcore/harmony-tests. We somehow managed to end up with two vastly different copies of CharsetDecoderTest & CharsetEncoderTest. I've renamed the copies CharsetDecoder2Test & CharsetEncoder2Test to avoid having to go in and resolve the complicated diffs or speculate about the reasons for their divergence. Change-Id: Ic34e69c2faab8893edd54e05eccd7091f4a09abd
|