Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 May 2000 02:31:20 +0900
From:      "Shin'ya Kumabuchi" <kumabu@t3.rim.or.jp>
To:        freebsd-java@FreeBSD.ORG
Subject:   RE: Socket read problem in 1.2.2?
Message-ID:  <20000516023120B.kumabu@t3.rim.or.jp>
In-Reply-To: Your message of "Sun, 14 May 2000 15:54:07 %2B0100" <59063B5B4D98D311BC0D0001FA7E4522026D7503@l04.research.kpn.com>
References:  <59063B5B4D98D311BC0D0001FA7E4522026D7503@l04.research.kpn.com>

next in thread | previous in thread | raw e-mail | index | archive | help
----Next_Part(Tue_May_16_02:31:15_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi.

Koster, K J wrote:
  >> HANDLER THREAD PROBLEM: java.net.SocketException: Resource
  >> temporarily unavailable: Resource temporarily unavailable
  >> 
> As Greg says, this is a socket bug in the current JDK port. I have included
> a description of this problem on my web site:

>   http://web.inter.nl.net/users/kjkoster/java/index.html

Try attached patch. (for patchset 7)

Summary:
   There's two kinds of file flags, one is system(OS) level's and the
   other is green thread's.
   Patchset 7 uses fcntl(2) system call directly for F_{GET,SET}FL,
   and this makes status of green thread's file flag incorrect in some
   cases.

In addition, I changed file flags from FXXX to O_XXX, since
/usr/include/sys/fcntl.h says
 * Open/fcntl flags begin with O_; kernel-internal flags begin with F.

Regards.
--

----Next_Part(Tue_May_16_02:31:15_2000_809)--
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=iomgr.c.patch

--- src/freebsd/hpi/green_threads/src/iomgr.c.~1~	Mon May 15 14:07:41 2000
+++ src/freebsd/hpi/green_threads/src/iomgr.c	Mon May 15 22:10:29 2000
@@ -567,18 +567,15 @@
 	/* if it's already non-blocking, do nothing... */
 #ifdef __FreeBSD__
 	struct stat inode;
-	if ((flgs = (*systable[SYS_FCNTL].addr)(desc, F_GETFL, 0)) == -1) {
-	  err:
-#else
-	if ((flgs = fcntl(desc, F_GETFL, 0)) == -1) {
 #endif
+	if ((flgs = fcntl(desc, F_GETFL, 0)) == -1) {
 	    IO_UNLOCK(self);
 	    sysMonitorExit(self, fdmon[desc]);
 	    return -1;
 	}
 
 #ifdef __FreeBSD__
-	if (flgs & (FNONBLOCK|FASYNC)) {
+	if (flgs & (O_NONBLOCK | O_ASYNC)) {
 #else
 	if (flgs & O_NONBLOCK) {
 #endif
@@ -592,7 +589,7 @@
 	     * Make the fd non-blocking for use by the wrappers
 	     */
 #ifdef __FreeBSD__
-	    systable[SYS_FCNTL].addr(desc, F_SETFL, flgs | FNONBLOCK|FASYNC);
+	    systable[SYS_FCNTL].addr(desc, F_SETFL, flgs | O_NONBLOCK | O_ASYNC);
 #else
 	    systable[SYS_FCNTL].addr(desc, F_SETFL, flgs | O_NONBLOCK);
 #endif
@@ -617,18 +614,14 @@
 	 * If it's already blocking, do nothing... 
 	 * otherwise make fd blocking.
 	 */
-#ifdef __FreeBSD__
-	if ((flgs = systable[SYS_FCNTL].addr(desc, F_GETFL, 0)) == -1) {
-#else
 	if ((flgs = fcntl(desc, F_GETFL, 0)) == -1) {
-#endif
 	    IO_UNLOCK(self);
 	    sysMonitorExit(self, fdmon[desc]);
 	    return -1;
 	}
 
 #ifdef __FreeBSD__
-	systable[SYS_FCNTL].addr(desc, F_SETFL, flgs & ~(FNONBLOCK|FASYNC));
+	fcntl(desc, F_SETFL, flgs & ~(O_NONBLOCK | O_ASYNC));
 	systable[SYS_FCNTL].addr(desc, F_SETOWN, 0);
 #else
 	fcntl(desc, F_SETFL, flgs & ~O_NONBLOCK);
@@ -2153,7 +2146,7 @@
 	 * to be non-blocking by adding O_NONBLOCK to the flags.
 	 */
 #ifdef __FreeBSD__
-	arg |= FNONBLOCK|FASYNC;
+	arg |= (O_NONBLOCK | O_ASYNC);
 #else
 	arg |= O_NONBLOCK;
 #endif
@@ -2188,7 +2181,11 @@
 	 * state and not ours.  
 	 */
 	if (!(fd_flags[fd] & FD_NONBLOCKING))
+#ifdef __FreeBSD__
+	    ret &= ~(O_NONBLOCK | O_ASYNC);
+#else
 	    ret &= ~O_NONBLOCK;
+#endif
     }
 
     IO_UNLOCK(self);

----Next_Part(Tue_May_16_02:31:15_2000_809)----


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000516023120B.kumabu>