From owner-freebsd-java@FreeBSD.ORG Wed Jul 6 20:37:50 2005 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6DAE416A41C for ; Wed, 6 Jul 2005 20:37:50 +0000 (GMT) (envelope-from landonf@threerings.net) Received: from mail.earth.threerings.net (mail.earth.threerings.net [64.81.51.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3139E43D48 for ; Wed, 6 Jul 2005 20:37:50 +0000 (GMT) (envelope-from landonf@threerings.net) Received: from [192.168.50.11] (timor.sea.earth.threerings.net [192.168.50.11]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by mail.earth.threerings.net (Postfix) with ESMTP id 808296118; Wed, 6 Jul 2005 13:37:49 -0700 (PDT) In-Reply-To: <20050621210125.GA96069@misty.eyesbeyond.com> References: <20050621210125.GA96069@misty.eyesbeyond.com> Mime-Version: 1.0 (Apple Message framework v622) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <1aebb438473c6cf4694df15d071be468@threerings.net> Content-Transfer-Encoding: 7bit From: Landon Fuller Date: Wed, 6 Jul 2005 13:37:46 -0700 To: Greg Lewis X-Pgp-Agent: GPGMail 1.0.2 X-Mailer: Apple Mail (2.622) Cc: freebsd-java@freebsd.org Subject: Re: [PATCH] jdk1.4.2, getsockname(), and ECONNRESET 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, 06 Jul 2005 20:37:50 -0000 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Jun 21, 2005, at 14:01, Greg Lewis wrote: > Hi Landon, > > On Linux and/or Solaris, what happens when you call getsockname() on a > socket that has had the connection reset by the peer? In particular, > is it compatible with what your patch does or are we introducing a new > scenario that the socket code for applications must handle? I looked over the Linux network implementation to be certain. When the socket is reset, the source address and port are reset to 0. The kernel handles IPv6 vs. IPv4 sockets, returning the correct sockaddr type. In our case, we're only provided with the file descriptor, leaving us with no means to discern whether the socket was formerly connected via IPv4 or IPv6 - as such, we're forced to improvise by returning a sockaddr_in if an error occurs. In terms of the localPort() method, this makes no difference to the calling Java code as only the port number is returned. In the localAddress() method, returning an IPv4 address should not be fatal. For localAddress() to in turn call getsockname(), the connect() must have been issued without a bind() first being issued (otherwise, java would have cached the local port and address previously). There should be no expectation by the caller that either a Inet4Address or a Inet6Address will be returned. It would obviously be more correct to pass up the java.net.SocketException (as opposed to the current java.lang.Error), but our hands are tied by the published API. >> Also, any comments on the thread-safe resolver patch? > > My bad, I haven't gotten to testing it yet :(. One concern was that > you mention the routines you're using are thread safe under 5.4 and > better and I wondered if there was an impact on 4.x users? I will > try and get this tested soon, as I want it in the next patchset. It's a good question. 4.x completely lacks a thread-safe resolver library, and getaddrinfo() makes up for this by maintaining a Giant lock on all resolver functions. This can result in painful delays while threads block on name resolution. Which is worse? Occasionally crashing java using the non-thread-safe resolver, or potentially causing significant resolution delays? I worry about the potential for breaking mostly-working installations. Then again, the non-thread-safe resolver may already be doing a better job of breaking them. - -landonf -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFCzEEclplZCE/15mMRAvP8AKCLo5SBgTV/21zuz76QpkAW4BoH+QCfXyfN c9kNkbmG9mbMhpZc2AXE/vY= =Bxo3 -----END PGP SIGNATURE-----