On 09/22/2013 03:39 PM, Rainer Jung wrote:
On 22.09.2013 13:17, Rainer Jung wrote:
I debugged around my occasional failures for TestCoyoteAdapter when
using APR.

Error is:

SEVERE [http-apr-127.0.0.1-auto-13-Poller]
org.apache.tomcat.util.net.AprEndpoint$Poller.run Poller failed with
error [81] : [File descriptor in bad state]

...


Not sure whether the problem is more in the concurrent poll plus remove,
or the following code in poll.c:

TCN_IMPLEMENT_CALL(jint, Poll, remove)(TCN_STDARGS, jlong pollset,
                                        jlong socket)
{
     apr_pollfd_t fd;
     apr_status_t rv;
     tcn_pollset_t *p = J2P(pollset,  tcn_pollset_t *);
     tcn_socket_t  *s = J2P(socket, tcn_socket_t *);

     UNREFERENCED_STDARGS;
     TCN_ASSERT(socket != 0);

     if (s->pe == NULL) {
         /* Already removed */
         return APR_SUCCESS;
     }

Here we return APR_SUCCESS and the code calling Poll.remove in
AprEndpoint always does:

                     rv = Poll.remove(pollers[i], socket);
                     if (rv != Status.APR_NOTFOUND) {
                         pollerSpace[i]++;
                         connectionCount--;
                         break;
                     }

So the pollerSpace and connectionCount numbers are (in/de)cremented.

The following patch seems to fix it for me, at least 150 test runs for
TestCoyoteAdapter were successful:

Index: ../native/branches/1.1.x/native/src/poll.c
===================================================================
--- ../native/branches/1.1.x/native/src/poll.c  (revision 1525348)
+++ ../native/branches/1.1.x/native/src/poll.c  (working copy)
@@ -259,7 +259,7 @@

      if (s->pe == NULL) {
          /* Already removed */
-        return APR_SUCCESS;
+        return APR_NOTFOUND;
      }
      fd.desc_type   = APR_POLL_SOCKET;
      fd.desc.s      = s->sock;



The patch seems fine. I mean any return value should do in theory.
The main question is why is particular socket removed twice
from the Poller. This is called directly from java code
so wrapper seems to call it twice (or more).
I suspect that the socket is first closed and then Poller loop removes it.
Or it can be removed by poll with doRemove == true or during pollset maintain.
In any case after removed either by poll or maintain returned set of removed
sockets must be invalidated from pollset so it doesn't use it again in explicit 
remove.


Regards
--
^TM

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

Reply via email to