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]

Socket regressions


I've had some trouble testing our application on the 3.1 branch
(with i686-pc-linux-gnu):

1) write() sometimes hangs in an infinite loop.  It appears that we don't
handle an error return from the system call properly.  Moreover we ignore
certain important errors like EBADF (why?).

2) SIGPIPE randomly occurs while running in gdb, even though we ignore
this signal.

3) available() tends to return 1 for sockets even when there's nothing to
be read.  Is it important to also check FD_ISSET on the read descriptor?
Or can we trust the return value of select()?

Below is a patch for 1).  I'm unsure whether 2) is a real problem, but 3)
seems to break existing code like Apache JServ (the code could be more
robust, but it is widely used nonetheless).

2002-03-18  Jeff Sturm  <jsturm@one-point.com>

	* java/nat/natPlainSocketImpl.cc (write): Abort loop on error.

Index: natPlainSocketImpl.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/natPlainSocketImpl.cc,v
retrieving revision 1.30.2.6
diff -u -p -r1.30.2.6 natPlainSocketImpl.cc
--- natPlainSocketImpl.cc	2002/03/11 03:43:56	1.30.2.6
+++ natPlainSocketImpl.cc	2002/03/19 04:28:32
@@ -450,6 +450,7 @@ java::net::PlainSocketImpl::write(jint b
 	  // Some errors should not cause exceptions.
 	  if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
 	    throw new java::io::IOException (JvNewStringUTF (strerror (errno)));
+	  break;
 	}
     }
 }
@@ -481,6 +482,7 @@ java::net::PlainSocketImpl::write(jbyteA
 	  // Some errors should not cause exceptions.
 	  if (errno != ENOTCONN && errno != ECONNRESET && errno != EBADF)
 	    throw new java::io::IOException (JvNewStringUTF (strerror (errno)));
+	  break;
 	}
       written += r;
       len -= r;


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