mturk       2005/06/14 00:14:00

  Modified:    jni/java/org/apache/tomcat/jni Poll.java
               jni/native/src poll.c
  Log:
  Add Poll.pollset method to return all the descriptors that are
  currently in the Poll.
  
  Revision  Changes    Path
  1.9       +19 -1     
jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Poll.java
  
  Index: Poll.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Poll.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Poll.java 19 Apr 2005 16:32:11 -0000      1.8
  +++ Poll.java 14 Jun 2005 07:14:00 -0000      1.9
  @@ -144,4 +144,22 @@
        */
       public static native long getTtl(long pollset);
   
  +    /**
  +     * Return all descriptor(s) in a pollset
  +     * @param pollset The pollset to use
  +     * @param descriptors Array of descriptors (output parameter)
  +     *        The desctiptor array must be four times the size of pollset.
  +     *        and are populated as follows:
  +     * <PRE>
  +     * descriptors[n + 0] -> returned events
  +     * descriptors[n + 1] -> socket
  +     * descriptors[n + 2] -> client data
  +     * descriptors[n + 2] -> reserved
  +     * </PRE>
  +     * @return Number of descriptors (output parameter) in the Poll
  +     *         or negative APR error code.
  +     */
  +    public static native int pollset(long pollset, long [] descriptors,
  +                                     boolean remove);
  +
   }
  
  
  
  1.19      +26 -1     jakarta-tomcat-connectors/jni/native/src/poll.c
  
  Index: poll.c
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/jni/native/src/poll.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- poll.c    10 Jun 2005 07:06:10 -0000      1.18
  +++ poll.c    14 Jun 2005 07:14:00 -0000      1.19
  @@ -340,3 +340,28 @@
       UNREFERENCED_STDARGS;
       return (jlong)p->max_ttl;
   }
  +
  +TCN_IMPLEMENT_CALL(jint, Poll, pollset)(TCN_STDARGS, jlong pollset,
  +                                        jlongArray set)
  +{
  +    tcn_pollset_t *p = J2P(pollset,  tcn_pollset_t *);
  +    jlong *pset = (*e)->GetLongArrayElements(e, set, NULL);
  +    apr_int32_t  i = 0;
  +    apr_pollfd_t fd;
  +
  +    UNREFERENCED(o);
  +    TCN_ASSERT(pollset != 0);
  +
  +    for (i = 0; i < p->nelts; i++) {
  +        p->socket_set[i].rtnevents = APR_POLLHUP | APR_POLLIN;
  +        fd = p->socket_set[i];
  +        pset[i*4+0] = (jlong)(fd.rtnevents);
  +        pset[i*4+1] = P2J(fd.desc.s);
  +        pset[i*4+2] = P2J(fd.client_data);
  +    }
  +    if (p->nelts)
  +        (*e)->ReleaseLongArrayElements(e, set, pset, 0);
  +    else
  +        (*e)->ReleaseLongArrayElements(e, set, pset, JNI_ABORT);
  +    return (jint)p->nelts;
  +}
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to