提交 322f2f3f 编写于 作者: C chegar

6917317: (sctp) Remove dependency on handleSocketError

Reviewed-by: alanb
上级 f5baa833
...@@ -110,6 +110,38 @@ jboolean loadSocketExtensionFuncs ...@@ -110,6 +110,38 @@ jboolean loadSocketExtensionFuncs
return JNI_TRUE; return JNI_TRUE;
} }
jint
handleSocketError(JNIEnv *env, jint errorValue)
{
char *xn;
switch (errorValue) {
case EINPROGRESS: /* Non-blocking connect */
return 0;
case EPROTO:
xn= JNU_JAVANETPKG "ProtocolException";
break;
case ECONNREFUSED:
xn = JNU_JAVANETPKG "ConnectException";
break;
case ETIMEDOUT:
xn = JNU_JAVANETPKG "ConnectException";
break;
case EHOSTUNREACH:
xn = JNU_JAVANETPKG "NoRouteToHostException";
break;
case EADDRINUSE: /* Fall through */
case EADDRNOTAVAIL:
xn = JNU_JAVANETPKG "BindException";
break;
default:
xn = JNU_JAVANETPKG "SocketException";
break;
}
errno = errorValue;
JNU_ThrowByNameWithLastError(env, xn, "NioSocketError");
return IOS_THROWN;
}
/* /*
* Class: sun_nio_ch_SctpNet * Class: sun_nio_ch_SctpNet
* Method: init * Method: init
......
...@@ -192,6 +192,18 @@ public class Connect { ...@@ -192,6 +192,18 @@ public class Connect {
testCCE(new Callable<Void>() { testCCE(new Callable<Void>() {
public Void call() throws IOException { public Void call() throws IOException {
cceChannel.finishConnect(); return null; } }); cceChannel.finishConnect(); return null; } });
/* TEST 8: IOException: Connection refused. Exercises handleSocketError.
* Assumption: no sctp socket listening on 3456 */
SocketAddress addr = new InetSocketAddress("localhost", 3456);
channel = SctpChannel.open();
try {
channel.connect(addr);
fail("should have thrown ConnectException: Connection refused");
} catch (IOException ioe) {
pass();
}
} catch (IOException ioe) { } catch (IOException ioe) {
unexpected(ioe); unexpected(ioe);
} finally { } finally {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册