commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1099058 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr/jnidefs.h shared/iofd.c shared/psockimpl.c shared/ssock.c
Date Tue, 03 May 2011 14:03:34 GMT
Author: mturk
Date: Tue May  3 14:03:33 2011
New Revision: 1099058

URL: http://svn.apache.org/viewvc?rev=1099058&view=rev
Log:
Set both server sockets to nonblockin mode for TwoStacks sockets

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h
    commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c
    commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c
    commons/sandbox/runtime/trunk/src/main/native/shared/ssock.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h?rev=1099058&r1=1099057&r2=1099058&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/jnidefs.h Tue May  3 14:03:33
2011
@@ -95,6 +95,7 @@
 #define J_DECLARE_F_ID(I)       static JAVA_F_ID _f##I##n
 #define J_DECLARE_M_ID(I)       static JAVA_M_ID _m##I##n
 #define J4MID(I)                _m##I##n.i
+#define J4FID(I)                _f##I##n.i
 #define J4FLD_OFF(I)            _f##I##n.o
 #define J4FLD_PTR(I)            (ptrdiff_t)_f##I##n.o
 

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c?rev=1099058&r1=1099057&r2=1099058&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/iofd.c Tue May  3 14:03:33 2011
@@ -180,7 +180,7 @@ AcrNewFileDescriptor(JNI_STDENV, int fd,
     else
         fo = (*env)->NewObject(env, _clazzn.i, J4MID(0000));
     if (fo != 0) {
-        if (J4MID(0001) != 0)
+        if (J4MID(0001) == 0)
             rc = AcrSetFileDescriptorFd(env, fo, fd);
         else
             rc = 0;

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c?rev=1099058&r1=1099057&r2=1099058&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/psockimpl.c Tue May  3 14:03:33 2011
@@ -70,8 +70,8 @@ ACR_CLASS_CTOR(SocketImpl)
         tsc = 0;
     }
     else {
-        _f0001n.i = (*env)->GetFieldID(env, tsc, _f0001n.n, _f0001n.s);
-        if (_f0001n.i == 0) {
+        J4FID(0001) = (*env)->GetFieldID(env, tsc, _f0001n.n, _f0001n.s);
+        if (J4FID(0001) == 0) {
             (*env)->ExceptionClear(env);                            
         }
         else {
@@ -80,10 +80,10 @@ ACR_CLASS_CTOR(SocketImpl)
             if (TwoStacksPlainSocketImplClass == 0) {
                 (*env)->ExceptionClear(env);
                 /* Reference failed */
-                _f0001n.i = 0;
+                J4FID(0001) = 0;
             }
             else {
-                _f0001n.o = AcrUnsafeObjectFieldIdOffset(env, TwoStacksPlainSocketImplClass,
_f0001n.i);                 
+                _f0001n.o = AcrUnsafeObjectFieldIdOffset(env, TwoStacksPlainSocketImplClass,
J4FID(0001));                 
                 printf("TwoStacksPlainSocketImplClass loaded\n");
                 fflush(stdout);
             }
@@ -112,3 +112,22 @@ jobject AcrGetSocketImplFd(JNI_STDARGS)
     }
     return o;
 }
+
+#if defined(WINDOWS)
+jobject AcrGetSocketImplFa(JNI_STDARGS)
+{
+    jobject o = 0;
+
+    if ((*env)->IsInstanceOf(env, obj, TwoStacksPlainSocketImplClass) == JNI_FALSE)
+        return 0;
+    if (J4FLD_OFF(0001) != INVALID_FIELD_OFFSET) {
+        char *oa = *(char **)obj;
+        if (oa != 0)
+            o = (jobject)(oa + J4FLD_PTR(0001));
+    }
+    else {
+        o = GET_IFIELD_O(0001, obj);
+    }
+    return o;
+}
+#endif

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/ssock.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/ssock.c?rev=1099058&r1=1099057&r2=1099058&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/ssock.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/ssock.c Tue May  3 14:03:33 2011
@@ -95,6 +95,30 @@ AcrGetServerSocketFd(JNI_STDARGS)
     }
     return -1;
 }
+#if defined(WINDOWS)
+extern jobject AcrGetSocketImplFa(JNI_STDARGS);
+static int
+AcrGetServerSocketFa(JNI_STDARGS)
+{
+    jobject impl = 0;
+    jobject fd;
+
+    if (J4FLD_OFF(0000) != INVALID_FIELD_OFFSET) {
+        char *oa = *(char **)obj;
+        if (oa != 0)
+            impl = (jobject)(oa + J4FLD_PTR(0000));
+    }
+    else if (CLAZZ_LOADED) {
+        impl = GET_IFIELD_O(0000, obj);
+    }
+    if (impl != 0) {
+        fd = AcrGetSocketImplFa(env, impl);
+        if (fd != 0)
+            return AcrGetFileDescriptorFd(env, fd);
+    }
+    return -1;
+}
+#endif
 
 ACR_NET_EXPORT(jint, SocketInstance, nd1)(JNI_STDARGS, jobject sock)
 {
@@ -136,6 +160,11 @@ ACR_NET_EXPORT(jint, SocketInstance, nb1
         impl = GET_IFIELD_O(0000, sock);
     }
     if (impl != 0) {
+#if defined(WINDOWS)
+        jobject fa = AcrGetSocketImplFa(env, impl);
+        if (fa != 0)
+            AcrNonblock(AcrGetFileDescriptorFd(env, fa), on);
+#endif
         fd = AcrGetSocketImplFd(env, impl);
         if (fd != 0) {
             /* Set socket to nonblocking mode if on == JNI_TRUE*/



Mime
View raw message