harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r952336 - /harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/port/unix/hysock.c
Date Mon, 07 Jun 2010 17:14:05 GMT
Author: hindessm
Date: Mon Jun  7 17:14:05 2010
New Revision: 952336

URL: http://svn.apache.org/viewvc?rev=952336&view=rev
Log:
Fix FreeBSD socket problem - it requires the sin_len field to be correct.
"ant -Dexclude.module=awt,swing test" now passes 99.27% of 17597 tests.

This indirectly fixes "[#HARMONY-6458] [classlib] [portlib] unix/hysock.c
hysock_bind has redundant code".

Modified:
    harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/port/unix/hysock.c

Modified: harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/port/unix/hysock.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/port/unix/hysock.c?rev=952336&r1=952335&r2=952336&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/port/unix/hysock.c
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/portlib/src/main/native/port/unix/hysock.c
Mon Jun  7 17:14:05 2010
@@ -602,12 +602,16 @@ hysock_bind (struct HyPortLibrary * port
     {
       length = ((OSSOCKADDR_IN6 *) & addr->addr)->sin6_len;
     }
+#if defined(FREEBSD)
+  else {
+    length = ((OSSOCKADDR *) & addr->addr)->sin_len;
+  }
+#endif
 #endif
 #endif
 
   if (bind
-      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
-       sizeof (addr->addr)) < 0)
+      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr, length) < 0)
     {
       rc = errno;
       HYSOCKDEBUG ("<bind failed, err=%d>\n", rc);
@@ -678,10 +682,15 @@ hysock_connect (struct HyPortLibrary * p
                 hysockaddr_t addr)
 {
   I_32 rc = 0;
+  I_32 length =
+#if !defined(FREEBSD)
+           sizeof (addr->addr);
+#else
+           ((OSSOCKADDR *) & addr->addr)->sin_len;
+#endif
 
   if (connect
-      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr,
-       sizeof (addr->addr)) < 0)
+      (SOCKET_CAST (sock), (struct sockaddr *) &addr->addr, length) < 0)
     {
       rc = errno;
       HYSOCKDEBUG ("<connect failed, err=%d>\n", rc);
@@ -3465,6 +3474,9 @@ hysock_sockaddr_init (struct HyPortLibra
   sockaddr->sin_family = family;
   sockaddr->sin_addr.s_addr = nipAddr;
   sockaddr->sin_port = nPort;
+#if defined(FREEBSD)
+  sockaddr->sin_len = sizeof(OSSOCKADDR);
+#endif
 
   return 0;
 }
@@ -3530,6 +3542,9 @@ hysock_sockaddr_init6 (struct HyPortLibr
           sockaddr_6->sin6_family = OS_AF_INET6;
           sockaddr_6->sin6_scope_id = scope_id;
           sockaddr_6->sin6_flowinfo = htonl (flowinfo);
+#if defined(FREEBSD)
+          sockaddr_6->sin6_len = sizeof(OSSOCKADDR_IN6);
+#endif
         }
       else
         {
@@ -3540,6 +3555,10 @@ hysock_sockaddr_init6 (struct HyPortLibr
           memcpy (&sockaddr->sin_addr.s_addr, addr, addrlength);
           sockaddr->sin_port = nPort;
           sockaddr->sin_family = OS_AF_INET4;
+#if defined(FREEBSD)
+          sockaddr->sin_len = sizeof(OSSOCKADDR);
+#endif
+
 #if defined(IPv6_FUNCTION_SUPPORT)
         }
 #endif
@@ -3555,7 +3574,7 @@ hysock_sockaddr_init6 (struct HyPortLibr
       sockaddr_6->sin6_scope_id = scope_id;
       sockaddr_6->sin6_flowinfo = htonl (flowinfo);
 #if defined(SIN6_LEN)
-      sockaddr_6->sin6_len = sizeof (struct sockaddr_in6);
+      sockaddr_6->sin6_len = sizeof(OSSOCKADDR_IN6);
       if (((OSSOCKADDR_IN6 *) & handle->addr)->sin6_len != 0)
         {
           sockaddr_6->sin6_len =
@@ -3571,6 +3590,9 @@ hysock_sockaddr_init6 (struct HyPortLibr
       memcpy (&sockaddr->sin_addr.s_addr, addr, HYSOCK_INADDR_LEN);
       sockaddr->sin_port = nPort;
       sockaddr->sin_family = map_addr_family_Hy_to_OS (family);
+#if defined(FREEBSD)
+          sockaddr->sin_len = sizeof(OSSOCKADDR);
+#endif
     }
 
   return 0;



Mime
View raw message