You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/06/24 13:55:30 UTC

svn commit: r1139258 - in /commons/sandbox/runtime/trunk/src/main/native/os: linux/epoll.c unix/pollset.c

Author: mturk
Date: Fri Jun 24 11:55:30 2011
New Revision: 1139258

URL: http://svn.apache.org/viewvc?rev=1139258&view=rev
Log:
Check for TTLd sockets on timeout

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c?rev=1139258&r1=1139257&r2=1139258&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c Fri Jun 24 11:55:30 2011
@@ -497,20 +497,14 @@ ACR_NET_EXPORT(jint, LinuxSelector, wait
     }
     if (ns == 0) {
         /* Timeout occured */
-        ps->state = 0;
-        pthread_cond_broadcast(&ps->wakeup);
-        pthread_mutex_unlock(&ps->mutex);
-        return 0;
+        pevents = JARRAY_CRITICAL(jshort, revents);
+        goto cleanup;
     }
     if (ps->state == PSS_WAKEUP) {
-        /* Interrupted by wakeup0 */
-        //if (ps->fdset[0].revents != 0)
-        {         
-            /* Drain the wakeup pipe.
-             * Wakeup pipe is always at index zero.
-             */
-            AcrDrainPipe(ps->wpipe[0]);
-        }
+        /* Interrupted by wakeup0.
+         * Drain the wakeup pipe.
+         */
+        AcrDrainPipe(ps->wpipe[0]);
         ps->state = 0;
         pthread_cond_broadcast(&ps->wakeup);
         pthread_mutex_unlock(&ps->mutex);
@@ -550,6 +544,7 @@ ACR_NET_EXPORT(jint, LinuxSelector, wait
             }
         }
     }
+cleanup:
     /* Remove expired descriptors */
     ACR_RING_FOREACH_SAFE(pe, np, &ps->eset_ring, pfd_elem_t, link) {
         if (pe->pfd.ttl > 0) {

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c?rev=1139258&r1=1139257&r2=1139258&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c Fri Jun 24 11:55:30 2011
@@ -307,11 +307,20 @@ ACR_NET_EXPORT(jint, PollSelector, wait0
         return 0;
     }
     if (ns == 0) {
-        /* Timeout occured */
-        ps->state = 0;
-        pthread_cond_broadcast(&ps->wakeup);
-        pthread_mutex_unlock(&ps->mutex);
-        return 0;
+        pevents = JARRAY_CRITICAL(jshort, revents);
+        for (i = 1; i < ps->used; i++) {
+            if (ps->ooset[i].ttl > 0) {
+                if (now == 0)
+                    now = AcrTimeNow();
+                if (now > ps->ooset[i].exp) {
+                    /* Expired descriptor */
+                    ps->fdset[i].revents = POLLHUP;
+                    pevents[rv] = ACR_OP_TIMEOUT;
+                    (*env)->SetObjectArrayElement(env, rs, rv++, ps->ooset[i].obj);
+                }
+            }
+        }
+        goto cleanup;
     }
     if (ps->state == PSS_WAKEUP) {
         /* Interrupted by wakeup0 */
@@ -365,6 +374,7 @@ ACR_NET_EXPORT(jint, PollSelector, wait0
             }
         }
     }
+cleanup:
     RELEASE_CRITICAL(revents, pevents);
     if (autocancel == JNI_TRUE && rv > 0) {
         /* Remove all descriptors with revents set except