History log of /libcore/luni/src/main/java/java/nio/SelectorImpl.java
Revision Date Author Comments
fa542091e45db699a937c5ac0191194405107827 16-Dec-2014 Elliott Hughes <enh@google.com> Fix poll to never return EINTR.

Bug: 18759467
Change-Id: Ia5b97a55318b5990ad6b80d15641223aa4fb06f5
0d8b5c3692c36837d22c4e7d9c4d7d95f6a10235 12-Dec-2014 Elliott Hughes <enh@google.com> Add pipe2 and O_CLOEXEC to the libcore POSIX API.

@hide right now, but we should expose these at some point.

Bug: 18719692
Change-Id: I0a73606cf089ed307d1ab2916a7df28b3c45aaf0
8806710d7a5cd6a168f2463de21498c58f70948a 04-Sep-2014 Przemyslaw Jakwert <przemyslaw2.jakwert@sonymobile.com> High CPU load in java.nio using poll

Sometimes when phone goes out of coverage CPU is
stuck at high load when it should not.

System.os.poll() returns the number of file descriptors
ready to be processed, but since they all have
revent=POLLERR, they are not handled/sent to the
application. Next time application does Selector.select(),
native will not block since there are FDs which have to
be processed and Java will discard them again.

As a result, Selector.select() gets called again and again,
producing 100% CPU load per thread that polls for FDs with
POLLERR set.

The fix is to add POLLERR handling (POLLHUP is being
handled already).

Bug: 17456151

(cherry picked from commit f41df4f9710dafffdedb5fa6c40550532069036a)

Change-Id: I3de249f5cac575da76cc16cdc7b986fb66417e04
f41df4f9710dafffdedb5fa6c40550532069036a 04-Sep-2014 Przemyslaw Jakwert <przemyslaw2.jakwert@sonymobile.com> High CPU load in java.nio using poll

Sometimes when phone goes out of coverage CPU is
stuck at high load when it should not.

System.os.poll() returns the number of file descriptors
ready to be processed, but since they all have
revent=POLLERR, they are not handled/sent to the
application. Next time application does Selector.select(),
native will not block since there are FDs which have to
be processed and Java will discard them again.

As a result, Selector.select() gets called again and again,
producing 100% CPU load per thread that polls for FDs with
POLLERR set.

The fix is to add POLLERR handling (POLLHUP is being
handled already).

Bug: 17456151
Change-Id: I04bbb8e64bf64aee1e95ea7a1a2e1d16c6e1c990
5d930cadc8f62aee5f18e7921296fe66a54f18ab 24-Apr-2014 Elliott Hughes <enh@google.com> Groundwork towards making the Libcore.os functionality public.

Change-Id: Ie700aa16d91fba53fc5eb2555829cb74d84b12ad
f0d40d662d9dfdb04215c718961765837d2cf00c 11-Apr-2014 Neil Fuller <nfuller@google.com> libcore changes to support asynchronous close interruption

Previously AsynchronousSocketCloseMonitor was used to handle
socket interruption on close. To support the same for
FileChannel it has been renamed to AsynchronousCloseMonitor.
The Java class was already called this.

FileInputStream, FileOutputStream, RandomAccessFile will
now throw IOException if a connection is closed by another
thread during read. Thread.interrupt() continues to have no effect
on streams.

FileChannel will now throw AsynchronousCloseException during
reads and writes if the file is closed, per the documentation.

FileChannel will now throw ClosedByInterruptException during
reads and writes if the thread reading/writing is interrupted.

Note: FileChannel.lock() will probably still not not throw
AsynchronousCloseException, though it probably should.

This change also has impact on external/conscrypt and
frameworks/base.

Change-Id: I37de3e7d1a005a73821221e6156d10b95c595d7a
Bug: 13927110
a7f57f4eeb646195183b6a7fecf38cf35b37b196 20-Aug-2013 Elliott Hughes <enh@google.com> Fix Selector's handling of POLLHUP.

Bug: 10310709

(cherry picked from commit ed3322f25d79b6607fc314d75f96d46b7c783f43)

Change-Id: I3f9ce080170ed49f46650420673ca27863381852
ed3322f25d79b6607fc314d75f96d46b7c783f43 20-Aug-2013 Elliott Hughes <enh@google.com> Fix Selector's handling of POLLHUP.

Bug: 10310709
Change-Id: I5e4f0def0a5dd0aacc28012373884053aad30bdc
318d6de23bec3024a85eb211f5843d925774622a 01-Aug-2013 Elliott Hughes <enh@google.com> Minor cleanup from investigating UnixSelectorTest failures.

This doesn't address the failures, but I'm moving on to look at the
other failures first.

Bug: 10127357
Change-Id: I6382e843bcb0d3e4b8726500beba2b5e123e9e01
57656d21f772aacbe0d05e54b1274f4c58993a52 10-Jul-2013 Elliott Hughes <enh@google.com> Fix Selector to allow read and write at the same time.

Bug: https://code.google.com/p/android/issues/detail?id=57456
Change-Id: I29e6688aafce886803bbbd12793df3ab952459c8
126ab1b546c71137a97cef68cc89267e7f7be634 28-Aug-2012 Elliott Hughes <enh@google.com> Improve nio IllegalArgumentException detail messages.

Bug: 7005326
Change-Id: Ibab8b776865dbed5da062cc683f834a79f068b32
f7bd2a99f6f4024e9034300b30a13a2ea871aa97 12-May-2012 Elliott Hughes <enh@google.com> Work around poll(2) failing with EINTR.

This restores the gingerbread behavior, which is arguably pretty annoying too,
but it's what we've always done so less likely to be disruptive.

