From owner-freebsd-java@FreeBSD.ORG Sun Dec 10 08:10:23 2006 Return-Path: X-Original-To: freebsd-java@hub.freebsd.org Delivered-To: freebsd-java@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7EFDF16A415 for ; Sun, 10 Dec 2006 08:10:23 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id CA04443CA7 for ; Sun, 10 Dec 2006 08:09:08 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kBA8AHhV054421 for ; Sun, 10 Dec 2006 08:10:17 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kBA8AHH1054420; Sun, 10 Dec 2006 08:10:17 GMT (envelope-from gnats) Resent-Date: Sun, 10 Dec 2006 08:10:17 GMT Resent-Message-Id: <200612100810.kBA8AHH1054420@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-java@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Toshiharu Moriyama Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6EC9916A47B for ; Sun, 10 Dec 2006 08:05:40 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [69.147.83.33]) by mx1.FreeBSD.org (Postfix) with ESMTP id 24A1143CA6 for ; Sun, 10 Dec 2006 08:04:27 +0000 (GMT) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.13.1/8.13.1) with ESMTP id kBA85ZD8098287 for ; Sun, 10 Dec 2006 08:05:35 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.13.1/8.13.1/Submit) id kBA85ZQT098285; Sun, 10 Dec 2006 08:05:35 GMT (envelope-from nobody) Message-Id: <200612100805.kBA85ZQT098285@www.freebsd.org> Date: Sun, 10 Dec 2006 08:05:35 GMT From: Toshiharu Moriyama To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.0 Cc: Subject: java/106552: plz change distfiles X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Dec 2006 08:10:23 -0000 >Number: 106552 >Category: java >Synopsis: plz change distfiles >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-java >State: open >Quarter: >Keywords: >Date-Required: >Class: update >Submitter-Id: current-users >Arrival-Date: Sun Dec 10 08:10:11 GMT 2006 >Closed-Date: >Last-Modified: >Originator: Toshiharu Moriyama >Release: 4-stable >Organization: >Environment: >Description: ports/java/linux-sun-jdk14 file not found j2sdk-1_4_2_12-linux-i586.bin in java.sun.com now file is j2sdk-1_4_2_13-linux-i586.bin please change distinfo file >How-To-Repeat: >Fix: MD5 (j2sdk-1_4_2_13-linux-i586.bin) = e2e610267fd9ff8fc5f8a807a5606751 SHA256 (2sdk-1_4_2_13-linux-i586.bin) = f5dd8045fe791bd5c52bddf33a1cf65968ee03981e0663f75cd97a942daa24e2 SIZE (2sdk-1_4_2_13-linux-i586.bin) = 36361814 >Release-Note: >Audit-Trail: >Unformatted: From owner-freebsd-java@FreeBSD.ORG Sun Dec 10 18:42:22 2006 Return-Path: X-Original-To: java@freebsd.org Delivered-To: freebsd-java@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3446F16A407 for ; Sun, 10 Dec 2006 18:42:22 +0000 (UTC) (envelope-from linimon@FreeBSD.org) Received: from mail.droso.net (koala.droso.net [193.88.12.38]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4558443C9D for ; Sun, 10 Dec 2006 18:41:10 +0000 (GMT) (envelope-from linimon@FreeBSD.org) Received: from localhost (localhost.droso.net [127.0.0.1]) by mail.droso.net (Postfix) with ESMTP id E5ACA1CD0C for ; Sun, 10 Dec 2006 19:42:20 +0100 (CET) Received: from koala.droso.net (localhost.droso.net [IPv6:::1]) by mail.droso.net (Postfix) with ESMTP id 2A9D61CF59 for ; Sun, 10 Dec 2006 19:41:25 +0100 (CET) From: linimon@FreeBSD.org To: java@freebsd.org Message-Id: <20061210184125.2A9D61CF59@mail.droso.net> Date: Sun, 10 Dec 2006 19:41:25 +0100 (CET) X-Virus-Scanned: by amavisd 0.1 Cc: Subject: FreeBSD ports that you maintain which are currently marked forbidden X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Dec 2006 18:42:22 -0000 Dear FreeBSD port maintainer: As part of an ongoing effort to reduce the number of problems in the FreeBSD ports system, we are attempting to notify maintainers of ports that are marked as "forbidden" in their Makefiles. Often, these ports are so marked due to security concerns, such as known exploits. An overview of the port, including errors seen on the build farm, is included below. portname: java/linux-blackdown-jdk13 forbidden because: Vulnerabilities in the browser plugin build errors: none. overview: http://portsmon.FreeBSD.org/portoverview.py?category=java&portname=linux-blackdown-jdk13 portname: java/linux-ibm-jdk13 forbidden because: Vulnerabilities in the browser plugin build errors: none. overview: http://portsmon.FreeBSD.org/portoverview.py?category=java&portname=linux-ibm-jdk13 If this problem is one that you are already aware of, please accept our apologies and ignore this message. On the other hand, if you no longer wish to maintain this port (or ports), please reply with a message stating that, and accept our thanks for your efforts in the past. Thanks for your efforts to help improve FreeBSD. From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 11:14:47 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 142D016A674 for ; Mon, 11 Dec 2006 11:14:47 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88A594406E for ; Mon, 11 Dec 2006 11:07:20 +0000 (GMT) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (linimon@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kBBB8Zw0022894 for ; Mon, 11 Dec 2006 11:08:35 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from linimon@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kBBB8Xb4022890 for freebsd-java@FreeBSD.org; Mon, 11 Dec 2006 11:08:33 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 11 Dec 2006 11:08:33 GMT Message-Id: <200612111108.kBBB8Xb4022890@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: linimon set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-java@FreeBSD.org Cc: Subject: Current problem reports assigned to you X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 11:14:47 -0000 Current FreeBSD problem reports Critical problems Serious problems S Tracker Resp. Description -------------------------------------------------------------------------------- s ports/60083 java Unsafe use of getaddrinfo in jvm 1.4.2-p5 o java/66151 java JBuilderX (sun jvm 1.4.1 builtin) crashes on 4.9 works f java/72151 java JVM crash on 5.2.1-R o java/76631 java any port linux-*-jdk12 will core dump if using linux_b o ports/100529 java linux-sun-jdk1.4.2_12 coredumps on FreeBSD 4.x o java/104627 java Makefile jdk14 broken o java/105369 java problem with port diablo-jdk15 o java/105482 java diablo-jdk1.5.0/jdk-1.5.0 java.nio.Selector bug 8 problems total. Non-critical problems S Tracker Resp. Description -------------------------------------------------------------------------------- f ports/56928 java jce-aba port should install to $JAVA_HOME/jre/lib/ext f java/62837 java linux-sun-jdk14 executables hang with COMPAT_LINUX in o ports/84742 java make ports/java/jdk14 use dynamic Motif librarires f ports/91244 java Bad instruction on making process of jdk14 o java/97461 java Diablo JDK does not report Update level in a format su o ports/106552 java java/linux-sun-jdk14: plz change distfiles 6 problems total. From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 14:46:14 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9983216A407 for ; Mon, 11 Dec 2006 14:46:14 +0000 (UTC) (envelope-from arnej@pvv.ntnu.no) Received: from decibel.pvv.ntnu.no (decibel.pvv.ntnu.no [129.241.210.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2261343CBA for ; Mon, 11 Dec 2006 14:44:56 +0000 (GMT) (envelope-from arnej@pvv.ntnu.no) Received: from arnej by decibel.pvv.ntnu.no with local (Exim 4.60) (envelope-from ) id 1GtmQ0-0002pG-EW for freebsd-java@FreeBSD.org; Mon, 11 Dec 2006 15:46:12 +0100 Date: Mon, 11 Dec 2006 15:46:12 +0100 (CET) From: "Arne H. Juul" To: freebsd-java@FreeBSD.org Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 14:46:14 -0000 I've had problems with some tests hanging on FreeBSD 6/amd64. This happens both with diablo-1.5.0_07-b01 and the java/jdk15 compiled from ports. After much digging we've determined that the root cause is that the guarantee in the socket.close() API, see the documentation at http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() isn't fulfulled - the thread blocked in I/O on the socket doesn't wake up. Here's a pretty small test program that demonstrates the problem (given that you're running sshd on port 22, if not change the port number to something that the program can connect to). Is this a known problem? Does it happen for everybody on FreeBSD 6? import java.io.*; import java.net.*; import java.util.*; import java.util.logging.*; public class FooConn extends Thread { private boolean alive; public final int port; private Socket socket = null; public FooConn(int port) { super("FooConn:" + port); this.port = port; this.alive = true; } private void connect() { while (socket == null) { try { socket = new Socket("localhost", port); } catch(IOException e) { System.err.println("Connect failed: " + e); try { Thread.sleep(1000); } catch(InterruptedException ie) {} } } } public void disconnect() throws IOException, InterruptedException { alive = false; System.out.println("closing socket"); socket.close(); System.out.println("calling join"); join(); } public void run() { while (alive) { if (socket == null) { System.out.println("socket null, connect"); connect(); } try { int b = socket.getInputStream().read(); System.out.println("got byte "+ b); } catch (IOException e) { System.out.println("IOException, set socket to null"); socket = null; //triggers reconnect } catch (RuntimeException e) { System.err.println("RuntimeException "+e); return; } } } public static void main(String[] args) throws IOException { try { FooConn conn = new FooConn(22); conn.start(); Thread.sleep(1000); conn.disconnect(); } catch(InterruptedException ie) {} } } From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 15:07:10 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DBFE516A403; Mon, 11 Dec 2006 15:07:10 +0000 (UTC) (envelope-from arnej@pvv.ntnu.no) Received: from decibel.pvv.ntnu.no (decibel.pvv.ntnu.no [129.241.210.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 382E243CAC; Mon, 11 Dec 2006 15:05:53 +0000 (GMT) (envelope-from arnej@pvv.ntnu.no) Received: from arnej by decibel.pvv.ntnu.no with local (Exim 4.60) (envelope-from ) id 1GtmkH-00080J-6z; Mon, 11 Dec 2006 16:07:09 +0100 Date: Mon, 11 Dec 2006 16:07:09 +0100 (CET) From: "Arne H. Juul" To: freebsd-java@FreeBSD.org In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-threads@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 15:07:11 -0000 On Mon, 11 Dec 2006, Arne H. Juul wrote: > I've had problems with some tests hanging on FreeBSD 6/amd64. This happens > both with diablo-1.5.0_07-b01 and the java/jdk15 compiled from ports. > > After much digging we've determined that the root cause is that > the guarantee in the socket.close() API, see the documentation at > http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() > isn't fulfulled - the thread blocked in I/O on the socket doesn't wake up. Looking at the Java VM source code it does some tricks with dup2() to reopen the close()'d filedescriptor, making it point to a filedescriptor that's pre-connected to a closed socket. A small C program that duplicates this (using pipes to make it a bit simpler) follows. I'm not sure if any standards demand that this works like it used to on FreeBSD 4 / libc_r, but since Java uses it it would be really nice if this could be made to work in FreeBSD 6 (libthr and libpthread). Or maybe somebody has another suggestions on how to implement the Java close() semantics? Anyway, the following C program works as intended on FreeBSD 4, hangs on FreeBSD 6 (amd64), compiled with: cc -Wall -pthread read_dup2.c -o read_dup2 #include #include #include #include #include int p[2]; void *run(void *arg) { ssize_t res; char tmp[128]; fprintf(stderr, "reading...\n"); res = read(p[0], tmp, sizeof(tmp)); fprintf(stderr, "read result: %d\n", (int)res); if (res < 0) { perror("read"); } return arg; } int main(int argc, char **argv) { pthread_t t; int d = open("/dev/null", O_RDONLY); if (pipe(p) != 0) { perror("pipe"); return 1; } if (pthread_create(&t, NULL, run, NULL) != 0) { perror("thread create"); return 1; } sleep(1); d = open("/dev/null", O_RDONLY); if (d < 0) { perror("open dev null"); exit(1); } if (dup2(d, p[0]) < 0) { perror("dup2"); exit(1); } if (pthread_join(t, NULL) != 0) { perror("thread join"); exit(1); } return 0; } From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 15:25:23 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2821E16A40F for ; Mon, 11 Dec 2006 15:25:23 +0000 (UTC) (envelope-from achill@matrix.gatewaynet.com) Received: from matrix.gatewaynet.com (host2.dynacom.ondsl.gr [62.103.35.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3A95443CB3 for ; Mon, 11 Dec 2006 15:23:41 +0000 (GMT) (envelope-from achill@matrix.gatewaynet.com) Received: from host3.dynacom.ondsl.gr ([62.103.35.211] helo=ip216.internal.net) by matrix.gatewaynet.com with esmtp (Exim 4.62) (envelope-from ) id 1Gtn1L-0006Ai-BB for freebsd-java@freebsd.org; Mon, 11 Dec 2006 17:24:47 +0200 From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: freebsd-java@freebsd.org Date: Mon, 11 Dec 2006 17:24:46 +0200 User-Agent: KMail/1.9.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200612111724.46716.achill@matrix.gatewaynet.com> Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 15:25:23 -0000 =D3=F4=E9=F2 =C4=E5=F5=F4=DD=F1=E1 11 =C4=E5=EA=DD=EC=E2=F1=E9=EF=F2 2006 1= 6:46, =EF/=E7 Arne H. Juul =DD=E3=F1=E1=F8=E5: > I've had problems with some tests hanging on FreeBSD 6/amd64. This happens > both with diablo-1.5.0_07-b01 and the java/jdk15 compiled from ports. > > After much digging we've determined that the root cause is that > the guarantee in the socket.close() API, see the documentation at > http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() > isn't fulfulled - the thread blocked in I/O on the socket doesn't wake up. > > Here's a pretty small test program that demonstrates the problem (given > that you're running sshd on port 22, if not change the port number to > something that the program can connect to). Is this a known problem? > Does it happen for everybody on FreeBSD 6? > In my systems, 1.4.2-p7, diablo-1.5.0_07-b00 have this problem. However with linux 1.4.2_12-b03 right after socket.close(), IOException is= =20 thrown and caught by the FooConn thread. > > > import java.io.*; > import java.net.*; > import java.util.*; > import java.util.logging.*; > > public class FooConn extends Thread { > private boolean alive; > public final int port; > private Socket socket =3D null; > > public FooConn(int port) { > super("FooConn:" + port); > this.port =3D port; > this.alive =3D true; > } > private void connect() { > while (socket =3D=3D null) { > try { > socket =3D new Socket("localhost", port); > } catch(IOException e) { > System.err.println("Connect failed: " + e); > try { Thread.sleep(1000); } catch(InterruptedException i= e) > {} > } > } > } > public void disconnect() throws IOException, InterruptedException { > alive =3D false; > System.out.println("closing socket"); > socket.close(); > System.out.println("calling join"); > join(); > } > public void run() { > while (alive) { > if (socket =3D=3D null) { > System.out.println("socket null, connect"); > connect(); > } > try { > int b =3D socket.getInputStream().read(); > System.out.println("got byte "+ b); > } catch (IOException e) { > System.out.println("IOException, set socket to null"); > socket =3D null; //triggers reconnect > } catch (RuntimeException e) { > System.err.println("RuntimeException "+e); > return; > } > } > } > public static void main(String[] args) throws IOException { > try { > FooConn conn =3D new FooConn(22); > conn.start(); > Thread.sleep(1000); > conn.disconnect(); > } catch(InterruptedException ie) {} > } > } > _______________________________________________ > freebsd-java@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-java > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" =2D-=20 Achilleas Mantzios From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 15:48:19 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8E99F16A47B for ; Mon, 11 Dec 2006 15:48:19 +0000 (UTC) (envelope-from achill@matrix.gatewaynet.com) Received: from matrix.gatewaynet.com (host2.dynacom.ondsl.gr [62.103.35.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id 043BC43DFC for ; Mon, 11 Dec 2006 15:44:28 +0000 (GMT) (envelope-from achill@matrix.gatewaynet.com) Received: from host3.dynacom.ondsl.gr ([62.103.35.211] helo=ip216.internal.net) by matrix.gatewaynet.com with esmtp (Exim 4.62) (envelope-from ) id 1GtnLT-0006B7-Ke for freebsd-java@freebsd.org; Mon, 11 Dec 2006 17:45:35 +0200 From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: freebsd-java@freebsd.org Date: Mon, 11 Dec 2006 17:45:34 +0200 User-Agent: KMail/1.9.3 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-7" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200612111745.35227.achill@matrix.gatewaynet.com> Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 15:48:19 -0000 =D3=F4=E9=F2 =C4=E5=F5=F4=DD=F1=E1 11 =C4=E5=EA=DD=EC=E2=F1=E9=EF=F2 2006 1= 7:07, =EF/=E7 Arne H. Juul =DD=E3=F1=E1=F8=E5: > On Mon, 11 Dec 2006, Arne H. Juul wrote: > > I've had problems with some tests hanging on FreeBSD 6/amd64. This > > happens both with diablo-1.5.0_07-b01 and the java/jdk15 compiled from > > ports. > > > > After much digging we've determined that the root cause is that > > the guarantee in the socket.close() API, see the documentation at > > http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() > > isn't fulfulled - the thread blocked in I/O on the socket doesn't wake > > up. > > Looking at the Java VM source code it does some tricks with dup2() to > reopen the close()'d filedescriptor, making it point to a filedescriptor > that's pre-connected to a closed socket. > > A small C program that duplicates this (using pipes to make it a bit > simpler) follows. I'm not sure if any standards demand that this > works like it used to on FreeBSD 4 / libc_r, but since Java uses it it > would be really nice if this could be made to work in FreeBSD 6 (libthr > and libpthread). Or maybe somebody has another suggestions on how to > implement the Java close() semantics? > I forgot to mention that all my tests were on 386. (So most probably it's n= ot=20 amd64 related). And indeed in FreeBSD 6, by mapping libpthread.so.2 to libc_r.so.6 =46ooConn seems to work correctly. Only with libthr.so.2 / libpthread.so.2 the problem exists. > Anyway, the following C program works as intended on FreeBSD 4, > hangs on FreeBSD 6 (amd64), compiled with: > cc -Wall -pthread read_dup2.c -o read_dup2 > > > #include > #include > #include > #include > #include > > int p[2]; > > void *run(void *arg) { > ssize_t res; > char tmp[128]; > fprintf(stderr, "reading...\n"); > res =3D read(p[0], tmp, sizeof(tmp)); > fprintf(stderr, "read result: %d\n", (int)res); > if (res < 0) { > perror("read"); > } > return arg; > } > > int main(int argc, char **argv) { > pthread_t t; > int d =3D open("/dev/null", O_RDONLY); > if (pipe(p) !=3D 0) { > perror("pipe"); > return 1; > } > if (pthread_create(&t, NULL, run, NULL) !=3D 0) { > perror("thread create"); > return 1; > } > sleep(1); > d =3D open("/dev/null", O_RDONLY); > if (d < 0) { > perror("open dev null"); > exit(1); > } > if (dup2(d, p[0]) < 0) { > perror("dup2"); > exit(1); > } > if (pthread_join(t, NULL) !=3D 0) { > perror("thread join"); > exit(1); > } > return 0; > } > _______________________________________________ > freebsd-java@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-java > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" =2D-=20 Achilleas Mantzios From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 17:11:25 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id C578A16A415; Mon, 11 Dec 2006 17:11:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from fw.zoral.com.ua (fw.zoral.com.ua [213.186.206.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4BAE743C9E; Mon, 11 Dec 2006 17:10:06 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id kBBHBGA1063307 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 11 Dec 2006 19:11:16 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8) with ESMTP id kBBHBGqu020278; Mon, 11 Dec 2006 19:11:16 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8/Submit) id kBBHBFH3020277; Mon, 11 Dec 2006 19:11:15 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 11 Dec 2006 19:11:15 +0200 From: Kostik Belousov To: "Arne H. Juul" Message-ID: <20061211171115.GD311@deviant.kiev.zoral.com.ua> References: Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7qSK/uQB79J36Y4o" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on fw.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL, UNPARSEABLE_RELAY autolearn=no version=3.1.4 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on fw.zoral.com.ua Cc: freebsd-arch@freebsd.org, freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 17:11:26 -0000 --7qSK/uQB79J36Y4o Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 11, 2006 at 04:07:09PM +0100, Arne H. Juul wrote: > On Mon, 11 Dec 2006, Arne H. Juul wrote: > Looking at the Java VM source code it does some tricks with dup2() to=20 > reopen the close()'d filedescriptor, making it point to a filedescriptor= =20 > that's pre-connected to a closed socket. >=20 > A small C program that duplicates this (using pipes to make it a bit > simpler) follows. I'm not sure if any standards demand that this > works like it used to on FreeBSD 4 / libc_r, but since Java uses it it > would be really nice if this could be made to work in FreeBSD 6 (libthr > and libpthread). Or maybe somebody has another suggestions on how to > implement the Java close() semantics? >=20 > Anyway, the following C program works as intended on FreeBSD 4, > hangs on FreeBSD 6 (amd64), compiled with: > cc -Wall -pthread read_dup2.c -o read_dup2 >=20 >=20 > #include > #include > #include > #include > #include >=20 > int p[2]; >=20 > void *run(void *arg) { > ssize_t res; > char tmp[128]; > fprintf(stderr, "reading...\n"); > res =3D read(p[0], tmp, sizeof(tmp)); > fprintf(stderr, "read result: %d\n", (int)res); > if (res < 0) { > perror("read"); > } > return arg; > } >=20 > int main(int argc, char **argv) { > pthread_t t; > int d =3D open("/dev/null", O_RDONLY); > if (pipe(p) !=3D 0) { > perror("pipe"); > return 1; > } > if (pthread_create(&t, NULL, run, NULL) !=3D 0) { > perror("thread create"); > return 1; > } > sleep(1); > d =3D open("/dev/null", O_RDONLY); > if (d < 0) { > perror("open dev null"); > exit(1); > } > if (dup2(d, p[0]) < 0) { > perror("dup2"); > exit(1); > } > if (pthread_join(t, NULL) !=3D 0) { > perror("thread join"); > exit(1); > } > return 0; > } I think that -arch@ is proper ML to discuss the issue. Your test example hangs becase read() takes one more hold count on the file descriptor operated upon. As result, when calling close, f_count of the rpipe (aka p[0]) is 2, close() decrements it, f_count becomes 1. Since f_count > 0, fdrop_locked simply returns instead of calling fo_close (see kern_descrip.c). I cannot find the statement in SUSv3 that would require interruption of the read() upon close() from another thread; this looks like undefined behaviour from the standard point of view. I think that JVM is more appropriate place for fix, but others may have different view point. --7qSK/uQB79J36Y4o Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFFfZEzC3+MBN1Mb4gRAqKBAJ0e2xoeobSLeRZjJQbFUs5/uXX3ywCgqkJM ZoWAOIyyznh7U1KYx8vpB8s= =CgYu -----END PGP SIGNATURE----- --7qSK/uQB79J36Y4o-- From owner-freebsd-java@FreeBSD.ORG Mon Dec 11 22:40:41 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E163A16A4A0; Mon, 11 Dec 2006 22:40:41 +0000 (UTC) (envelope-from arnej@pvv.ntnu.no) Received: from decibel.pvv.ntnu.no (decibel.pvv.ntnu.no [129.241.210.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 73FF144040; Mon, 11 Dec 2006 22:33:22 +0000 (GMT) (envelope-from arnej@pvv.ntnu.no) Received: from arnej by decibel.pvv.ntnu.no with local (Exim 4.60) (envelope-from ) id 1GttjM-0003Kw-2u; Mon, 11 Dec 2006 23:34:40 +0100 Date: Mon, 11 Dec 2006 23:34:40 +0100 (CET) From: "Arne H. Juul" To: Kostik Belousov In-Reply-To: <20061211171115.GD311@deviant.kiev.zoral.com.ua> Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-arch@freebsd.org, freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Dec 2006 22:40:42 -0000 On Mon, 11 Dec 2006, Kostik Belousov wrote: > On Mon, Dec 11, 2006 at 04:07:09PM +0100, Arne H. Juul wrote: >> Looking at the Java VM source code it does some tricks with dup2() to >> reopen the close()'d filedescriptor, making it point to a filedescriptor >> that's pre-connected to a closed socket. >> >> A small C program that duplicates this (using pipes to make it a bit >> simpler) follows. I'm not sure if any standards demand that this >> works like it used to on FreeBSD 4 / libc_r, but since Java uses it it >> would be really nice if this could be made to work in FreeBSD 6 (libthr >> and libpthread). Or maybe somebody has another suggestions on how to >> implement the Java close() semantics? > > I think that -arch@ is proper ML to discuss the issue. > > Your test example hangs becase read() takes one more hold count on the > file descriptor operated upon. As result, when calling close, f_count > of the rpipe (aka p[0]) is 2, close() decrements it, f_count becomes > 1. Since f_count > 0, fdrop_locked simply returns instead of calling > fo_close (see kern_descrip.c). > > I cannot find the statement in SUSv3 that would require interruption of > the read() upon close() from another thread; this looks like undefined > behaviour from the standard point of view. The best authority I've found says that the standards are silent (so the current FreeBSD 6 behaviour is allowed), I'm asking whether it is best practice and why it's changed since FreeBSD 4. > I think that JVM is more appropriate place for fix, but others may have > different view point. If it was just the JVM I would agree, but any threaded program that uses blocking I/O in some threads will probably need the same kind of handling at some point. And if you think about what that handling looks like, it's not exactly pretty: * when calling any potentially blocking system call (read/readv, write/writev, recv/recvfrom/recvmsg, send/sendto/sendmsg, accept, connect, poll, select, maybe others that I didn't think of) the application must: ** take a mutex ** remember in some structure (linked list or similar) keyed off the file descriptor that "this thread will now do blocking I/O" ** release the mutex ** perform the actual operation ** take the mutex again ** check if the operation was interrupted in a special way, if so return with EBADF ** release the mutex * instead of calling close() and dup2() the application must: ** take the mutex ** for each thread in the FD-associated structure, interrupt it in some special way (I'm guessing that setting a special flag and then sending SIGIO should work). ** actually do the close() / dup2() ** release the mutex This is exactly the sort of issue that should be solved by the thread library / kernel threads implementation and not in every threaded application that needs it, in my view. - Arne H. J. From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 00:16:10 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from localhost.my.domain (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 910F216A407; Tue, 12 Dec 2006 00:16:09 +0000 (UTC) (envelope-from davidxu@freebsd.org) From: David Xu To: freebsd-arch@freebsd.org Date: Tue, 12 Dec 2006 08:16:07 +0800 User-Agent: KMail/1.8.2 References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612120816.07608.davidxu@freebsd.org> Cc: Kostik Belousov , "Arne H. Juul" , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 00:16:10 -0000 On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: > This is exactly the sort of issue that should be solved by the > thread library / kernel threads implementation and not in every > threaded application that needs it, in my view. > It should not be done in new thread library, do you want a bloat and error-prone thread library ? Instead if this semantic is really necessary, it should be done in kernel. > - Arne H. J. David Xu From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 00:25:43 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0A08E16A415 for ; Tue, 12 Dec 2006 00:25:43 +0000 (UTC) (envelope-from arnej@pvv.ntnu.no) Received: from decibel.pvv.ntnu.no (decibel.pvv.ntnu.no [129.241.210.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id A054B44071 for ; Tue, 12 Dec 2006 00:14:47 +0000 (GMT) (envelope-from arnej@pvv.ntnu.no) Received: from arnej by decibel.pvv.ntnu.no with local (Exim 4.60) (envelope-from ) id 1GtvJW-0001fM-4I for freebsd-java@FreeBSD.org; Tue, 12 Dec 2006 01:16:06 +0100 Date: Tue, 12 Dec 2006 01:16:06 +0100 (CET) From: "Arne H. Juul" To: freebsd-java@FreeBSD.org In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 00:25:43 -0000 On Mon, 11 Dec 2006, Arne H. Juul wrote: > I've had problems with some tests hanging on FreeBSD 6/amd64. This happens > both with diablo-1.5.0_07-b01 and the java/jdk15 compiled from ports. > > After much digging we've determined that the root cause is that > the guarantee in the socket.close() API, see the documentation at > http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() > isn't fulfulled - the thread blocked in I/O on the socket doesn't wake up. after more hours of digging in standards, mailing list archives, and bug tickets, it looks like the best thing for now is to just copy the workaround used in the Java VM already for linux, something like this should work: diff -ruN jdk-1_5_0_09.b3/j2se/make/java/net/FILES_c.gmk jdk-1_5_0_09.b3-ahj8/j2se/make/java/net/FILES_c.gmk --- jdk-1_5_0_09.b3/j2se/make/java/net/FILES_c.gmk Sun Oct 15 12:44:55 2006 +++ jdk-1_5_0_09.b3-ahj8/j2se/make/java/net/FILES_c.gmk Mon Dec 11 23:38:44 2006 @@ -26,3 +26,7 @@ ifeq ($(PLATFORM), linux) FILES_c += $(CTARGDIR)linux_close.c endif + +ifeq ($(PLATFORM), bsd) + FILES_c += $(CTARGDIR)bsd_close.c +endif diff -ruN jdk-1_5_0_09.b3/j2se/src/solaris/native/java/net/net_util_md.h jdk-1_5_0_09.b3-ahj8/j2se/src/solaris/native/java/net/net_util_md.h --- jdk-1_5_0_09.b3/j2se/src/solaris/native/java/net/net_util_md.h Sun Oct 15 12:48:14 2006 +++ jdk-1_5_0_09.b3-ahj8/j2se/src/solaris/native/java/net/net_util_md.h Mon Dec 11 23:40:51 2006 @@ -39,7 +39,7 @@ #endif -#ifdef __linux__ +#if defined(__linux__) || defined(_ALLBSD_SOURCE) extern int NET_Timeout(int s, long timeout); extern int NET_Read(int s, void* buf, size_t len); extern int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, diff -ruN jdk-1_5_0_09.b3/j2se/src/solaris/native/java/net/bsd_close.c jdk-1_5_0_09.b3-ahj8/j2se/src/solaris/native/java/net/bsd_close.c --- jdk-1_5_0_09.b3/j2se/src/solaris/native/java/net/bsd_close.c Thu Jan 1 01:00:00 1970 +++ jdk-1_5_0_09.b3-ahj8/j2se/src/solaris/native/java/net/bsd_close.c Mon Dec 11 23:39:45 2006 @@ -0,0 +1,367 @@ +/* + * @(#)bsd_close.c 1.7 03/12/19 + * + * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. + */ + +/* XXXBSD: almost exact copy of linux_close.c */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +/* + * Stack allocated by thread when doing blocking operation + */ +typedef struct threadEntry { + pthread_t thr; /* this thread */ + struct threadEntry *next; /* next thread */ + int intr; /* interrupted */ +} threadEntry_t; + +/* + * Heap allocated during initialized - one entry per fd + */ +typedef struct { + pthread_mutex_t lock; /* fd lock */ + threadEntry_t *threads; /* threads blocked on fd */ +} fdEntry_t; + +/* + * Signal to unblock thread + */ +static int sigWakeup = SIGIO; + +/* + * The fd table and the number of file descriptors + */ +static fdEntry_t *fdTable; +static int fdCount; + +/* + * Null signal handler + */ +static void sig_wakeup(int sig) { +} + +/* + * Initialization routine (executed when library is loaded) + * Allocate fd tables and sets up signal handler. + */ +static void __attribute((constructor)) init() { + struct rlimit nbr_files; + sigset_t sigset; + struct sigaction sa; + + /* + * Allocate table based on the maximum number of + * file descriptors. + */ + getrlimit(RLIMIT_NOFILE, &nbr_files); + fdCount = nbr_files.rlim_max; + fdTable = (fdEntry_t *)calloc(fdCount, sizeof(fdEntry_t)); + if (fdTable == NULL) { + fprintf(stderr, "library initialization failed - " + "unable to allocate file descriptor table - out of memory"); + abort(); + } + + /* + * Setup the signal handler + */ + sa.sa_handler = sig_wakeup; + sa.sa_flags = 0; + sigemptyset(&sa.sa_mask); + sigaction(sigWakeup, &sa, NULL); + + sigemptyset(&sigset); + sigaddset(&sigset, sigWakeup); + sigprocmask(SIG_UNBLOCK, &sigset, NULL); +} + +/* + * Return the fd table for this fd or NULL is fd out + * of range. + */ +static inline fdEntry_t *getFdEntry(int fd) +{ + if (fd < 0 || fd > fdCount) { + return NULL; + } + return &fdTable[fd]; +} + +/* + * Start a blocking operation :- + * Insert thread onto thread list for the fd. + */ +static inline void startOp(fdEntry_t *fdEntry, threadEntry_t *self) +{ + self->thr = pthread_self(); + self->intr = 0; + + pthread_mutex_lock(&(fdEntry->lock)); + { + self->next = fdEntry->threads; + fdEntry->threads = self; + } + pthread_mutex_unlock(&(fdEntry->lock)); +} + +/* + * End a blocking operation :- + * Remove thread from thread list for the fd + * If fd has been interrupted then set errno to EBADF + */ +static inline void endOp + (fdEntry_t *fdEntry, threadEntry_t *self) +{ + int orig_errno = errno; + pthread_mutex_lock(&(fdEntry->lock)); + { + threadEntry_t *curr, *prev=NULL; + curr = fdEntry->threads; + while (curr != NULL) { + if (curr == self) { + if (curr->intr) { + orig_errno = EBADF; + } + if (prev == NULL) { + fdEntry->threads = curr->next; + } else { + prev->next = curr->next; + } + break; + } + prev = curr; + curr = curr->next; + } + } + pthread_mutex_unlock(&(fdEntry->lock)); + errno = orig_errno; +} + +/* + * Close or dup2 a file descriptor ensuring that all threads blocked on + * the file descriptor are notified via a wakeup signal. + * + * fd1 < 0 => close(fd2) + * fd1 >= 0 => dup2(fd1, fd2) + * + * Returns -1 with errno set if operation fails. + */ +static int closefd(int fd1, int fd2) { + int rv, orig_errno; + fdEntry_t *fdEntry = getFdEntry(fd2); + if (fdEntry == NULL) { + errno = EBADF; + return -1; + } + + /* + * Lock the fd to hold-off additional I/O on this fd. + */ + pthread_mutex_lock(&(fdEntry->lock)); + + { + /* + * Send a wakeup signal to all threads blocked on this + * file descriptor. + */ + threadEntry_t *curr = fdEntry->threads; + while (curr != NULL) { + curr->intr = 1; + pthread_kill( curr->thr, sigWakeup ); + curr = curr->next; + } + + /* + * And close/dup the file descriptor + * (restart if interrupted by signal) + */ + do { + if (fd1 < 0) { + rv = close(fd2); + } else { + rv = dup2(fd1, fd2); + } + } while (rv == -1 && errno == EINTR); + + } + + /* + * Unlock without destroying errno + */ + orig_errno = errno; + pthread_mutex_unlock(&(fdEntry->lock)); + errno = orig_errno; + + return rv; +} + +/* + * Wrapper for dup2 - same semantics as dup2 system call except + * that any threads blocked in an I/O system call on fd2 will be + * preempted and return -1/EBADF; + */ +int NET_Dup2(int fd, int fd2) { + if (fd < 0) { + errno = EBADF; + return -1; + } + return closefd(fd, fd2); +} + +/* + * Wrapper for close - same semantics as close system call + * except that any threads blocked in an I/O on fd will be + * preempted and the I/O system call will return -1/EBADF. + */ +int NET_SocketClose(int fd) { + return closefd(-1, fd); +} + +/************** Basic I/O operations here ***************/ + +/* + * Macro to perform a blocking IO operation. Restarts + * automatically if interrupted by signal (other than + * our wakeup signal) + */ +#define BLOCKING_IO_RETURN_INT(FD, FUNC) { \ + int ret; \ + threadEntry_t self; \ + fdEntry_t *fdEntry = getFdEntry(FD); \ + if (fdEntry == NULL) { \ + errno = EBADF; \ + return -1; \ + } \ + do { \ + startOp(fdEntry, &self); \ + ret = FUNC; \ + endOp(fdEntry, &self); \ + } while (ret == -1 && errno == EINTR); \ + return ret; \ +} + +int NET_Read(int s, void* buf, size_t len) { + BLOCKING_IO_RETURN_INT( s, recv(s, buf, len, 0) ); +} + +int NET_ReadV(int s, const struct iovec * vector, int count) { + BLOCKING_IO_RETURN_INT( s, readv(s, vector, count) ); +} + +int NET_RecvFrom(int s, void *buf, int len, unsigned int flags, + struct sockaddr *from, int *fromlen) { + BLOCKING_IO_RETURN_INT( s, recvfrom(s, buf, len, flags, from, fromlen) ); +} + +int NET_Send(int s, void *msg, int len, unsigned int flags) { + BLOCKING_IO_RETURN_INT( s, send(s, msg, len, flags) ); +} + +int NET_WriteV(int s, const struct iovec * vector, int count) { + BLOCKING_IO_RETURN_INT( s, writev(s, vector, count) ); +} + +int NET_SendTo(int s, const void *msg, int len, unsigned int + flags, const struct sockaddr *to, int tolen) { + BLOCKING_IO_RETURN_INT( s, sendto(s, msg, len, flags, to, tolen) ); +} + +int NET_Accept(int s, struct sockaddr *addr, int *addrlen) { + BLOCKING_IO_RETURN_INT( s, accept(s, addr, addrlen) ); +} + +int NET_Connect(int s, struct sockaddr *addr, int addrlen) { + BLOCKING_IO_RETURN_INT( s, connect(s, addr, addrlen) ); +} + +#ifndef USE_SELECT +int NET_Poll(struct pollfd *ufds, unsigned int nfds, int timeout) { + BLOCKING_IO_RETURN_INT( ufds[0].fd, poll(ufds, nfds, timeout) ); +} +#else +int NET_Select(int s, fd_set *readfds, fd_set *writefds, + fd_set *exceptfds, struct timeval *timeout) { + BLOCKING_IO_RETURN_INT( s-1, + select(s, readfds, writefds, exceptfds, timeout) ); +} +#endif + +/* + * Wrapper for poll(s, timeout). + * Auto restarts with adjusted timeout if interrupted by + * signal other than our wakeup signal. + */ +int NET_Timeout(int s, long timeout) { + long prevtime,newtime; + struct timeval t; + fdEntry_t *fdEntry = getFdEntry(s); + + /* + * Check that fd hasn't been closed. + */ + if (fdEntry == NULL) { + errno = EBADF; + return -1; + } + + /* + * Pick up current time as may need to adjust timeout + */ + if (timeout > 0) { + gettimeofday(&t, NULL); + prevtime = t.tv_sec * 1000 + t.tv_usec / 1000; + } + + for(;;) { + struct pollfd pfd; + int rv; + threadEntry_t self; + + /* + * Poll the fd. If interrupted by our wakeup signal + * errno will be set to EBADF. + */ + pfd.fd = s; + pfd.events = POLLIN | POLLERR; + + startOp(fdEntry, &self); + rv = poll(&pfd, 1, timeout); + endOp(fdEntry, &self); + + /* + * If interrupted then adjust timeout. If timeout + * has expired return 0 (indicating timeout expired). + */ + if (rv < 0 && errno == EINTR) { + if (timeout > 0) { + gettimeofday(&t, NULL); + newtime = t.tv_sec * 1000 + t.tv_usec / 1000; + timeout -= newtime - prevtime; + if (timeout <= 0) { + return 0; + } + prevtime = newtime; + } + } else { + return rv; + } + + } +} + + From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 00:50:24 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5F4B916A4C8; Tue, 12 Dec 2006 00:50:24 +0000 (UTC) (envelope-from arnej@pvv.ntnu.no) Received: from decibel.pvv.ntnu.no (decibel.pvv.ntnu.no [129.241.210.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5DDC043CD0; Tue, 12 Dec 2006 00:48:40 +0000 (GMT) (envelope-from arnej@pvv.ntnu.no) Received: from arnej by decibel.pvv.ntnu.no with local (Exim 4.60) (envelope-from ) id 1GtvqI-0001FY-Pe; Tue, 12 Dec 2006 01:49:58 +0100 Date: Tue, 12 Dec 2006 01:49:58 +0100 (CET) From: "Arne H. Juul" To: David Xu In-Reply-To: <200612120816.07608.davidxu@freebsd.org> Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Kostik Belousov , freebsd-java@freebsd.org, freebsd-arch@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 00:50:24 -0000 On Tue, 12 Dec 2006, David Xu wrote: > On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: > >> This is exactly the sort of issue that should be solved by the >> thread library / kernel threads implementation and not in every >> threaded application that needs it, in my view. >> > It should not be done in new thread library, do you want a bloat > and error-prone thread library ? Instead if this semantic is really > necessary, it should be done in kernel. Well, it depends on the alternatives. If a clean kernel implementation is possible - yes please, of course. If only a complex, error-prone kernel implementation is possible, I would prefer to have the complexity in the thread library. That's better than having it in the kernel and (IMHO) better than having N implementation in various applications, especially since the applications don't necessarily know enough about the internals of the thread library and kernel interactions to get it right, much less efficient. That said, copying the linux_close.c workaround in the Java VM seems to solve my immediate problem, even if I think it's a bit ugly. But I have confidence that you can do a better and cleaner solution :-) - Arne H. J. From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 01:04:52 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from localhost.my.domain (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 720F616A675; Tue, 12 Dec 2006 01:04:52 +0000 (UTC) (envelope-from davidxu@freebsd.org) From: David Xu To: freebsd-arch@freebsd.org Date: Tue, 12 Dec 2006 09:04:49 +0800 User-Agent: KMail/1.8.2 References: <200612120816.07608.davidxu@freebsd.org> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612120904.49744.davidxu@freebsd.org> Cc: Kostik Belousov , "Arne H. Juul" , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 01:04:52 -0000 On Tuesday 12 December 2006 08:49, Arne H. Juul wrote: > On Tue, 12 Dec 2006, David Xu wrote: > > On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: > > > > > >> This is exactly the sort of issue that should be solved by the > >> thread library / kernel threads implementation and not in every > >> threaded application that needs it, in my view. > > > > It should not be done in new thread library, do you want a bloat > > and error-prone thread library ? Instead if this semantic is really > > necessary, it should be done in kernel. > > Well, it depends on the alternatives. > If a clean kernel implementation is possible - yes please, of course. > If only a complex, error-prone kernel implementation is possible, > I would prefer to have the complexity in the thread library. > > That's better than having it in the kernel and (IMHO) better than having N > implementation in various applications, especially since the applications > don't necessarily know enough about the internals of the thread library > and kernel interactions to get it right, much less efficient. > > That said, copying the linux_close.c workaround in the Java VM seems to > solve my immediate problem, even if I think it's a bit ugly. But I have > confidence that you can do a better and cleaner solution :-) > > - Arne H. J. Thread library only manages POSIX threads, it is nothing to do with how user will use file. Sorry, I will not mess the thread library. David Xu From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 01:09:03 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9C99F16A40F; Tue, 12 Dec 2006 01:09:03 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CA3943E27; Tue, 12 Dec 2006 01:04:41 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBC15whr006985; Mon, 11 Dec 2006 20:05:58 -0500 (EST) Date: Mon, 11 Dec 2006 20:05:58 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: "Arne H. Juul" In-Reply-To: Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Mon, 11 Dec 2006 20:05:58 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: Kostik Belousov , freebsd-arch@freebsd.org, David Xu , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 01:09:03 -0000 On Tue, 12 Dec 2006, Arne H. Juul wrote: > On Tue, 12 Dec 2006, David Xu wrote: >> On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: >> >>> This is exactly the sort of issue that should be solved by the >>> thread library / kernel threads implementation and not in every >>> threaded application that needs it, in my view. >>> >> It should not be done in new thread library, do you want a bloat >> and error-prone thread library ? Instead if this semantic is really >> necessary, it should be done in kernel. > > Well, it depends on the alternatives. > If a clean kernel implementation is possible - yes please, of course. > If only a complex, error-prone kernel implementation is possible, > I would prefer to have the complexity in the thread library. Hacking libthr or libpthread to do this for you is not an option. They would then look like libc_r since all fd's accesses would need to be wrapped. If this needs to be done, it must be in the kernel. Common sense leads me to think that a close() should release threads in IO operations (reads/writes/selects/polls) and return EBADF or something appropriate. At least when behavior is not dictated by POSIX or other historical/defactor behavior. -- DE From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 05:54:25 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6DFEC16A403; Tue, 12 Dec 2006 05:54:25 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailout2.pacific.net.au (mailout2-3.pacific.net.au [61.8.2.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 13CA443CAC; Tue, 12 Dec 2006 05:53:04 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy2.pacific.net.au (mailproxy2.pacific.net.au [61.8.2.163]) by mailout2.pacific.net.au (Postfix) with ESMTP id 589B21291E2; Tue, 12 Dec 2006 16:54:20 +1100 (EST) Received: from katana.zip.com.au (katana.zip.com.au [61.8.7.246]) by mailproxy2.pacific.net.au (Postfix) with ESMTP id 11AB527432; Tue, 12 Dec 2006 16:54:19 +1100 (EST) Date: Tue, 12 Dec 2006 16:54:19 +1100 (EST) From: Bruce Evans X-X-Sender: bde@delplex.bde.org To: Daniel Eischen In-Reply-To: Message-ID: <20061212160016.W56465@delplex.bde.org> References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Kostik Belousov , "Arne H. Juul" , freebsd-java@FreeBSD.org, David Xu , freebsd-arch@FreeBSD.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 05:54:25 -0000 On Mon, 11 Dec 2006, Daniel Eischen wrote: > Hacking libthr or libpthread to do this for you is not > an option. They would then look like libc_r since all > fd's accesses would need to be wrapped. If this needs > to be done, it must be in the kernel. > > Common sense leads me to think that a close() should release > threads in IO operations (reads/writes/selects/polls) and > return EBADF or something appropriate. At least when behavior > is not dictated by POSIX or other historical/defactor behavior. It's probably a nightmare in the kernel too. close() starts looking like revoke(), and revoke() has large problems and bugs in this area. At higher levels, revoke() has no support for either waking up or synchronizing with threads in I/O operations on the revoked file; it only tries to force a close on revoked files that are open, but due to reference counting problems it sometimes gets even this wrong. At lower levels, I think only the tty driver even partly understands that a device close() can occur while an (other) thread is in another operation on the device. Of course, most revokes are of ttys so the tty driver needs to understand this more than most. It uses a generation count to detect changes of the open instance. It doesn't wake up the other threads and depends on them checking the generation count. The check occurs mainly in ttysleep() where it is fundamentally incomplete on SMP systems -- there is no synchronization, so after a revoke(), threads running on other CPUs just blunder on like they do in other drivers. Giant locking of the tty driver reduces the problem. Bruce From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 06:37:14 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4128816A416 for ; Tue, 12 Dec 2006 06:37:14 +0000 (UTC) (envelope-from conrad.burger@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.235]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6893043CB8 for ; Tue, 12 Dec 2006 06:35:52 +0000 (GMT) (envelope-from conrad.burger@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so1669993wxc for ; Mon, 11 Dec 2006 22:37:12 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=Zs/Y/GMF6KXVaY31FVs/9cbKCjFtKBVPRMTqTCxbNXAy/5fn+wpNobaCOA/7H3A8ZBJy37am/7SuUUZyaS3BFgNTsI9KLoAc3F2fvESJanSCs7fCBEkamKw7tlvpFHKB+Fh4m1ABBqvH5CZPWVBJXu14Y+Q8bZrriH/3H8GLITY= Received: by 10.70.113.16 with SMTP id l16mr13948631wxc.1165905432389; Mon, 11 Dec 2006 22:37:12 -0800 (PST) Received: by 10.70.54.2 with HTTP; Mon, 11 Dec 2006 22:37:12 -0800 (PST) Message-ID: Date: Tue, 12 Dec 2006 08:37:12 +0200 From: "Conrad Burger" To: freebsd-java@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Cc: Subject: Compiling JAVA 6 on FreeBSD X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 06:37:14 -0000 Hi Has anyone tried to compile JDK6 from source on FreeBSD? And when will the diablo binaries for JDK6 be available? Regards Conrad From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 06:44:11 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3130D16A412; Tue, 12 Dec 2006 06:44:11 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.FreeBSD.org (Postfix) with ESMTP id C8F7643CA4; Tue, 12 Dec 2006 06:42:49 +0000 (GMT) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (critter.freebsd.dk [192.168.48.2]) by phk.freebsd.dk (Postfix) with ESMTP id CE2611747B; Tue, 12 Dec 2006 06:44:08 +0000 (UTC) To: Bruce Evans From: "Poul-Henning Kamp" In-Reply-To: Your message of "Tue, 12 Dec 2006 16:54:19 +1100." <20061212160016.W56465@delplex.bde.org> Date: Tue, 12 Dec 2006 06:44:03 +0000 Message-ID: <32874.1165905843@critter.freebsd.dk> Sender: phk@critter.freebsd.dk Cc: "Arne H. Juul" , Daniel Eischen , David Xu , freebsd-arch@FreeBSD.org, Kostik Belousov , freebsd-java@FreeBSD.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 06:44:11 -0000 In message <20061212160016.W56465@delplex.bde.org>, Bruce Evans writes: >On Mon, 11 Dec 2006, Daniel Eischen wrote: >It's probably a nightmare in the kernel too. close() starts looking >like revoke(), and revoke() has large problems and bugs in this area. There is the distinctive difference that revoke() operates on a name and close() on a filedescriptor, but otherwise I agree. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 13:21:20 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B479916A417; Tue, 12 Dec 2006 13:21:20 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 52E3443DBA; Tue, 12 Dec 2006 13:17:24 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBCDIWqu003219; Tue, 12 Dec 2006 08:18:33 -0500 (EST) Date: Tue, 12 Dec 2006 08:18:32 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: "Arne H. Juul" In-Reply-To: Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Tue, 12 Dec 2006 08:18:33 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: Kostik Belousov , freebsd-arch@freebsd.org, David Xu , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 13:21:20 -0000 On Mon, 11 Dec 2006, Daniel Eischen wrote: > On Tue, 12 Dec 2006, Arne H. Juul wrote: > >> On Tue, 12 Dec 2006, David Xu wrote: >>> On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: >>> >>>> This is exactly the sort of issue that should be solved by the >>>> thread library / kernel threads implementation and not in every >>>> threaded application that needs it, in my view. >>>> >>> It should not be done in new thread library, do you want a bloat >>> and error-prone thread library ? Instead if this semantic is really >>> necessary, it should be done in kernel. >> >> Well, it depends on the alternatives. >> If a clean kernel implementation is possible - yes please, of course. >> If only a complex, error-prone kernel implementation is possible, >> I would prefer to have the complexity in the thread library. > > Hacking libthr or libpthread to do this for you is not > an option. They would then look like libc_r since all > fd's accesses would need to be wrapped. If this needs > to be done, it must be in the kernel. It's also couldn't be entirely solved by fixing it in the threads library. You could still have a non-threaded application that waits on a read operation, but receives a signal and closes the socket in the signal handler. -- DE From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 13:59:23 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B42D916A492; Tue, 12 Dec 2006 13:59:23 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from fw.zoral.com.ua (fw.zoral.com.ua [213.186.206.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id 993A343D36; Tue, 12 Dec 2006 13:56:03 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id kBCDumHp001088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 Dec 2006 15:56:48 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8) with ESMTP id kBCDumka019314; Tue, 12 Dec 2006 15:56:48 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8/Submit) id kBCDulHY019313; Tue, 12 Dec 2006 15:56:47 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 12 Dec 2006 15:56:47 +0200 From: Kostik Belousov To: Daniel Eischen Message-ID: <20061212135647.GK311@deviant.kiev.zoral.com.ua> References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5uO961YFyoDlzFnP" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on fw.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL, UNPARSEABLE_RELAY autolearn=no version=3.1.4 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on fw.zoral.com.ua Cc: freebsd-arch@freebsd.org, "Arne H. Juul" , David Xu , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 13:59:24 -0000 --5uO961YFyoDlzFnP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 12, 2006 at 08:18:32AM -0500, Daniel Eischen wrote: > On Mon, 11 Dec 2006, Daniel Eischen wrote: >=20 > >On Tue, 12 Dec 2006, Arne H. Juul wrote: > > > >>On Tue, 12 Dec 2006, David Xu wrote: > >>>On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: > >>> > >>>>This is exactly the sort of issue that should be solved by the > >>>>thread library / kernel threads implementation and not in every > >>>>threaded application that needs it, in my view. > >>>> > >>>It should not be done in new thread library, do you want a bloat > >>>and error-prone thread library ? Instead if this semantic is really > >>>necessary, it should be done in kernel. > >> > >>Well, it depends on the alternatives. > >>If a clean kernel implementation is possible - yes please, of course. > >>If only a complex, error-prone kernel implementation is possible, > >>I would prefer to have the complexity in the thread library. > > > >Hacking libthr or libpthread to do this for you is not > >an option. They would then look like libc_r since all > >fd's accesses would need to be wrapped. If this needs > >to be done, it must be in the kernel. >=20 > It's also couldn't be entirely solved by fixing it in the > threads library. You could still have a non-threaded > application that waits on a read operation, but receives > a signal and closes the socket in the signal handler. This is not the problem. The read (as syscall being executed) is aborted when signal is delivered. Original poster considered situation where read() is active (in particular, f_count of struct file is incremented by fget, that caused the reported behaviour). --5uO961YFyoDlzFnP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFFfrUeC3+MBN1Mb4gRAhCXAKCJxzJsY0KFk3GYwKTqTSC2ZLWybQCgjA8M Lfnc6O8F144t8wd826jDuX0= =6wvE -----END PGP SIGNATURE----- --5uO961YFyoDlzFnP-- From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 14:24:39 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3568F16A4C8; Tue, 12 Dec 2006 14:24:39 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 21B7B4403A; Tue, 12 Dec 2006 14:07:41 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBCE8UAQ020207; Tue, 12 Dec 2006 09:08:30 -0500 (EST) Date: Tue, 12 Dec 2006 09:08:30 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Kostik Belousov In-Reply-To: <20061212135647.GK311@deviant.kiev.zoral.com.ua> Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> <20061212135647.GK311@deviant.kiev.zoral.com.ua> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Tue, 12 Dec 2006 09:08:31 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: freebsd-arch@freebsd.org, "Arne H. Juul" , David Xu , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 14:24:39 -0000 On Tue, 12 Dec 2006, Kostik Belousov wrote: > On Tue, Dec 12, 2006 at 08:18:32AM -0500, Daniel Eischen wrote: >> It's also couldn't be entirely solved by fixing it in the >> threads library. You could still have a non-threaded >> application that waits on a read operation, but receives >> a signal and closes the socket in the signal handler. > > This is not the problem. The read (as syscall being executed) is aborted > when signal is delivered. Original poster considered situation where > read() is active (in particular, f_count of struct file is incremented > by fget, that caused the reported behaviour). Even when SA_RESTART is set? -- DE From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 14:34:39 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0367216A51C; Tue, 12 Dec 2006 14:34:39 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FB3044407; Tue, 12 Dec 2006 14:17:59 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBCEJ94W000917; Tue, 12 Dec 2006 09:19:09 -0500 (EST) Date: Tue, 12 Dec 2006 09:19:09 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: "Arne H. Juul" In-Reply-To: Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Tue, 12 Dec 2006 09:19:10 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: Kostik Belousov , freebsd-arch@freebsd.org, David Xu , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 14:34:39 -0000 On Mon, 11 Dec 2006, Daniel Eischen wrote: > > Common sense leads me to think that a close() should release > threads in IO operations (reads/writes/selects/polls) and > return EBADF or something appropriate. At least when behavior > is not dictated by POSIX or other historical/defactor behavior. BTW, I tested the behavior on Solaris. Solaris returns EBADF with the posted sample C program. -- DE From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 14:38:19 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A5BF316A416; Tue, 12 Dec 2006 14:38:19 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from relay02.kiev.sovam.com (relay02.kiev.sovam.com [62.64.120.197]) by mx1.FreeBSD.org (Postfix) with ESMTP id DF0C343DA8; Tue, 12 Dec 2006 14:24:05 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from [212.82.216.227] (helo=fw.zoral.com.ua) by relay02.kiev.sovam.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.60) (envelope-from ) id 1Gu8ZE-000GNm-Uw; Tue, 12 Dec 2006 16:25:21 +0200 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id kBCEOuFg003721 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 Dec 2006 16:24:57 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8) with ESMTP id kBCEOutV020035; Tue, 12 Dec 2006 16:24:56 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8/Submit) id kBCEOsKu020034; Tue, 12 Dec 2006 16:24:54 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 12 Dec 2006 16:24:54 +0200 From: Kostik Belousov To: Daniel Eischen Message-ID: <20061212142454.GL311@deviant.kiev.zoral.com.ua> References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> <20061212135647.GK311@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="0FRtVia6Q6lt+M0P" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on fw.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL, UNPARSEABLE_RELAY autolearn=no version=3.1.4 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on fw.zoral.com.ua X-Scanner-Signature: b22dd54e5e410b0526d530b08df0ebb5 X-DrWeb-checked: yes X-SpamTest-Envelope-From: kostikbel@gmail.com X-SpamTest-Group-ID: 00000000 X-SpamTest-Info: Profiles 594 [Dec 12 2006] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {received from trusted relay: not dialup} X-SpamTest-Method: none X-SpamTest-Method: Local Lists X-SpamTest-Rate: 0 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release Cc: freebsd-arch@freebsd.org, "Arne H. Juul" , David Xu , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 14:38:19 -0000 --0FRtVia6Q6lt+M0P Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 12, 2006 at 09:08:30AM -0500, Daniel Eischen wrote: > On Tue, 12 Dec 2006, Kostik Belousov wrote: >=20 > >On Tue, Dec 12, 2006 at 08:18:32AM -0500, Daniel Eischen wrote: > >>It's also couldn't be entirely solved by fixing it in the > >>threads library. You could still have a non-threaded > >>application that waits on a read operation, but receives > >>a signal and closes the socket in the signal handler. > > > >This is not the problem. The read (as syscall being executed) is aborted > >when signal is delivered. Original poster considered situation where > >read() is active (in particular, f_count of struct file is incremented > >by fget, that caused the reported behaviour). >=20 > Even when SA_RESTART is set? Yes. Since SA_RESTART causes syscall to be reissued, read() would fail with EBADFD on its own. --0FRtVia6Q6lt+M0P Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFFfru1C3+MBN1Mb4gRAmT9AJ0bq2u672FpTLNZylM4pQ21mGT4uACg6x5N e6Kn5izt2nTwOeKXkeC4iwQ= =h6zM -----END PGP SIGNATURE----- --0FRtVia6Q6lt+M0P-- From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 15:29:27 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5D6D316A4D2 for ; Tue, 12 Dec 2006 15:29:27 +0000 (UTC) (envelope-from girgen@FreeBSD.org) Received: from melon.pingpong.net (melon.pingpong.net [195.178.174.161]) by mx1.FreeBSD.org (Postfix) with ESMTP id 65C2543E77 for ; Tue, 12 Dec 2006 15:24:09 +0000 (GMT) (envelope-from girgen@FreeBSD.org) Received: from localhost (localhost.pingpong.net [127.0.0.1]) by melon.pingpong.net (Postfix) with ESMTP id 8761C5087D; Tue, 12 Dec 2006 16:25:42 +0100 (CET) Received: from melon.pingpong.net ([127.0.0.1]) by localhost (melon.pingpong.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 58303-01-10; Tue, 12 Dec 2006 16:25:42 +0100 (CET) Received: from [192.168.1.187] (unknown [213.136.40.204]) by melon.pingpong.net (Postfix) with ESMTP id 220675087C; Tue, 12 Dec 2006 16:25:41 +0100 (CET) Date: Tue, 12 Dec 2006 16:25:29 +0100 From: Palle Girgensohn To: Nikos Ntarmos , freebsd-java@freebsd.org Message-ID: In-Reply-To: <20061110203714.GA89006@ace.b020.ceid.upatras.gr> References: <20061110203714.GA89006@ace.b020.ceid.upatras.gr> X-Mailer: Mulberry/4.0.6 (Linux/x86) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: by amavisd-new at pingpong.net Cc: Subject: Re: Performance of Java on FBSD vs. others... X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 15:29:27 -0000 Hi! This mail thread died a while back. Any news, did you succeed in getting it faster? We are experiencing similar slowness with tomcat - it seems it runs much faster on Linux. I have not done any tests yet, it is just a feeling, but developers here are already moaning and want to replace FreeBSD with Linux. I'd love to get the BSD boxes running as fast instead... Any input appreciated. Regards, Palle --On fredag, november 10, 2006 22.37.14 +0200 Nikos Ntarmos wrote: > Hi all. > > I've spent the last week or so running the exact same Java code on the > exact same hardware, under different OSs. The code i'm running is > heavily cpu-bound (no i/o other than light logging), uses a lot of > memory (~1G), and does not rely on threading libraries (i.e. the program > creates two threads when it starts and that's all about it). > > I'm running a small and a large version of the program (wrt memory > requirements and run-time). The average execution time for the small > version goes from ~200'' under win32, to ~220'' under linux, and to > ~800'' under freebsd. For the large version, the numbers are ~1600'' > for win32, ~1800'' for linux, and ~4700'' for freebsd. > > This is all on a 1.7GHz Pentium-M laptop with 1G RAM (dmesg at > http://ntarmos.dyndns.org/Computers/dmesgs/ace.dmesg), running -current > as of Sep 29. The JDKs tested are diablo-jdk15 (1.5.0.07.01) and > sun-jdk15 (1.5.0p6) for FreeBSD, and sun-jdk15 (1.5.0_07) for linux and > win32. > > Does anybody else see such a performance drop across OSs? Is there some > specific (known) reason why freebsd lags behind the other two OSs by > this 3x-4x factor? Any pointers as to some (sysctl or other) knob I've > missed? > > Thanks in advance. > > \n\n > _______________________________________________ > freebsd-java@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-java > To unsubscribe, send any mail to "freebsd-java-unsubscribe@freebsd.org" From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 19:31:37 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 054D716A407 for ; Tue, 12 Dec 2006 19:31:37 +0000 (UTC) (envelope-from glewis@eyesbeyond.com) Received: from misty.eyesbeyond.com (gerbercreations.com [71.39.140.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id AE64E43CEE for ; Tue, 12 Dec 2006 19:15:00 +0000 (GMT) (envelope-from glewis@eyesbeyond.com) Received: from misty.eyesbeyond.com (localhost.eyesbeyond.com [127.0.0.1]) by misty.eyesbeyond.com (8.13.1/8.13.3) with ESMTP id kBCJHCY5000613; Tue, 12 Dec 2006 11:17:12 -0800 (PST) (envelope-from glewis@eyesbeyond.com) Received: (from glewis@localhost) by misty.eyesbeyond.com (8.13.1/8.13.3/Submit) id kBCJHBLN000612; Tue, 12 Dec 2006 11:17:11 -0800 (PST) (envelope-from glewis@eyesbeyond.com) X-Authentication-Warning: misty.eyesbeyond.com: glewis set sender to glewis@eyesbeyond.com using -f Date: Tue, 12 Dec 2006 11:17:10 -0800 From: Greg Lewis To: "Arne H. Juul" Message-ID: <20061212191710.GA483@misty.eyesbeyond.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i Cc: freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 19:31:37 -0000 On Mon, Dec 11, 2006 at 03:46:12PM +0100, Arne H. Juul wrote: > I've had problems with some tests hanging on FreeBSD 6/amd64. This happens > both with diablo-1.5.0_07-b01 and the java/jdk15 compiled from ports. > > After much digging we've determined that the root cause is that > the guarantee in the socket.close() API, see the documentation at > http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#close() > isn't fulfulled - the thread blocked in I/O on the socket doesn't wake up. > > Here's a pretty small test program that demonstrates the problem (given > that you're running sshd on port 22, if not change the port number to > something that the program can connect to). Is this a known problem? > Does it happen for everybody on FreeBSD 6? This is, unfortunately, a known problem. See http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/97921 -- Greg Lewis Email : glewis@eyesbeyond.com Eyes Beyond Web : http://www.eyesbeyond.com Information Technology FreeBSD : glewis@FreeBSD.org From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 20:49:56 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13F9716A407; Tue, 12 Dec 2006 20:49:56 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E45443CF9; Tue, 12 Dec 2006 20:48:26 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBCKnmnT006945; Tue, 12 Dec 2006 15:49:48 -0500 (EST) Date: Tue, 12 Dec 2006 15:49:48 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Poul-Henning Kamp In-Reply-To: <32874.1165905843@critter.freebsd.dk> Message-ID: References: <32874.1165905843@critter.freebsd.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Tue, 12 Dec 2006 15:49:50 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) Cc: "Arne H. Juul" , Bruce Evans , David Xu , freebsd-arch@freebsd.org, Kostik Belousov , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 20:49:56 -0000 On Tue, 12 Dec 2006, Poul-Henning Kamp wrote: > In message <20061212160016.W56465@delplex.bde.org>, Bruce Evans writes: >> On Mon, 11 Dec 2006, Daniel Eischen wrote: > >> It's probably a nightmare in the kernel too. close() starts looking >> like revoke(), and revoke() has large problems and bugs in this area. > > There is the distinctive difference that revoke() operates on a name > and close() on a filedescriptor, but otherwise I agree. Well, if threads waiting on IO are interruptable by signals, can't we make a new signal that's only used by the kernel and send it to all threads waiting on IO for that descriptor? When it gets out to actually setup the signal handler, it just resumes like it is returning from an SA_RESTART signal handler (which according to another posting would reissue the IO command and get EBADF). -- Dan From owner-freebsd-java@FreeBSD.ORG Tue Dec 12 23:30:13 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from localhost.my.domain (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 73A0D16A51E; Tue, 12 Dec 2006 23:30:13 +0000 (UTC) (envelope-from davidxu@freebsd.org) From: David Xu To: Daniel Eischen Date: Wed, 13 Dec 2006 07:30:10 +0800 User-Agent: KMail/1.8.2 References: <32874.1165905843@critter.freebsd.dk> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612130730.10973.davidxu@freebsd.org> Cc: "Arne H. Juul" , Bruce Evans , Poul-Henning Kamp , freebsd-arch@freebsd.org, Kostik Belousov , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Dec 2006 23:30:13 -0000 On Wednesday 13 December 2006 04:49, Daniel Eischen wrote: > On Tue, 12 Dec 2006, Poul-Henning Kamp wrote: > > In message <20061212160016.W56465@delplex.bde.org>, Bruce Evans writes: > >> On Mon, 11 Dec 2006, Daniel Eischen wrote: > >> > >> It's probably a nightmare in the kernel too. close() starts looking > >> like revoke(), and revoke() has large problems and bugs in this area. > > > > There is the distinctive difference that revoke() operates on a name > > and close() on a filedescriptor, but otherwise I agree. > > Well, if threads waiting on IO are interruptable by signals, > can't we make a new signal that's only used by the kernel > and send it to all threads waiting on IO for that descriptor? > When it gets out to actually setup the signal handler, it > just resumes like it is returning from an SA_RESTART signal > handler (which according to another posting would reissue > the IO command and get EBADF). Stop using signal, it is slow for threaded process, first you don't know which threads are using the descriptor, second, you have to run long code path in kernel signal code to find and deliver the signals to all interested threads, that is too expensive for benchmark like apache benchmark. David Xu From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 01:59:49 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5B5D116A500 for ; Wed, 13 Dec 2006 01:59:49 +0000 (UTC) (envelope-from arnej@pvv.ntnu.no) Received: from decibel.pvv.ntnu.no (decibel.pvv.ntnu.no [129.241.210.179]) by mx1.FreeBSD.org (Postfix) with ESMTP id E9C6F43CA8 for ; Wed, 13 Dec 2006 01:58:22 +0000 (GMT) (envelope-from arnej@pvv.ntnu.no) Received: from arnej by decibel.pvv.ntnu.no with local (Exim 4.60) (envelope-from ) id 1GuJPM-00066D-Ip; Wed, 13 Dec 2006 02:59:45 +0100 Date: Wed, 13 Dec 2006 02:59:44 +0100 (CET) From: "Arne H. Juul" To: Greg Lewis In-Reply-To: <20061212191710.GA483@misty.eyesbeyond.com> Message-ID: References: <20061212191710.GA483@misty.eyesbeyond.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 01:59:49 -0000 On Tue, 12 Dec 2006, Greg Lewis wrote: > This is, unfortunately, a known problem. See > > http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/97921 Yeah, I got redirected there by somebody else too; it seems I've managed to spark lots of debate now at least. Copying linux_close.c and thereby working around the problem in the Java VM looks like it solves my immediate problem, and could probably be integrated into the diablo jdk too? I've tried the C version of the test program and it behaves "badly" on Linux, FreeBSD 6, and NetBSD at least, so patching over it is probably the best medium-term solution. - Arne H. J. From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 02:02:28 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 62DA416A407 for ; Wed, 13 Dec 2006 02:02:28 +0000 (UTC) (envelope-from indigo23@gmail.com) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.243]) by mx1.FreeBSD.org (Postfix) with ESMTP id AF65643CA6 for ; Wed, 13 Dec 2006 02:01:01 +0000 (GMT) (envelope-from indigo23@gmail.com) Received: by an-out-0708.google.com with SMTP id c24so4178ana for ; Tue, 12 Dec 2006 18:02:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=TJLSq3aVj9YOg5uRtUQ+H1qPmwNjoCw00FZSaKPpbDMXucP1TyAAdG4tnf2+6nRoErmO5+wHyyaAjiljPaUIXWNSGtLKbxJU8aQzi0sR87WiY0UWDYz2BFVlpIBoI5fdEdmpI2StAdO+Iwf0KpTnZSG8vaNkQdjzXXNQbdQIh3I= Received: by 10.100.33.14 with SMTP id g14mr171979ang.1165975346843; Tue, 12 Dec 2006 18:02:26 -0800 (PST) Received: by 10.100.33.20 with HTTP; Tue, 12 Dec 2006 18:02:26 -0800 (PST) Message-ID: <6f50eac40612121802j4e387bf4ra9aeabf81acf32bc@mail.gmail.com> Date: Tue, 12 Dec 2006 21:02:26 -0500 From: "Indigo 23" To: freebsd-java@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: Re: Compiling JAVA 6 on FreeBSD X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 02:02:28 -0000 > Hi > > Has anyone tried to compile JDK6 from source on FreeBSD? > And when will the diablo binaries for JDK6 be available? > > Regards > Conrad I'm also wondering when diablo binaries for JDK6 will be available for FreeBSD...Anyone have any ideas? From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 03:28:52 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9197C16A403; Wed, 13 Dec 2006 03:28:52 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailout1.pacific.net.au (mailout1-3.pacific.net.au [61.8.2.210]) by mx1.FreeBSD.org (Postfix) with ESMTP id 67BE443CA7; Wed, 13 Dec 2006 03:27:25 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout1.pacific.net.au (Postfix) with ESMTP id 11ABE5A3F5C; Wed, 13 Dec 2006 14:28:17 +1100 (EST) Received: from besplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailproxy1.pacific.net.au (Postfix) with ESMTP id 817638C0C; Wed, 13 Dec 2006 14:28:15 +1100 (EST) Date: Wed, 13 Dec 2006 14:28:15 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: David Xu In-Reply-To: <200612130730.10973.davidxu@freebsd.org> Message-ID: <20061213141257.J2006@besplex.bde.org> References: <32874.1165905843@critter.freebsd.dk> <200612130730.10973.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: "Arne H. Juul" , Daniel Eischen , Poul-Henning Kamp , freebsd-arch@freebsd.org, Kostik Belousov , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 03:28:52 -0000 On Wed, 13 Dec 2006, David Xu wrote: > On Wednesday 13 December 2006 04:49, Daniel Eischen wrote: >> On Tue, 12 Dec 2006, Poul-Henning Kamp wrote: >>> In message <20061212160016.W56465@delplex.bde.org>, Bruce Evans writes: >>>> On Mon, 11 Dec 2006, Daniel Eischen wrote: >>>> >>>> It's probably a nightmare in the kernel too. close() starts looking >>>> like revoke(), and revoke() has large problems and bugs in this area. >>> >>> There is the distinctive difference that revoke() operates on a name >>> and close() on a filedescriptor, but otherwise I agree. >> >> Well, if threads waiting on IO are interruptable by signals, >> can't we make a new signal that's only used by the kernel >> and send it to all threads waiting on IO for that descriptor? >> When it gets out to actually setup the signal handler, it >> just resumes like it is returning from an SA_RESTART signal >> handler (which according to another posting would reissue >> the IO command and get EBADF). > > Stop using signal, it is slow for threaded process, first you don't > know which threads are using the descriptor, second, you have > to run long code path in kernel signal code to find and deliver > the signals to all interested threads, that is too expensive for > benchmark like apache benchmark. A signal would be fast enough for revoke() since revoke() is not used much, and would work well if the signal could be sent, and is unmaskable, and all device drivers catch signals (oops, all of them act like applications whose signal catching function just sets a flag, except while they sleep, so they have the usual problems with just setting a flag -- they may run for too long before actually using the setting). However, I think there is no way to determine which threads are using an fd short of doing the equivalent of fstat(1) searching throuhj kmem. Kernel data structures just aren't set up to do this search efficiently, and shouldn't be bloated to do it. For close() on non-devices, there is the additional problem of infinite disk waits due to things like nfs servers down and bugs. Then signals don't work and you wouldn't like close() by a thread trying to clean up the problem to hang too. Otherwise close()/revoke() would be a good way to cancel an infinite disk wait. Bruce From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 07:06:36 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 014E316A403; Wed, 13 Dec 2006 07:06:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from digger1.defence.gov.au (digger1.defence.gov.au [203.5.217.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5B59D43CA0; Wed, 13 Dec 2006 07:05:07 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from ednmsw501.dsto.defence.gov.au (ednmsw501.dsto.defence.gov.au [131.185.2.150]) by digger1.defence.gov.au (8.13.8/8.13.8) with ESMTP id kBD6xVLV029681; Wed, 13 Dec 2006 17:29:31 +1030 (CST) Received: from ednux519.dsto.defence.gov.au (unverified) by ednmsw501.dsto.defence.gov.au (Content Technologies SMTPRS 4.3.17) with ESMTP id ; Wed, 13 Dec 2006 17:36:28 +1030 Received: from ednex510.dsto.defence.gov.au (ednex510.dsto.defence.gov.au [131.185.2.170]) by ednux519.dsto.defence.gov.au (8.13.6+Sun/8.13.6) with ESMTP id kBD3CpiR015368; Wed, 13 Dec 2006 13:42:52 +1030 (CST) Received: from ednexdev.dsto.defence.gov.au ([131.185.2.82]) by ednex510.dsto.defence.gov.au with Microsoft SMTPSVC(6.0.3790.1830); Wed, 13 Dec 2006 13:50:39 +1030 Received: from mail pickup service by ednexdev.dsto.defence.gov.au with Microsoft SMTPSVC; Wed, 13 Dec 2006 13:50:30 +1030 Received: from ednmsw506.dsto.defence.gov.au ([131.185.2.88]) by ednexdev.dsto.defence.gov.au with Microsoft SMTPSVC(6.0.3790.1830); Wed, 13 Dec 2006 00:37:09 +1030 Received: from digger1.defence.gov.au (unverified) by ednmsw506.dsto.defence.gov.au (Content Technologies SMTPRS 4.3.14) with ESMTP id for ; Wed, 13 Dec 2006 00:37:09 +1030 Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by digger1.defence.gov.au (8.13.8/8.13.8) with ESMTP id kBCE07N9018736 for ; Wed, 13 Dec 2006 00:30:07 +1030 (CST) Received: from hub.freebsd.org (hub.freebsd.org [69.147.83.54]) by mx2.freebsd.org (Postfix) with ESMTP id 95F4E14C9C9; Tue, 12 Dec 2006 13:59:33 +0000 (GMT) (envelope-from owner-freebsd-arch@freebsd.org) Received: from hub.freebsd.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 9EB0616A57C; Tue, 12 Dec 2006 13:59:33 +0000 (UTC) (envelope-from owner-freebsd-arch@freebsd.org) X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B42D916A492; Tue, 12 Dec 2006 13:59:23 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from fw.zoral.com.ua (fw.zoral.com.ua [213.186.206.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id 993A343D36; Tue, 12 Dec 2006 13:56:03 +0000 (GMT) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by fw.zoral.com.ua (8.13.4/8.13.4) with ESMTP id kBCDumHp001088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 12 Dec 2006 15:56:48 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8) with ESMTP id kBCDumka019314; Tue, 12 Dec 2006 15:56:48 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.13.8/8.13.8/Submit) id kBCDulHY019313; Tue, 12 Dec 2006 15:56:47 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Tue, 12 Dec 2006 15:56:47 +0200 From: Kostik Belousov To: Daniel Eischen Message-ID: <20061212135647.GK311@deviant.kiev.zoral.com.ua> References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="5uO961YFyoDlzFnP" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i X-Virus-Scanned: ClamAV version 0.88.4, clamav-milter version 0.88.4 on fw.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=1.4 required=5.0 tests=SPF_NEUTRAL, UNPARSEABLE_RELAY autolearn=no version=3.1.4 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.1.4 (2006-07-25) on fw.zoral.com.ua X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Sender: owner-freebsd-arch@freebsd.org Errors-To: owner-freebsd-arch@freebsd.org X-OriginalArrivalTime: 12 Dec 2006 14:07:09.0321 (UTC) FILETIME=[D00FDF90:01C71DF6] X-TM-AS-Product-Ver: SMEX-7.0.0.1345-3.6.1039-14784.003 X-TM-AS-Result: No--20.528900-8.000000-31 Cc: freebsd-java@freebsd.org, "Arne H. Juul" , David Xu , freebsd-arch@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 07:06:36 -0000 --5uO961YFyoDlzFnP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Dec 12, 2006 at 08:18:32AM -0500, Daniel Eischen wrote: > On Mon, 11 Dec 2006, Daniel Eischen wrote: >=20 > >On Tue, 12 Dec 2006, Arne H. Juul wrote: > > > >>On Tue, 12 Dec 2006, David Xu wrote: > >>>On Tuesday 12 December 2006 06:34, Arne H. Juul wrote: > >>> > >>>>This is exactly the sort of issue that should be solved by the > >>>>thread library / kernel threads implementation and not in every > >>>>threaded application that needs it, in my view. > >>>> > >>>It should not be done in new thread library, do you want a bloat > >>>and error-prone thread library ? Instead if this semantic is really > >>>necessary, it should be done in kernel. > >> > >>Well, it depends on the alternatives. > >>If a clean kernel implementation is possible - yes please, of course. > >>If only a complex, error-prone kernel implementation is possible, > >>I would prefer to have the complexity in the thread library. > > > >Hacking libthr or libpthread to do this for you is not > >an option. They would then look like libc_r since all > >fd's accesses would need to be wrapped. If this needs > >to be done, it must be in the kernel. >=20 > It's also couldn't be entirely solved by fixing it in the > threads library. You could still have a non-threaded > application that waits on a read operation, but receives > a signal and closes the socket in the signal handler. This is not the problem. The read (as syscall being executed) is aborted when signal is delivered. Original poster considered situation where read() is active (in particular, f_count of struct file is incremented by fget, that caused the reported behaviour). --5uO961YFyoDlzFnP Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (FreeBSD) iD8DBQFFfrUeC3+MBN1Mb4gRAhCXAKCJxzJsY0KFk3GYwKTqTSC2ZLWybQCgjA8M Lfnc6O8F144t8wd826jDuX0= =6wvE -----END PGP SIGNATURE----- --5uO961YFyoDlzFnP-- From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 07:12:26 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 2B4B416A407 for ; Wed, 13 Dec 2006 07:12:26 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outQ.internet-mail-service.net (outQ.internet-mail-service.net [216.240.47.240]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7123243CCE for ; Wed, 13 Dec 2006 07:10:39 +0000 (GMT) (envelope-from julian@elischer.org) Received: from shell.idiom.com (HELO idiom.com) (216.240.47.20) by out.internet-mail-service.net (qpsmtpd/0.32) with ESMTP; Tue, 12 Dec 2006 22:57:09 -0800 Received: from [192.168.2.4] (home.elischer.org [216.240.48.38]) by idiom.com (8.12.11/8.12.11) with ESMTP id kBD7C23r098829; Tue, 12 Dec 2006 23:12:03 -0800 (PST) (envelope-from julian@elischer.org) Message-ID: <457FA7C0.408@elischer.org> Date: Tue, 12 Dec 2006 23:12:00 -0800 From: Julian Elischer User-Agent: Thunderbird 1.5.0.8 (Macintosh/20061025) MIME-Version: 1.0 To: Bruce Evans References: <32874.1165905843@critter.freebsd.dk> <200612130730.10973.davidxu@freebsd.org> <20061213141257.J2006@besplex.bde.org> In-Reply-To: <20061213141257.J2006@besplex.bde.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: "Arne H. Juul" , Daniel Eischen , Poul-Henning Kamp , David Xu , freebsd-arch@freebsd.org, Kostik Belousov , freebsd-java@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 07:12:26 -0000 Bruce Evans wrote: > On Wed, 13 Dec 2006, David Xu wrote: > >> On Wednesday 13 December 2006 04:49, Daniel Eischen wrote: >>> On Tue, 12 Dec 2006, Poul-Henning Kamp wrote: >>>> In message <20061212160016.W56465@delplex.bde.org>, Bruce Evans writes: >>>>> On Mon, 11 Dec 2006, Daniel Eischen wrote: >>>>> >>>>> It's probably a nightmare in the kernel too. close() starts looking >>>>> like revoke(), and revoke() has large problems and bugs in this area. >>>> >>>> There is the distinctive difference that revoke() operates on a name >>>> and close() on a filedescriptor, but otherwise I agree. >>> >>> Well, if threads waiting on IO are interruptable by signals, >>> can't we make a new signal that's only used by the kernel >>> and send it to all threads waiting on IO for that descriptor? >>> When it gets out to actually setup the signal handler, it >>> just resumes like it is returning from an SA_RESTART signal >>> handler (which according to another posting would reissue >>> the IO command and get EBADF). >> >> Stop using signal, it is slow for threaded process, first you don't >> know which threads are using the descriptor, second, you have >> to run long code path in kernel signal code to find and deliver >> the signals to all interested threads, that is too expensive for >> benchmark like apache benchmark. > > A signal would be fast enough for revoke() since revoke() is not used > much, and would work well if the signal could be sent, and is unmaskable, > and all device drivers catch signals (oops, all of them act like > applications whose signal catching function just sets a flag, except > while they sleep, so they have the usual problems with just setting a > flag -- they may run for too long before actually using the setting). > However, I think there is no way to determine which threads are using > an fd short of doing the equivalent of fstat(1) searching throuhj kmem. > Kernel data structures just aren't set up to do this search efficiently, > and shouldn't be bloated to do it. that's processes.. which thread in the process is the one that is currently waiting on the socket? > > For close() on non-devices, there is the additional problem of infinite > disk waits due to things like nfs servers down and bugs. Then signals > don't work and you wouldn't like close() by a thread trying to clean > up the problem to hang too. Otherwise close()/revoke() would be a good > way to cancel an infinite disk wait. > > Bruce > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org" From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 11:28:29 2006 Return-Path: X-Original-To: freebsd-java@FreeBSD.org Delivered-To: freebsd-java@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0047E16A508; Wed, 13 Dec 2006 11:28:28 +0000 (UTC) (envelope-from bde@zeta.org.au) Received: from mailout2.pacific.net.au (mailout2-3.pacific.net.au [61.8.2.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id A552743CF7; Wed, 13 Dec 2006 11:26:38 +0000 (GMT) (envelope-from bde@zeta.org.au) Received: from mailproxy1.pacific.net.au (mailproxy1.pacific.net.au [61.8.2.162]) by mailout2.pacific.net.au (Postfix) with ESMTP id 3B070111229; Wed, 13 Dec 2006 22:28:04 +1100 (EST) Received: from besplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailproxy1.pacific.net.au (Postfix) with ESMTP id C9A3E8C0B; Wed, 13 Dec 2006 22:28:03 +1100 (EST) Date: Wed, 13 Dec 2006 22:28:03 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Julian Elischer In-Reply-To: <457FA7C0.408@elischer.org> Message-ID: <20061213220952.H792@besplex.bde.org> References: <32874.1165905843@critter.freebsd.dk> <200612130730.10973.davidxu@freebsd.org> <20061213141257.J2006@besplex.bde.org> <457FA7C0.408@elischer.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: "Arne H. Juul" , Daniel Eischen , Poul-Henning Kamp , David Xu , freebsd-arch@FreeBSD.org, Kostik Belousov , freebsd-java@FreeBSD.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 11:28:29 -0000 On Tue, 12 Dec 2006, Julian Elischer wrote: > Bruce Evans wrote: >> A signal would be fast enough for revoke() since revoke() is not used >> much, and would work well if the signal could be sent, and is unmaskable, >> and all device drivers catch signals (oops, all of them act like >> ... >> However, I think there is no way to determine which threads are using >> an fd short of doing the equivalent of fstat(1) searching throuhj kmem. >> Kernel data structures just aren't set up to do this search efficiently, >> and shouldn't be bloated to do it. > > that's processes.. which thread in the process is the one that is currently > waiting on the socket? Do you mean that this wouldn't work the signal would need to be per-thread but signals are per-process? Aren't there per-thread signals now? It's not just one thread, at least for general files. There can be any number. I just remembered that SIGIO delivery has problems near here. There is some i/o on a device, and the kernel has to figure out all open fd's on the device with O_ASYNC set on the open file of the fd. It has difficulty doing this, even with some data structures pointing from the device back to the processes. In theory there can be any number of fd's with the same open file and the signal should be broadcast to the processes owning these fd's). This is still simpler than signaling threads in i/o functions since the signal is broadcast. I said that something like fstat(1) groping in kmem is needed to find all the relevant threads. That is nowhere near enough -- fstat cannot tell which threads are currently in i/o functions. Something closer to what debuggers do is needed -- stop all threads and stack trace them all to see where they are :-). Bruce From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 12:10:54 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from localhost.my.domain (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id B4BE516A416; Wed, 13 Dec 2006 12:10:53 +0000 (UTC) (envelope-from davidxu@freebsd.org) From: David Xu To: freebsd-java@freebsd.org, Daniel Eischen Date: Wed, 13 Dec 2006 20:10:49 +0800 User-Agent: KMail/1.8.2 References: <32874.1165905843@critter.freebsd.dk> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200612132010.49601.davidxu@freebsd.org> Cc: Kostik Belousov , Poul-Henning Kamp , "Arne H. Juul" , Bruce Evans , freebsd-arch@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 12:10:54 -0000 On Wednesday 13 December 2006 04:49, Daniel Eischen wrote: > On Tue, 12 Dec 2006, Poul-Henning Kamp wrote: > > In message <20061212160016.W56465@delplex.bde.org>, Bruce Evans writes: > >> On Mon, 11 Dec 2006, Daniel Eischen wrote: > >> > >> It's probably a nightmare in the kernel too. close() starts looking > >> like revoke(), and revoke() has large problems and bugs in this area. > > > > There is the distinctive difference that revoke() operates on a name > > and close() on a filedescriptor, but otherwise I agree. > > Well, if threads waiting on IO are interruptable by signals, > can't we make a new signal that's only used by the kernel > and send it to all threads waiting on IO for that descriptor? > When it gets out to actually setup the signal handler, it > just resumes like it is returning from an SA_RESTART signal > handler (which according to another posting would reissue > the IO command and get EBADF). Even if you have implemented the close() with the interruption, another thread openning a file still can reuse the file handle immediately, according to specifications, the lowest free file handle will be returned, if SA_RESTART is used, the interrupted thread restart the syscall, it will be using a wrong file, I think even if we have implemented the feature in kernel, useland threads still has serious race to fix. David Xu From owner-freebsd-java@FreeBSD.ORG Wed Dec 13 14:25:01 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id E7F5016A494; Wed, 13 Dec 2006 14:25:01 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from digger1.defence.gov.au (digger1.defence.gov.au [203.5.217.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 585EC43CC1; Wed, 13 Dec 2006 14:23:23 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from ednmsw501.dsto.defence.gov.au (ednmsw501.dsto.defence.gov.au [131.185.2.150]) by digger1.defence.gov.au (8.13.8/8.13.8) with ESMTP id kBDEHnur016958; Thu, 14 Dec 2006 00:47:49 +1030 (CST) Received: from ednux519.dsto.defence.gov.au (unverified) by ednmsw501.dsto.defence.gov.au (Content Technologies SMTPRS 4.3.17) with ESMTP id ; Thu, 14 Dec 2006 00:54:47 +1030 Received: from ednex510.dsto.defence.gov.au (ednex510.dsto.defence.gov.au [131.185.2.170]) by ednux519.dsto.defence.gov.au (8.13.6+Sun/8.13.6) with ESMTP id kBD3Vb4P011855; Wed, 13 Dec 2006 14:01:40 +1030 (CST) Received: from ednexdev.dsto.defence.gov.au ([131.185.2.82]) by ednex510.dsto.defence.gov.au with Microsoft SMTPSVC(6.0.3790.1830); Wed, 13 Dec 2006 14:08:58 +1030 Received: from mail pickup service by ednexdev.dsto.defence.gov.au with Microsoft SMTPSVC; Wed, 13 Dec 2006 14:08:57 +1030 Received: from ednmsw506.dsto.defence.gov.au ([131.185.2.88]) by ednexdev.dsto.defence.gov.au with Microsoft SMTPSVC(6.0.3790.1830); Wed, 13 Dec 2006 01:06:39 +1030 Received: from digger1.defence.gov.au (unverified) by ednmsw506.dsto.defence.gov.au (Content Technologies SMTPRS 4.3.14) with ESMTP id for ; Wed, 13 Dec 2006 01:06:39 +1030 Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by digger1.defence.gov.au (8.13.8/8.13.8) with ESMTP id kBCETbgl022078 for ; Wed, 13 Dec 2006 00:59:38 +1030 (CST) Received: from hub.freebsd.org (hub.freebsd.org [69.147.83.54]) by mx2.freebsd.org (Postfix) with ESMTP id 1317663003; Tue, 12 Dec 2006 14:35:43 +0000 (GMT) (envelope-from owner-freebsd-arch@freebsd.org) Received: from hub.freebsd.org (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id D07D116A575; Tue, 12 Dec 2006 14:35:47 +0000 (UTC) (envelope-from owner-freebsd-arch@freebsd.org) X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0367216A51C; Tue, 12 Dec 2006 14:34:39 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FB3044407; Tue, 12 Dec 2006 14:17:59 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.ntplx.net (8.13.8/8.13.8/NETPLEX) with ESMTP id kBCEJ94W000917; Tue, 12 Dec 2006 09:19:09 -0500 (EST) Date: Tue, 12 Dec 2006 09:19:09 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: "Arne H. Juul" In-Reply-To: Message-ID: References: <20061211171115.GD311@deviant.kiev.zoral.com.ua> <200612120816.07608.davidxu@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-3.0 (mail.ntplx.net [204.213.176.10]); Tue, 12 Dec 2006 09:19:10 -0500 (EST) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Sender: owner-freebsd-arch@freebsd.org Errors-To: owner-freebsd-arch@freebsd.org X-OriginalArrivalTime: 12 Dec 2006 14:36:39.0605 (UTC) FILETIME=[EF3BC650:01C71DFA] X-TM-AS-Product-Ver: SMEX-7.0.0.1345-3.6.1039-14784.003 X-TM-AS-Result: No--10.765100-8.000000-2 Cc: Kostik Belousov , freebsd-java@freebsd.org, David Xu , freebsd-arch@freebsd.org Subject: Re: close() of active socket does not work on FreeBSD 6 X-BeenThere: freebsd-java@freebsd.org Reply-To: Daniel Eischen List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Dec 2006 14:25:02 -0000 On Mon, 11 Dec 2006, Daniel Eischen wrote: > > Common sense leads me to think that a close() should release > threads in IO operations (reads/writes/selects/polls) and > return EBADF or something appropriate. At least when behavior > is not dictated by POSIX or other historical/defactor behavior. BTW, I tested the behavior on Solaris. Solaris returns EBADF with the posted sample C program. -- DE _______________________________________________ freebsd-arch@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-arch To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"