From owner-freebsd-java@FreeBSD.ORG Thu Feb 16 21:43: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 [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CF05216A420 for ; Thu, 16 Feb 2006 21:43:52 +0000 (GMT) (envelope-from Arne.Juul@europe.yahoo-inc.com) Received: from mrout2.corp.ukl.yahoo.com (mrout2.corp.ukl.yahoo.com [217.12.1.88]) by mx1.FreeBSD.org (Postfix) with ESMTP id 48BC543D4C for ; Thu, 16 Feb 2006 21:43:52 +0000 (GMT) (envelope-from Arne.Juul@europe.yahoo-inc.com) Received: from [172.24.94.128] (pat-gw.trondheim.corp.yahoo.com [217.144.236.4]) by mrout2.corp.ukl.yahoo.com (8.13.4/8.13.4/y.out) with ESMTP id k1GLhPrX049844 for ; Thu, 16 Feb 2006 21:43:25 GMT DomainKey-Signature: a=rsa-sha1; s=serpent; d=yahoo-inc.com; c=nofws; q=dns; h=message-id:date:from:user-agent:x-accept-language: mime-version:to:subject:content-type:content-transfer-encoding; b=y7CyvUWeEdftbKMK7GipAQUxW7ncld+xEauGEJwqa0vF4rMG6i3PYu1DViyYXtRS Message-ID: <43F4F22F.1060402@europe.yahoo-inc.com> Date: Thu, 16 Feb 2006 22:44:15 +0100 From: Arne Juul User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: freebsd-java@freebsd.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Subject: SO_REUSEADDR should not also mean SO_REUSEPORT 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: Thu, 16 Feb 2006 21:43:52 -0000 Description by Håvard Pettersen (Havard.Pettersen@europe.yahoo-inc.com) > Ticket Opened: 2006-02-02 13:37 PST > > In the FreeBSD Java port, setting the reuse_address feature on a > server socket also sets the reuse_port feature, which is not a good > thing, since it allows multiple server sockets to bind to the same > local port. > > A possible work-around is to also disable reuse_address, but this > will disallow listening to an unused local port if a connection > established against that port is still active, which is not good > either. I don't know why this code was put into the bsd jdk patches, it just seems plain wrong to me. It makes java subtly non-portable in a very strange manner; I suggest this code is removed. Below is the patch I'm currently using :-) --- ../../j2se/src/solaris/native/java/net/net_util_md.c.orig Thu Feb 16 20:24:41 2006 +++ ../../j2se/src/solaris/native/java/net/net_util_md.c Thu Feb 16 20:23:24 2006 @@ -1019,17 +1019,20 @@ *bufsize = maxsockbuf; } } } +#if 0 +this is just plain wrong! /* * If SO_REUSEADDR option requested, unconditionally set SO_REUSEPORT. */ if (level == SOL_SOCKET && opt == SO_REUSEADDR) { addopt = SO_REUSEPORT; setsockopt(fd, level, addopt, arg, len); } +#endif /* * Don't allow SO_LINGER value to be too big. * Current max value (240) is empiric value based on tcp_timer.h's * constant TCP_LINGERTIME, which was doubled. - Arne H. J.