jdk/src/java.base/linux/classes/sun/nio/ch/EPollArrayWrapper.java
author prr
Fri, 29 Apr 2016 16:37:02 -0700
changeset 38394 2adb3640d70d
parent 25859 3317bb8137f4
child 41976 fb4ce696b742
permissions -rw-r--r--
8155772: gtk3_interface.c compilation error on Ubuntu 12.10 Reviewed-by: serb, kcr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20176
diff changeset
     2
 * Copyright (c) 2005, 2013, 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: 4183
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: 4183
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: 4183
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4183
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4183
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
20176
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
    29
import java.security.AccessController;
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    30
import java.util.BitSet;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    31
import java.util.HashMap;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    32
import java.util.Map;
20176
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
    33
import sun.security.action.GetIntegerAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * Manipulates a native array of epoll_event structs on Linux:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * typedef union epoll_data {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *     void *ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *     int fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *     __uint32_t u32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *     __uint64_t u64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *  } epoll_data_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * struct epoll_event {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *     __uint32_t events;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *     epoll_data_t data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * The system call to wait for I/O events is epoll_wait(2). It populates an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * array of epoll_event structures that are passed to the call. The data
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * member of the epoll_event structure contains the same data as was set
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * when the file descriptor was registered to epoll via epoll_ctl(2). In
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * this implementation we set data.fd to be the file descriptor that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * register. That way, we have the file descriptor available when we
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * process the events.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
class EPollArrayWrapper {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    // EPOLL_EVENTS
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    61
    private static final int EPOLLIN      = 0x001;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    // opcodes
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    64
    private static final int EPOLL_CTL_ADD      = 1;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    65
    private static final int EPOLL_CTL_DEL      = 2;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    66
    private static final int EPOLL_CTL_MOD      = 3;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // Miscellaneous constants
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    69
    private static final int SIZE_EPOLLEVENT  = sizeofEPollEvent();
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    70
    private static final int EVENT_OFFSET     = 0;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    71
    private static final int DATA_OFFSET      = offsetofData();
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    72
    private static final int FD_OFFSET        = DATA_OFFSET;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    73
    private static final int OPEN_MAX         = IOUtil.fdLimit();
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    74
    private static final int NUM_EPOLLEVENTS  = Math.min(OPEN_MAX, 8192);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    75
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    76
    // Special value to indicate that an update should be ignored
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    77
    private static final byte  KILLED = (byte)-1;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    79
    // Initial size of arrays for fd registration changes
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    80
    private static final int INITIAL_PENDING_UPDATE_SIZE = 64;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    81
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    82
    // maximum size of updatesLow
20176
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
    83
    private static final int MAX_UPDATE_ARRAY_SIZE = AccessController.doPrivileged(
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
    84
        new GetIntegerAction("sun.nio.ch.maxUpdateArraySize", Math.min(OPEN_MAX, 64*1024)));
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    85
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    86
    // The fd of the epoll driver
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    87
    private final int epfd;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    88
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    89
     // The epoll_event array for results from epoll_wait
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    90
    private final AllocatedNativeObject pollArray;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    91
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    92
    // Base address of the epoll_event array
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    private final long pollArrayAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    95
    // The fd of the interrupt line going out
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    96
    private int outgoingInterruptFD;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    97
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    98
    // The fd of the interrupt line coming in
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
    99
    private int incomingInterruptFD;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   100
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   101
    // The index of the interrupt FD
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   102
    private int interruptedIndex;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   103
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   104
    // Number of updated pollfd entries
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   105
    int updated;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   106
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   107
    // object to synchronize fd registration changes
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   108
    private final Object updateLock = new Object();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   110
    // number of file descriptors with registration changes pending
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   111
    private int updateCount;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   112
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   113
    // file descriptors with registration changes pending
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   114
    private int[] updateDescriptors = new int[INITIAL_PENDING_UPDATE_SIZE];
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   115
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   116
    // events for file descriptors with registration changes pending, indexed
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   117
    // by file descriptor and stored as bytes for efficiency reasons. For
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   118
    // file descriptors higher than MAX_UPDATE_ARRAY_SIZE (unlimited case at
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   119
    // least) then the update is stored in a map.
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   120
    private final byte[] eventsLow = new byte[MAX_UPDATE_ARRAY_SIZE];
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   121
    private Map<Integer,Byte> eventsHigh;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   122
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   123
    // Used by release and updateRegistrations to track whether a file
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   124
    // descriptor is registered with epoll.
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   125
    private final BitSet registered = new BitSet();
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   126
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   127
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   128
    EPollArrayWrapper() throws IOException {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        // creates the epoll file descriptor
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        epfd = epollCreate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        // the epoll_event array passed to epoll_wait
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        int allocationSize = NUM_EPOLLEVENTS * SIZE_EPOLLEVENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        pollArray = new AllocatedNativeObject(allocationSize, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        pollArrayAddress = pollArray.address();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   137
        // eventHigh needed when using file descriptors > 64k
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   138
        if (OPEN_MAX > MAX_UPDATE_ARRAY_SIZE)
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   139
            eventsHigh = new HashMap<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    void initInterrupt(int fd0, int fd1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        outgoingInterruptFD = fd1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        incomingInterruptFD = fd0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        epollCtl(epfd, EPOLL_CTL_ADD, fd0, EPOLLIN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    void putEventOps(int i, int event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        int offset = SIZE_EPOLLEVENT * i + EVENT_OFFSET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        pollArray.putInt(offset, event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    void putDescriptor(int i, int fd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        int offset = SIZE_EPOLLEVENT * i + FD_OFFSET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        pollArray.putInt(offset, fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    int getEventOps(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        int offset = SIZE_EPOLLEVENT * i + EVENT_OFFSET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        return pollArray.getInt(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    int getDescriptor(int i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        int offset = SIZE_EPOLLEVENT * i + FD_OFFSET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        return pollArray.getInt(offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    /**
20176
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   169
     * Returns {@code true} if updates for the given key (file
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   170
     * descriptor) are killed.
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   171
     */
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   172
    private boolean isEventsHighKilled(Integer key) {
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   173
        assert key >= MAX_UPDATE_ARRAY_SIZE;
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   174
        Byte value = eventsHigh.get(key);
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   175
        return (value != null && value == KILLED);
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   176
    }
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   177
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   178
    /**
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   179
     * Sets the pending update events for the given file descriptor. This
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   180
     * method has no effect if the update events is already set to KILLED,
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   181
     * unless {@code force} is {@code true}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   183
    private void setUpdateEvents(int fd, byte events, boolean force) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   184
        if (fd < MAX_UPDATE_ARRAY_SIZE) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   185
            if ((eventsLow[fd] != KILLED) || force) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   186
                eventsLow[fd] = events;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   187
            }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   188
        } else {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   189
            Integer key = Integer.valueOf(fd);
20176
59b7a49e7f8b 8024883: (se) SelectableChannel.register throws NPE if fd >= 64k (lnx)
alanb
parents: 19607
diff changeset
   190
            if (!isEventsHighKilled(key) || force) {
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   191
                eventsHigh.put(key, Byte.valueOf(events));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            }
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   193
        }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   194
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   196
    /**
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   197
     * Returns the pending update events for the given file descriptor.
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   198
     */
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   199
    private byte getUpdateEvents(int fd) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   200
        if (fd < MAX_UPDATE_ARRAY_SIZE) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   201
            return eventsLow[fd];
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   202
        } else {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   203
            Byte result = eventsHigh.get(Integer.valueOf(fd));
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   204
            // result should never be null
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   205
            return result.byteValue();
2433
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   206
        }
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   207
    }
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   208
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   209
    /**
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   210
     * Update the events for a given file descriptor
2433
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   211
     */
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   212
    void setInterest(int fd, int mask) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   213
        synchronized (updateLock) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   214
            // record the file descriptor and events
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   215
            int oldCapacity = updateDescriptors.length;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   216
            if (updateCount == oldCapacity) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   217
                int newCapacity = oldCapacity + INITIAL_PENDING_UPDATE_SIZE;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   218
                int[] newDescriptors = new int[newCapacity];
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   219
                System.arraycopy(updateDescriptors, 0, newDescriptors, 0, oldCapacity);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   220
                updateDescriptors = newDescriptors;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   221
            }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   222
            updateDescriptors[updateCount++] = fd;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   223
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   224
            // events are stored as bytes for efficiency reasons
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   225
            byte b = (byte)mask;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   226
            assert (b == mask) && (b != KILLED);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   227
            setUpdateEvents(fd, b, false);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   232
     * Add a file descriptor
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   234
    void add(int fd) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   235
        // force the initial update events to 0 as it may be KILLED by a
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   236
        // previous registration.
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   237
        synchronized (updateLock) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   238
            assert !registered.get(fd);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   239
            setUpdateEvents(fd, (byte)0, true);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   240
        }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   241
    }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   242
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   243
    /**
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   244
     * Remove a file descriptor
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   245
     */
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   246
    void remove(int fd) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   247
        synchronized (updateLock) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   248
            // kill pending and future update for this file descriptor
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   249
            setUpdateEvents(fd, KILLED, false);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   250
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   251
            // remove from epoll
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   252
            if (registered.get(fd)) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   253
                epollCtl(epfd, EPOLL_CTL_DEL, fd, 0);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   254
                registered.clear(fd);
2433
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   255
            }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Close epoll file descriptor and free poll array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    void closeEPollFD() throws IOException {
2057
3acf8e5e2ca0 6781363: New I/O: Update socket-channel API to jsr203/nio2-b99
alanb
parents: 1247
diff changeset
   263
        FileDispatcherImpl.closeIntFD(epfd);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        pollArray.free();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    int poll(long timeout) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        updateRegistrations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        updated = epollWait(pollArrayAddress, NUM_EPOLLEVENTS, timeout, epfd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        for (int i=0; i<updated; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            if (getDescriptor(i) == incomingInterruptFD) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
                interruptedIndex = i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
                interrupted = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        return updated;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * Update the pending registrations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     */
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   283
    private void updateRegistrations() {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   284
        synchronized (updateLock) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   285
            int j = 0;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   286
            while (j < updateCount) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   287
                int fd = updateDescriptors[j];
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   288
                short events = getUpdateEvents(fd);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   289
                boolean isRegistered = registered.get(fd);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   290
                int opcode = 0;
2433
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   291
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   292
                if (events != KILLED) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   293
                    if (isRegistered) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   294
                        opcode = (events != 0) ? EPOLL_CTL_MOD : EPOLL_CTL_DEL;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   295
                    } else {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   296
                        opcode = (events != 0) ? EPOLL_CTL_ADD : 0;
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   297
                    }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   298
                    if (opcode != 0) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   299
                        epollCtl(epfd, opcode, fd, events);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   300
                        if (opcode == EPOLL_CTL_ADD) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   301
                            registered.set(fd);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   302
                        } else if (opcode == EPOLL_CTL_DEL) {
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   303
                            registered.clear(fd);
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   304
                        }
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   305
                    }
2433
9f0ab7f726b8 6693490: (se) select throws "File exists" IOException under load (lnx)
alanb
parents: 2057
diff changeset
   306
                }
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   307
                j++;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            }
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   309
            updateCount = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
    // interrupt support
16474
93db93a49848 8009751: (se) Selector spin when select, close and interestOps(0) invoked at same time (lnx)
alanb
parents: 14342
diff changeset
   314
    private boolean interrupted = false;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
    public void interrupt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        interrupt(outgoingInterruptFD);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public int interruptedIndex() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        return interruptedIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    boolean interrupted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        return interrupted;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    void clearInterrupted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        interrupted = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    static {
19607
bee007586d06 8022594: Potential deadlock in <clinit> of sun.nio.ch.Util/IOUtil
alanb
parents: 16474
diff changeset
   333
        IOUtil.load();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    private native int epollCreate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    private native void epollCtl(int epfd, int opcode, int fd, int events);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    private native int epollWait(long pollAddress, int numfds, long timeout,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                                 int epfd) throws IOException;
1142
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   341
    private static native int sizeofEPollEvent();
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   342
    private static native int offsetofData();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    private static native void interrupt(int fd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    private static native void init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
}