author | chegar |
Thu, 21 Nov 2019 12:14:29 +0000 | |
changeset 59205 | afcc8af048e6 |
parent 54154 | 1caf2daef7cf |
permissions | -rw-r--r-- |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
1 |
/* |
54086
ccb4a50bee06
8220083: Use InetAddress.getLoopbackAddress() in place of 127.0.0.1 for some tests
aeubanks
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
4 |
* |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
8 |
* |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
13 |
* accompanied this code). |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
14 |
* |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
18 |
* |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
21 |
* questions. |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
22 |
*/ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
23 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
24 |
/* @test |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
25 |
* @bug 8067846 |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
26 |
* @summary Test for send failed notification |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
27 |
*/ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
28 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
29 |
import com.sun.nio.sctp.*; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
30 |
import java.io.IOException; |
54154
1caf2daef7cf
8220738: (sc) Move ServerSocketChannelImpl remaining native method to Net
alanb
parents:
54086
diff
changeset
|
31 |
import java.net.InetAddress; |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
32 |
import java.net.InetSocketAddress; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
33 |
import java.net.SocketAddress; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
34 |
import java.nio.ByteBuffer; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
35 |
import static java.lang.System.out; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
36 |
import static java.nio.ByteBuffer.*; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
37 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
38 |
public class SendFailed { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
39 |
|
54086
ccb4a50bee06
8220083: Use InetAddress.getLoopbackAddress() in place of 127.0.0.1 for some tests
aeubanks
parents:
47216
diff
changeset
|
40 |
static final SocketAddress remoteAddress = new InetSocketAddress(InetAddress.getLoopbackAddress(), 3000); |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
41 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
42 |
static final int[] bufferSizes = |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
43 |
{ 20, 49, 50, 51, 100, 101, 1024, 1025, 4095, 4096, 4097, 8191, 8192, 8193}; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
44 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
45 |
void test(String[] args) throws IOException { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
46 |
SocketAddress address = null; |
29592
66b56dc305f5
8075039: (sctp) com/sun/nio/sctp/SctpMultiChannel/SendFailed.java fails on Solaris only
robm
parents:
28970
diff
changeset
|
47 |
String os = System.getProperty("os.name").toLowerCase(); |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
48 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
49 |
if (!Util.isSCTPSupported()) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
50 |
out.println("SCTP protocol is not supported"); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
51 |
out.println("Test cannot be run"); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
52 |
return; |
29592
66b56dc305f5
8075039: (sctp) com/sun/nio/sctp/SctpMultiChannel/SendFailed.java fails on Solaris only
robm
parents:
28970
diff
changeset
|
53 |
} else if (os.startsWith("sunos")) { |
66b56dc305f5
8075039: (sctp) com/sun/nio/sctp/SctpMultiChannel/SendFailed.java fails on Solaris only
robm
parents:
28970
diff
changeset
|
54 |
out.println("Test not supported on Solaris"); |
66b56dc305f5
8075039: (sctp) com/sun/nio/sctp/SctpMultiChannel/SendFailed.java fails on Solaris only
robm
parents:
28970
diff
changeset
|
55 |
out.println("Test cannot be run"); |
66b56dc305f5
8075039: (sctp) com/sun/nio/sctp/SctpMultiChannel/SendFailed.java fails on Solaris only
robm
parents:
28970
diff
changeset
|
56 |
return; |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
57 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
58 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
59 |
System.out.println("remote address: " + remoteAddress); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
60 |
System.out.println("Note, remote address should not be up"); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
61 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
62 |
/* combinations with various buffer sizes, and offsets */ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
63 |
for (int send=0; send < bufferSizes.length; send++) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
64 |
for (int recv=0; recv < bufferSizes.length; recv++) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
65 |
for (boolean direct : new boolean[] {true, false}) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
66 |
runWithManyOffsets(bufferSizes[send], bufferSizes[recv], direct); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
67 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
68 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
69 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
70 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
71 |
void runWithManyOffsets(int sendBufferSize, int recvBufferSize, boolean direct) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
72 |
throws IOException |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
73 |
{ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
74 |
doTest(sendBufferSize, recvBufferSize, direct, 0); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
75 |
doTest(sendBufferSize, recvBufferSize, direct, 1); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
76 |
doTest(sendBufferSize, recvBufferSize, direct, 3); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
77 |
doTest(sendBufferSize, recvBufferSize, direct, 7); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
78 |
doTest(sendBufferSize, recvBufferSize, direct, 9); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
79 |
doTest(sendBufferSize, recvBufferSize, direct, 13); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
80 |
doTest(sendBufferSize, recvBufferSize, direct, 15); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
81 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
82 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
83 |
void doTest(int sendBufferSize, int recvBufferSize, boolean direct, int offset) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
84 |
throws IOException |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
85 |
{ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
86 |
debug("%n--- Testing with send size:[%d], recv size:[%d], offset:[%d] " |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
87 |
+ ", direct [%s]. ", sendBufferSize, recvBufferSize, offset, direct); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
88 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
89 |
try (SctpMultiChannel channel = SctpMultiChannel.open()) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
90 |
MessageInfo messageInfo = MessageInfo.createOutgoing(remoteAddress, 0); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
91 |
ByteBuffer sendBuffer = filledBuffer(sendBufferSize, direct); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
92 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
93 |
debug("%nAttempting to send to %s. ", remoteAddress); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
94 |
int sent = channel.send(sendBuffer, messageInfo); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
95 |
sendBuffer.flip(); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
96 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
97 |
SendFailedNotificationHandler handler = |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
98 |
new SendFailedNotificationHandler(); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
99 |
ByteBuffer recvBuffer = direct ? allocateDirect(recvBufferSize) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
100 |
: allocate((recvBufferSize)); |
59205
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
101 |
MessageInfo info = channel.receive(recvBuffer, null, handler); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
102 |
debug("receive returned info:" + info); |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
103 |
|
59205
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
104 |
if (handler.receivedSendFailed) { |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
105 |
// verify sent buffer received by send failed notification |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
106 |
ByteBuffer buffer = handler.getSendFailedByteBuffer(); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
107 |
check(buffer.remaining() == sent); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
108 |
check(buffer.position() == 0); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
109 |
check(buffer.limit() == sent); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
110 |
assertSameContent(sendBuffer, handler.getSendFailedByteBuffer()); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
111 |
} else { |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
112 |
debug("Unexpected event or received data. Check output."); |
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
113 |
} |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
114 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
115 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
116 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
117 |
class SendFailedNotificationHandler extends AbstractNotificationHandler<Object> |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
118 |
{ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
119 |
/** Reference to the buffer captured in send failed notification */ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
120 |
private ByteBuffer sentBuffer; |
59205
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
121 |
boolean receivedSendFailed; |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
122 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
123 |
@Override |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
124 |
public HandlerResult handleNotification( |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
125 |
Notification notification, Object attachment) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
126 |
fail("Unknown notification type"); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
127 |
return HandlerResult.CONTINUE; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
128 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
129 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
130 |
@Override |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
131 |
public HandlerResult handleNotification( |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
132 |
AssociationChangeNotification notification, Object attachment) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
133 |
AssociationChangeNotification.AssocChangeEvent event = notification.event(); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
134 |
debug("%nAssociationChangeNotification"); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
135 |
debug("%n Association: %s. ", notification.association()); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
136 |
debug("%n Event: %s. ", event); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
137 |
return HandlerResult.CONTINUE; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
138 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
139 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
140 |
@Override |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
141 |
public HandlerResult handleNotification( |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
142 |
SendFailedNotification notification, Object attachment) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
143 |
debug("%nSendFailedNotification: %s. ", notification); |
59205
afcc8af048e6
8233847: (sctp) Flx link-local IPv6 scope handling and test cleanup
chegar
parents:
54154
diff
changeset
|
144 |
receivedSendFailed = true; |
28970
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
145 |
sentBuffer = notification.buffer(); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
146 |
return HandlerResult.RETURN; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
147 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
148 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
149 |
public ByteBuffer getSendFailedByteBuffer() { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
150 |
return sentBuffer; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
151 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
152 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
153 |
@Override |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
154 |
public HandlerResult handleNotification( |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
155 |
PeerAddressChangeNotification pacn, Object attachment) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
156 |
{ |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
157 |
debug("%nPeerAddressChangeNotification: %s", pacn); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
158 |
return HandlerResult.CONTINUE; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
159 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
160 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
161 |
@Override |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
162 |
public HandlerResult handleNotification( |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
163 |
ShutdownNotification notification, Object attachment) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
164 |
debug("%nShutdownNotification"); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
165 |
debug("%n Association: %s. ", notification.association()); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
166 |
return HandlerResult.CONTINUE; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
167 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
168 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
169 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
170 |
static ByteBuffer filledBuffer(int size, boolean direct) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
171 |
ByteBuffer buffer = direct ? allocateDirect(size) : allocate((size)); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
172 |
for (int i=0; i< size; i++) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
173 |
buffer.put((byte)i); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
174 |
buffer.flip(); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
175 |
return buffer; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
176 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
177 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
178 |
static void assertSameContent(ByteBuffer bb1, ByteBuffer bb2) { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
179 |
if (!bb1.equals(bb2)) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
180 |
throw new RuntimeException("Buffers are not equal; bb1: " + bb1 + ", bb2: " + bb2); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
181 |
} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
182 |
|
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
183 |
//--------------------- Infrastructure --------------------------- |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
184 |
boolean debug = true; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
185 |
volatile int passed = 0, failed = 0; |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
186 |
void pass() {passed++;} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
187 |
void fail() {failed++; Thread.dumpStack();} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
188 |
void fail(String msg) {System.err.println(msg); fail();} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
189 |
void unexpected(Throwable t) {failed++; t.printStackTrace();} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
190 |
void check(boolean cond) {if (cond) pass(); else fail();} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
191 |
void check(boolean cond, String failMessage) {if (cond) pass(); else fail(failMessage);} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
192 |
void debug(String message, Object... args) {if(debug) { out.printf(message, args); } } |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
193 |
public static void main(String[] args) throws Throwable { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
194 |
Class<?> k = new Object(){}.getClass().getEnclosingClass(); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
195 |
try {k.getMethod("instanceMain",String[].class) |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
196 |
.invoke( k.newInstance(), (Object) args);} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
197 |
catch (Throwable e) {throw e.getCause();}} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
198 |
public void instanceMain(String[] args) throws Throwable { |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
199 |
try {test(args);} catch (Throwable t) {unexpected(t);} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
200 |
out.printf("%nPassed = %d, failed = %d%n%n", passed, failed); |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
201 |
if (failed > 0) throw new AssertionError("Some tests failed");} |
aaec841a1a3c
8067846: (sctp) InternalError when receiving SendFailedNotification
robm
parents:
diff
changeset
|
202 |
} |