From owner-freebsd-java@FreeBSD.ORG Wed Jun 8 19:01:23 2011 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 80D95106564A for ; Wed, 8 Jun 2011 19:01:23 +0000 (UTC) (envelope-from prvs=114023f9f1=killing@multiplay.co.uk) Received: from mail1.multiplay.co.uk (mail1.multiplay.co.uk [85.236.96.23]) by mx1.freebsd.org (Postfix) with ESMTP id F02AA8FC13 for ; Wed, 8 Jun 2011 19:01:22 +0000 (UTC) X-MDAV-Processed: mail1.multiplay.co.uk, Wed, 08 Jun 2011 19:50:01 +0100 X-Spam-Processed: mail1.multiplay.co.uk, Wed, 08 Jun 2011 19:50:01 +0100 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail1.multiplay.co.uk X-Spam-Level: X-Spam-Status: No, score=-5.0 required=6.0 tests=USER_IN_WHITELIST shortcircuit=ham autolearn=disabled version=3.2.5 Received: from r2d2 ([188.220.16.49]) by mail1.multiplay.co.uk (mail1.multiplay.co.uk [85.236.96.23]) (MDaemon PRO v10.0.4) with ESMTP id md50013516691.msg for ; Wed, 08 Jun 2011 19:50:00 +0100 X-MDRemoteIP: 188.220.16.49 X-Return-Path: prvs=114023f9f1=killing@multiplay.co.uk X-Envelope-From: killing@multiplay.co.uk X-MDaemon-Deliver-To: freebsd-java@freebsd.org Message-ID: <82AE59EF1F6D4E7FA7AF3E2CD549278B@multiplay.co.uk> From: "Steven Hartland" To: Date: Wed, 8 Jun 2011 19:50:32 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6090 Subject: jdk opening connection to self on socket creation 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, 08 Jun 2011 19:01:23 -0000 I'm trying to find a bug which looks like its in the jdk where by when you create a ServerSocket in java it opens a connection to itself on loopback prior to creating the requested socket. This wouldn't be an issue if it was cleanly shutting dow said socket but it isn't. This is preventing jail clean shutdown in a timely manor as the socket is left in TIME_WAIT. The following code causes this behviour:- import java.net.InetAddress; import java.net.ServerSocket; public class Main { public static void main(String[] args) throws java.io.IOException { InetAddress inetaddress = InetAddress.getByName( "10.10.0.21" ); ServerSocket d = new ServerSocket(25665, 0, inetaddress); System.out.println( "Done" ); } } If you then perform a netstat -na | grep 127.0.0.1 you will see the offending socket e.g. tcp4 0 0 127.0.0.1.26948 127.0.0.1.46429 TIME_WAIT This looks like it might be caused by libnet.so in the jre being loaded bi SocketAddres? write(1,"[Loaded java.net.SocksSocketImpl"...,74) = 74 (0x4a) stat("/usr/local/openjdk6/jre/lib/amd64/libnet.so",{ mode=-rwxr-xr-x ,inode=76507,size=98571,blksize=98816 }) = 0 (0x0) socket(PF_INET,SOCK_STREAM,0) = 5 (0x5) listen(0x5,0x1,0x0,0x1a,0x2,0x80535a8b8) = 0 (0x0) getsockname(5,{ AF_INET 0.0.0.0:12095 },0x7fffffbfe37c) = 0 (0x0) socket(PF_INET,SOCK_STREAM,0) = 6 (0x6) connect(6,{ AF_INET 127.0.0.1:12095 },16) = 0 (0x0) fcntl(5,F_GETFL,) = 2 (0x2) fcntl(5,F_SETFL,O_NONBLOCK|0x2) = 0 (0x0) accept(5,{ AF_INET 127.0.0.1:38895 },0x7fffffbfe37c) = 7 (0x7) shutdown(6,SHUT_RDWR) = 0 (0x0) close(7) = 0 (0x0) close(5) = 0 (0x0) lseek(3,0x2cce5e0,SEEK_SET) = 46982624 (0x2cce5e0) read(3,"PK\^C\^D\n\0\0\0\0\0I\M^W{>\M-/"...,30) = 30 (0x1e) lseek(3,0x2cce61e,SEEK_SET) = 46982686 (0x2cce61e) read(3,"\M-J\M-~\M-:\M->\0\0\0001\0z\n\0"...,3028) = 3028 (0xbd4) lseek(3,0x2cce4b9,SEEK_SET) = 46982329 (0x2cce4b9) read(3,"PK\^C\^D\n\0\0\0\0\0G\M^W{>K0"...,30) = 30 (0x1e) lseek(3,0x2cce4f3,SEEK_SET) = 46982387 (0x2cce4f3) read(3,"\M-J\M-~\M-:\M->\0\0\0001\0\^O\n"...,237) = 237 (0xed) write(1,"[Loaded java.net.SocketAddress f"...,72) = 72 (0x48) Any ideas? Regards Steve ================================================ This e.mail is private and confidential between Multiplay (UK) Ltd. and the person or entity to whom it is addressed. In the event of misdirection, the recipient is prohibited from using, copying, printing or otherwise disseminating it or any information contained in it. In the event of misdirection, illegible or incomplete transmission please telephone +44 845 868 1337 or return the E.mail to postmaster@multiplay.co.uk.