Author: remy.maucherat(a)jboss.com
Date: 2008-03-12 11:50:16 -0400 (Wed, 12 Mar 2008)
New Revision: 495
Modified:
trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
Log:
- Fix an obvious bug in duplicate after the last refactoring (which I hadn't tested).
- Improve the add methods (doing operations with syncs is wrong).
- Some cleanups.
Modified: trunk/java/org/apache/tomcat/util/net/AprEndpoint.java
===================================================================
--- trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-03-12 15:00:12 UTC (rev
494)
+++ trunk/java/org/apache/tomcat/util/net/AprEndpoint.java 2008-03-12 15:50:16 UTC (rev
495)
@@ -1190,7 +1190,7 @@
copy.pos = pos;
System.arraycopy(sockets, 0, copy.sockets, 0, size);
System.arraycopy(timeouts, 0, copy.timeouts, 0, size);
- System.arraycopy(flags, 0, copy.timeouts, 0, size);
+ System.arraycopy(flags, 0, copy.flags, 0, size);
}
}
@@ -1378,20 +1378,23 @@
if (timeout < 0) {
timeout = soTimeout;
}
+ boolean ok = false;
synchronized (this) {
// Add socket to the list. Newly added sockets will wait
// at most for pollTime before being polled
- if (!addList.add(socket, timeout, true, false, false)) {
- // Can't do anything: close the socket right away
- if (comet) {
- processSocket(socket, SocketStatus.ERROR);
- } else {
- Socket.destroy(socket);
- }
- return;
+ if (addList.add(socket, timeout, true, false, false)) {
+ ok = true;
+ this.notify();
}
- this.notify();
}
+ if (!ok) {
+ // Can't do anything: close the socket right away
+ if (comet) {
+ processSocket(socket, SocketStatus.ERROR);
+ } else {
+ Socket.destroy(socket);
+ }
+ }
}
/**
@@ -1413,20 +1416,23 @@
if (timeout < 0) {
timeout = soTimeout;
}
+ boolean ok = false;
synchronized (this) {
// Add socket to the list. Newly added sockets will wait
// at most for pollTime before being polled
- if (!addList.add(socket, timeout, read, write, resume)) {
- // Can't do anything: close the socket right away
- if (comet) {
- processSocket(socket, SocketStatus.ERROR);
- } else {
- Socket.destroy(socket);
- }
- return;
+ if (addList.add(socket, timeout, read, write, resume)) {
+ ok = true;
+ this.notify();
}
- this.notify();
}
+ if (!ok) {
+ // Can't do anything: close the socket right away
+ if (comet) {
+ processSocket(socket, SocketStatus.ERROR);
+ } else {
+ Socket.destroy(socket);
+ }
+ }
}
/**
@@ -1539,14 +1545,8 @@
if (comet) {
removeFromPoller(info.socket);
}
- // Windows only: check status code and loop over the
other pollers
- int events = 0;
- if (info.read()) {
- events = Poll.APR_POLLIN;
- }
- if (info.write()) {
- events = events | Poll.APR_POLLOUT;
- }
+ int events = ((info.read()) ? Poll.APR_POLLIN : 0)
+ | ((info.write()) ? Poll.APR_POLLOUT : 0);
if (!addToPoller(info.socket, events)) {
// Can't do anything: close the socket right
away
if (comet) {
Modified: trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties
===================================================================
--- trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties 2008-03-12 15:00:12
UTC (rev 494)
+++ trunk/java/org/apache/tomcat/util/net/res/LocalStrings.properties 2008-03-12 15:50:16
UTC (rev 495)
@@ -18,7 +18,6 @@
endpoint.poll.limitedpollsize=Failed to create poller with specified size of {0}
endpoint.poll.initfail=Poller creation failed
endpoint.poll.fail=Critical poller failure (restarting poller): [{0}] {1}
-endpoint.poll.fail=Socket [{0}] poll event: [{1}] {2}
endpoint.poll.error=Unexpected poller error
endpoint.maintain.error=Error processing timeouts
endpoint.process.fail=Error allocating socket processor