Author: fhanik
Date: Thu Jun 22 15:02:23 2006
New Revision: 416481
URL: http://svn.apache.org/viewvc?rev=416481&view=rev
Log:
Dont do the not needed operations, if they are not needed.
Performance is just a tad under java.io, which is expected as we need to poll,
as opposed to constantly wait for data.
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
Modified:
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
URL:
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java?rev=416481&r1=416480&r2=416481&view=diff
==============================================================================
---
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
(original)
+++
tomcat/tc6.0.x/trunk/java/org/apache/coyote/http11/InternalNioInputBuffer.java
Thu Jun 22 15:02:23 2006
@@ -567,10 +567,14 @@
try {
final SelectionKey key =
socket.keyFor(poller.getSelector());
final KeyAttachment att = (KeyAttachment)key.attachment();
- att.setWakeUp(true);
-
- poller.addEvent(
- new Runnable() {
+ //to do, add in a check, we might have just timed out on
the wait,
+ //so there is no need to register us again.
+ boolean addToQueue = false;
+ try { addToQueue =
((key.interestOps()&SelectionKey.OP_READ) != SelectionKey.OP_READ); } catch (
CancelledKeyException ignore ){}
+ if ( addToQueue ) {
+ att.setWakeUp(true);
+ poller.addEvent(
+ new Runnable() {
public void run() {
try {
if (key != null)
key.interestOps(SelectionKey.OP_READ);
@@ -582,12 +586,16 @@
} catch (Exception ignore) {}
}
}
- });
- synchronized (att.getMutex()) { att.getMutex().wait(25);}
+ });
+ }//end if
+ synchronized (att.getMutex()) {
+ if ( att.getWakeUp() ) att.getMutex().wait(25);
+ }
}catch ( Exception x ) {}
}while ( nRead == 0 && (!timedOut) );
//else throw new IOException(sm.getString("iib.failedread"));
- return false; //timeout
+ //return false; //timeout
+ throw new IOException("read timed out.");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]