harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r759913 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ main/java/org/apache/harmony/luni/net/ main/java/org/apache/harmony/luni/platform/ main/native/luni/shared/ main/native/luni/unix/ main/native/luni/windows/...
Date Mon, 30 Mar 2009 10:49:13 GMT
Author: tellison
Date: Mon Mar 30 10:49:12 2009
New Revision: 759913

URL: http://svn.apache.org/viewvc?rev=759913&view=rev
Log:
Fix for HARMONY-6090 ([classlib][luni] - the SO_REUSEADDR's default value of ServerSocket
should be true on Linux)

Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt
    harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/ServerSocket.java
Mon Mar 30 10:49:12 2009
@@ -20,7 +20,7 @@
 import java.io.IOException;
 import java.nio.channels.ServerSocketChannel;
 
-import org.apache.harmony.luni.net.PlainSocketImpl;
+import org.apache.harmony.luni.net.PlainServerSocketImpl;
 import org.apache.harmony.luni.platform.Platform;
 import org.apache.harmony.luni.util.Msg;
 
@@ -56,7 +56,7 @@
      */
     public ServerSocket() throws IOException {
         impl = factory != null ? factory.createSocketImpl()
-                : new PlainSocketImpl();
+                : new PlainServerSocketImpl();
     }
 
     protected ServerSocket(SocketImpl impl) {
@@ -109,7 +109,7 @@
         super();
         checkListen(aport);
         impl = factory != null ? factory.createSocketImpl()
-                : new PlainSocketImpl();
+                : new PlainServerSocketImpl();
         InetAddress addr = localAddr == null ? InetAddress.ANY : localAddr;
 
         synchronized (this) {

Added: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java?rev=759913&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java
Mon Mar 30 10:49:12 2009
@@ -0,0 +1,50 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.luni.net;
+
+import java.io.FileDescriptor;
+import java.net.SocketException;
+
+import org.apache.harmony.luni.net.NetUtil;
+import org.apache.harmony.luni.net.PlainSocketImpl;
+
+/**
+ * This class overrides create to call natives that set the options required
+ * for server sockets.
+ */
+public class PlainServerSocketImpl extends PlainSocketImpl {
+
+    public PlainServerSocketImpl() {
+        super();
+    }
+
+    public PlainServerSocketImpl(FileDescriptor fd) {
+        super();
+        this.fd = fd;
+    }
+
+    @Override
+    protected void create(boolean isStreaming) throws SocketException {
+        streaming = isStreaming;
+        if (isStreaming) {
+            netImpl.createServerStreamSocket(fd, NetUtil.preferIPv4Stack());
+        } else {
+            netImpl.createDatagramSocket(fd, NetUtil.preferIPv4Stack());
+        }
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainServerSocketImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/INetworkSystem.java
Mon Mar 30 10:49:12 2009
@@ -134,9 +134,12 @@
 			SocketImpl newSocket, FileDescriptor fdnewSocket, int timeout)
 			throws IOException;
 
-	public void createStreamSocket(FileDescriptor aFD, boolean preferIPv4Stack)
-			throws SocketException;
+	public void createServerStreamSocket(FileDescriptor aFD, boolean preferIPv4Stack)
+            throws SocketException;
 
+    public void createStreamSocket(FileDescriptor aFD, boolean preferIPv4Stack)
+            throws SocketException;
+    
 	public void listenStreamSocket(FileDescriptor aFD, int backlog)
 			throws SocketException;
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/OSNetworkSystem.java
Mon Mar 30 10:49:12 2009
@@ -94,6 +94,9 @@
     public native void createDatagramSocket(FileDescriptor fd,
             boolean preferIPv4Stack) throws SocketException;
 
+    public native void createServerStreamSocket(FileDescriptor fd,
+            boolean preferIPv4Stack) throws SocketException;
+
     public native void createStreamSocket(FileDescriptor fd,
             boolean preferIPv4Stack) throws SocketException;
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
Mon Mar 30 10:49:12 2009
@@ -145,6 +145,15 @@
 
 /*
  * Class:     org.apache.harmony.luni.platform.OSNetworkSystem
+ * Method:    createServerStreamSocket
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ * Throws:    java.net.SocketException
+ */
+JNIEXPORT void JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_createServerStreamSocket
+  (JNIEnv *, jobject, jobject, jboolean);
+
+/*
+ * Class:     org.apache.harmony.luni.platform.OSNetworkSystem
  * Method:    createStreamSocket
  * Signature: (Ljava/io/FileDescriptor;Z)V
  * Throws:    java.net.SocketException

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/OSNetworkSystemLinux.c
Mon Mar 30 10:49:12 2009
@@ -39,7 +39,9 @@
 
 #include "nethelp.h"
 #include "harmonyglob.h"
+#include "helpers.h"
 #include "hysock.h"
+#include "socket.h"
 #include "hyport.h"
 #include "jni.h"
 #include "OSNetworkSystem.h"
@@ -80,6 +82,29 @@
   return result;
 }
 
+
+/*
+ * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
+ * Method:    createServerStreamSocket
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_createServerStreamSocket
+  (JNIEnv * env, jobject thiz, jobject thisObjFD, jboolean preferIPv4Stack)
+{
+  PORT_ACCESS_FROM_ENV (env);
+  hysocket_t socketP;
+  BOOLEAN value = TRUE;
+
+  createSocket(env, thisObjFD, HYSOCK_STREAM, preferIPv4Stack);
+
+  /* Also sets HY_SO_REUSEADDR = TRUE on Linux only */
+  socketP =
+    (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer(env, thisObjFD);
+  hysock_setopt_bool (socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);
+}
+
+
 JNIEXPORT jint JNICALL
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_isReachableByICMPImpl
   (JNIEnv * env, jobject thiz, jobject address, jobject localaddr, jint ttl, jint timeout)

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt Mon
Mar 30 10:49:12 2009
@@ -215,6 +215,7 @@
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownInput
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownOutput
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_acceptStreamSocket
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_createServerStreamSocket
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_createStreamSocket
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagram2
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_selectImpl

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/windows/OSNetworkSystemWin32.c
Mon Mar 30 10:49:12 2009
@@ -32,6 +32,19 @@
 
 /*
  * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
+ * Method:    createServerStreamSocket
+ * Signature: (Ljava/io/FileDescriptor;Z)V
+ */
+JNIEXPORT void JNICALL
+Java_org_apache_harmony_luni_platform_OSNetworkSystem_createServerStreamSocket
+  (JNIEnv * env, jobject thiz, jobject thisObjFD, jboolean preferIPv4Stack)
+{
+  createSocket(env, thisObjFD, HYSOCK_STREAM, preferIPv4Stack);
+}
+
+
+/*
+ * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
  * Method:    selectImpl
  * Signature: ([Ljava/io/FileDescriptor;[Ljava/io/FileDescriptor;II[IJ)I
  */

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java?rev=759913&r1=759912&r2=759913&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/ServerSocketTest.java
Mon Mar 30 10:49:12 2009
@@ -35,7 +35,7 @@
 import java.util.Date;
 import java.util.Properties;
 
-import org.apache.harmony.luni.net.PlainSocketImpl;
+import org.apache.harmony.luni.net.PlainServerSocketImpl;
 
 import tests.support.Support_Configuration;
 import tests.support.Support_Exec;
@@ -333,7 +333,7 @@
 
     private static class MockSocketImplFactory implements SocketImplFactory {
         public SocketImpl createSocketImpl() {
-            return new PlainSocketImpl();
+            return new PlainServerSocketImpl();
         }
     }
 



Mime
View raw message