mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 02:54:35 +02:00
8221252: (sc) SocketChannel and its socket adaptor need to handle connection reset
Reviewed-by: bpb
This commit is contained in:
parent
cc590f5765
commit
3a4d5db248
13 changed files with 507 additions and 88 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2019, 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
|
||||
|
@ -465,7 +465,7 @@ public class SctpChannelImpl extends SctpChannel
|
|||
if (state != ChannelState.PENDING)
|
||||
throw new NoConnectionPendingException();
|
||||
}
|
||||
int n = 0;
|
||||
boolean connected = false;
|
||||
try {
|
||||
try {
|
||||
begin();
|
||||
|
@ -477,26 +477,11 @@ public class SctpChannelImpl extends SctpChannel
|
|||
receiverThread = NativeThread.current();
|
||||
}
|
||||
if (!isBlocking()) {
|
||||
for (;;) {
|
||||
n = Net.pollConnect(fd, 0);
|
||||
if ( (n == IOStatus.INTERRUPTED)
|
||||
&& isOpen())
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
connected = Net.pollConnect(fd, 0);
|
||||
} else {
|
||||
for (;;) {
|
||||
n = Net.pollConnect(fd, -1);
|
||||
if (n == 0) {
|
||||
// Loop in case of
|
||||
// spurious notifications
|
||||
continue;
|
||||
}
|
||||
if ( (n == IOStatus.INTERRUPTED)
|
||||
&& isOpen())
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
do {
|
||||
connected = Net.pollConnect(fd, -1);
|
||||
} while (!connected && isOpen());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
|
@ -504,16 +489,10 @@ public class SctpChannelImpl extends SctpChannel
|
|||
receiverThread = 0;
|
||||
if (state == ChannelState.KILLPENDING) {
|
||||
kill();
|
||||
/* poll()/getsockopt() does not report
|
||||
* error (throws exception, with n = 0)
|
||||
* on Linux platform after dup2 and
|
||||
* signal-wakeup. Force n to 0 so the
|
||||
* end() can throw appropriate exception */
|
||||
n = 0;
|
||||
connected = false;
|
||||
}
|
||||
}
|
||||
end((n > 0) || (n == IOStatus.UNAVAILABLE));
|
||||
assert IOStatus.check(n);
|
||||
end(connected);
|
||||
}
|
||||
} catch (IOException x) {
|
||||
/* If an exception was thrown, close the channel after
|
||||
|
@ -523,7 +502,7 @@ public class SctpChannelImpl extends SctpChannel
|
|||
throw x;
|
||||
}
|
||||
|
||||
if (n > 0) {
|
||||
if (connected) {
|
||||
synchronized (stateLock) {
|
||||
state = ChannelState.CONNECTED;
|
||||
if (!isBound()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue