commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1133451 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/ java/org/apache/commons/runtime/net/ native/os/unix/ native/shared/
Date Wed, 08 Jun 2011 16:09:40 GMT
Author: mturk
Date: Wed Jun  8 16:09:40 2011
New Revision: 1133451

URL: http://svn.apache.org/viewvc?rev=1133451&view=rev
Log:
Add ACR_EINPROGRESS check

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointAddress.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalEndpoint.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalServerEndpoint.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketEndpoint.java
    commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c
    commons/sandbox/runtime/trunk/src/main/native/shared/error.c
    commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Status.java Wed
Jun  8 16:09:40 2011
@@ -184,6 +184,12 @@ public final class Status
         return is0(7, s);
     }
 
+    /** Operation in progress */
+    public static boolean IS_EINPROGRESS(int s)
+    {
+        return is0(8, s);
+    }
+
     /** Obtain an error string for system error code.
      *
      * @param s error code

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointAddress.java?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointAddress.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/EndpointAddress.java
Wed Jun  8 16:09:40 2011
@@ -32,7 +32,6 @@ public abstract class EndpointAddress
 
     private int    family;
     private static native int     family0(byte[] sa);
-    private static native void    free0(byte[] sa);
     private static native boolean equals0(byte[] sa1, byte[] sa2);
     private static native String  name0(byte[] sa);
 

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalEndpoint.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalEndpoint.java?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalEndpoint.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalEndpoint.java
Wed Jun  8 16:09:40 2011
@@ -83,6 +83,7 @@ public class LocalEndpoint extends Endpo
             else
                 throw new IOException(Status.describe(rc));
         }
+        ea = endpoint;
     }
 
     public final void connect(EndpointAddress endpoint)

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalServerEndpoint.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalServerEndpoint.java?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalServerEndpoint.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/LocalServerEndpoint.java
Wed Jun  8 16:09:40 2011
@@ -25,6 +25,8 @@ import java.io.SyncFailedException;
 import java.net.SocketException;
 import org.apache.commons.runtime.io.ClosedDescriptorException;
 import org.apache.commons.runtime.io.Descriptor;
+import org.apache.commons.runtime.io.OperationInProgressException;
+import org.apache.commons.runtime.io.OperationWouldBlockException;
 import org.apache.commons.runtime.OverflowException;
 import org.apache.commons.runtime.Status;
 
@@ -148,7 +150,7 @@ public class LocalServerEndpoint extends
     }
 
     private static native int           bind0(int fd, byte[] sa, int backlog);
-    private static native int           accept0(int fd, byte[] addr)
+    private static native int           accept0(int fd, byte[] sa)
         throws SocketException;
 
     @Override
@@ -176,11 +178,8 @@ public class LocalServerEndpoint extends
     {
         if (sd.closed())
             throw new ClosedDescriptorException();
-        byte[] addr = AbstractAddress.alloc();
-
-        int fd = accept0(sd.fd(), addr);
+        int fd = accept0(sd.fd(), sa.sockaddr());
         LocalDescriptor ad = new LocalDescriptor(fd);
-        AbstractAddress aa = new AbstractAddress(AddressFamily.LOCAL, addr);
-        return new LocalEndpoint(ad, aa);
+        return new LocalEndpoint(ad, sa);
     }
 }

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketAddress.java
Wed Jun  8 16:09:40 2011
@@ -49,7 +49,10 @@ public abstract class SocketAddress exte
      * Set to true if the IPV6 is supported by the
      * Operating system
      */
-    public static final boolean   HAVE_IPV6 = haveipv6();
+    public static final boolean   HAVE_IPV6;
+    static {
+        HAVE_IPV6 = haveipv6();
+    }
 
     /**
      * Creates an new object

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketEndpoint.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketEndpoint.java?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketEndpoint.java
(original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/net/SocketEndpoint.java
Wed Jun  8 16:09:40 2011
@@ -34,7 +34,8 @@ import org.apache.commons.runtime.Status
 public class SocketEndpoint extends Endpoint
 {
     private final SocketDescriptor      sd;
-    private EndpointAddress             ea;
+    private SocketAddress               ea; // Remote address
+    private SocketAddress               sa; // Local  address
     private SelectionKeyImpl            key;
     private boolean                     connected = false;
 
@@ -49,9 +50,9 @@ public class SocketEndpoint extends Endp
 
     /**
      * Creates a new connected socket endpoint from a socket descriptor
-     * and local address.
+     * and remote address.
      */
