src/java.base/windows/classes/sun/nio/ch/WindowsSelectorImpl.java
author michaelm
Fri, 25 Oct 2019 15:56:35 +0100
branchunixdomainchannels
changeset 58801 119ac9128c1b
parent 50602 ed8de3d0cd28
child 59004 84e08e00c29c
permissions -rw-r--r--
Initial implementation of unix domain channels. See j.n.c.{Server}SocketChannel apidoc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
49248
15a0e60c8b97 8199611: (se) Minor selector implementation clean-up
alanb
parents: 47216
diff changeset
     2
 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2445
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2445
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2445
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2445
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2445
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.nio.ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    28
import java.io.IOException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.nio.channels.ClosedSelectorException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.nio.channels.Pipe;
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
    31
import java.nio.channels.SelectionKey;
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    32
import java.nio.channels.Selector;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    33
import java.nio.channels.spi.SelectorProvider;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    34
import java.util.ArrayDeque;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    35
import java.util.ArrayList;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    36
import java.util.Deque;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    37
import java.util.HashMap;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.util.List;
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
    39
import java.util.Map;
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
    40
import java.util.function.Consumer;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * A multi-threaded implementation of Selector for Windows.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @author Konstantin Kladko
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @author Mark Reinhold
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
49248
15a0e60c8b97 8199611: (se) Minor selector implementation clean-up
alanb
parents: 47216
diff changeset
    49
