remm 2005/04/15 09:37:40 Modified: util/java/org/apache/tomcat/util/net AprEndpoint.java Log: - The events are not a good way to check for EOFed sockets. This fixes looping. New problem: failed requests. Revision Changes Path 1.6 +37 -33 jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java Index: AprEndpoint.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/AprEndpoint.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- AprEndpoint.java 15 Apr 2005 16:06:30 -0000 1.5 +++ AprEndpoint.java 15 Apr 2005 16:37:39 -0000 1.6 @@ -598,6 +598,29 @@ } + + /** + * Return a new worker thread, and block while to worker is available. + */ + protected Worker getWorkerThread() { + // Allocate a new worker thread + Worker workerThread = createWorkerThread(); + while (workerThread == null) { + try { + // Wait a little for load to go down: as a result, + // no accept will be made until the concurrency is + // lower than the specified maxThreads, and current + // connections will wait for a little bit instead of + // failing right away. + Thread.sleep(100); + } catch (InterruptedException e) { + // Ignore + } + workerThread = createWorkerThread(); + } + return workerThread; + } + /** * Recycle the specified Processor so that it can be used again. @@ -640,20 +663,7 @@ } // Allocate a new worker thread - Worker workerThread = createWorkerThread(); - if (workerThread == null) { - try { - // Wait a little for load to go down: as a result, - // no accept will be made until the concurrency is - // lower than the specified maxThreads, and current - // connections will wait for a little bit instead of - // failing right away. - Thread.sleep(100); - } catch (InterruptedException e) { - // Ignore - } - continue; - } + Worker workerThread = getWorkerThread(); // Accept the next incoming connection from the server socket long socket = 0; @@ -763,13 +773,21 @@ // Get the socket pool pools[n] = Poll.data(desc[n]); // Get retuned events for this socket - events[n] = Poll.events(desc[n]); + //events[n] = Poll.events(desc[n]); // Remove each socket from the poll right away remove(sockets[n]); } } for (int n = 0; n < rv; n++) { - //System.out.println("Events: " + sockets[n] + " code: " + events[n] + " OK: " + Poll.APR_POLLIN); + // Check the health of the socket + int res = Socket.recvt(sockets[n], null, 0, 0, 0); + //System.out.println("Events: " + sockets[n] + " code: " + events[n] + " res: " + res); + if (res < 0) { + // Close socket and clear pool + Pool.destroy(pools[n]); + continue; + } + /* // Problem events if (((events[n] & Poll.APR_POLLHUP) == Poll.APR_POLLHUP) || ((events[n] & Poll.APR_POLLERR) == Poll.APR_POLLERR)) { @@ -783,24 +801,10 @@ Pool.destroy(pools[n]); continue; } - // Allocate a new worker thread - Worker workerThread = createWorkerThread(); - while (workerThread == null) { - try { - // Wait a little for load to go down: as a result, - // no accept will be made until the concurrency is - // lower than the specified maxThreads, and current - // connections will wait for a little bit instead of - // failing right away. - Thread.sleep(100); - } catch (InterruptedException e) { - // Ignore - } - workerThread = createWorkerThread(); - } - // Hand this socket off to an appropriate processor + */ + // Hand this socket off to a worker //System.out.println("Process: " + sockets[n]); - workerThread.assign(sockets[n], pools[n]); + getWorkerThread().assign(sockets[n], pools[n]); } } } catch (Throwable t) {
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]