Hi,

I found this commit cause luni test crash on my window32 machine, and the core dump show:

> hyluni.dll!netGetJavaNetInetAddressValue(const JNINativeInterface_ * * env=0x015b8600, _jobject * anInetAddress=0x00000000, unsigned char * buffer=0x0013f724, unsigned int * length=0x0013f7c4) Line 675 + 0x3f C hyluni.dll!Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind(const JNINativeInterface_ * * env=0x015b8600, _jobject * thiz=0x021feb30, _jobject * fileDescriptor=0x021feb2c, int localPort=35646248, _jobject * inetAddress=0x00000000) Line 648 + 0x18 C

Did anyone also see this?

[email protected] wrote:
Author: tellison
Date: Tue Dec 16 07:06:49 2008
New Revision: 727062

URL: http://svn.apache.org/viewvc?rev=727062&view=rev
Log:
Remove bind2 native and just use bind.
The 'bindToDevice' parameter is passed around, but ultimately ignored.  Keeping 
it around now in case we need it, but its also a candidate for removal.
Reordered the param list for bind to be a bit more intuitive.

Modified:
    
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
    
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
    
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.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/InetAddress.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java?rev=727062&r1=727061&r2=727062&view=diff
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/InetAddress.java
 Tue Dec 16 07:06:49 2008
