From owner-freebsd-threads@FreeBSD.ORG Fri Aug 19 05:10:12 2005 Return-Path: X-Original-To: freebsd-threads@hub.freebsd.org Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0C85A16A41F for ; Fri, 19 Aug 2005 05:10:12 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C18443D48 for ; Fri, 19 Aug 2005 05:10:11 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.3/8.13.3) with ESMTP id j7J5ABfK037179 for ; Fri, 19 Aug 2005 05:10:11 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.3/8.13.1/Submit) id j7J5ABxb037178; Fri, 19 Aug 2005 05:10:11 GMT (envelope-from gnats) Resent-Date: Fri, 19 Aug 2005 05:10:11 GMT Resent-Message-Id: <200508190510.j7J5ABxb037178@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Nick Johnson Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 60DB216A41F for ; Fri, 19 Aug 2005 05:07:08 +0000 (GMT) (envelope-from root@turing.morons.org) Received: from mail.morons.org (morons.org [64.147.161.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id D442043D91 for ; Fri, 19 Aug 2005 05:07:03 +0000 (GMT) (envelope-from root@turing.morons.org) Received: by turing.morons.org (Postfix, from userid 0) id E24F31701D; Wed, 17 Aug 2005 10:52:57 -0700 (PDT) Message-Id: <20050817175257.E24F31701D@turing.morons.org> Date: Wed, 17 Aug 2005 10:52:57 -0700 (PDT) From: Nick Johnson To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Cc: Subject: threads/85112: Resource temporarily unavailable reading from sockets with Java/libpthread/jdbc X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Nick Johnson List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Aug 2005 05:10:12 -0000 >Number: 85112 >Category: threads >Synopsis: Resource temporarily unavailable reading from sockets with Java/libpthread/jdbc >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Aug 19 05:10:08 GMT 2005 >Closed-Date: >Last-Modified: >Originator: Nick Johnson >Release: FreeBSD 5.4-STABLE i386 >Organization: morons.org >Environment: System: FreeBSD turing.morons.org 5.4-STABLE FreeBSD 5.4-STABLE #4: Mon Aug 15 21:22:19 PDT 2005 root@turing.morons.org:/usr/src/sys/i386/compile/TURING i386 Java 1.4.2-p7 built from ports Postgresql 8.0.3 built from ports; however still using the Postgresql 7.4 JDBC driver >Description: When attempting to get a database connection with Java linked to libpthread, a socket exception is thrown: java.net.SocketException: Resource temporarily unavailable at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at java.io.BufferedInputStream.fill(BufferedInputStream.java:183) at java.io.BufferedInputStream.read(BufferedInputStream.java:201) at org.postgresql.PG_Stream.ReceiveChar(PG_Stream.java:139) at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:190) at org.postgresql.Driver.connect(Driver.java:122) at java.sql.DriverManager.getConnection(DriverManager.java:512) at java.sql.DriverManager.getConnection(DriverManager.java:193) at net.spatula.news.Utils.getJDBCconnection(Utils.java:816) Here is the code from getJDBCconnection, verbatim, including ugliness just for fun... public static synchronized Connection getJDBCconnection() { try { Class.forName("org.postgresql.Driver"); } catch (Exception e) { e.printStackTrace(); } int retryCount = 5; while (retryCount >0) { try { //XXX database name and username should be properties String dbURL = "jdbc:postgresql://"+ getProperty("spatula.dbhost")+":"+ getProperty("spatula.dbport")+"/morons.org?user=www&password="+ getProperty("spatula.dbpass"); Connection c = DriverManager.getConnection(dbURL); // <--- this is line 816 return c; } catch (Exception e) { e.printStackTrace(); } retryCount--; try { Thread.sleep(200 + (int)(Math.random()*50.0)); } catch (Exception e) {} } return null; } This fails every time when java links against libpthread and works every time when it is linked against libc_r. I'm not entirely sure, but this may have started showing itself after I added this to /etc/make.conf: CPUTYPE?=i686 CFLAGS=-O2 -pipe or it may be totally unrelated. See also threads/84778 (http://www.freebsd.org/cgi/query-pr.cgi?pr=84778) which was previously preventing me from getting far enough to make a database connection. (Once the class files were compiled with a process linked against libc_r, they were in place for a process linked against libpthread to use.) >How-To-Repeat: Try to get a database connection. >Fix: Workaround is to configure the linker to use libc_r for all Java processes in /etc/libmap.conf: [/usr/local/jdk1.4.2/] libpthread.so.1 libc_r.so.5 libpthread.so libc_r.so >Release-Note: >Audit-Trail: >Unformatted: