8048212: Two tests failed with "java.net.SocketException: Bad protocol option" on Windows after 8029607

Reviewed-by: alanb
This commit is contained in:
Michael McMahon 2014-07-07 12:42:14 +01:00
parent f7d6809219
commit c5665a7027
2 changed files with 14 additions and 2 deletions

View File

@ -443,6 +443,13 @@ NET_GetSockOpt(int s, int level, int optname, void *optval,
{
int rv;
if (level == IPPROTO_IPV6 && optname == IPV6_TCLASS) {
int *intopt = (int *)optval;
*intopt = 0;
*optlen = sizeof(*intopt);
return 0;
}
rv = getsockopt(s, level, optname, optval, optlen);

View File

@ -295,9 +295,9 @@ Java_sun_nio_ch_Net_getIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
/**
* HACK: IP_TOS is deprecated on Windows and querying the option
* returns a protocol error. NET_GetSockOpt handles this and uses
* a fallback mechanism.
* a fallback mechanism. Same applies to IPV6_TCLASS
*/
if (level == IPPROTO_IP && opt == IP_TOS) {
if ((level == IPPROTO_IP && opt == IP_TOS) || (level == IPPROTO_IPV6 && opt == IPV6_TCLASS)) {
mayNeedConversion = JNI_TRUE;
}
@ -340,6 +340,11 @@ Java_sun_nio_ch_Net_setIntOption0(JNIEnv *env, jclass clazz, jobject fdo,
arglen = sizeof(arg);
}
if (level == IPPROTO_IPV6 && opt == IPV6_TCLASS) {
/* No op */
return;
}
if (mayNeedConversion) {
n = NET_SetSockOpt(fdval(env, fdo), level, opt, parg, arglen);
} else {