Not really going to file a bug on another system once it's already been 
reported here - this code should mitigate the high CPU usage.  Seems like 
no-one realises sockets can remain idle for long periods of time (or never be 
closed fully by browsers if using HTTP1/1)

Replace Channel.createReadableSelectionChannel() with the following code to 
mitigate the issue until it can be properly fixed.  You'll still get the cyclic 
barrier timeouts, but at least it will no longer chew through your CPU cores!

org.restlet.engine.connector.Connection.java

    /**
    * Creates a new readable channel.
    * 
    * @return A new readable channel.
    */
   protected ReadableSelectionChannel createReadableSelectionChannel() {
      return new ReadableSocketChannel(getSocketChannel(), getRegistration()) {
         @Override
         public int read(ByteBuffer dst) throws IOException {
            int read =  super.read(dst);
            if (read > 0) {
               onActivity();
            } else {
               try { Thread.sleep(10); } catch(InterruptedException e) { }
            }
            
            return read;
         }
      };
   }

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=3064686

Reply via email to