jdk/src/solaris/native/sun/nio/ch/EPollArrayWrapper.c
author alanb
Tue, 26 Aug 2008 09:23:12 +0100
changeset 1142 e01e390f6551
parent 2 90ce3da70b43
child 1247 b4c26443dee5
permissions -rw-r--r--
6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64 Reviewed-by: sherman
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2005-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "jni_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "jvm.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "jlong.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "sun_nio_ch_EPollArrayWrapper.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include <dlfcn.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include <unistd.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include <sys/resource.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include <sys/time.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#ifdef  __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/* epoll_wait(2) man page */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
typedef union epoll_data {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    void *ptr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    int fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    __uint32_t u32;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    __uint64_t u64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
} epoll_data_t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
1142
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    51
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    52
/* x86-64 has same alignment as 32-bit */
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    53
#ifdef __x86_64__
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    54
#define EPOLL_PACKED __attribute__((packed))
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    55
#else
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    56
#define EPOLL_PACKED
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    57
#endif
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    58
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
struct epoll_event {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    __uint32_t events;  /* Epoll events */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    epoll_data_t data;  /* User data variable */
1142
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
    62
} EPOLL_PACKED;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
#ifdef  __cplusplus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
#define RESTARTABLE(_cmd, _result) do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
  do { \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    _result = _cmd; \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
  } while((_result == -1) && (errno == EINTR)); \
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
} while(0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * epoll event notification is new in 2.6 kernel. As the offical build
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * platform for the JDK is on a 2.4-based distribution then we must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * obtain the addresses of the epoll functions dynamically.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
typedef int (*epoll_create_t)(int size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
typedef int (*epoll_ctl_t)   (int epfd, int op, int fd, struct epoll_event *event);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
typedef int (*epoll_wait_t)  (int epfd, struct epoll_event *events, int maxevents, int timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
static epoll_create_t epoll_create_func;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
static epoll_ctl_t    epoll_ctl_func;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
static epoll_wait_t   epoll_wait_func;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
static int
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
iepoll(int epfd, struct epoll_event *events, int numfds, jlong timeout)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    jlong start, now;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    int remaining = timeout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    struct timeval t;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    int diff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    gettimeofday(&t, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    start = t.tv_sec * 1000 + t.tv_usec / 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    for (;;) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        int res = (*epoll_wait_func)(epfd, events, numfds, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        if (res < 0 && errno == EINTR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            if (remaining >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                gettimeofday(&t, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                now = t.tv_sec * 1000 + t.tv_usec / 1000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                diff = now - start;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                remaining -= diff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                if (diff < 0 || remaining <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
                    return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
                start = now;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
Java_sun_nio_ch_EPollArrayWrapper_init(JNIEnv *env, jclass this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    epoll_create_func = (epoll_create_t) dlsym(RTLD_DEFAULT, "epoll_create");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    epoll_ctl_func    = (epoll_ctl_t)    dlsym(RTLD_DEFAULT, "epoll_ctl");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    epoll_wait_func   = (epoll_wait_t)   dlsym(RTLD_DEFAULT, "epoll_wait");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    if ((epoll_create_func == NULL) || (epoll_ctl_func == NULL) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        (epoll_wait_func == NULL)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        JNU_ThrowInternalError(env, "unable to get address of epoll functions, pre-2.6 kernel?");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
Java_sun_nio_ch_EPollArrayWrapper_epollCreate(JNIEnv *env, jobject this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * epoll_create expects a size as a hint to the kernel about how to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * dimension internal structures. We can't predict the size in advance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    int epfd = (*epoll_create_func)(256);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    if (epfd < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
       JNU_ThrowIOExceptionWithLastError(env, "epoll_create failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    return epfd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
Java_sun_nio_ch_EPollArrayWrapper_fdLimit(JNIEnv *env, jclass this)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    struct rlimit rlp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    if (getrlimit(RLIMIT_NOFILE, &rlp) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        JNU_ThrowIOExceptionWithLastError(env, "getrlimit failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    return (jint)rlp.rlim_max;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
1142
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   154
JNIEXPORT jint JNICALL
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   155
Java_sun_nio_ch_EPollArrayWrapper_sizeofEPollEvent(JNIEnv* env, jclass this)
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   156
{
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   157
    return sizeof(struct epoll_event);
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   158
}
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   159
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   160
JNIEXPORT jint JNICALL
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   161
Java_sun_nio_ch_EPollArrayWrapper_offsetofData(JNIEnv* env, jclass this)
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   162
{
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   163
    return offsetof(struct epoll_event, data);
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   164
}
e01e390f6551 6728542: (se) epoll based SelectorProvider should be portable to platforms other than x86 and x64
alanb
parents: 2
diff changeset
   165
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
Java_sun_nio_ch_EPollArrayWrapper_epollCtl(JNIEnv *env, jobject this, jint epfd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                           jint opcode, jint fd, jint events)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    struct epoll_event event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    int res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    event.events = events;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    event.data.fd = fd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    RESTARTABLE((*epoll_ctl_func)(epfd, (int)opcode, (int)fd, &event), res);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * A channel may be registered with several Selectors. When each Selector
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * is polled a EPOLL_CTL_DEL op will be inserted into its pending update
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * list to remove the file descriptor from epoll. The "last" Selector will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * close the file descriptor which automatically unregisters it from each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * epoll descriptor. To avoid costly synchronization between Selectors we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * allow pending updates to be processed, ignoring errors. The errors are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * harmless as the last update for the file descriptor is guaranteed to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * be EPOLL_CTL_DEL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    if (res < 0 && errno != EBADF && errno != ENOENT && errno != EPERM) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        JNU_ThrowIOExceptionWithLastError(env, "epoll_ctl failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
Java_sun_nio_ch_EPollArrayWrapper_epollWait(JNIEnv *env, jobject this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                                            jlong address, jint numfds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
                                            jlong timeout, jint epfd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    struct epoll_event *events = jlong_to_ptr(address);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    int res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    if (timeout <= 0) {           /* Indefinite or no wait */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        RESTARTABLE((*epoll_wait_func)(epfd, events, numfds, timeout), res);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    } else {                      /* Bounded wait; bounded restarts */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        res = iepoll(epfd, events, numfds, timeout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    if (res < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        JNU_ThrowIOExceptionWithLastError(env, "epoll_wait failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
Java_sun_nio_ch_EPollArrayWrapper_interrupt(JNIEnv *env, jobject this, jint fd)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    int fakebuf[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    fakebuf[0] = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    if (write(fd, fakebuf, 1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        JNU_ThrowIOExceptionWithLastError(env,"write to interrupt fd failed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
}