1 Reply Latest reply on Jan 23, 2008 7:18 AM by Daniel Bevenius

    AprEndpoint$Acceptor blocking on accept.

    Daniel Bevenius Master


      We are having a problem with Apache APR with JBossESB (http://jira.jboss.com/jira/browse/JBESB-1378).

      The problem we have is that we need to be able to redeploy our services but the port we are using is still in-use when we deploy the service again.

      I've added some log statements and can see that AprEndPoint.destroy is getting called, but if I run netstat I can see that the port is still in-use.
      Telneting to the port will "free" the port.

      I seems like AprEndPoint$Acceptor.run is blocking on the call to :

       getWorkerThread().assign(Socket.accept(serverSock), true);

      I noticed the following comment in the run method of

      // The processor will recycle itself when it finishes

      This seems to indicate that there is a way to recycle
      the Acceptor and maybe break out of the accept method.
      Or is there a way to make the Socket.accept method non-blocking or have a timeout perhaps?

      Or is there something obvious that we are missing that could be configured.

      Any suggestions are welcome!



        • 1. Re: AprEndpoint$Acceptor blocking on accept.
          Daniel Bevenius Master

          I've learnt that the Apr connector has a unlockAccept
          method that should break the accept call by
          making a dummy request to"

          But I can't get this to work unless I write something to the socket like this:

          protected void unlockAccept() {
           java.net.Socket s = null;
           try {
           // Need to create a connection to unlock the accept();
           if (address == null) {
           s = new java.net.Socket("", port);
           } else {
           s = new java.net.Socket(address, port);
           // setting soLinger to a small value will help shutdown the
           // connection quicker
           s.setSoLinger(true, 0);
           } catch(Exception e) {

          Is anyone else seeing this behaviour