Date: Wed, 8 Jun 2011 19:50:32 +0100 From: "Steven Hartland" <killing@multiplay.co.uk> To: <freebsd-java@freebsd.org> Subject: jdk opening connection to self on socket creation Message-ID: <82AE59EF1F6D4E7FA7AF3E2CD549278B@multiplay.co.uk>
next in thread | raw e-mail | index | archive | help
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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?82AE59EF1F6D4E7FA7AF3E2CD549278B>