From owner-java@jp.FreeBSD.org Mon Oct 28 21:04:55 2002
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) id g9SC4tr69656;
	Mon, 28 Oct 2002 21:04:55 +0900 (JST)
	(envelope-from owner-java@jp.FreeBSD.org)
Received: from ongs.co.jp (ns.ongs.co.jp [202.216.232.58])
	by castle.jp.FreeBSD.org (8.11.6+3.4W/8.11.3) with SMTP/inet id g9SC4r369646
	for <java@jp.freebsd.org>; Mon, 28 Oct 2002 21:04:53 +0900 (JST)
	(envelope-from daichi@freebsd.org)
Received: (qmail 5836 invoked from network); 28 Oct 2002 11:59:54 -0000
Received: from unknown (HELO parancell.ongs.co.jp) (202.216.232.62)
  by ns.ongs.co.jp with SMTP; 28 Oct 2002 11:59:54 -0000
From: daichi <daichi@freebsd.org>
To: Greg Lewis <glewis@eyesbeyond.com>
Cc: freebsd-java@freebsd.org, java@jp.FreeBSD.org
Message-Id: <20021028210702.77c49536.daichi@freebsd.org>
Organization: FreeBSD Project
X-Mailer: Sylpheed version 0.8.5 (GTK+ 1.2.10; i386-portbld-freebsd4.6)
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Reply-To: java@jp.FreeBSD.org
Precedence: list
Date: Mon, 28 Oct 2002 21:07:02 +0900
X-Sequence: java 239
Subject: [java 239] UDP problem fix patch for FreeBSD JDK131 patchset8
Errors-To: owner-java@jp.FreeBSD.org
Sender: owner-java@jp.FreeBSD.org
X-Originator: daichi@freebsd.org
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+021028

Hi Greg :)

This is udp problem fix patch for FreeBSD JDK131. Please merge this
patch to next patchset8 or jdk13 ports.

----------------------------------------------------------------------
--- ../src/solaris/native/java/net/PlainDatagramSocketImpl.c.orig       Sun May  6 21:27:32 2001
+++ ../src/solaris/native/java/net/PlainDatagramSocketImpl.c    Mon Oct 28 19:54:10 2002
@@ -9,10 +9,10 @@
  */
 
 #include <errno.h>
-#include <netinet/in.h>
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#include <netinet/in.h>
 #include <sys/socket.h>
 
 #include "jvm.h"
@@ -489,7 +489,7 @@
                        strerror(errno));
        return;
     }
-#if defined(__linux__) && defined(SO_BROADCAST)
+#if (defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)) && defined(SO_BROADCAST)
      {
         int t = 1;
         setsockopt(fd, SOL_SOCKET, SO_BROADCAST, (char*) &t, sizeof(int));
@@ -568,8 +568,10 @@
 
        int tmp = (*env)->GetIntField(env, value, i_valueID);
        int arg = tmp ? -1: 0;
-       if (JVM_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR,
-                      (char *)&arg, sizeof(arg)) < 0) {
+       if ((JVM_SetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR,
+                      (char *)&arg, sizeof(arg)) < 0) ||
+           (JVM_SetSockOpt(fd, SOL_SOCKET, SO_REUSEPORT,
+                      (char *)&arg, sizeof(arg)) < 0)) {
            JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
                            strerror(errno));
        }
----------------------------------------------------------------------

Mr. Zachary Pincus had pointed out this problem(2002/09/10). And 
Hideki KAWAI-san had pointed out this, too(2002/10/26).  Their 
contents of indication are almost the same.  I also checked the 
problem.

  http://www.freebsd.org/cgi/getmsg.cgi?fetch=26469+30997+/usr/local/www/db/text/2002/freebsd-java/20020915.freebsd-java
  http://home.jp.freebsd.org/cgi-bin/showmail/FreeBSD-users-jp/71564
  http://home.jp.freebsd.org/cgi-bin/showmail/FreeBSD-users-jp/71568

In response, Tetsuo Suzuki-san taught us the solution today.

  http://home.jp.freebsd.org/cgi-bin/showmail/java/237
  http://home.jp.freebsd.org/cgi-bin/showmail/java/238

The above patch is created according to his directions. As a result 
of my investigating, I think that the udp problem is repaired by the
patch.

Please merge this patch, Greg.

Thanks.

--
  daichi@freebsd.org, http://people.freebsd.org/~daichi
