commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1126610 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr/iodefs.h os/unix/poll.c
Date Mon, 23 May 2011 17:33:59 GMT
Author: mturk
Date: Mon May 23 17:33:58 2011
New Revision: 1126610

URL: http://svn.apache.org/viewvc?rev=1126610&view=rev
Log:
Reference objects stored in pollset

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h?rev=1126610&r1=1126609&r2=1126610&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr/iodefs.h Mon May 23 17:33:58
2011
@@ -23,8 +23,8 @@
  */
 #define ACR_PIPE_FULL_BLOCK     1
 #define ACR_PIPE_FULL_NONBLOCK  2
-#define ACR_PIPE_READ_BLOCK     3
-#define ACR_PIPE_WRITE_BLOCK    4
+#define ACR_PIPE_READ_BLOCK     3     /**< Read blocking, Write nonblocking */  
+#define ACR_PIPE_WRITE_BLOCK    4     /**< Write blocking, Read nonblocking */
 
 #define ACR_PIPE_MODE_MASK      0x000F
 #define ACR_PIPE_NOINHERIT      0x0010

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c?rev=1126610&r1=1126609&r2=1126610&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/poll.c Mon May 23 17:33:58 2011
@@ -185,9 +185,10 @@ ACR_NET_EXPORT(void, Pollset, destroy0)(
     }
     ps->state = PSS_DESTROY;
     pthread_mutex_unlock(&ps->mutex);
-    for (i = 0; i < ps->used; i++) {
+    for (i = 1; i < ps->used; i++) {
         if (ps->ooset[i].obj != 0) {
-            /* XXX: Invalidate the container. */
+            /* Invalidate the container. */
+            (*env)->DeleteGlobalRef(env, ps->ooset[i].obj);
         }
     }
     r_close(ps->wpipe[0]);
@@ -229,7 +230,10 @@ ACR_NET_EXPORT(jint, Pollset, clear0)(JN
         }
     }
     for (i = 1; i < ps->used; i++) {
-        (*env)->SetObjectArrayElement(env, rs, cnt++, ps->ooset[i].obj);
+        if (ps->ooset[i].obj != 0) {
+            (*env)->SetObjectArrayElement(env, rs, cnt++, ps->ooset[i].obj);
+            (*env)->DeleteGlobalRef(env, ps->ooset[i].obj);
+        }
     }
     ps->used = 1;
     pthread_mutex_unlock(&ps->mutex);
@@ -359,6 +363,10 @@ ACR_NET_EXPORT(jint, Pollset, wait0)(JNI
                 int dest = i;
                 int used = ps->used;
                 ps->used--;
+                if (ps->ooset[i].obj != 0) {
+                    (*env)->DeleteGlobalRef(env, ps->ooset[i].obj);
+                    ps->ooset[i].obj = 0;
+                }
                 for (++i; i < used; i++) {
                     if (ps->fdset[i].revents != 0) {
                         /* Skip signaled descriptor */
@@ -408,7 +416,7 @@ ACR_NET_EXPORT(jint, Pollset, add0)(JNI_
     ps->fdset[ps->used].fd      = f;
     ps->fdset[ps->used].events  = ieventt(events);
     ps->fdset[ps->used].revents = 0;
-    ps->ooset[ps->used].obj     = fo;
+    ps->ooset[ps->used].obj     = (*env)->NewGlobalRef(env, fo);
     if (ttlms > 0)
         ps->ooset[ps->used].ttl = AcrTimeNow() + AcrTimeFromMsec(ttlms);
     else



Mime
View raw message