This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

natPlainSocketImplWin32 fix and natPlainSocketImplPosix adjustment


Hello list

If a remote host closes a socket connection, posix throws an IOException. Win32 doesn't do anything because WSAECONNRESET is set and this is ignored (it looks like it's the equivalent to the "Broken pipe" errno on posix).
The consequences are, that on win32 an application just continues sending data until all data is sent.


Another thing is, that sun jvms throw SocketException, not IOException. I adapted both files for that.

The copyright assignment isn't done yet, but I think we can discuss the patch anyway. I will repost it (as well as the security patch) as soon as the assignment stuff has taken place.

Comments, hints?


Marco
Index: gnu/java/net/natPlainSocketImplPosix.cc
===================================================================
--- gnu/java/net/natPlainSocketImplPosix.cc	(revision 117394)
+++ gnu/java/net/natPlainSocketImplPosix.cc	(working copy)
@@ -388,7 +388,7 @@
             }
           // Some errors should not cause exceptions.
           if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
-            throw new ::java::io::IOException (JvNewStringUTF (strerror (errno)));
+            throw new ::java::net::SocketException (JvNewStringUTF (strerror (errno)));
           break;
         }
 
Index: gnu/java/net/natPlainSocketImplWin32.cc
===================================================================
--- gnu/java/net/natPlainSocketImplWin32.cc	(revision 117394)
+++ gnu/java/net/natPlainSocketImplWin32.cc	(working copy)
@@ -379,10 +379,14 @@
           // operations on Win32 anyway.
           ::java::lang::Thread::interrupted();
 
-          // Some errors should not cause exceptions.
-          if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
-            && dwErr != WSAENOTSOCK)
-            _Jv_ThrowIOException ();
+          // Some errors should not cause exceptions;
+          // But we can't ignore "WSAECONNRESET" as the posix port does.
+          // It will be set when the remote host closes the connection
+          // (posix port gets "Broken pipe", win32 gets WSAECONNRESET)
+          if (dwErr != WSAENOTCONN && dwErr != WSAENOTSOCK)
+            // FIXME get the actual error (FormatMessage?)
+            throw new ::java::net::SocketException ();
+
           break;
         }
     }
@@ -411,10 +415,14 @@
           // Reset and ignore our thread's interrupted flag.
           ::java::lang::Thread::interrupted();
 
-          // Some errors should not cause exceptions.
-          if (dwErr != WSAENOTCONN && dwErr != WSAECONNRESET
-            && dwErr != WSAENOTSOCK)
-            _Jv_ThrowIOException ();
+          // Some errors should not cause exceptions;
+          // But we can't ignore "WSAECONNRESET" as the posix port does.
+          // It will be set when the remote host closes the connection
+          // (posix port gets "Broken pipe", win32 gets WSAECONNRESET)
+          if (dwErr != WSAENOTCONN && dwErr != WSAENOTSOCK)
+            // FIXME get the actual error (FormatMessage?)
+            throw new ::java::net::SocketException ();
+
           break;
         }
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]