提交 29a714c1 编写于 作者: C chegar

Merge

......@@ -143,7 +143,7 @@ typedef struct _SurfaceType {
* structure from the information present in a given Java Composite
* object.
*/
typedef JNIEXPORT void (JNICALL CompInfoFunc)(JNIEnv *env,
typedef void (JNICALL CompInfoFunc)(JNIEnv *env,
CompositeInfo *pCompInfo,
jobject Composite);
......
......@@ -94,12 +94,12 @@ typedef struct {
JNIEXPORT void JNICALL nptInitialize
(NptEnv **pnpt, char *nptVersion, char *options);
typedef JNIEXPORT void (JNICALL *NptInitialize)
typedef void (JNICALL *NptInitialize)
(NptEnv **pnpt, char *nptVersion, char *options);
JNIEXPORT void JNICALL nptTerminate
(NptEnv* npt, char *options);
typedef JNIEXPORT void (JNICALL *NptTerminate)
typedef void (JNICALL *NptTerminate)
(NptEnv* npt, char *options);
#ifdef __cplusplus
......
......@@ -26,8 +26,17 @@
#ifndef _JAVASOFT_JNI_MD_H_
#define _JAVASOFT_JNI_MD_H_
#define JNIEXPORT
#define JNIIMPORT
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility)
#define JNIEXPORT __attribute__((visibility("default")))
#define JNIIMPORT __attribute__((visibility("default")))
#else
#define JNIEXPORT
#define JNIIMPORT
#endif
#define JNICALL
typedef int jint;
......
......@@ -43,7 +43,7 @@
static void *awtHandle = NULL;
typedef JNIEXPORT jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
typedef jint JNICALL JNI_OnLoad_type(JavaVM *vm, void *reserved);
/* Initialize the Java VM instance variable when the library is
first loaded */
......@@ -206,7 +206,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
jobject frame, jstring jcommand)
{
/* type of the old backdoor function */
typedef JNIEXPORT void JNICALL
typedef void JNICALL
XsessionWMcommand_type(JNIEnv *env, jobject this,
jobject frame, jstring jcommand);
......@@ -234,7 +234,7 @@ Java_sun_awt_motif_XsessionWMcommand(JNIEnv *env, jobject this,
JNIEXPORT void JNICALL
Java_sun_awt_motif_XsessionWMcommand_New(JNIEnv *env, jobjectArray jargv)
{
typedef JNIEXPORT void JNICALL
typedef void JNICALL
XsessionWMcommand_New_type(JNIEnv *env, jobjectArray jargv);
static XsessionWMcommand_New_type *XsessionWMcommand = NULL;
......
......@@ -152,8 +152,9 @@ class DualStackPlainSocketImpl extends AbstractPlainSocketImpl
if (!fd.valid())
return;
close0(fdAccess.get(fd));
final int nativefd = fdAccess.get(fd);
fdAccess.set(fd, -1);
close0(nativefd);
}
void socketShutdown(int howto) throws IOException {
......
......@@ -134,9 +134,11 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
(*env)->SetByteArrayRegion(env, data, off, nread, (jbyte *)bufP);
} else {
if (nread < 0) {
/*
* Recv failed.
*/
// Check if the socket has been closed since we last checked.
// This could be a reason for recv failing.
if ((*env)->GetIntField(env, fdObj, IO_fd_fdID) == -1) {
NET_ThrowSocketException(env, "Socket closed");
} else {
switch (WSAGetLastError()) {
case WSAEINTR:
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
......@@ -163,6 +165,7 @@ Java_java_net_SocketInputStream_socketRead0(JNIEnv *env, jobject this,
}
}
}
}
if (bufP != BUF) {
free(bufP);
}
......
......@@ -23,8 +23,8 @@
/*
* @test
* @bug 8006395
* @summary Race in async socket close on Linux
* @bug 8006395 8012244
* @summary Tests racing code that reads and closes a Socket
*/
import java.io.InputStream;
......@@ -58,7 +58,7 @@ public class Race {
Thread.sleep(50);
} catch (Exception x) {
if (!(x instanceof SocketException
&& x.getMessage().equals("Socket closed")))
&& x.getMessage().equalsIgnoreCase("socket closed")))
x.printStackTrace();
// ok, expect Socket closed
}
......
......@@ -486,40 +486,61 @@ public class Basic {
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 1 || x == 2); return x; });
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; });
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); return x; }, executor);
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 2);
cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
check(cf1.isDone() || cf2.isDone());
try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
try { check(cf3.join() == 2); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; });
check(cf1.isDone() || cf2.isDone());
try { check(cf3.join() == 1); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
cf3 = cf1.applyToEitherAsync(cf2, (x) -> { fail(); return x; });
check(cf1.isDone() || cf2.isDone());
checkCompletedExceptionally(cf3);
check(cf1.isDone() || cf2.isDone());
final Phaser cf3Done = new Phaser(2);
cf1 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 1; });
cf2 = supplyAsync(() -> 2);
cf3 = cf1.applyToEither(cf2, (x) -> { check(x == 2); return x; });
checkCompletedNormally(cf3, 2);
checkCompletedNormally(cf2, 2);
check(!cf1.isDone());
cf3Done.arrive();
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf3, 2);
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 2; });
cf3 = cf1.applyToEitherAsync(cf2, (x) -> { check(x == 1); return x; });
checkCompletedNormally(cf3, 1);
checkCompletedNormally(cf1, 1);
check(!cf2.isDone());
cf3Done.arrive();
checkCompletedNormally(cf2, 2);
checkCompletedNormally(cf3, 1);
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
......@@ -531,45 +552,66 @@ public class Basic {
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); });
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> 2);
cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1 || x == 2); atomicInt.incrementAndGet(); }, executor);
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> 2);
cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 2); }, executor);
check(cf1.isDone() || cf2.isDone());
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
cf3 = cf2.acceptEitherAsync(cf1, (x) -> { check(x == 1); });
check(cf1.isDone() || cf2.isDone());
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
cf1 = supplyAsync(() -> { throw new RuntimeException(); });
cf2 = supplyAsync(() -> { throw new RuntimeException(); });
cf3 = cf2.acceptEitherAsync(cf1, (x) -> { fail(); });
check(cf1.isDone() || cf2.isDone());
checkCompletedExceptionally(cf3);
check(cf1.isDone() || cf2.isDone());
final Phaser cf3Done = new Phaser(2);
cf1 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 1; });
cf2 = supplyAsync(() -> 2);
cf3 = cf1.acceptEither(cf2, (x) -> { check(x == 2); });
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf2, 2);
check(!cf1.isDone());
cf3Done.arrive();
checkCompletedNormally(cf1, 1);
checkCompletedNormally(cf3, null);
cf1 = supplyAsync(() -> 1);
cf2 = supplyAsync(() -> { cf3Done.arriveAndAwaitAdvance(); return 2; });
cf3 = cf1.acceptEitherAsync(cf2, (x) -> { check(x == 1); });
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf1, 1);
check(!cf2.isDone());
cf3Done.arrive();
checkCompletedNormally(cf2, 2);
checkCompletedNormally(cf3, null);
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
......@@ -581,51 +623,80 @@ public class Basic {
CompletableFuture<Void> cf1 = runAsync(() -> { });
CompletableFuture<Void> cf2 = runAsync(() -> { });
cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); });
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = runAsync(() -> { });
cf2 = runAsync(() -> { });
cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = runAsync(() -> { });
cf2 = runAsync(() -> { });
cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
check(cf1.isDone() || cf2.isDone());
checkCompletedNormally(cf3, null);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == (before + 1));
before = atomicInt.get();
cf1 = runAsync(() -> { throw new RuntimeException(); });
cf2 = runAsync(() -> { });
cf3 = cf2.runAfterEither(cf1, () -> { atomicInt.incrementAndGet(); });
check(cf1.isDone() || cf2.isDone());
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
try {
check(cf3.join() == null);
check(atomicInt.get() == (before + 1));
} catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
before = atomicInt.get();
cf1 = runAsync(() -> { });
cf2 = runAsync(() -> { throw new RuntimeException(); });
cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
check(cf1.isDone() || cf2.isDone());
try { check(cf3.join() == null); } catch (CompletionException x) { pass(); }
check(cf3.isDone());
try {
check(cf3.join() == null);
check(atomicInt.get() == (before + 1));
} catch (CompletionException x) { pass(); }
check(cf3.isDone());
check(cf1.isDone() || cf2.isDone());
before = atomicInt.get();
cf1 = runAsync(() -> { throw new RuntimeException(); });
cf2 = runAsync(() -> { throw new RuntimeException(); });
cf3 = cf2.runAfterEitherAsync(cf1, () -> { atomicInt.incrementAndGet(); }, executor);
check(cf1.isDone() || cf2.isDone());
checkCompletedExceptionally(cf3);
check(cf1.isDone() || cf2.isDone());
check(atomicInt.get() == before);
final Phaser cf3Done = new Phaser(2);
before = atomicInt.get();
cf1 = runAsync(() -> { cf3Done.arriveAndAwaitAdvance(); });
cf2 = runAsync(() -> { });
cf3 = cf1.runAfterEither(cf2, () -> { atomicInt.incrementAndGet(); });
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf2, null);
check(!cf1.isDone());
check(atomicInt.get() == (before + 1));
cf3Done.arrive();
checkCompletedNormally(cf1, null);
checkCompletedNormally(cf3, null);
before = atomicInt.get();
cf1 = runAsync(() -> { });
cf2 = runAsync(() -> { cf3Done.arriveAndAwaitAdvance(); });
cf3 = cf1.runAfterEitherAsync(cf2, () -> { atomicInt.incrementAndGet(); });
checkCompletedNormally(cf3, null);
checkCompletedNormally(cf1, null);
check(!cf2.isDone());
check(atomicInt.get() == (before + 1));
cf3Done.arrive();
checkCompletedNormally(cf2, null);
checkCompletedNormally(cf3, null);
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
......@@ -670,16 +741,16 @@ public class Basic {
//----------------------------------------------------------------
// anyOf tests
//----------------------------------------------------------------
//try {
// CompletableFuture<Object> cf3;
// for (int k=0; k < 10; k++){
// CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
// CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
// cf3 = CompletableFuture.anyOf(cf1, cf2);
// check(cf1.isDone() || cf2.isDone());
// checkCompletedNormally(cf3, new Object[] {1, 2});
// }
//} catch (Throwable t) { unexpected(t); }
try {
CompletableFuture<Object> cf3;
for (int k=0; k < 10; k++){
CompletableFuture<Integer> cf1 = supplyAsync(() -> 1);
CompletableFuture<Integer> cf2 = supplyAsync(() -> 2);
cf3 = CompletableFuture.anyOf(cf1, cf2);
checkCompletedNormally(cf3, new Object[] {1, 2});
check(cf1.isDone() || cf2.isDone());
}
} catch (Throwable t) { unexpected(t); }
//----------------------------------------------------------------
// allOf tests
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册