class WindowsSelectorImpl extends SelectorImpl {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    // Initial capacity of the poll array
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private final int INIT_CAP = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    // Maximum number of sockets for select().
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    // Should be INIT_CAP times a power of 2
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 29920
diff changeset
    54
    private static final int MAX_SELECTABLE_FDS = 1024;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    // The list of SelectableChannels serviced by this Selector. Every mod
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    // MAX_SELECTABLE_FDS entry is bogus, to align this array with the poll
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    // array,  where the corresponding entry is occupied by the wakeupSocket
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private SelectionKeyImpl[] channelArray = new SelectionKeyImpl[INIT_CAP];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    // The global native poll array holds file decriptors and event masks
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private PollArrayWrapper pollWrapper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    // The number of valid entries in  poll array, including entries occupied
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // by wakeup socket handle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private int totalChannels = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // Number of helper threads needed for select. We need one thread per
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    // each additional set of MAX_SELECTABLE_FDS - 1 channels.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private int threadsCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    // A list of helper threads for select.
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
    73
    private final List<SelectThread> threads = new ArrayList<SelectThread>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    //Pipe used as a wakeup object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    private final Pipe wakeupPipe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // File descriptors corresponding to source and sink
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    private final int wakeupSourceFd, wakeupSinkFd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    // Maps file descriptors to their indices in  pollArray
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 29920
diff changeset
    82
    private static final class FdMap extends HashMap<Integer, MapEntry> {
895
67f1dc69ad10 6726309: Compiler warnings in nio code
alanb
parents: 2
diff changeset
    83
        static final long serialVersionUID = 0L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        private MapEntry get(int desc) {
37521
b6e0f285c998 8145468: update java.lang APIs with new deprecations
smarks
parents: 34774
diff changeset
    85
            return get(Integer.valueOf(desc));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        private MapEntry put(SelectionKeyImpl ski) {
49526
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
    88
            return put(Integer.valueOf(ski.getFDVal()), new MapEntry(ski));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        private MapEntry remove(SelectionKeyImpl ski) {
49526
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
    91
            Integer fd = Integer.valueOf(ski.getFDVal());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            MapEntry x = get(fd);
49526
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
    93
            if ((x != null) && (x.ski.channel() == ski.channel()))
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                return remove(fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    // class for fdMap entries
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 29920
diff changeset
   100
    private static final class MapEntry {
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   101
        final SelectionKeyImpl ski;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        long updateCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        MapEntry(SelectionKeyImpl ski) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            this.ski = ski;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    private final FdMap fdMap = new FdMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    // SubSelector for the main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    private final SubSelector subSelector = new SubSelector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    private long timeout; //timeout for poll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    // Lock for interrupt triggering and clearing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    private final Object interruptLock = new Object();
34774
03b4e6dc367b 8145680: Remove unnecessary explicit initialization of volatile variables in java.base
redestad
parents: 34716
diff changeset
   116
    private volatile boolean interruptTriggered;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
49526
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
   118
    // pending new registrations/updates, queued by implRegister and setEventOps
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   119
    private final Object updateLock = new Object();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   120
    private final Deque<SelectionKeyImpl> newKeys = new ArrayDeque<>();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   121
    private final Deque<SelectionKeyImpl> updateKeys = new ArrayDeque<>();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   122
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   123
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    WindowsSelectorImpl(SelectorProvider sp) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        super(sp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        pollWrapper = new PollArrayWrapper(INIT_CAP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        wakeupPipe = Pipe.open();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        wakeupSourceFd = ((SelChImpl)wakeupPipe.source()).getFDVal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        // Disable the Nagle algorithm so that the wakeup is more immediate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        SinkChannelImpl sink = (SinkChannelImpl)wakeupPipe.sink();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        (sink.sc).socket().setTcpNoDelay(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        wakeupSinkFd = ((SelChImpl)sink).getFDVal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        pollWrapper.addWakeupSocket(wakeupSourceFd, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   138
    private void ensureOpen() {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   139
        if (!isOpen())
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   140
            throw new ClosedSelectorException();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   141
    }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   142
49248
15a0e60c8b97 8199611: (se) Minor selector implementation clean-up
alanb
parents: 47216
diff changeset
   143
    @Override
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   144
    protected int doSelect(Consumer<SelectionKey> action, long timeout)
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   145
        throws IOException
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   146
    {
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   147
        assert Thread.holdsLock(this);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        this.timeout = timeout; // set selector timeout
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   149
        processUpdateQueue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        processDeregisterQueue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        if (interruptTriggered) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            resetWakeupSocket();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        // Calculate number of helper threads needed for poll. If necessary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // threads are created here and start waiting on startLock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        adjustThreadsCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        finishLock.reset(); // reset finishLock
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        // Wakeup helper threads, waiting on startLock, so they start polling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        // Redundant threads will exit here after wakeup.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        startLock.startThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        // do polling in the main thread. Main thread is responsible for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        // first MAX_SELECTABLE_FDS entries in pollArray.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            begin();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                subSelector.poll();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                finishLock.setException(e); // Save this exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            // Main thread is out of poll(). Wakeup others and wait for them
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            if (threads.size() > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                finishLock.waitForHelperThreads();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
          } finally {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
              end();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
          }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        finishLock.checkForException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        processDeregisterQueue();
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   180
        int updated = updateSelectedKeys(action);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        // Done with poll(). Set wakeupSocket to nonsignaled  for the next run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        resetWakeupSocket();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        return updated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   186
    /**
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   187
     * Process new registrations and changes to the interest ops.
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   188
     */
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   189
    private void processUpdateQueue() {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   190
        assert Thread.holdsLock(this);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   191
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   192
        synchronized (updateLock) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   193
            SelectionKeyImpl ski;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   194
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   195
            // new registrations
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   196
            while ((ski = newKeys.pollFirst()) != null) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   197
                if (ski.isValid()) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   198
                    growIfNeeded();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   199
                    channelArray[totalChannels] = ski;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   200
                    ski.setIndex(totalChannels);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   201
                    pollWrapper.putEntry(totalChannels, ski);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   202
                    totalChannels++;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   203
                    MapEntry previous = fdMap.put(ski);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   204
                    assert previous == null;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   205
                }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   206
            }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   207
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   208
            // changes to interest ops
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   209
            while ((ski = updateKeys.pollFirst()) != null) {
49526
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
   210
                int events = ski.translateInterestOps();
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
   211
                int fd = ski.getFDVal();
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   212
                if (ski.isValid() && fdMap.containsKey(fd)) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   213
                    int index = ski.getIndex();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   214
                    assert index >= 0 && index < totalChannels;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   215
                    pollWrapper.putEventOps(index, events);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   216
                }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   217
            }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   218
        }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   219
    }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   220
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    // Helper threads wait on this lock for the next poll.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    private final StartLock startLock = new StartLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    private final class StartLock {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        // A variable which distinguishes the current run of doSelect from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        // previous one. Incrementing runsCounter and notifying threads will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        // trigger another round of poll.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        private long runsCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
       // Triggers threads, waiting on this lock to start polling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        private synchronized void startThreads() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            runsCounter++; // next run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            notifyAll(); // wake up threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        // This function is called by a helper thread to wait for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        // next round of poll(). It also checks, if this thread became
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        // redundant. If yes, it returns true, notifying the thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        // that it should exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        private synchronized boolean waitForStart(SelectThread thread) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            while (true) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                while (runsCounter == thread.lastRun) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                        startLock.wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                    } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                        Thread.currentThread().interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                }
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   247
                if (thread.isZombie()) { // redundant thread
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                    return true; // will cause run() to exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                    thread.lastRun = runsCounter; // update lastRun
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                    return false; //   will cause run() to poll.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    // Main thread waits on this lock, until all helper threads are done
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    // with poll().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    private final FinishLock finishLock = new FinishLock();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    private final class FinishLock  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        // Number of helper threads, that did not finish yet.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        private int threadsToFinish;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 19607
diff changeset
   265
        // IOException which occurred during the last run.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        IOException exception = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        // Called before polling.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        private void reset() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            threadsToFinish = threads.size(); // helper threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        // Each helper thread invokes this function on finishLock, when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        // the thread is done with poll().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        private synchronized void threadFinished() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            if (threadsToFinish == threads.size()) { // finished poll() first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                // if finished first, wakeup others
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                wakeup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            threadsToFinish--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            if (threadsToFinish == 0) // all helper threads finished poll().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
                notify();             // notify the main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
        // The main thread invokes this function on finishLock to wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        // for helper threads to finish poll().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        private synchronized void waitForHelperThreads() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            if (threadsToFinish == threads.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                // no helper threads finished yet. Wakeup them up.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                wakeup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
            while (threadsToFinish != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                    finishLock.wait();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
                } catch (InterruptedException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
                    // Interrupted - set interrupted state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                    Thread.currentThread().interrupt();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        // sets IOException for this run
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        private synchronized void setException(IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            exception = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        // Checks if there was any exception during the last run.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        // If yes, throws it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        private void checkForException() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            if (exception == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                return;
21591
35320b590d9b 8026491: Typos in string literals
malenkov
parents: 21278
diff changeset
   312
            StringBuffer message =  new StringBuffer("An exception occurred" +
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                                       " during the execution of select(): \n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            message.append(exception);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            message.append('\n');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            exception = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            throw new IOException(message.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    private final class SubSelector {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        private final int pollArrayIndex; // starting index in pollArray to poll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        // These arrays will hold result of native select().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        // The first element of each array is the number of selected sockets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        // Other elements are file descriptors of selected sockets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        private final int[] readFds = new int [MAX_SELECTABLE_FDS + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        private final int[] writeFds = new int [MAX_SELECTABLE_FDS + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        private final int[] exceptFds = new int [MAX_SELECTABLE_FDS + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        private SubSelector() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            this.pollArrayIndex = 0; // main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        private SubSelector(int threadIndex) { // helper threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            this.pollArrayIndex = (threadIndex + 1) * MAX_SELECTABLE_FDS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        private int poll() throws IOException{ // poll for the main thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            return poll0(pollWrapper.pollArrayAddress,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                         Math.min(totalChannels, MAX_SELECTABLE_FDS),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                         readFds, writeFds, exceptFds, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        private int poll(int index) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            // poll for helper threads
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            return  poll0(pollWrapper.pollArrayAddress +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                     (pollArrayIndex * PollArrayWrapper.SIZE_POLLFD),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                     Math.min(MAX_SELECTABLE_FDS,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                             totalChannels - (index + 1) * MAX_SELECTABLE_FDS),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                     readFds, writeFds, exceptFds, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        private native int poll0(long pollAddress, int numfds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
             int[] readFds, int[] writeFds, int[] exceptFds, long timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   356
        private int processSelectedKeys(long updateCount, Consumer<SelectionKey> action) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            int numKeysUpdated = 0;
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   358
            numKeysUpdated += processFDSet(updateCount, action, readFds,
22604
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 21591
diff changeset
   359
                                           Net.POLLIN,
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   360
                                           false);
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   361
            numKeysUpdated += processFDSet(updateCount, action, writeFds,
22604
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 21591
diff changeset
   362
                                           Net.POLLCONN |
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 21591
diff changeset
   363
                                           Net.POLLOUT,
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   364
                                           false);
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   365
            numKeysUpdated += processFDSet(updateCount, action, exceptFds,
22604
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 21591
diff changeset
   366
                                           Net.POLLIN |
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 21591
diff changeset
   367
                                           Net.POLLCONN |
9b394795e216 8031997: PPC64: Make the various POLL constants system dependant
simonis
parents: 21591
diff changeset
   368
                                           Net.POLLOUT,
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   369
                                           true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            return numKeysUpdated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        /**
49527
5aa40f834b50 8200458: (se) Readiness information previously recorded in the ready set not preserved
alanb
parents: 49526
diff changeset
   374
         * updateCount is used to tell if a key has been counted as updated
5aa40f834b50 8200458: (se) Readiness information previously recorded in the ready set not preserved
alanb
parents: 49526
diff changeset
   375
         * in this select operation.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
         *
49527
5aa40f834b50 8200458: (se) Readiness information previously recorded in the ready set not preserved
alanb
parents: 49526
diff changeset
   377
         * me.updateCount <= updateCount
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
         */
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   379
        private int processFDSet(long updateCount,
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   380
                                 Consumer<SelectionKey> action,
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   381
                                 int[] fds, int rOps,
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   382
                                 boolean isExceptFds)
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   383
        {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            int numKeysUpdated = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            for (int i = 1; i <= fds[0]; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                int desc = fds[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                if (desc == wakeupSourceFd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    synchronized (interruptLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                        interruptTriggered = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                MapEntry me = fdMap.get(desc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                // If me is null, the key was deregistered in the previous
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                // processDeregisterQueue.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                if (me == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                SelectionKeyImpl sk = me.ski;
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   399
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   400
                // The descriptor may be in the exceptfds set because there is
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   401
                // OOB data queued to the socket. If there is OOB data then it
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   402
                // is discarded and the key is not added to the selected set.
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   403
                if (isExceptFds &&
58801
119ac9128c1b Initial implementation of unix domain channels. See j.n.c.{Server}SocketChannel apidoc
michaelm
parents: 50602
diff changeset
   404
                    (sk.channel() instanceof InetSocketChannelImpl) &&
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   405
                    discardUrgentData(desc))
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   406
                {
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   407
                    continue;
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   408
                }
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   409
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   410
                int updated = processReadyEvents(rOps, sk, action);
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   411
                if (updated > 0 && me.updateCount != updateCount) {
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   412
                    me.updateCount = updateCount;
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   413
                    numKeysUpdated++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            return numKeysUpdated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    // Represents a helper thread used for select.
34716
7477a052aecc 8056152: API to create Threads that do not inherit inheritable thread-local initial values
chegar
parents: 32649
diff changeset
   421
    private final class SelectThread extends Thread {
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   422
        private final int index; // index of this thread
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   423
        final SubSelector subSelector;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        private long lastRun = 0; // last run number
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   425
        private volatile boolean zombie;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        // Creates a new thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        private SelectThread(int i) {
34716
7477a052aecc 8056152: API to create Threads that do not inherit inheritable thread-local initial values
chegar
parents: 32649
diff changeset
   428
            super(null, null, "SelectorHelper", 0, false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            this.index = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            this.subSelector = new SubSelector(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            //make sure we wait for next round of poll
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
            this.lastRun = startLock.runsCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        }
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   434
        void makeZombie() {
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   435
            zombie = true;
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   436
        }
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   437
        boolean isZombie() {
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   438
            return zombie;
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   439
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
        public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            while (true) { // poll loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                // wait for the start of poll. If this thread has become
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                // redundant, then exit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                if (startLock.waitForStart(this))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
                // call poll()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
                    subSelector.poll(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
                } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                    // Save this exception and let other threads finish.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
                    finishLock.setException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
                // notify main thread, that this thread has finished, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
                // wakeup others, if this thread is the first to finish.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
                finishLock.threadFinished();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    // After some channels registered/deregistered, the number of required
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    // helper threads may have changed. Adjust this number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    private void adjustThreadsCount() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        if (threadsCount > threads.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            // More threads needed. Start more threads.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            for (int i = threads.size(); i < threadsCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                SelectThread newThread = new SelectThread(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                threads.add(newThread);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
                newThread.setDaemon(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
                newThread.start();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        } else if (threadsCount < threads.size()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            // Some threads become redundant. Remove them from the threads List.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            for (int i = threads.size() - 1 ; i >= threadsCount; i--)
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   474
                threads.remove(i).makeZombie();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    // Sets Windows wakeup socket to a signaled state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    private void setWakeupSocket() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        setWakeupSocket0(wakeupSinkFd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    private native void setWakeupSocket0(int wakeupSinkFd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    // Sets Windows wakeup socket to a non-signaled state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    private void resetWakeupSocket() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        synchronized (interruptLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
            if (interruptTriggered == false)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            resetWakeupSocket0(wakeupSourceFd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
            interruptTriggered = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    private native void resetWakeupSocket0(int wakeupSourceFd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
5983
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   496
    private native boolean discardUrgentData(int fd);
b5bc332cd233 6213702: (so) non-blocking sockets with TCP urgent disabled get still selected for read ops (win)
alanb
parents: 5506
diff changeset
   497
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    // We increment this counter on each call to updateSelectedKeys()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    // each entry in  SubSelector.fdsMap has a memorized value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    // updateCount. When we increment numKeysUpdated we set updateCount
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    // for the corresponding entry to its current value. This is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    // avoid counting the same key more than once - the same key can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    // appear in readfds and writefds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    private long updateCount = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    // Update ops of the corresponding Channels. Add the ready keys to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    // ready queue.
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   508
    private int updateSelectedKeys(Consumer<SelectionKey> action) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        updateCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        int numKeysUpdated = 0;
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   511
        numKeysUpdated += subSelector.processSelectedKeys(updateCount, action);
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   512
        for (SelectThread t: threads) {
50602
ed8de3d0cd28 8199433: (se) select(Consumer<SelectionKey> action) as alternative to selected-key set
alanb
parents: 49527
diff changeset
   513
            numKeysUpdated += t.subSelector.processSelectedKeys(updateCount, action);
2445
a1fa6863fc50 6823609: (se) Selector.select hangs on Windows under load
alanb
parents: 1639
diff changeset
   514
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        return numKeysUpdated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
49248
15a0e60c8b97 8199611: (se) Minor selector implementation clean-up
alanb
parents: 47216
diff changeset
   518
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    protected void implClose() throws IOException {
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   520
        assert !isOpen();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   521
        assert Thread.holdsLock(this);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   522
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   523
        // prevent further wakeup
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   524
        synchronized (interruptLock) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   525
            interruptTriggered = true;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        }
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   527
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   528
        wakeupPipe.sink().close();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   529
        wakeupPipe.source().close();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   530
        pollWrapper.free();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   531
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   532
        // Make all remaining helper threads exit
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   533
        for (SelectThread t: threads)
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   534
             t.makeZombie();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   535
        startLock.startThreads();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   538
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    protected void implRegister(SelectionKeyImpl ski) {
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   540
        ensureOpen();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   541
        synchronized (updateLock) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   542
            newKeys.addLast(ski);
1449
2ed6188288d6 5025260: Register methods should throw ClosedChannelException instead of NPE
sherman
parents: 1247
diff changeset
   543
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    private void growIfNeeded() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        if (channelArray.length == totalChannels) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            int newSize = totalChannels * 2; // Make a larger array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            SelectionKeyImpl temp[] = new SelectionKeyImpl[newSize];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            System.arraycopy(channelArray, 1, temp, 1, totalChannels - 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            channelArray = temp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            pollWrapper.grow(newSize);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        if (totalChannels % MAX_SELECTABLE_FDS == 0) { // more threads needed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            pollWrapper.addWakeupSocket(wakeupSourceFd, totalChannels);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            totalChannels++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            threadsCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   561
    @Override
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   562
    protected void implDereg(SelectionKeyImpl ski) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   563
        assert !ski.isValid();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   564
        assert Thread.holdsLock(this);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   565
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   566
        if (fdMap.remove(ski) != null) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   567
            int i = ski.getIndex();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   568
            assert (i >= 0);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   569
16004
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   570
            if (i != totalChannels - 1) {
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   571
                // Copy end one over it
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   572
                SelectionKeyImpl endChannel = channelArray[totalChannels-1];
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   573
                channelArray[i] = endChannel;
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   574
                endChannel.setIndex(i);
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   575
                pollWrapper.replaceEntry(pollWrapper, totalChannels-1, pollWrapper, i);
16004
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   576
            }
6dcf0b33fe6f 6429204: (se) Concurrent Selector.register and SelectionKey.interestOps can ignore interestOps
dingxmin
parents: 14342
diff changeset
   577
            ski.setIndex(-1);
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   578
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   579
            channelArray[totalChannels - 1] = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
            totalChannels--;
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   581
            if (totalChannels != 1 && totalChannels % MAX_SELECTABLE_FDS == 1) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   582
                totalChannels--;
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   583
                threadsCount--; // The last thread has become redundant.
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   584
            }
1449
2ed6188288d6 5025260: Register methods should throw ClosedChannelException instead of NPE
sherman
parents: 1247
diff changeset
   585
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   588
    @Override
49526
cad4c844902a 8200583: (se) Selector clean-up, part 4
alanb
parents: 49493
diff changeset
   589
    public void setEventOps(SelectionKeyImpl ski) {
49493
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   590
        ensureOpen();
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   591
        synchronized (updateLock) {
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   592
            updateKeys.addLast(ski);
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   593
        }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   594
    }
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   595
814bd31f8da0 8200257: (se) More Selector cleanup
alanb
parents: 49248
diff changeset
   596
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    public Selector wakeup() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        synchronized (interruptLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
            if (!interruptTriggered) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
                setWakeupSocket();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
                interruptTriggered = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        return this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    static {
19607
bee007586d06 8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents: 16004
diff changeset
   608
        IOUtil.load();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
}