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]

[PATCH] [POSIX]: SocketTimeoutException for PlainDatagramSocketImpl + Minor Case Changes


Hi Michael,

This patch has PlainDatagramSocketImpl throw a
SocketTimeoutException instead of an InterruptedIOException
and has minor case changes for Plain[Datagram]SocketImpl
to make the output of the test attached to this post:

http://gcc.gnu.org/ml/java-patches/2003-q4/msg00736.html

...diff more cleanly between Sun JRE 1.4.1 on Linux and
i686-pc-linux-gnu-gcj.

It does <i>not</i> attempt to change the fact that
i686-pc-linux-gnu-gcj supports interruptible I/O
on Plain[Datagram]Sockets whereas Sun's JRE (on
both Linux and Win32) and i686-pc-mingw32-gcj
do not.

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/

ChangeLog
2003-12-11  Mohan Embar  <gnustuff@thisiscool.com>

	* gnu/java/net/natPlainDatagramSocketImplPosix.cc
	(peekData): Throw SocketTimeoutException instead of
	InterruptedIOException on timeout.
	(receive): Likewise.
	* gnu/java/net/natPlainSocketImplPosix.cc
	(connect): Made a minor exception text case change.
	(read): Likewise.

Index: gnu/java/net/natPlainDatagramSocketImplPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/natPlainDatagramSocketImplPosix.cc,v
retrieving revision 1.5
diff -u -2 -r1.5 natPlainDatagramSocketImplPosix.cc
--- gnu/java/net/natPlainDatagramSocketImplPosix.cc	4 Dec 2003 10:59:56 -0000	1.5
+++ gnu/java/net/natPlainDatagramSocketImplPosix.cc	12 Dec 2003 05:11:28 -0000
@@ -30,4 +30,5 @@
 #include <java/net/BindException.h>
 #include <java/net/SocketException.h>
+#include <java/net/SocketTimeoutException.h>
 #include <java/net/InetAddress.h>
 #include <java/net/NetworkInterface.h>
@@ -226,5 +227,6 @@
         goto error;
       else if (retval == 0)
-        throw new ::java::io::InterruptedIOException ();
+        throw new ::java::net::SocketTimeoutException
+          (JvNewStringUTF ("PeekData timed out") );
     }
 
@@ -346,5 +348,6 @@
         goto error;
       else if (retval == 0)
-        throw new ::java::io::InterruptedIOException ();
+        throw new ::java::net::SocketTimeoutException
+          (JvNewStringUTF ("Receive timed out") );
     }
 
Index: gnu/java/net/natPlainSocketImplPosix.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/java/net/natPlainSocketImplPosix.cc,v
retrieving revision 1.5
diff -u -2 -r1.5 natPlainSocketImplPosix.cc
--- gnu/java/net/natPlainSocketImplPosix.cc	1 Dec 2003 14:32:26 -0000	1.5
+++ gnu/java/net/natPlainSocketImplPosix.cc	12 Dec 2003 05:11:31 -0000
@@ -188,5 +188,5 @@
       else if (retval == 0)
         throw new ::java::net::SocketTimeoutException
-          (JvNewStringUTF ("Connect timed out"));
+          (JvNewStringUTF ("connect timed out"));
        // Set the socket back into a blocking state.
        ::fcntl (native_fd, F_SETFL, flags);
@@ -409,5 +409,5 @@
       if (sel_retval == 0)
         throw new ::java::net::SocketTimeoutException
-          (JvNewStringUTF ("read timed out") );
+          (JvNewStringUTF ("Read timed out") );
       // If select returns ok we know we either got signalled or read some data...
       // either way we need to try to read.
@@ -423,5 +423,5 @@
       ::java::io::InterruptedIOException *iioe =
         new ::java::io::InterruptedIOException
-        (JvNewStringUTF("read interrupted"));
+        (JvNewStringUTF("Read interrupted"));
       iioe->bytesTransferred = r == -1 ? 0 : r;
       throw iioe;
@@ -479,5 +479,5 @@
           ::java::net::SocketTimeoutException *timeoutException =
             new ::java::net::SocketTimeoutException
-            (JvNewStringUTF ("read timed out"));
+            (JvNewStringUTF ("Read timed out"));
 	  throw timeoutException;
         }
@@ -494,5 +494,5 @@
       ::java::io::InterruptedIOException *iioe =
         new ::java::io::InterruptedIOException
-        (JvNewStringUTF ("read interrupted"));
+        (JvNewStringUTF ("Read interrupted"));
       iioe->bytesTransferred = r == -1 ? 0 : r;
       throw iioe;




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