You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2008/11/28 23:03:03 UTC
svn commit: r721570 - in
/harmony/enhanced/classlib/trunk/modules/luni/src/main: java/java/net/
java/org/apache/harmony/luni/net/ java/org/apache/harmony/luni/platform/
native/luni/shared/ native/luni/unix/
Author: tellison
Date: Fri Nov 28 14:03:02 2008
New Revision: 721570
URL: http://svn.apache.org/viewvc?rev=721570&view=rev
Log:
Remove multicast socket native call, and replace it with regular datagram socket creation.
The main difference here is that the setting of SO_REUSEADDR will be called for sockets created from a user defined datagram socket factory (it wasn't previously). Since we need the option set, this is a good thing.
Removed:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainMulticastSocketImpl.java
Modified:
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/SocketImplProvider.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.c
harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.h
harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/unix/exports.txt
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java?rev=721570&r1=721569&r2=721570&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/MulticastSocket.java Fri Nov 28 14:03:02 2008
@@ -551,11 +551,10 @@
synchronized void createSocket(int aPort, InetAddress addr)
throws SocketException {
impl = factory != null ? factory.createDatagramSocketImpl()
- : SocketImplProvider.getMulticastSocketImpl();
+ : SocketImplProvider.getDatagramSocketImpl();
impl.create();
try {
- // the required default options are now set in the VM where they
- // should be
+ impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.TRUE);
impl.bind(aPort, addr);
isBound = true;
} catch (SocketException e) {
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/SocketImplProvider.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/SocketImplProvider.java?rev=721570&r1=721569&r2=721570&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/SocketImplProvider.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/SocketImplProvider.java Fri Nov 28 14:03:02 2008
@@ -51,10 +51,6 @@
return new PlainDatagramSocketImpl();
}
- public static DatagramSocketImpl getMulticastSocketImpl() {
- return new PlainMulticastSocketImpl();
- }
-
public static DatagramSocketImpl getDatagramSocketImpl(FileDescriptor fd, int localPort) {
return new PlainDatagramSocketImpl(fd, localPort);
}
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=721570&r1=721569&r2=721570&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 Fri Nov 28 14:03:02 2008
@@ -119,9 +119,6 @@
public void connectDatagram(FileDescriptor aFD, int port, int trafficClass,
InetAddress inetAddress) throws SocketException;
- public void createMulticastSocket(FileDescriptor aFD,
- boolean preferIPv4Stack) throws SocketException;
-
/**
* @deprecated Use {@link #read(FileDescriptor, byte[], int, int, int)}
*/
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=721570&r1=721569&r2=721570&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 Fri Nov 28 14:03:02 2008
@@ -102,30 +102,11 @@
boolean preferIPv4Stack) throws SocketException;
/**
- * Answer the result of attempting to create a multicast socket in the IP
- * stack. Any special options required for server sockets will be set by
- * this method.
- *
- * @param aFD
- * the socket FileDescriptor
- * @param preferIPv4Stack
- * if use IPV4
- * @throws SocketException
- * if an error occurs while creating the socket
- *
- * @deprecated use {@link #createDatagramSocket(FileDescriptor, boolean)}
+ * @deprecated use {@link #createStreamSocket(FileDescriptor, boolean)}
*/
- @Deprecated
- public native void createMulticastSocket(FileDescriptor aFD,
- boolean preferIPv4Stack) throws SocketException;
-
public native void createSocket(FileDescriptor fd, boolean preferIPv4Stack)
throws IOException;
- /**
- * @deprecated use {@link #createSocket(FileDescriptor, boolean)}
- */
- @Deprecated
public native void createStreamSocket(FileDescriptor fd,
boolean preferIPv4Stack) throws SocketException;
Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c?rev=721570&r1=721569&r2=721570&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/native/luni/shared/OSNetworkSystem.c Fri Nov 28 14:03:02 2008
@@ -343,28 +343,6 @@
/*
* Class: org_apache_harmony_luni_platform_OSNetworkSystem
- * Method: createMulticastSocket
- * Signature: (Ljava/io/FileDescriptor;Z)V
- */
-JNIEXPORT void JNICALL
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createMulticastSocket
- (JNIEnv * env, jobject thiz, jobject thisObjFD, jboolean preferIPv4Stack)
-{
- PORT_ACCESS_FROM_ENV(env);
- BOOLEAN value = TRUE;
- hysocket_t socketP;
-
- createSocket(env, thisObjFD, HYSOCK_DGRAM, preferIPv4Stack);
- socketP =
- (hysocket_t) getJavaIoFileDescriptorContentsAsAPointer(env, thisObjFD);
-
- hysock_setopt_bool(socketP, HY_SOL_SOCKET, HY_SO_REUSEPORT, &value);
- hysock_setopt_bool(socketP, HY_SOL_SOCKET, HY_SO_REUSEADDR, &value);
-}
-
-
-/*
- * Class: org_apache_harmony_luni_platform_OSNetworkSystem
* Method: read
* Signature: (Ljava/io/FileDescriptor;[BIII)I
*/
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=721570&r1=721569&r2=721570&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 Fri Nov 28 14:03:02 2008
@@ -154,15 +154,6 @@
/*
* Class: org.apache.harmony.luni.platform.OSNetworkSystem
- * Method: createMulticastSocket
- * Signature: (Ljava/io/FileDescriptor;Z)V
- * Throws: java.net.SocketException
- */
-JNIEXPORT void JNICALL Java_org_apache_harmony_luni_platform_OSNetworkSystem_createMulticastSocket
- (JNIEnv *, jobject, jobject, jboolean);
-
-/*
- * Class: org.apache.harmony.luni.platform.OSNetworkSystem
* Method: createSocket
* Signature: (Ljava/io/FileDescriptor;Z)V
* Throws: java.io.IOException
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=721570&r1=721569&r2=721570&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 Fri Nov 28 14:03:02 2008
@@ -213,7 +213,6 @@
Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendDatagramDirect
Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendConnectedDatagram
Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendConnectedDatagramDirect
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_createMulticastSocket
Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveStream
Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownInput
Java_org_apache_harmony_luni_platform_OSNetworkSystem_shutdownOutput
Re: svn commit: r721570 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main:
java/java/net/ java/org/apache/harmony/luni/net/ java/org/apache/harmony/luni/platform/
native/luni/shared/ native/luni/unix/
Posted by Tim Ellison <t....@gmail.com>.
Nathan Beyer wrote:
> I'm seeing a compile error in NIO's ServerSocketChannelImpl on line
> 90. It was calling INetworkSystem createServerSocketStream. I changed
> to the only comparable method I could find - createStreamSocket.
>
> I haven't checked this in yet, but I probably will in a bit once I
> verify all compiles are successful.
Sorry, I didn't commit r721516 from high enough in the tree, so I still
had local changes. Thanks for catching it.
Strange that there was no build alert triggered by this, the last I see
is a "[build-test alert] PASSED Linux x86: drlvm-test debug" on Nov 28?
Regards,
Tim
Re: svn commit: r721570 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main: java/java/net/ java/org/apache/harmony/luni/net/ java/org/apache/harmony/luni/platform/ native/luni/shared/ native/luni/unix/
Posted by Nathan Beyer <nb...@gmail.com>.
I'm seeing a compile error in NIO's ServerSocketChannelImpl on line
90. It was calling INetworkSystem createServerSocketStream. I changed
to the only comparable method I could find - createStreamSocket.
I haven't checked this in yet, but I probably will in a bit once I
verify all compiles are successful.
-Nathan
On Fri, Nov 28, 2008 at 4:14 PM, Tim Ellison <t....@gmail.com> wrote:
> I'm just sending this to the dev list for the record in case people want
> to recreate the logic I went through...
>
> tellison@apache.org wrote:
>> Log:
>> Remove multicast socket native call, and replace it with regular
>> datagram socket creation.
>> The main difference here is that the setting of SO_REUSEADDR will be
>> called for sockets created from a user defined datagram socket factory
>> (it wasn't previously). Since we need the option set, this is a good
>> thing.
> <snip>
>> - // the required default options are now set in the VM where they
>> - // should be
>> + impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.TRUE);
>
> I figured this out by creating a mock socket impl and seeing what calls
> were made on it from the RI, which were:
>
> constructor
> create
> setOption id: 4 val:true
> bind
>
>
> import java.io.IOException;
> import java.net.DatagramPacket;
> import java.net.DatagramSocket;
> import java.net.DatagramSocketImpl;
> import java.net.DatagramSocketImplFactory;
> import java.net.InetAddress;
> import java.net.MulticastSocket;
> import java.net.NetworkInterface;
> import java.net.SocketAddress;
> import java.net.SocketException;
>
> public class TestDGSocket {
>
> private static class FakeSock extends DatagramSocketImpl {
> public FakeSock() { System.out.println("constructor"); }
> protected void bind(int lport, InetAddress laddr) throws
> SocketException { System.out.println("bind"); }
> protected void close() { System.out.println("close"); }
> protected void create() throws SocketException {
> System.out.println("create"); }
> protected byte getTTL() throws IOException {
> System.out.println("getTTL"); return 0; }
> protected int getTimeToLive() throws IOException {
> System.out.println("getTimeToLive"); return 0; }
> protected void join(InetAddress inetaddr) throws IOException {
> System.out.println("join"); }
> protected void joinGroup(SocketAddress mcastaddr,
> NetworkInterface netIf) throws IOException {
> System.out.println("joinGroup"); }
> protected void leave(InetAddress inetaddr) throws IOException {
> System.out.println("leave"); }
> protected void leaveGroup(SocketAddress mcastaddr,
> NetworkInterface netIf) throws IOException {
> System.out.println("leaveGroup"); }
> protected int peek(InetAddress i) throws IOException {
> System.out.println("peek"); return 0; }
> protected int peekData(DatagramPacket p) throws IOException {
> System.out.println("peekData"); return 0; }
> protected void receive(DatagramPacket p) throws IOException {
> System.out.println("receive"); }
> protected void send(DatagramPacket p) throws IOException {
> System.out.println("send"); }
> protected void setTTL(byte ttl) throws IOException {
> System.out.println("setTTL"); }
> protected void setTimeToLive(int ttl) throws IOException {
> System.out.println("setTimeToLive"); }
> public Object getOption(int optID) throws SocketException {
> System.out.println("getOption"); return null; }
> public void setOption(int optID, Object value) throws
> SocketException { System.out.println("setOption id: " + optID + " val:"
> + value); }
> }
>
> public static void main(String[] args) throws IOException {
> DatagramSocketImplFactory factory = new
> DatagramSocketImplFactory() {
> public DatagramSocketImpl createDatagramSocketImpl() {
> return new FakeSock();
> }
> };
> DatagramSocket.setDatagramSocketImplFactory(factory);
> MulticastSocket s = new MulticastSocket();
> System.out.println(s);
> }
> }
>
Re: svn commit: r721570 - in /harmony/enhanced/classlib/trunk/modules/luni/src/main:
java/java/net/ java/org/apache/harmony/luni/net/ java/org/apache/harmony/luni/platform/
native/luni/shared/ native/luni/unix/
Posted by Tim Ellison <t....@gmail.com>.
I'm just sending this to the dev list for the record in case people want
to recreate the logic I went through...
tellison@apache.org wrote:
> Log:
> Remove multicast socket native call, and replace it with regular
> datagram socket creation.
> The main difference here is that the setting of SO_REUSEADDR will be
> called for sockets created from a user defined datagram socket factory
> (it wasn't previously). Since we need the option set, this is a good
> thing.
<snip>
> - // the required default options are now set in the VM where they
> - // should be
> + impl.setOption(SocketOptions.SO_REUSEADDR, Boolean.TRUE);
I figured this out by creating a mock socket impl and seeing what calls
were made on it from the RI, which were:
constructor
create
setOption id: 4 val:true
bind
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.DatagramSocketImpl;
import java.net.DatagramSocketImplFactory;
import java.net.InetAddress;
import java.net.MulticastSocket;
import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.SocketException;
public class TestDGSocket {
private static class FakeSock extends DatagramSocketImpl {
public FakeSock() { System.out.println("constructor"); }
protected void bind(int lport, InetAddress laddr) throws
SocketException { System.out.println("bind"); }
protected void close() { System.out.println("close"); }
protected void create() throws SocketException {
System.out.println("create"); }
protected byte getTTL() throws IOException {
System.out.println("getTTL"); return 0; }
protected int getTimeToLive() throws IOException {
System.out.println("getTimeToLive"); return 0; }
protected void join(InetAddress inetaddr) throws IOException {
System.out.println("join"); }
protected void joinGroup(SocketAddress mcastaddr,
NetworkInterface netIf) throws IOException {
System.out.println("joinGroup"); }
protected void leave(InetAddress inetaddr) throws IOException {
System.out.println("leave"); }
protected void leaveGroup(SocketAddress mcastaddr,
NetworkInterface netIf) throws IOException {
System.out.println("leaveGroup"); }
protected int peek(InetAddress i) throws IOException {
System.out.println("peek"); return 0; }
protected int peekData(DatagramPacket p) throws IOException {
System.out.println("peekData"); return 0; }
protected void receive(DatagramPacket p) throws IOException {
System.out.println("receive"); }
protected void send(DatagramPacket p) throws IOException {
System.out.println("send"); }
protected void setTTL(byte ttl) throws IOException {
System.out.println("setTTL"); }
protected void setTimeToLive(int ttl) throws IOException {
System.out.println("setTimeToLive"); }
public Object getOption(int optID) throws SocketException {
System.out.println("getOption"); return null; }
public void setOption(int optID, Object value) throws
SocketException { System.out.println("setOption id: " + optID + " val:"
+ value); }
}
public static void main(String[] args) throws IOException {
DatagramSocketImplFactory factory = new
DatagramSocketImplFactory() {
public DatagramSocketImpl createDatagramSocketImpl() {
return new FakeSock();
}
};
DatagramSocket.setDatagramSocketImplFactory(factory);
MulticastSocket s = new MulticastSocket();
System.out.println(s);
}
}