-    public SocketEndpoint(Descriptor sd, EndpointAddress ea)
+    public SocketEndpoint(Descriptor sd, SocketAddress ea)
     {
         super(EndpointType.SOCKET);
         if (sd == null || ea == null)
@@ -61,14 +62,14 @@ public class SocketEndpoint extends Endp
         connected = true;
     }
 
-    public void connect(EndpointAddress endpoint, int timeout)
+    public void connect(SocketAddress endpoint, int timeout)
         throws IOException
     {
         if (connected)
             throw new IOException(Local.sm.get("endpoint.ECONNECTED"));
     }
 
-    public final void connect(EndpointAddress endpoint)
+    public final void connect(SocketAddress endpoint)
         throws IOException
     {
         connect(endpoint, -1);

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_defs.h Wed Jun  8 16:09:40
2011
@@ -80,6 +80,9 @@ typedef struct stat         struct_stat_
 #define ACR_CRLF            "\n"
 /* Any value will do */
 #define ACR_FTOK_ID         's'
+#if !defined(SOCKET_ERROR)
+# define SOCKET_ERROR       (-1)
+#endif
 
 #if defined(_SOLARIS)
 # define SHELL_PATH         "/usr/xpg4/bin/sh"

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/usock.c Wed Jun  8 16:09:40 2011
@@ -182,7 +182,6 @@ ACR_NET_EXPORT(jint, LocalServerEndpoint
 
     memset(&aa, 0, sizeof(aa));
     aalen = ISIZEOF(struct sockaddr_un);
-
     do {
 #if !HAVE_ACCEPT4
         sd = accept(fd,  (struct sockaddr *)&aa.sa, &aalen);
@@ -210,15 +209,6 @@ ACR_NET_EXPORT(jint, LocalServerEndpoint
         fprintf(stderr, "Expected AF_LOCAL but found %d\n", aa.sa.unx.sun_family);
         fflush(stderr);
     }
-#endif    
-    aa.family  = AF_LOCAL;
-    aa.salen   = ISIZEOF(struct sockaddr_un);
-    aa.addrlen = ISIZEOF(aa.sa.unx.sun_path);
-    aa.iplen   = aa.addrlen;
-    aa.addrcnt = 1;
-    /* Copy sockaddr to the provided byte array
-     * Note that byte array must be of valid size
-     */
-    (*env)->SetByteArrayRegion(env, ba, 0, ISIZEOF(acr_sockaddr_t), (jbyte *)&aa);
+#endif
     return sd;
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/error.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/error.c?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/error.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/error.c Wed Jun  8 16:09:40 2011
@@ -945,6 +945,10 @@ ACR_JNI_EXPORT(jboolean, Status, is0)(JN
             if (ACR_STATUS_IS_TIMEUP(err) || err == ACR_ETIMEDOUT)
                 rv = JNI_TRUE;
         break;
+        case 8:
+            if (ACR_STATUS_IS_EINPROGRESS(err))
+                rv = JNI_TRUE;
+        break;
         default:
         break;
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c?rev=1133451&r1=1133450&r2=1133451&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/netaddr.c Wed Jun  8 16:09:40 2011
@@ -412,7 +412,7 @@ int
 AcrGetLocalAddr(int sockfd, acr_sockaddr_t *sockaddr)
 {
     socklen_t salen = sizeof(sockaddr->sa);
-    if (getsockname(ACR_SOCKET(sockfd), (struct sockaddr *)&sockaddr->sa, &salen)
< 0) {
+    if (getsockname(ACR_SOCKET(sockfd), (struct sockaddr *)&sockaddr->sa, &salen)
== SOCKET_ERROR) {
         return ACR_GET_NETOS_ERROR();
     }
     else {
@@ -426,7 +426,7 @@ int
 AcrGetRemoteAddr(int sockfd, acr_sockaddr_t *sockaddr)
 {
     socklen_t salen = sizeof(sockaddr->sa);
-    if (getpeername(ACR_SOCKET(sockfd), (struct sockaddr *)&sockaddr->sa, &salen)
< 0) {
+    if (getpeername(ACR_SOCKET(sockfd), (struct sockaddr *)&sockaddr->sa, &salen)
== SOCKET_ERROR) {
         return ACR_GET_NETOS_ERROR();
     }
     else {



Mime
View raw message