El ds 23 de 10 de 2010 a les 03:17 +0400, en/na Konstantin Kolinko va
escriure:

> From Poll.java of Tomcat trunk:
> 
>      * @param descriptors Array of signaled descriptors (output parameter)
>      *        The descriptor array must be two times the size of pollset.
>      *        and are populated as follows:
> 
> You create a pollset with size of 10, but pass in an array of 2 ?

You are right, I was just trying things here, but 2 should be ok since
pollset length is 1 (listening socket only)

> AprEndpoint.java:
>             return Poll.create(size, pool, 0, timeout * 1000);
> 
> See also [1]
> 
> The ttl value is apr_interval_time_t, which is measured in microseconds.
> 
> The value for "timeout" may come from
> org.apache.tomcat.util.net.SocketProperties.soTimeout, which defaults
> to 20000 (20 seconds).
> 
> Thus 20000 * 1000;

Thanks for this, I'll pass same value

> From the source code (it is network.c) it looks like -1 wouldn't be a
> valid value for nbytes argument,  so the javadoc in Socket.java is
> wrong here.

agreed

> Tomcat sources?

Of course. Key point is that it seems as if there is a severe bug in
tomcat-native-1.1.20-src/jni/native/src/poll.c:

TCN_IMPLEMENT_CALL(jint, Poll, poll)(TCN_STDARGS, jlong pollset,
                                     jlong timeout, jlongArray set,
                                     jboolean remove)
{
    ....
    if (ptime > 0 && p->max_ttl >= 0) {
        now = apr_time_now();

        /* Find the minimum timeout */
        for (i = 0; i < p->nelts; i++) {
            apr_interval_time_t t = now - p->socket_ttl[i];
            if (t >= p->max_ttl) {
                ptime = 0;
                break;
            }
            else {
                ptime = TCN_MIN(p->max_ttl - t, ptime);
            }
        }
    }
    else if (ptime < 0)
        ptime = 0;
    for (;;) {
        rv = apr_pollset_poll(p->pollset, ptime, &num, &fd);
    ....

There is no way for this code that ptime can be made negative.
apr_pollset_poll never blocks! As a short workaround I commented:

    /*else if (ptime < 0)
        ptime = 0;*/

I'm waiting for Mladen Turk to say something about this.

Best regards,
Francesc Oller
> 
> > Regards, francesc
> >
> 
> [1] 
> http://svn.apache.org/viewvc/tomcat/native/branches/1.1.x/native/src/poll.c?view=markup
> 
> 
> Best regards,
> Konstantin Kolinko
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to