changeset 7406:8d0a1cb7b3b9

8048212: Two tests failed with "java.net.SocketException: Bad protocol option" on Windows after 8029607 Reviewed-by: alanb
author michaelm
date Mon, 07 Jul 2014 12:42:14 +0100
parents 75dceeafa4c8
children 6c199d604eef
files src/windows/native/java/net/net_util_md.c src/windows/native/sun/nio/ch/Net.c
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/native/java/net/net_util_md.c	Fri Aug 15 14:50:27 2014 +0100
+++ b/src/windows/native/java/net/net_util_md.c	Mon Jul 07 12:42:14 2014 +0100
@@ -443,6 +443,13 @@
 {
     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);
 
 
--- a/src/windows/native/sun/nio/ch/Net.c	Fri Aug 15 14:50:27 2014 +0100
+++ b/src/windows/native/sun/nio/ch/Net.c	Mon Jul 07 12:42:14 2014 +0100
@@ -294,9 +294,9 @@
     /**
      * 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;
     }
 
@@ -339,6 +339,11 @@
         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 {