@@ -916,7 +916,7 @@
         NETIMPL.createStreamSocket(fd, NetUtil.preferIPv4Stack());
         try {
             if (null != source) {
-                NETIMPL.bind(fd, 0, source);
+                NETIMPL.bind(fd, source, 0);
             }
             NETIMPL.connectStreamWithTimeoutSocket(fd, 7, timeout, traffic,
                     dest);

Modified: 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java?rev=727062&r1=727061&r2=727062&view=diff
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainDatagramSocketImpl.java
 Tue Dec 16 07:06:49 2008
@@ -70,7 +70,8 @@
      */
     static final int REUSEADDR_AND_REUSEPORT = 10001;
- private boolean bindToDevice;
+    // Ignored in native code
+    private boolean bindToDevice = false;
private byte[] ipaddress = { 0, 0, 0, 0 }; @@ -116,7 +117,7 @@
     public void bind(int port, InetAddress addr) throws SocketException {
         String prop = AccessController.doPrivileged(new 
PriviAction<String>("bindToDevice")); //$NON-NLS-1$
         boolean useBindToDevice = prop != null && 
prop.toLowerCase().equals("true"); //$NON-NLS-1$
-        bindToDevice = netImpl.bind2(fd, port, useBindToDevice, addr);
+        netImpl.bind(fd, addr, port);
         if (0 != port) {
             localPort = port;
         } else {

Modified: 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
URL: 
http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java?rev=727062&r1=727061&r2=727062&view=diff
==============================================================================
--- 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
 (original)
+++ 
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
 Tue Dec 16 07:06:49 2008
@@ -175,7 +175,7 @@
@Override
     protected void bind(InetAddress anAddr, int aPort) throws IOException {
-        netImpl.bind(fd, aPort, anAddr);
+        netImpl.bind(fd, anAddr, aPort);
         // PlainSocketImpl2.socketBindImpl2(fd, aPort, anAddr);
         address = anAddr;
         if (0 != aPort) {

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=727062&r1=727061&r2=727062&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
 Tue Dec 16 07:06:49 2008
@@ -47,12 +47,9 @@
        public void accept(FileDescriptor fdServer, SocketImpl newSocket,
                        FileDescriptor fdnewSocket, int timeout) throws 
IOException;
- public void bind(FileDescriptor aFD, int port, InetAddress inetAddress)
+       public void bind(FileDescriptor aFD, InetAddress inetAddress, int port)
                        throws SocketException;
- public boolean bind2(FileDescriptor aFD, int port, boolean bindToDevice,
-                       InetAddress inetAddress) throws SocketException;
-
        public int read(FileDescriptor aFD, byte[] data, int offset, int count,
                        int timeout) throws IOException;
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=727062&r1=727061&r2=727062&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
 Tue Dec 16 07:06:49 2008
@@ -62,27 +62,19 @@
public native int availableStream(FileDescriptor fd) throws SocketException; - public native void bind(FileDescriptor aFD, int port,
-            InetAddress inetAddress) throws SocketException;
-
     /**
-     * Bind the socket to the port/localhost in the IP stack.
+     * Associates a local address with a socket.
* * @param fd
      *            the socket descriptor
      * @param port
-     *            the option selector
-     * @param bindToDevice
-     *            bind the socket to the specified interface
+     *            the port number
      * @param inetAddress
-     *            address to connect to.
-     * @return if bind successful
+     *            address to bind
      * @throws SocketException
      *             thrown if bind operation fails
      */
-    public native boolean bind2(FileDescriptor fd, int port,
-            boolean bindToDevice, InetAddress inetAddress)
-            throws SocketException;
+    public native void bind(FileDescriptor fd, InetAddress inetAddress, int 
port) throws SocketException;
public native int connect(FileDescriptor fd, int trafficClass,
             InetAddress inetAddress, int port) throws IOException;

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=727062&r1=727061&r2=727062&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
 Tue Dec 16 07:06:49 2008
@@ -623,12 +623,12 @@
 /*
  * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
  * Method:    bind
- * Signature: (Ljava/io/FileDescriptor;ILjava/net/InetAddress;)V
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/InetAddress;I)V
  */
 JNIEXPORT void JNICALL
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind
   (JNIEnv * env, jobject thiz, jobject fileDescriptor,
-   jint localPort, jobject inetAddress)
+   jobject inetAddress, jint localPort)
 {
   PORT_ACCESS_FROM_ENV(env);
   jbyte nlocalAddrBytes[HYSOCK_INADDR6_LEN];
@@ -881,58 +881,6 @@
/*
  * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
- * Method:    bind2
- * Signature: (Ljava/io/FileDescriptor;IZLjava/net/InetAddress;)Z
- */
-JNIEXPORT jboolean JNICALL
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind2
-  (JNIEnv * env, jobject thiz, jobject fileDescriptor, jint localPort,
-   jboolean doDevice, jobject inetAddress)
-{
-  PORT_ACCESS_FROM_ENV(env);
-  jbyte nlocalAddrBytes[HYSOCK_INADDR6_LEN];
-  int length;
-  U_16 nPort;
-  I_32 result;
-  hysocket_t socketP;
-  hysockaddr_struct sockaddrP;
-  U_32 scope_id = 0;
-
-  /* This method still needs work for IPv6 support */
-
-  socketP = getJavaIoFileDescriptorContentsAsAPointer(env, fileDescriptor);
-  if (!hysock_socketIsValid(socketP)) {
-    throwJavaNetSocketException(env, HYPORT_ERROR_SOCKET_BADSOCKET);
-    return 0;
-  }
-
-  netGetJavaNetInetAddressValue(env, inetAddress, (U_8 *) nlocalAddrBytes,
-                                (U_32 *) & length);
-
-  nPort = hysock_htons((U_16) localPort);
-  if (length == HYSOCK_INADDR6_LEN) {
-    netGetJavaNetInetAddressScopeId(env, inetAddress, &scope_id);
-    hysock_sockaddr_init6(&sockaddrP, (U_8 *) nlocalAddrBytes, length,
-                          HYADDR_FAMILY_AFINET6, nPort, 0, scope_id, socketP);
-  } else {
-    hysock_sockaddr_init6(&sockaddrP, (U_8 *) nlocalAddrBytes, length,
-                          HYADDR_FAMILY_AFINET4, nPort, 0, scope_id, socketP);
-  }
-  result = hysock_bind(socketP, &sockaddrP);
-  if (0 != result) {
-    throwJavaNetBindException(env, result);
-    return 0;
-  }
-
-  /* TOFIX: This matches the windows behaviour but it doesn't look right
-     result must be zero so the return code is zero from all paths.
-   */
-  return result;
-}
-
-
-/*
- * Class:     org_apache_harmony_luni_platform_OSNetworkSystem
  * Method:    peekDatagram
  * Signature: (Ljava/io/FileDescriptor;Ljava/net/InetAddress;I)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=727062&r1=727061&r2=727062&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
 Tue Dec 16 07:06:49 2008
@@ -92,20 +92,11 @@
 /*
  * Class:     org.apache.harmony.luni.platform.OSNetworkSystem
  * Method:    bind
- * Signature: (Ljava/io/FileDescriptor;ILjava/net/InetAddress;)V
+ * Signature: (Ljava/io/FileDescriptor;Ljava/net/InetAddress;I)V
  * Throws:    java.net.SocketException
  */
 JNIEXPORT void JNICALL 
Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind
-  (JNIEnv *, jobject, jobject, jint, jobject);
-
-/*
- * Class:     org.apache.harmony.luni.platform.OSNetworkSystem
- * Method:    bind2
- * Signature: (Ljava/io/FileDescriptor;IZLjava/net/InetAddress;)Z
- * Throws:    java.net.SocketException
- */
-JNIEXPORT jboolean JNICALL 
Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind2
-  (JNIEnv *, jobject, jobject, jint, jboolean, jobject);
+  (JNIEnv *, jobject, jobject, jobject, jint);
/*
  * Class:     org.apache.harmony.luni.platform.OSNetworkSystem

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=727062&r1=727061&r2=727062&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
 Tue Dec 16 07:06:49 2008
@@ -202,7 +202,6 @@
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_sendUrgentData
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_connectDatagram
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_disconnectDatagram
-Java_org_apache_harmony_luni_platform_OSNetworkSystem_bind2
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_peekDatagram
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveDatagram
 Java_org_apache_harmony_luni_platform_OSNetworkSystem_receiveDatagramDirect




--
Best Regards,
Regis.

Reply via email to