You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by mt...@apache.org on 2008/05/26 14:42:14 UTC

svn commit: r660175 - in /tomcat/connectors/trunk/jni: CHANGELOG.txt native/src/poll.c

Author: mturk
Date: Mon May 26 05:42:11 2008
New Revision: 660175

URL: http://svn.apache.org/viewvc?rev=660175&view=rev
Log:
Fix 45071 by updating ttl for signaled but not removed sockets

Modified:
    tomcat/connectors/trunk/jni/CHANGELOG.txt
    tomcat/connectors/trunk/jni/native/src/poll.c

Modified: tomcat/connectors/trunk/jni/CHANGELOG.txt
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/CHANGELOG.txt?rev=660175&r1=660174&r2=660175&view=diff
==============================================================================
--- tomcat/connectors/trunk/jni/CHANGELOG.txt (original)
+++ tomcat/connectors/trunk/jni/CHANGELOG.txt Mon May 26 05:42:11 2008
@@ -19,7 +19,7 @@
 ./jnirelease.sh
 TO BUILD THE TEXT VERSION.
 
-
+Fix: BZ45071 by reseting ttl when Poll.pool remove is false(mturk)
 Fix: IFS problem in native/build/tcnative.m4 (rjung)
 Fix: Wrong gcc link flag in native/build/tcnative.m4 (rjung)
 Tag: 1_1.12

Modified: tomcat/connectors/trunk/jni/native/src/poll.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jni/native/src/poll.c?rev=660175&r1=660174&r2=660175&view=diff
==============================================================================
--- tomcat/connectors/trunk/jni/native/src/poll.c (original)
+++ tomcat/connectors/trunk/jni/native/src/poll.c Mon May 26 05:42:11 2008
@@ -224,6 +224,20 @@
     return apr_pollset_remove(p->pollset, fd);
 }
 
