From owner-freebsd-java Tue Sep 4 7:33:10 2001 Delivered-To: freebsd-java@freebsd.org Received: from matsulab.is.titech.ac.jp (matsulab.is.titech.ac.jp [131.112.35.129]) by hub.freebsd.org (Postfix) with ESMTP id E81D737B407 for ; Tue, 4 Sep 2001 07:33:03 -0700 (PDT) Received: from tripper.private by matsulab.is.titech.ac.jp (8.8.8+Sun/3.7W) id XAA28851; Tue, 4 Sep 2001 23:28:53 +0900 (JST) Date: Tue, 04 Sep 2001 23:31:27 +0900 Message-ID: <5566az81ts.wl@tripper.private> From: Fuyuhiko Maruyama To: Bill Huey Cc: Mikhail Kruk , java@freebsd.org Subject: Re: jdk1.3.1 socket problem In-Reply-To: <20010831023820.A20158@gnuppy> References: <55lmk5czi0.wl@tripper.private> <20010831023820.A20158@gnuppy> User-Agent: Wanderlust/2.6.0 (Twist And Shout) on XEmacs/21.5.1 (anise) MIME-Version: 1.0 (generated by SEMI 1.14.3 - "Ushinoya") Content-Type: multipart/mixed; boundary="Multipart_Tue_Sep__4_23:31:27_2001-1" Sender: owner-freebsd-java@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org --Multipart_Tue_Sep__4_23:31:27_2001-1 Content-Type: text/plain; charset=US-ASCII Hi, I made a patch will solve the problem that connect() on green_threads *almost always* fails. The problem is in caused by the logic at `src/solaris/hpi/green_threads/src/iomgr.c'. We use non-blocking mode socket and connect() wrapper in iomgr.c have a code to wait until connection is established. At the end of waiting path, the codes check whether the connection is really established using *the second* syscall of connect, it will always fail because it is really the second attempt of connect so EISCONN(errno == 56) may mean the fact that conection is established. My patch uses Solaris's path, so it doesn't use second syscall of connect. Why I use Solaris's path instead of linux's path is that is the way JDK 1.2.2 does. My patch also solves another problem, that Java VM sometimes fails by assertion. It is caused because some functions in libc uses shortcut path to syscall such as _open, _close,,, etc. So we need more wrappers in iomgr.c. -- Fuyuhiko MARUYAMA Matsuoka laboratory, Department of Mathematical and Computing Sciences, Graduate School of Information Science and Engineering, Tokyo Institute of Technology. --Multipart_Tue_Sep__4_23:31:27_2001-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="iomgr.c.diff" Content-Transfer-Encoding: 7bit Index: iomgr.c =================================================================== RCS file: /data/java/JDK2/javasrc_1_3_scsl/j2sdk1.3.1/src/solaris/hpi/green_threads/src/iomgr.c,v retrieving revision 1.2 diff -u -r1.2 iomgr.c --- iomgr.c 2001/07/13 16:38:45 1.2 +++ iomgr.c 2001/09/04 13:53:10 @@ -699,6 +699,29 @@ * fds before we return control. Known calls that are already taken care * of are: open, fcntl, pipe dup and creat. */ +#if defined(__FreeBSD__) +#if defined(__i386__) +#define ASM __asm__ volatile +#define WRAPFUNC(FUNC) \ +do { \ + ASM(".globl _" #FUNC); \ + ASM(" .type _" #FUNC ",@function"); \ + ASM("_" #FUNC ":"); \ + ASM("jmp " #FUNC); \ +} while (0) + +static void __dummy() { + WRAPFUNC(open); + WRAPFUNC(close); + WRAPFUNC(read); + WRAPFUNC(write); + WRAPFUNC(fcntl); + __dummy(); +} +#else +#error "Unsupported architecture." +#endif +#endif /* * Although we set the SA_RESTART flag on all our signal handlers we @@ -766,8 +789,10 @@ asyncIODeactivateFD(fd); } #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) - else + else { + sysAssert(fd_flags[fd] == 0); fd_flags[fd] = 0; + } #endif ret = (*systable[SYS_CLOSE].addr)(fd); @@ -2428,7 +2453,7 @@ #endif if (cnt == 1) { int bytes; -#if defined(__solaris__) +#if defined(__solaris__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) if (ioctl(fd, FIONREAD, &bytes) == -1) { if (errno == EPIPE) { errno = ECONNREFUSED; @@ -2445,11 +2470,11 @@ break; #else if ((*systable[SYS_CONNECT].addr)(fd, him, len) == -1) { - if (errno == ENOTCONN) { - errno = ECONNREFUSED; - } - /* see comment above */ - break; + if (errno == ENOTCONN) { + errno = ECONNREFUSED; + } + /* see comment above */ + break; } #endif #ifdef __linux__ --Multipart_Tue_Sep__4_23:31:27_2001-1-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-java" in the body of the message