Date: Tue, 04 Sep 2001 23:31:27 +0900 From: Fuyuhiko Maruyama <fuyuhik8@is.titech.ac.jp> To: Bill Huey <billh@gnuppy.monkey.org> Cc: Mikhail Kruk <meshko@cs.brandeis.edu>, java@freebsd.org Subject: Re: jdk1.3.1 socket problem Message-ID: <5566az81ts.wl@tripper.private> In-Reply-To: <20010831023820.A20158@gnuppy> References: <55lmk5czi0.wl@tripper.private> <Pine.LNX.4.33.0108271126100.16201-100000@calliope.cs.brandeis.edu> <20010831023820.A20158@gnuppy>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <fuyuhik8@is.titech.ac.jp>
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5566az81ts.wl>