Bug: 6453247
Change-Id: I22635e36a37cb36cf2b22d1739ab6a28662c9188
9b510df35b57946d843ffc34cf23fdcfc84c5220 28-May-2011 Elliott Hughes <enh@google.com> Make ErrnoException a checked exception.

Bug: 4486011
Change-Id: I1877ce593d441653f75ab14884aa2d85f52652ad
0b736ebc4efef64f2db1999aea90297ad8196146 20-May-2011 Elliott Hughes <enh@google.com> Move the stuff to bridge between io/net/nio semantics and POSIX semantics.

IoUtils should be more generally useful.

Change-Id: I5665f2a94d226ada3077a30045549a53cc741cf0
70c820401677ca251ad09ac64cc23c760764e75d 12-May-2011 Elliott Hughes <enh@google.com> Expose poll(2) and reimplement java.nio.channels.Selector.

This also adds UnsafeArrayList<T>, which is like ArrayList but lets you access
the underlying array (as opposed to ArrayList.toArray which creates a copy).

Bug: 3107501
Change-Id: I8dc570a9fd7951b1435047017ea7aa19f8f8fc53
a7bb29434692e01aed843b88cd042628bab74a23 11-May-2011 Elliott Hughes <enh@google.com> Clean up the select(2) implementation.

I wasn't planning on touching this code (since I want to replace it), but the
purported "fix" for http://code.google.com/p/android/issues/detail?id=6309 was
actually a regression. The supplied test fails on the RI. This patch replaces
the bogus test with new tests, and reverts the old "fix".

This was found while trying to work out what "true" and "false" return values
from OSNetworkSystem.select are supposed to mean. This patch also switches to
a more traditional int return value.

Bug: 3107501
Change-Id: Iddce55e081d440b7eb3ddcf94db7d0739dc89c70
d320e321d5567a4ac94b6e5874eda4b1f1189e13 30-Mar-2011 Elliott Hughes <enh@google.com> Move and rename an implementation detail.

Change-Id: I563c2fd6689dd7249049671c3c01c6434d9b5fa5
78c7cc547101002b9f9043cf3845970719d1bda8 26-Mar-2011 Elliott Hughes <enh@google.com> Add write(2).

Note that this is a functional change, because the old code was wrong: it
assumed that short writes don't happen. I thought we'd (I'd) cleaned this
up just recently, but it looks like I must have only gone through the network
code. Embarrassing.

This also cleans up the previous read change a bit, factoring out a bit more
duplication, and taking advantage of the fact that we now get decent
exceptions thrown from invalid FileDescriptors (meaning we can remove explicit
checks).

Bug: 3107501
Change-Id: I8bd5324836c9d151dceaef5b84ec523a67391b64
26c7025a7a919044771fb89031161bd26fe03032 26-Mar-2011 Elliott Hughes <enh@google.com> Add read(2).

For both byte[]s and ByteBuffers.

Bug: 3107501
Change-Id: I93b781069ade4507371c8fe8c5fda0163fbb2dbb
41f0605d2c809bd9bc1c0fb68d86b49a0f59b6c5 24-Mar-2011 Elliott Hughes <enh@google.com> Add pipe(2).

This lets us kill quite a bit of IoUtils.

Bug: 3107501
Change-Id: Ic8a297b29cc53a17841cc77e266cd8dc3910c521
10959ae7eb41e8ceecb16378c25395eb2f29106c 18-Mar-2011 Jesse Wilson <jessewilson@google.com> Don't block a selector if the current thread has been interrupted.

This changes setInterruptAction to be push/pop rather than set/unset.
During testing I found that different classes were conflicting with
the interrupt action: Channels and Selectors were setting it
simultaneously.

Change-Id: Ie1f96c2a1db9412863f4a181cfa29a239ffa5996
http://code.google.com/p/android/issues/detail?id=15388
6186821cb13f4ac7ff50950c813394367e021eae 08-Feb-2011 Jesse Wilson <jessewilson@google.com> Move libcore.base classes to libcore.util and libcore.io.

Change-Id: I2340a9dbad3561fa681a8ab47d4f406e72c913e3
b46dab348e2007bc08abaf7ecae34d89a2474e50 09-Dec-2010 Elliott Hughes <enh@google.com> Rewrite all backwards comparisons.

Strictly, all the ones I could find. This is everything with 0 or null on the
left-hand side.

Note that this touches several incorrect bounds checks, which I haven't fixed:
I'm going to come back and finish that independent cleanup separately.

Change-Id: Ibdb054b53df9aace47c7d2a00ff19122190053e8
693eacca9fa67ad79d1b35dbaad61c5ac1ac457c 10-Nov-2010 Elliott Hughes <enh@google.com> Stop allocating empty arrays.

Bug: 3166662
Change-Id: I151de373b2bf53786d19824336fa434c02b0b0e8
5e23b687ef8b3c696d54d1880b454942875665b7 22-Sep-2010 Elliott Hughes <enh@google.com> Remove custom marker classes for locks.

Just use Object instead.

Bug: 3024308
Change-Id: I83a01020646d95e014743b76e27ca7134c155298
ae704b984c10a63883cc366e823d53902d6ac7a9 21-Sep-2010 Elliott Hughes <enh@google.com> Minor tidy-up.

The nio implementation is still a bit of a mess because Java doesn't have any
kind of "module" concept, nor "friend". But this makes it a little less untidy,
and makes the deliberate access control subversions a little more explicit, and
makes various things less accessible than they were.

Change-Id: I514b1e24000b91f86b768ed408fedae115dc3080