+static void update_ttl(tcn_pollset_t *p, const apr_pollfd_t *fd, apr_time_t t)
+{
+    apr_int32_t i;
+
+    for (i = 0; i < p->nelts; i++) {
+        if (fd->desc.s == p->socket_set[i].desc.s) {
+            /* Found an instance of the fd: update ttl */
+            p->socket_ttl[i] = t;
+            break;
+        }
+    }
+}
+
+
 static void remove_all(tcn_pollset_t *p)
 {
     apr_int32_t i;
@@ -266,6 +280,7 @@
     tcn_pollset_t *p = J2P(pollset,  tcn_pollset_t *);
     apr_int32_t  i, num = 0;
     apr_status_t rv = APR_SUCCESS;
+    apr_time_t now;
     apr_interval_time_t ptime = J2T(timeout);
     UNREFERENCED(o);
     TCN_ASSERT(pollset != 0);
@@ -275,7 +290,7 @@
 #endif
 
     if (ptime > 0 && p->max_ttl >= 0) {
-        apr_time_t now = apr_time_now();
+        now = apr_time_now();
 
         /* Find the minimum timeout */
         for (i = 0; i < p->nelts; i++) {
@@ -316,11 +331,15 @@
          p->sp_polled += num;
          p->sp_max_polled = TCN_MAX(p->sp_max_polled, num);
 #endif
+        if (!remove)
+            now = apr_time_now();
         for (i = 0; i < num; i++) {
             p->set[i*2+0] = (jlong)(fd->rtnevents);
             p->set[i*2+1] = P2J(fd->client_data);
             if (remove)
                 do_remove(p, fd);
+            else
+                update_ttl(p, fd, now);
             fd ++;
         }
         (*e)->SetLongArrayRegion(e, set, 0, num * 2, p->set);



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r660175 - in /tomcat/connectors/trunk/jni: CHANGELOG.txt native/src/poll.c

Posted by Mladen Turk <mt...@apache.org>.
Remy Maucherat wrote:
>> +static void update_ttl(tcn_pollset_t *p, const apr_pollfd_t *fd, apr_time_t t)
>> +{
>> +    apr_int32_t i;
>> +
>> +    for (i = 0; i < p->nelts; i++) {
>> +        if (fd->desc.s == p->socket_set[i].desc.s) {
>> +            /* Found an instance of the fd: update ttl */
>> +            p->socket_ttl[i] = t;
>> +            break;
>> +        }
>> +    }
>> +}
> 
> Why is it needed to iterate over the whole array rather than simply for
> the array position that is signaled ? I am not aware of cases where one
> socket is placed multiple times in the poller (actually, this would
> probably cause crashes when the socket is closed).
> 

It's because poll returns socket descriptor array not our internal data,
so we need to match the socket to our socket placeholder.
Not very efficient, I know.
The solution would be to add additional array to the internal
struct that would allow to skip this scan.
I'll see how this can be done more intelligently.


Regards
-- 
^(TM)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r660175 - in /tomcat/connectors/trunk/jni: CHANGELOG.txt native/src/poll.c

Posted by Remy Maucherat <re...@apache.org>.
On Mon, 2008-05-26 at 12:42 +0000, mturk@apache.org wrote:
> Author: mturk
> Date: Mon May 26 05:42:11 2008
> New Revision: 660175
> 
> URL: http://svn.apache.org/viewvc?rev=660175&view=rev
> Log:
> Fix 45071 by updating ttl for signaled but not removed sockets

> +static void update_ttl(tcn_pollset_t *p, const apr_pollfd_t *fd, apr_time_t t)
> +{
> +    apr_int32_t i;
> +
> +    for (i = 0; i < p->nelts; i++) {
> +        if (fd->desc.s == p->socket_set[i].desc.s) {
> +            /* Found an instance of the fd: update ttl */
> +            p->socket_ttl[i] = t;
> +            break;
> +        }
> +    }
> +}

Why is it needed to iterate over the whole array rather than simply for
the array position that is signaled ? I am not aware of cases where one
socket is placed multiple times in the poller (actually, this would
probably cause crashes when the socket is closed).

Of course, compared with the IO operation itself, this is still quite
cheap.

Rémy



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r660175 - in /tomcat/connectors/trunk/jni: CHANGELOG.txt native/src/poll.c

Posted by jean-frederic clere <jf...@gmail.com>.
Mladen Turk wrote:
> jean-frederic clere wrote:
>> mturk@apache.org wrote:
>>> Author: mturk
>>> Date: Mon May 26 05:42:11 2008
>>> New Revision: 660175
>>>
>>> URL: http://svn.apache.org/viewvc?rev=660175&view=rev
>>> Log:
>>> Fix 45071 by updating ttl for signaled but not removed sockets
>>>
>>> Modified:
>>>     tomcat/connectors/trunk/jni/CHANGELOG.txt
>>
>> Please could you put the information in 
>> jk/xdocs/miscellaneous/changelog.xml? (CHANGELOG.txt is a generated 
>> file).
>>
> 
> Are you sure?
> svn cat $SVNBASE/${JKJNIEXT}/jni/CHANGELOG.txt > ${JKJNIDIST}/CHANGELOG.txt
> 
> Again this is not mod_jk where this is auto generated from html

Right I missed the file while copy + paste: 
jni/xdocs/miscellaneous/changelog.xml is the file where the explaination 
about the fix should go. Sorry.

Cheers

Jean-Frederic

> 
> Regards


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r660175 - in /tomcat/connectors/trunk/jni: CHANGELOG.txt native/src/poll.c

Posted by Mladen Turk <mt...@apache.org>.
jean-frederic clere wrote:
> mturk@apache.org wrote:
>> Author: mturk
>> Date: Mon May 26 05:42:11 2008
>> New Revision: 660175
>>
>> URL: http://svn.apache.org/viewvc?rev=660175&view=rev
>> Log:
>> Fix 45071 by updating ttl for signaled but not removed sockets
>>
>> Modified:
>>     tomcat/connectors/trunk/jni/CHANGELOG.txt
> 
> Please could you put the information in 
> jk/xdocs/miscellaneous/changelog.xml? (CHANGELOG.txt is a generated file).
> 

Are you sure?
svn cat $SVNBASE/${JKJNIEXT}/jni/CHANGELOG.txt > ${JKJNIDIST}/CHANGELOG.txt

Again this is not mod_jk where this is auto generated from html

Regards
-- 
^(TM)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: svn commit: r660175 - in /tomcat/connectors/trunk/jni: CHANGELOG.txt native/src/poll.c

Posted by jean-frederic clere <jf...@gmail.com>.
mturk@apache.org wrote:
> Author: mturk
> Date: Mon May 26 05:42:11 2008
> New Revision: 660175
> 
> URL: http://svn.apache.org/viewvc?rev=660175&view=rev
> Log:
> Fix 45071 by updating ttl for signaled but not removed sockets
> 
> Modified:
>     tomcat/connectors/trunk/jni/CHANGELOG.txt

Please could you put the information in 
jk/xdocs/miscellaneous/changelog.xml? (CHANGELOG.txt is a generated file).

Cheers

Jean-Frederic

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org