Author: remm Date: Sun Apr 23 14:37:32 2006 New Revision: 396324 URL: http://svn.apache.org/viewcvs?rev=396324&view=rev Log: - Further sync the two endpoints.
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java URL: http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java?rev=396324&r1=396323&r2=396324&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/AprEndpoint.java Sun Apr 23 14:37:32 2006 @@ -698,7 +698,7 @@ workers = new WorkerStack(maxThreads); } - // Start acceptor thread + // Start acceptor threads for (int i = 0; i < acceptorThreadCount; i++) { Thread acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor-" + i); acceptorThread.setPriority(threadPriority); @@ -706,7 +706,7 @@ acceptorThread.start(); } - // Start poller thread + // Start poller threads pollers = new Poller[pollerThreadCount]; for (int i = 0; i < pollerThreadCount; i++) { pollers[i] = new Poller(); @@ -717,7 +717,7 @@ pollerThread.start(); } - // Start sendfile thread + // Start sendfile threads if (useSendfile) { sendfiles = new Sendfile[sendfileThreadCount]; for (int i = 0; i < sendfileThreadCount; i++) { @@ -1369,12 +1369,12 @@ protected long sendfilePollset = 0; protected long pool = 0; protected long[] desc; - protected HashMap sendfileData; + protected HashMap<Long, SendfileData> sendfileData; protected int sendfileCount; public int getSendfileCount() { return sendfileCount; } - protected ArrayList addS; + protected ArrayList<SendfileData> addS; /** * Create the sendfile poller. With some versions of APR, the maximum poller size will @@ -1393,8 +1393,8 @@ sendfilePollset = allocatePoller(size, pool, soTimeout); } desc = new long[size * 2]; - sendfileData = new HashMap(size); - addS = new ArrayList(); + sendfileData = new HashMap<Long, SendfileData>(size); + addS = new ArrayList<SendfileData>(); } /** @@ -1403,7 +1403,7 @@ protected void destroy() { // Close any socket remaining in the add queue for (int i = (addS.size() - 1); i >= 0; i--) { - SendfileData data = (SendfileData) addS.get(i); + SendfileData data = addS.get(i); Socket.destroy(data.socket); } // Close all sockets still in the poller @@ -1520,7 +1520,7 @@ if (addS.size() > 0) { synchronized (this) { for (int i = (addS.size() - 1); i >= 0; i--) { - SendfileData data = (SendfileData) addS.get(i); + SendfileData data = addS.get(i); int rv = Poll.add(sendfilePollset, data.socket, Poll.APR_POLLOUT); if (rv == Status.APR_SUCCESS) { sendfileData.put(new Long(data.socket), data); @@ -1540,7 +1540,7 @@ for (int n = 0; n < rv; n++) { // Get the sendfile state SendfileData state = - (SendfileData) sendfileData.get(new Long(desc[n*2+1])); + sendfileData.get(new Long(desc[n*2+1])); // Problem events if (((desc[n*2] & Poll.APR_POLLHUP) == Poll.APR_POLLHUP) || ((desc[n*2] & Poll.APR_POLLERR) == Poll.APR_POLLERR)) { Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java URL: http://svn.apache.org/viewcvs/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java?rev=396324&r1=396323&r2=396324&view=diff ============================================================================== --- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java (original) +++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/net/JIoEndpoint.java Sun Apr 23 14:37:32 2006 @@ -60,12 +60,6 @@ /** - * The acceptor thread. - */ - protected Thread acceptorThread = null; - - - /** * Available workers. */ protected WorkerStack workers = null; @@ -117,6 +111,14 @@ /** + * Acceptor thread count. + */ + protected int acceptorThreadCount = 0; + public void setAcceptorThreadCount(int acceptorThreadCount) { this.acceptorThreadCount = acceptorThreadCount; } + public int getAcceptorThreadCount() { return acceptorThreadCount; } + + + /** * External Executor based thread pool. */ protected Executor executor = null; @@ -291,6 +293,7 @@ try { socket.close(); } catch (IOException e) { + // Ignore } } } catch (Throwable t) { @@ -450,7 +453,16 @@ // -------------------- Public methods -------------------- - public void init() throws IOException, InstantiationException { + public void init() + throws Exception { + + if (initialized) + return; + + // Initialize thread count defaults for acceptor + if (acceptorThreadCount == 0) { + acceptorThreadCount = 1; + } if (serverSocketFactory == null) { serverSocketFactory = ServerSocketFactory.getDefault(); } @@ -467,7 +479,9 @@ } //if( serverTimeout >= 0 ) // serverSocket.setSoTimeout( serverTimeout ); + initialized = true; + } public void start() @@ -485,11 +499,13 @@ workers = new WorkerStack(maxThreads); } - // Start acceptor thread - acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor"); - acceptorThread.setPriority(threadPriority); - acceptorThread.setDaemon(daemon); - acceptorThread.start(); + // Start acceptor threads + for (int i = 0; i < acceptorThreadCount; i++) { + Thread acceptorThread = new Thread(new Acceptor(), getName() + "-Acceptor-" + i); + acceptorThread.setPriority(threadPriority); + acceptorThread.setDaemon(daemon); + acceptorThread.start(); + } } } @@ -510,7 +526,6 @@ if (running) { running = false; unlockAccept(); - acceptorThread = null; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]