mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-21 11:34:38 +02:00
8196787: (ch) Moving network channels to use j.u.c locks
Reviewed-by: prappo, rriggs
This commit is contained in:
parent
6ff900807d
commit
8deac7d09b
10 changed files with 270 additions and 126 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -47,8 +47,7 @@
|
|||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv *env, jobject this,
|
||||
jobject fdo, jboolean block,
|
||||
jboolean ready)
|
||||
jobject fdo, jboolean block)
|
||||
{
|
||||
int error = 0;
|
||||
socklen_t n = sizeof(int);
|
||||
|
@ -56,19 +55,16 @@ Java_sun_nio_ch_SocketChannelImpl_checkConnect(JNIEnv *env, jobject this,
|
|||
int result = 0;
|
||||
struct pollfd poller;
|
||||
|
||||
poller.revents = 1;
|
||||
if (!ready) {
|
||||
poller.fd = fd;
|
||||
poller.events = POLLOUT;
|
||||
poller.revents = 0;
|
||||
result = poll(&poller, 1, block ? -1 : 0);
|
||||
if (result < 0) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "Poll failed");
|
||||
return IOS_THROWN;
|
||||
}
|
||||
if (!block && (result == 0))
|
||||
return IOS_UNAVAILABLE;
|
||||
poller.fd = fd;
|
||||
poller.events = POLLOUT;
|
||||
poller.revents = 0;
|
||||
result = poll(&poller, 1, block ? -1 : 0);
|
||||
if (result < 0) {
|
||||
JNU_ThrowIOExceptionWithLastError(env, "Poll failed");
|
||||
return IOS_THROWN;
|
||||
}
|
||||
if (!block && (result == 0))
|
||||
return IOS_UNAVAILABLE;
|
||||
|
||||
if (poller.revents) {
|
||||
errno = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue