commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1144609 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/localsock.c
Date Sat, 09 Jul 2011 07:01:51 GMT
Author: mturk
Date: Sat Jul  9 07:01:51 2011
New Revision: 1144609

URL: http://svn.apache.org/viewvc?rev=1144609&view=rev
Log:
Implement win32 localsock accept

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/localsock.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/localsock.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/localsock.c?rev=1144609&r1=1144608&r2=1144609&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/localsock.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/localsock.c Sat Jul  9 07:01:51
2011
@@ -273,3 +273,46 @@ ACR_NET_EXPORT(void, LocalServerEndpoint
     }
     SOCKADDR_RELEASE(ba, sa);
 }
+
+ACR_NET_EXPORT(jlong, LocalServerEndpoint, accept0)(JNI_STDARGS, jlong fp,
+                                                    jbyteArray ba,
+                                                    jboolean block)
+{
+    SOCKET sd;
+    acr_sockaddr_t    *aa;
+    struct sockaddr_in sa;
+    int sas = ISIZEOF(sa);
+    wls_fd_t *sp;
+    wls_fd_t *wd  = J2P(fp, wls_fd_t *);
+
+    memset(&sa, 0, sizeof(sa));
+    sd = accept(wd->fd.u.s,  0, 0);
+
+    if (sd == SOCKET_ERROR) {
+        ACR_THROW_NET_ERRNO();
+        return 0;
+    }
+    if (block == JNI_FALSE) {
+        int rc = AcrNonblock(sd, 1);
+        if (rc != 0) {
+            closesocket(sd);
+            ACR_THROW_NET_ERROR(rc);
+            return 0;
+        }
+    }
+    if ((sp = ACR_TALLOC(wls_fd_t)) == 0) {
+        closesocket(sd);
+        return 0;
+    }
+    aa = SOCKADDR_CAST(ba);
+    if (aa != 0) {
+        /* The only thing that is unique is port
+         */
+        aa->port = ntohs(sa.sin_port);
+    }
+    SOCKADDR_RELEASE(ba, aa);
+    sp->fd.type = ACR_DT_LSOCK;
+    sp->fd.refs = 1;
+    sp->fd.u.s  = sd;
+    return P2J(sp);
+}



Mime
View raw message