cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-29 Thread remm
remm2005/07/29 03:23:56

  Modified:jk/java/org/apache/coyote/ajp AjpAprProcessor.java
LocalStrings.properties AjpMessage.java
   http11/src/java/org/apache/coyote/http11
LocalStrings.properties Http11Processor.java
Http11AprProcessor.java
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Internationalization for the processor classes.
  - Code cleanups.
  - No functional changes.
  
  Revision  ChangesPath
  1.14  +18 -24
jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java
  
  Index: AjpAprProcessor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- AjpAprProcessor.java  28 Jul 2005 13:48:47 -  1.13
  +++ AjpAprProcessor.java  29 Jul 2005 10:23:55 -  1.14
  @@ -42,7 +42,6 @@
   import org.apache.tomcat.util.http.HttpMessages;
   import org.apache.tomcat.util.http.MimeHeaders;
   import org.apache.tomcat.util.net.AprEndpoint;
  -import org.apache.tomcat.util.net.SSLSupport;
   import org.apache.tomcat.util.res.StringManager;
   import org.apache.tomcat.util.threads.ThreadWithAttributes;
   
  @@ -67,7 +66,6 @@
   protected static org.apache.commons.logging.Log log
   = 
org.apache.commons.logging.LogFactory.getLog(AjpAprProcessor.class);
   
  -
   /**
* The string manager for this package.
*/
  @@ -439,7 +437,7 @@
   error = true;
   break;
   } catch (Throwable t) {
  -log.debug(Error parsing HTTP request, t);
  +log.debug(sm.getString(ajpprocessor.header.error), t);
   // 400 - Bad Request
   response.setStatus(400);
   error = true;
  @@ -452,7 +450,7 @@
   prepareRequest();
   thrA.setParam(endpoint, request.requestURI());
   } catch (Throwable t) {
  -log.debug(Error preparing request, t);
  +log.debug(sm.getString(ajpprocessor.request.prepare), t);
   // 400 - Internal Server Error
   response.setStatus(400);
   error = true;
  @@ -467,7 +465,7 @@
   } catch (InterruptedIOException e) {
   error = true;
   } catch (Throwable t) {
  -log.error(Error processing request, t);
  +log.error(sm.getString(ajpprocessor.request.process), 
t);
   // 500 - Internal Server Error
   response.setStatus(500);
   error = true;
  @@ -616,11 +614,11 @@
   jsseCerts =  new X509Certificate[1];
   jsseCerts[0] = cert;
   } catch(java.security.cert.CertificateException e) {
  -log.error(Certificate convertion failed , e );
  +log.error(sm.getString(ajpprocessor.certs.fail), e);
   return;
   }
   
  -request.setAttribute(javax.servlet.request.X509Certificate, 
jsseCerts);
  +request.setAttribute(AprEndpoint.CERTIFICATE_KEY, jsseCerts);
   
   } else if (actionCode == ActionCode.ACTION_REQ_HOST_ADDR_ATTRIBUTE) {
   
  @@ -630,7 +628,7 @@
   long sa = Address.get(Socket.APR_REMOTE, socket);
   remoteAddr = Address.getip(sa);
   } catch (Exception e) {
  -log.warn(Exception getting socket information  ,e);
  +log.warn(sm.getString(ajpprocessor.socket.info), e);
   }
   }
   request.remoteAddr().setString(remoteAddr);
  @@ -643,7 +641,7 @@
   long sa = Address.get(Socket.APR_LOCAL, socket);
   localName = Address.getnameinfo(sa, 0);
   } catch (Exception e) {
  -log.warn(Exception getting socket information  ,e);
  +log.warn(sm.getString(ajpprocessor.socket.info), e);
   }
   }
   request.localName().setString(localName);
  @@ -656,7 +654,7 @@
   long sa = Address.get(Socket.APR_REMOTE, socket);
   remoteHost = Address.getnameinfo(sa, 0);
   } catch (Exception e) {
  -log.warn(Exception getting socket information  ,e);
  +log.warn(sm.getString(ajpprocessor.socket.info), e);
   }
   }
   request.remoteHost().setString(remoteHost);
  @@ -673,7 +671,7 @@
   localPort = addr.port;
   }
   } catch 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-16 Thread mturk
mturk   2005/07/16 05:11:11

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Add APR_SO_REUSEADDR and APR_SO_KEEPALIVE to the listening
  socket. This resolves 'address in use exception', and is the way how
  the Apache HTTPD is using the APR.
  See the: server/listen.c
  
  Revision  ChangesPath
  1.66  +8 -0  
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.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- AprEndpoint.java  15 Jul 2005 15:40:00 -  1.65
  +++ AprEndpoint.java  16 Jul 2005 12:11:11 -  1.66
  @@ -24,6 +24,7 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  +import org.apache.tomcat.jni.OS;
   import org.apache.tomcat.jni.Address;
   import org.apache.tomcat.jni.Error;
   import org.apache.tomcat.jni.File;
  @@ -511,6 +512,9 @@
   // Create the APR server socket
   serverSock = Socket.create(Socket.APR_INET, Socket.SOCK_STREAM,
   Socket.APR_PROTO_TCP, rootPool);
  +if (OS.IS_UNIX) {
  +Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
  +}
   // Bind the server socket
   int ret = Socket.bind(serverSock, inetAddress);
   if (ret != 0) {
  @@ -521,6 +525,10 @@
   if (ret != 0) {
   throw new Exception(sm.getString(endpoint.init.listen,  + 
ret));
   }
  +if (OS.IS_WIN32 || OS.IS_WIN64) {
  +// On Windows set the reuseaddr flag after the bind/listen
  +Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
  +}
   
   // Sendfile usage on systems which don't support it cause major 
problems
   if (useSendfile  !Library.APR_HAS_SENDFILE) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-16 Thread mturk
mturk   2005/07/16 05:22:42

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Add a missing SO_KEEPALIVE option.
  See the previous commit for an explanation.
  
  Revision  ChangesPath
  1.67  +2 -0  
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.66
  retrieving revision 1.67
  diff -u -r1.66 -r1.67
  --- AprEndpoint.java  16 Jul 2005 12:11:11 -  1.66
  +++ AprEndpoint.java  16 Jul 2005 12:22:42 -  1.67
  @@ -515,6 +515,8 @@
   if (OS.IS_UNIX) {
   Socket.optSet(serverSock, Socket.APR_SO_REUSEADDR, 1);
   }
  +// Deal with the firewalls that tend to drop the inactive sockets
  +Socket.optSet(serverSock, Socket.APR_SO_KEEPALIVE, 1);
   // Bind the server socket
   int ret = Socket.bind(serverSock, inetAddress);
   if (ret != 0) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-15 Thread remm
remm2005/07/15 08:40:00

  Modified:util/java/org/apache/tomcat/util/net/res
LocalStrings.properties
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Some localization.
  
  Revision  ChangesPath
  1.11  +2 -0  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- LocalStrings.properties   14 Jun 2005 13:14:18 -  1.10
  +++ LocalStrings.properties   15 Jul 2005 15:39:59 -  1.11
  @@ -11,6 +11,8 @@
   endpoint.debug.unlock=Caught exception trying to unlock accept on port {0}
   endpoint.err.close=Caught exception trying to close socket
   endpoint.noProcessor=No Processors - worker thread dead!
  +endpoint.init.bind=Socket bind failed: {0}
  +endpoint.init.listen=Socket listen failed: {0}
   
   endpoint.accept.fail=Socket accept failed
   endpoint.poll.limitedpollsize=Failed to create poller with specified size, 
uses 62 instead
  
  
  
  1.65  +7 -4  
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.64
  retrieving revision 1.65
  diff -u -r1.64 -r1.65
  --- AprEndpoint.java  14 Jul 2005 22:35:21 -  1.64
  +++ AprEndpoint.java  15 Jul 2005 15:40:00 -  1.65
  @@ -16,6 +16,7 @@
   
   package org.apache.tomcat.util.net;
   
  +import java.io.IOException;
   import java.net.InetAddress;
   import java.util.ArrayList;
   import java.util.HashMap;
  @@ -512,12 +513,14 @@
   Socket.APR_PROTO_TCP, rootPool);
   // Bind the server socket
   int ret = Socket.bind(serverSock, inetAddress);
  -if (ret != 0)
  -  throw(new Exception(bind failed:  + ret));
  +if (ret != 0) {
  +throw new Exception(sm.getString(endpoint.init.bind,  + 
ret));
  +}
   // Start listening on the server socket
   ret = Socket.listen(serverSock, backlog);
  -if (ret != 0)
  -  throw(new Exception(listen failed:  + ret));
  +if (ret != 0) {
  +throw new Exception(sm.getString(endpoint.init.listen,  + 
ret));
  +}
   
   // Sendfile usage on systems which don't support it cause major 
problems
   if (useSendfile  !Library.APR_HAS_SENDFILE) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-14 Thread remm
remm2005/07/14 10:45:25

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Cosmetic change. Set socket to 0.
  
  Revision  ChangesPath
  1.63  +1 -0  
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.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- AprEndpoint.java  8 Jul 2005 15:43:23 -   1.62
  +++ AprEndpoint.java  14 Jul 2005 17:45:25 -  1.63
  @@ -666,6 +666,7 @@
   serverSockPool = 0;
   // Close server socket
   Socket.close(serverSock);
  +serverSock = 0;
   sslContext = 0;
   // Close all APR memory pools and resources
   Pool.destroy(rootPool);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-14 Thread jfclere
jfclere 2005/07/14 15:35:21

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  throw an exception if listen or bind fails.
  
  Revision  ChangesPath
  1.64  +6 -2  
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.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- AprEndpoint.java  14 Jul 2005 17:45:25 -  1.63
  +++ AprEndpoint.java  14 Jul 2005 22:35:21 -  1.64
  @@ -511,9 +511,13 @@
   serverSock = Socket.create(Socket.APR_INET, Socket.SOCK_STREAM,
   Socket.APR_PROTO_TCP, rootPool);
   // Bind the server socket
  -Socket.bind(serverSock, inetAddress);
  +int ret = Socket.bind(serverSock, inetAddress);
  +if (ret != 0)
  +  throw(new Exception(bind failed:  + ret));
   // Start listening on the server socket
  -Socket.listen(serverSock, backlog);
  +ret = Socket.listen(serverSock, backlog);
  +if (ret != 0)
  +  throw(new Exception(listen failed:  + ret));
   
   // Sendfile usage on systems which don't support it cause major 
problems
   if (useSendfile  !Library.APR_HAS_SENDFILE) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-08 Thread remm
remm2005/07/08 08:43:23

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Add extra value.
  
  Revision  ChangesPath
  1.62  +2 -0  
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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- AprEndpoint.java  8 Jul 2005 14:19:04 -   1.61
  +++ AprEndpoint.java  8 Jul 2005 15:43:23 -   1.62
  @@ -543,6 +543,8 @@
   value = SSL.SSL_PROTOCOL_SSLV3;
   } else if (TLSv1.equalsIgnoreCase(SSLProtocol)) {
   value = SSL.SSL_PROTOCOL_TLSV1;
  +} else if (SSLv2+SSLv3.equalsIgnoreCase(SSLProtocol)) {
  +value = SSL.SSL_PROTOCOL_SSLV2 | SSL.SSL_PROTOCOL_SSLV3;
   }
   // Create SSL Context
   sslContext = SSLContext.make(rootPool, value, 
SSL.SSL_MODE_SERVER);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-07 Thread remm
remm2005/07/07 07:26:25

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Fix init a little.
  
  Revision  ChangesPath
  1.60  +1 -1  
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.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- AprEndpoint.java  7 Jul 2005 14:08:40 -   1.59
  +++ AprEndpoint.java  7 Jul 2005 14:26:25 -   1.60
  @@ -534,10 +534,10 @@
   // Load Server key and certificate
   SSLContext.setCertificate(sslContext, SSLCertificateFile, 
SSLCertificateKeyFile, SSLPassword, SSL.SSL_AIDX_RSA);
   // Support Client Certificates
  -SSLContext.setVerify(sslContext, SSLVerifyClient, 
SSLVerifyDepth);
   if (SSLCACertificateFile != null) {
   SSLContext.setCACertificate(sslContext, 
SSLCACertificateFile, null);
   }
  +SSLContext.setVerify(sslContext, SSLVerifyClient, 
SSLVerifyDepth);
   // For now, sendfile is not supported with SSL
   useSendfile = false;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-02 Thread mturk
mturk   2005/07/02 03:55:35

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Couple of fixes for Sendfile.
  The major is to remove the double call to the Socket.destroy if
  the return from senfile is ECONNRESET or similar.
  The socket will be destroyed on processSocket call too, so that
  made entile APR pool system in a unstable state.
  
  Revision  ChangesPath
  1.53  +6 -5  
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.52
  retrieving revision 1.53
  diff -u -r1.52 -r1.53
  --- AprEndpoint.java  29 Jun 2005 17:32:22 -  1.52
  +++ AprEndpoint.java  2 Jul 2005 10:55:34 -   1.53
  @@ -1102,7 +1102,7 @@
   log.error(sm.getString(endpoint.poll.initfail), e);
   }
   }
  -desc = new long[sendfileSize * 4];
  +desc = new long[sendfileSize * 2];
   sendfileData = new HashMap(sendfileSize);
   addS = new ArrayList();
   }
  @@ -1153,8 +1153,9 @@
data.pos, data.end, 0);
   if (nw  0) {
   if (!(-nw == Status.EAGAIN)) {
  -Socket.destroy(data.socket);
  -data.socket = 0;
  + /* The socket will be destroyed on the
  +  * return from the processSocket call
  +  */
   return false;
   } else {
   // Break the loop and add the socket to poller.
  @@ -1252,7 +1253,7 @@
   for (int n = 0; n  rv; n++) {
   // Get the sendfile state
   SendfileData state =
  -(SendfileData) sendfileData.get(new 
Long(desc[n*4+1]));
  +(SendfileData) 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)) {
  @@ -1265,7 +1266,7 @@
   continue;
   }
   // Write some data using sendfile
  -long nw = Socket.sendfile(desc[n*2+1], state.fd,
  +long nw = Socket.sendfile(state.socket, state.fd,
null, null, state.pos,
state.end - state.pos, 
0);
   if (nw  0) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-02 Thread mturk
mturk   2005/07/02 10:18:46

  Modified:http11/src/java/org/apache/coyote/http11
Http11AprProcessor.java
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Fix the Sendfile implementation.
  The APR sendfile always make it's internal full loop if the
  socket timeout is larger then 0. Setting soket timeout to
  zero also makes the socket nonblocking.
  I have added a keepAlive flag to the sendfile data because with
  sendfile the processing is done inside senfile poller.
  
  Revision  ChangesPath
  1.18  +6 -0  
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java
  
  Index: Http11AprProcessor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Http11AprProcessor.java   23 Jun 2005 11:47:32 -  1.17
  +++ Http11AprProcessor.java   2 Jul 2005 17:18:46 -   1.18
  @@ -884,9 +884,15 @@
   // Do sendfile as needed: add socket to sendfile and end
   if (sendfileData != null) {
   sendfileData.socket = socket;
  + sendfileData.keepAlive = keepAlive;
   if (!endpoint.getSendfile().add(sendfileData)) {
   keepAlive = false;
  +openSocket = false;
   }
  +else {
  + openSocket = true;
  +}
  +break;
   }
   
   }
  
  
  
  1.54  +19 -10
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.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- AprEndpoint.java  2 Jul 2005 10:55:34 -   1.53
  +++ AprEndpoint.java  2 Jul 2005 17:18:46 -   1.54
  @@ -1062,6 +1062,8 @@
   public long socket;
   // Position
   public long pos;
  +// KeepAlive flag
  +public boolean keepAlive;
   }
   
   
  @@ -1147,10 +1149,10 @@
0, data.fdpool);
   data.pos = data.start;
   // Set the socket to nonblocking mode
  -Socket.optSet(data.socket, Socket.APR_SO_NONBLOCK, 1);
  +Socket.timeoutSet(data.socket, 0);
   while (true) {
   long nw = Socket.sendfile(data.socket, data.fd, null, 
null,
  - data.pos, data.end, 0);
  +  data.pos, data.end, 0);
   if (nw  0) {
   if (!(-nw == Status.EAGAIN)) {
/* The socket will be destroyed on the
  @@ -1167,7 +1169,7 @@
   // Entire file has been send
   Pool.destroy(data.fdpool);
   // Set back socket to blocking mode
  -Socket.optSet(data.socket, 
Socket.APR_SO_NONBLOCK, 0);
  +Socket.timeoutSet(data.socket, soTimeout * 1000);
   return true;
   }
   }
  @@ -1182,7 +1184,7 @@
   addS.add(data);
   addS.notify();
   }
  -return false;
  +return true;
   }
   
   /**
  @@ -1260,7 +1262,6 @@
   // Close socket and clear pool
   remove(state);
   // Destroy file descriptor pool, which 
should close the file
  -Pool.destroy(state.fdpool);
   // Close the socket, as the reponse would be 
incomplete
   Socket.destroy(state.socket);
   continue;
  @@ -1281,11 +1282,19 @@
   state.pos = state.pos + nw;
   if (state.pos = state.end) {
   remove(state);
  -// Destroy file descriptor pool, which 
should close the file
  -Pool.destroy(state.fdpool);
  -// If all done hand this socket off to a 
worker for
  -// processing of further requests
  -getWorkerThread().assign(desc[n*2+1]);
  +if (state.keepAlive) {
  + // 

Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-07-02 Thread Natasha Hasmani
Thank-you for your e-mail.

Please note that i will be away from the office starting Wednesday June
29th, returning Thursday July 7th, with no access to email.  In my absence,
kindly contact Cheri Dueck at [EMAIL PROTECTED]

Kind Regards,

Natasha Hasmani
Senior Event Manager 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-29 Thread remm
remm2005/06/29 10:32:22

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Add back the two dummy properties (used for JMX).
  
  Revision  ChangesPath
  1.52  +12 -0 
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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- AprEndpoint.java  27 Jun 2005 13:44:04 -  1.51
  +++ AprEndpoint.java  29 Jun 2005 17:32:22 -  1.52
  @@ -314,6 +314,18 @@
   public Sendfile getSendfile() { return sendfile; }
   
   
  +/**
  + * Dummy maxSpareThreads property.
  + */
  +public int getMaxSpareThreads() { return 0; }
  +
  +
  +/**
  + * Dummy minSpareThreads property.
  + */
  +public int getMinSpareThreads() { return 0; }
  +
  +
   // - Public 
Methods
   
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-24 Thread remm
remm2005/06/24 06:14:29

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Better default maxThreads (20 is likely a bit too low).
  - Use wait/notify when running out of threads rather than sleep, as it does
not mean the same as for the regular connector.
  
  Revision  ChangesPath
  1.50  +5 -7  
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.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- AprEndpoint.java  24 Jun 2005 10:25:25 -  1.49
  +++ AprEndpoint.java  24 Jun 2005 13:14:28 -  1.50
  @@ -156,7 +156,7 @@
   /**
* Maximum amount of worker threads.
*/
  -protected int maxThreads = 20;
  +protected int maxThreads = 60;
   public void setMaxThreads(int maxThreads) { this.maxThreads = 
maxThreads; }
   public int getMaxThreads() { return maxThreads; }
   
  @@ -663,12 +663,9 @@
   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);
  +synchronized (workers) {
  +workers.wait();
  +}
   } catch (InterruptedException e) {
   // Ignore
   }
  @@ -687,6 +684,7 @@
   synchronized (workers) {
   workers.push(workerThread);
   curThreadsBusy--;
  +workers.notify();
   }
   }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-18 Thread mturk
mturk   2005/06/18 01:03:21

  Modified:jni/examples/org/apache/tomcat/jni Echo.java SSLServer.java
   jni/java/org/apache/tomcat/jni Poll.java SSLSocket.java
Socket.java
   jni/native/include tcn.h
   jni/native/src network.c poll.c
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Use auto pool management for Socket.accept.
  On each accept the socket's child pool is created and assigned
  to the accepted socket.
  
  Revision  ChangesPath
  1.14  +2 -2  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java
  
  Index: Echo.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/Echo.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Echo.java 17 Jun 2005 12:03:51 -  1.13
  +++ Echo.java 18 Jun 2005 08:03:21 -  1.14
  @@ -99,7 +99,7 @@
   int i = 0;
   try {
   while (true) {
  -long clientSock = Socket.accept(serverSock, pool);
  +long clientSock = Socket.accept(serverSock);
   System.out.println(Accepted id:  +  i);
   
   try {
  
  
  
  1.10  +3 -3  
jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java
  
  Index: SSLServer.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/examples/org/apache/tomcat/jni/SSLServer.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SSLServer.java17 Jun 2005 12:03:51 -  1.9
  +++ SSLServer.java18 Jun 2005 08:03:21 -  1.10
  @@ -116,7 +116,7 @@
   int i = 0;
   try {
   while (true) {
  -long clientSock = Socket.accept(serverSock, pool);
  +long clientSock = Socket.accept(serverSock);
   System.out.println(Accepted id:  +  i);
   
   try {
  @@ -142,7 +142,7 @@
   }
   
   Socket.timeoutSet(clientSock, 1000);
  -SSLSocket.attach(SSLServer.serverCtx, clientSock, pool);
  +SSLSocket.attach(SSLServer.serverCtx, clientSock);
   i = SSLSocket.handshake(clientSock);
   if (i == 0) {
   
  
  
  
  1.13  +3 -4  
jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Poll.java
  
  Index: Poll.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Poll.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Poll.java 17 Jun 2005 11:22:04 -  1.12
  +++ Poll.java 18 Jun 2005 08:03:21 -  1.13
  @@ -113,11 +113,10 @@
* Maintain on the descriptor(s) in a pollset
* @param pollset The pollset to use
* @param descriptors Array of signalled descriptors (output parameter)
  - *The desctiptor array must be two times the size of pollset.
  + *The desctiptor array must be the size of pollset.
*and are populated as follows:
* PRE
  - * descriptors[n + 0] - returned events
  - * descriptors[n + 1] - socket
  + * descriptors[n] - socket
* /PRE
* @param remove Remove signaled descriptors from pollset
* @return Number of signalled descriptors (output parameter)
  
  
  
  1.15  +3 -5  
jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/SSLSocket.java
  
  Index: SSLSocket.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/SSLSocket.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SSLSocket.java17 Jun 2005 12:04:40 -  1.14
  +++ SSLSocket.java18 Jun 2005 08:03:21 -  1.15
  @@ -30,12 +30,10 @@
   /**
* Attach APR socket on a SSL connection.
* @param ctx SSLContext to use.
  - * @param sock APR Socket that already did physical connect.
  - * @param pool The pool to use
  - * @param pool The pool to use
  + * @param sock APR Socket that already did physical connect or accept.
* @return APR_STATUS code.
*/
  -public static native int attach(long ctx, long sock, long pool)
  +public static native int attach(long ctx, long sock)
   throws Exception;
   
   /**
  
  
  
  1.17  +3 -3  
jakarta-tomcat-connectors/jni/java/org/apache/tomcat/jni/Socket.java
  
  Index: Socket.java
  ===
  RCS file: 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-17 Thread mturk
mturk   2005/06/17 02:43:35

  Modified:http11/src/java/org/apache/coyote/http11
Http11AprProcessor.java Http11AprProtocol.java
   jk/java/org/apache/coyote/ajp AjpAprProcessor.java
AjpAprProtocol.java
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Implement new socket abstraction.
  We don't need to maintain the pool, so the poll size can be half the size.
  
  Revision  ChangesPath
  1.15  +3 -3  
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java
  
  Index: Http11AprProcessor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProcessor.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Http11AprProcessor.java   26 May 2005 09:06:16 -  1.14
  +++ Http11AprProcessor.java   17 Jun 2005 09:43:35 -  1.15
  @@ -729,7 +729,7 @@
*
* @throws IOException error during an I/O operation
*/
  -public boolean process(long socket, long pool)
  +public boolean process(long socket)
   throws IOException {
   ThreadWithAttributes thrA=
   (ThreadWithAttributes)Thread.currentThread();
  @@ -779,7 +779,7 @@
   rp.setStage(org.apache.coyote.Constants.STAGE_ENDED);
   openSocket = true;
   // Add the socket to the poller
  -endpoint.getPoller().add(socket, pool);
  +endpoint.getPoller().add(socket);
   break;
   }
   request.setStartTime(System.currentTimeMillis());
  @@ -884,7 +884,7 @@
   // Do sendfile as needed: add socket to sendfile and end
   if (sendfileData != null) {
   sendfileData.socket = socket;
  -sendfileData.pool = pool;
  +sendfileData.pool = 0;
   if (!endpoint.getSendfile().add(sendfileData)) {
   keepAlive = false;
   }
  
  
  
  1.9   +2 -2  
jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProtocol.java
  
  Index: Http11AprProtocol.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/http11/src/java/org/apache/coyote/http11/Http11AprProtocol.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Http11AprProtocol.java27 May 2005 15:40:23 -  1.8
  +++ Http11AprProtocol.java17 Jun 2005 09:43:35 -  1.9
  @@ -664,7 +664,7 @@
   return  thData;
   }
   
  -public boolean process(long socket, long pool) {
  +public boolean process(long socket) {
   Http11AprProcessor processor=null;
   try {
   // FIXME: It is also possible to use the TWA data, so keep 
init() [] for
  @@ -696,7 +696,7 @@
   processor.setSocket( socket );
   */
   
  -return processor.process(socket, pool);
  +return processor.process(socket);
   
   } catch(java.net.SocketException e) {
   // SocketExceptions are normal
  
  
  
  1.5   +2 -2  
jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java
  
  Index: AjpAprProcessor.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProcessor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AjpAprProcessor.java  16 Jun 2005 11:52:26 -  1.4
  +++ AjpAprProcessor.java  17 Jun 2005 09:43:35 -  1.5
  @@ -352,7 +352,7 @@
*
* @throws IOException error during an I/O operation
*/
  -public boolean process(long socket, long pool)
  +public boolean process(long socket)
   throws IOException {
   ThreadWithAttributes thrA=
   (ThreadWithAttributes)Thread.currentThread();
  @@ -464,7 +464,7 @@
   
   // Add the socket to the poller
   if (!error) {
  -endpoint.getPoller().add(socket, pool);
  +endpoint.getPoller().add(socket);
   } else {
   openSocket = false;
   }
  
  
  
  1.2   +2 -2  
jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java
  
  Index: AjpAprProtocol.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/jk/java/org/apache/coyote/ajp/AjpAprProtocol.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AjpAprProtocol.java   9 Jun 2005 16:14:51 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-14 Thread mturk
mturk   2005/06/13 23:55:20

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Use the same locking object for add and maintain.
  Also make sure that sockets in the add queue are
  closed on destroy.
  
  Revision  ChangesPath
  1.42  +5 -1  
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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- AprEndpoint.java  10 Jun 2005 14:36:18 -  1.41
  +++ AprEndpoint.java  14 Jun 2005 06:55:20 -  1.42
  @@ -796,6 +796,10 @@
* Destroy the poller.
*/
   protected void destroy() {
  +/* Remove the sockets in the add queue */
  +for (int i = 0; i  addCount; i--) {
  +Pool.destroy(addP[i]);
  +}
   Pool.destroy(pool);
   }
   
  @@ -899,7 +903,7 @@
   }
   }
   if (rv == 0 || maintainTime  100L) {
  -synchronized (this) {
  +synchronized (addS) {
   rv = Poll.maintain(serverPollset, desc, true);
   maintainTime = 0;
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-14 Thread remm
remm2005/06/14 00:43:29

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Fix typo.
  
  Revision  ChangesPath
  1.43  +1 -1  
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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- AprEndpoint.java  14 Jun 2005 06:55:20 -  1.42
  +++ AprEndpoint.java  14 Jun 2005 07:43:29 -  1.43
  @@ -1168,7 +1168,7 @@
   // Add socket to the list. Newly added sockets will wait
   // at most for pollTime before being polled
   synchronized (addS) {
  -addS.add(sendfileData);
  +addS.add(data);
   addS.notify();
   }
   return false;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-14 Thread mturk
mturk   2005/06/14 01:23:25

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Change the way how maintain is called. There is no need to
  call the maintain on each TIMEUP.
  
  Revision  ChangesPath
  1.44  +9 -10 
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.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- AprEndpoint.java  14 Jun 2005 07:43:29 -  1.43
  +++ AprEndpoint.java  14 Jun 2005 08:23:25 -  1.44
  @@ -834,12 +834,13 @@
*/
   public void run() {
   
  +long maintainTime = 0;
   // Loop until we receive a shutdown command
   while (running) {
  -long maintainTime = 0;
   // Loop if endpoint is paused
   while (paused) {
   try {
  +// TODO: We can easly do the maintenance here
   Thread.sleep(1000);
   } catch (InterruptedException e) {
   // Ignore
  @@ -847,6 +848,8 @@
   }
   
   while (keepAliveCount  1  addCount  1) {
  +// Reset maintain time.
  +maintainTime = 0;
   try {
   synchronized (addS) {
   addS.wait();
  @@ -873,6 +876,7 @@
   addCount = 0;
   }
   }
  +maintainTime += pollTime;
   // Pool for the specified interval
   int rv = Poll.poll(serverPollset, pollTime, desc, true);
   if (rv  0) {
  @@ -888,12 +892,9 @@
   // Hand this socket off to a worker
   getWorkerThread().assign(desc[n*4+1], 
desc[n*4+2]);
   }
  -maintainTime += pollTime;
   } else if (rv  0) {
   /* Any non timeup error is critical */
  -if (-rv == Status.TIMEUP)
  -rv = 0;
  -else {
  +if (-rv != Status.TIMEUP) {
   log.error(sm.getString(endpoint.poll.fail));
   // Handle poll critical failure
   synchronized (this) {
  @@ -902,11 +903,9 @@
   }
   }
   }
  -if (rv == 0 || maintainTime  100L) {
  -synchronized (addS) {
  -rv = Poll.maintain(serverPollset, desc, true);
  -maintainTime = 0;
  -}
  +if (maintainTime  100L) {
  +rv = Poll.maintain(serverPollset, desc, true);
  +maintainTime = 0;
   if (rv  0) {
   keepAliveCount -= rv;
   for (int n = 0; n  rv; n++) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-14 Thread remm
remm2005/06/14 06:14:19

  Modified:util/java/org/apache/tomcat/util/net/res
LocalStrings.properties
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Add status codes on errors.
  - Close remaining sockets on destroy.
  
  Revision  ChangesPath
  1.10  +1 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- LocalStrings.properties   14 May 2005 15:42:30 -  1.9
  +++ LocalStrings.properties   14 Jun 2005 13:14:18 -  1.10
  @@ -15,7 +15,7 @@
   endpoint.accept.fail=Socket accept failed
   endpoint.poll.limitedpollsize=Failed to create poller with specified size, 
uses 62 instead
   endpoint.poll.initfail=Poller creation failed
  -endpoint.poll.fail=Critical poller failure, restarting poller
  +endpoint.poll.fail=Critical poller failure ({0}), restarting poller
   endpoint.poll.error=Unexpected poller error
   endpoint.sendfile.error=Unexpected sendfile error
   endpoint.sendfile.addfail=Sednfile failure with status {0}
  
  
  
  1.45  +25 -4 
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.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- AprEndpoint.java  14 Jun 2005 08:23:25 -  1.44
  +++ AprEndpoint.java  14 Jun 2005 13:14:19 -  1.45
  @@ -796,11 +796,20 @@
* Destroy the poller.
*/
   protected void destroy() {
  -/* Remove the sockets in the add queue */
  +// Close all sockets in the add queue
   for (int i = 0; i  addCount; i--) {
   Pool.destroy(addP[i]);
   }
  +// Close all sockets still in the poller
  +int rv = Poll.pollset(serverPollset, desc);
  +if (rv  0) {
  +for (int n = 0; n  rv; n++) {
  +Pool.destroy(desc[n*4+2]);
  +}
  +}
   Pool.destroy(pool);
  +keepAliveCount = 0;
  +addCount = 0;
   }
   
   /**
  @@ -895,7 +904,7 @@
   } else if (rv  0) {
   /* Any non timeup error is critical */
   if (-rv != Status.TIMEUP) {
  -log.error(sm.getString(endpoint.poll.fail));
  +log.error(sm.getString(endpoint.poll.fail, 
Error.strerror(-rv)));
   // Handle poll critical failure
   synchronized (this) {
   destroy();
  @@ -1113,8 +1122,20 @@
* Destroy the poller.
*/
   protected void destroy() {
  -sendfileData.clear();
  +// Close any socket remaining in the add queue
  +for (int i = (addS.size() - 1); i = 0; i--) {
  +SendfileData data = (SendfileData) addS.get(i);
  +Pool.destroy(data.pool);
  +}
  +// Close all sockets still in the poller
  +int rv = Poll.pollset(sendfilePollset, desc);
  +if (rv  0) {
  +for (int n = 0; n  rv; n++) {
  +Pool.destroy(desc[n*4+2]);
  +}
  +}
   Pool.destroy(pool);
  +sendfileData.clear();
   }
   
   /**
  @@ -1281,7 +1302,7 @@
   if (-rv == Status.TIMEUP)
   rv = 0;
   else {
  -log.error(sm.getString(endpoint.poll.fail));
  +log.error(sm.getString(endpoint.poll.fail, 
Error.strerror(-rv)));
   // Handle poll critical failure
   synchronized (this) {
   destroy();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-10 Thread remm
remm2005/06/10 04:03:32

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Use the new Status constants.
  
  Revision  ChangesPath
  1.38  +3 -3  
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.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- AprEndpoint.java  27 May 2005 16:45:56 -  1.37
  +++ AprEndpoint.java  10 Jun 2005 11:03:32 -  1.38
  @@ -887,7 +887,7 @@
   maintainTime += pollTime;
   } else if (rv  0) {
   /* Any non timeup error is critical */
  -if (Status.APR_STATUS_IS_TIMEUP(-rv))
  +if (-rv == Status.TIMEUP)
   rv = 0;
   else {
   log.error(sm.getString(endpoint.poll.fail));
  @@ -1139,7 +1139,7 @@
   long nw = Socket.sendfile(data.socket, data.fd, null, 
null,
data.pos, data.end, 0);
   if (nw  0) {
  -if (!Status.APR_STATUS_IS_EAGAIN((int) -nw)) {
  +if (!(-nw == Status.EAGAIN)) {
   Poll.destroy(data.pool);
   return false;
   } else {
  @@ -1275,7 +1275,7 @@
   }
   } else if (rv  0) {
   /* Any non timeup error is critical */
  -if (Status.APR_STATUS_IS_TIMEUP(-rv))
  +if (-rv == Status.TIMEUP)
   rv = 0;
   else {
   log.error(sm.getString(endpoint.poll.fail));
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-10 Thread remm
remm2005/06/10 05:55:12

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Start with the end of the socket list.
  
  Revision  ChangesPath
  1.40  +2 -2  
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.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- AprEndpoint.java  10 Jun 2005 12:49:56 -  1.39
  +++ AprEndpoint.java  10 Jun 2005 12:55:12 -  1.40
  @@ -856,7 +856,7 @@
   // Add sockets which are waiting to the poller
   if (addCount  0) {
   synchronized (addS) {
  -for (int i = 0; i  addCount; i++) {
  +for (int i = (addCount - 1); i = 0; i--) {
   int rv = Poll.add
   (serverPollset, addS[i], addP[i], 
Poll.APR_POLLIN);
   if (rv == Status.APR_SUCCESS) {
  @@ -1217,7 +1217,7 @@
   // Add socket to the poller
   if (addS.size()  0) {
   synchronized (addS) {
  -for (int i = 0; i  addS.size(); i++) {
  +for (int i = addS.size() - 1; i = 0; i--) {
   SendfileData data = (SendfileData) 
addS.get(i);
   int rv = Poll.add(sendfilePollset, 
data.socket, 0, Poll.APR_POLLOUT);
   if (rv == Status.APR_SUCCESS) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-06-10 Thread remm
remm2005/06/10 05:49:56

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Fix bad address usage.
  
  Revision  ChangesPath
  1.39  +1 -1  
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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- AprEndpoint.java  10 Jun 2005 11:03:32 -  1.38
  +++ AprEndpoint.java  10 Jun 2005 12:49:56 -  1.39
  @@ -863,7 +863,7 @@
   keepAliveCount++;
   } else {
   // Can't do anything: close the socket 
right away
  -Pool.destroy(pool);
  +Pool.destroy(addP[i]);
   }
   }
   addCount = 0;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-27 Thread remm
remm2005/05/27 01:26:38

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - If not using sendfile, don't allocate sebdfile resources.
  
  Revision  ChangesPath
  1.36  +11 -7 
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.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- AprEndpoint.java  26 May 2005 18:34:50 -  1.35
  +++ AprEndpoint.java  27 May 2005 08:26:38 -  1.36
  @@ -445,12 +445,14 @@
   pollerThread.start();
   
   // Start sendfile thread
  -sendfile = new Sendfile();
  -sendfile.init();
  -sendfileThread = new Thread(sendfile, getName() + -Sendfile);
  -sendfileThread.setPriority(getThreadPriority());
  -sendfileThread.setDaemon(true);
  -sendfileThread.start();
  +if (useSendfile) {
  +sendfile = new Sendfile();
  +sendfile.init();
  +sendfileThread = new Thread(sendfile, getName() + 
-Sendfile);
  +sendfileThread.setPriority(getThreadPriority());
  +sendfileThread.setDaemon(true);
  +sendfileThread.start();
  +}
   }
   }
   
  @@ -485,7 +487,9 @@
   running = false;
   unlockAccept();
   poller.destroy();
  -sendfile.destroy();
  +if (useSendfile) {
  +sendfile.destroy();
  +}
   acceptorThread = null;
   pollerThread = null;
   sendfileThread = null;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[MSK-31466]: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-27 Thread Technical Support
== Please reply above this line ==

tomcat-dev@jakarta.apache.org,

Your request for technical support has been submitted.

You will receive a response via e-mail within
two business days (excluding holidays).

Your problem or question will receive the attention it deserves.  Listed below 
are details of this ticket.  You will need to use the ticket key listed below 
to update the status of this ticket from web.

Ticket ID: MSK-31466
Ticket Key: 48e8f695
Subject: cvs commit: 
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java
Department: Technical Support

You can check the status or reply to this ticket online at 
http://assist.mediafour.com/index.php?_a=tickets_m=viewmain[EMAIL 
PROTECTED]ticketkeyre=48e8f695_i=MSK-31466

** Assistance from Mediafour representatives and
** other users is available at:

** http://forums.mediafour.com


We are dedicated to making great software. If you feel that your request is not 
handled well or in a timely manner, please contact: [EMAIL PROTECTED]

Please let us know if we can be of further assistance,

Team Mediafour

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-27 Thread mturk
mturk   2005/05/27 09:45:56

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Just a comment change for TCP_DEFER_ACCEPT.
  No functional change.
  
  Revision  ChangesPath
  1.37  +2 -1  
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.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- AprEndpoint.java  27 May 2005 08:26:38 -  1.36
  +++ AprEndpoint.java  27 May 2005 16:45:56 -  1.37
  @@ -409,7 +409,8 @@
   }
   
   // Delay accepting of new connections until data is available
  -// TODO: Make that configurable   
  +// Only Linux kernels 2.4 + have that implemented
  +// on other platforms this call is noop and will return APR_ENOTIMPL.
Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1);
   
   initialized = true;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-26 Thread funkman
funkman 2005/05/26 08:21:04

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  String concatentation (of InetAddress) doesn't work to bind to
  specific IP address
  
  Revision  ChangesPath
  1.33  +17 -17
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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- AprEndpoint.java  26 May 2005 14:43:09 -  1.32
  +++ AprEndpoint.java  26 May 2005 15:21:04 -  1.33
  @@ -43,10 +43,10 @@
* liSendfile thread/li
* liWorker threads pool/li
* /ul
  - * 
  - * When switching to Java 5, there's an opportunity to use the virtual 
  + *
  + * When switching to Java 5, there's an opportunity to use the virtual
* machine's thread pool.
  - * 
  + *
* @author Mladen Turk
* @author Remy Maucherat
*/
  @@ -390,7 +390,7 @@
   if (address == null) {
   addressStr = null;
   } else {
  -addressStr =  + address;
  +addressStr =  + address.getHostAddress();
   }
   long inetAddress = Address.info(addressStr, Socket.APR_INET,
   port, 0, rootPool);
  @@ -401,12 +401,12 @@
   Socket.bind(serverSock, inetAddress);
   // Start listening on the server socket
   Socket.listen(serverSock, backlog);
  -
  +
   // Sendfile usage on systems which don't support it cause major 
problems
   if (useSendfile  !Library.APR_HAS_SENDFILE) {
   log.warn(sm.getString(endpoint.sendfile.nosupport));
   useSendfile = false;
  -} 
  +}
   
   initialized = true;
   
  @@ -463,7 +463,7 @@
   
   
   /**
  - * Resume the endpoint, which will make it start accepting new sockets 
  + * Resume the endpoint, which will make it start accepting new sockets
* again.
*/
   public void resume() {
  @@ -472,7 +472,7 @@
   }
   }
   
  -
  +
   /**
* Stop the endpoint. This will cause all processing threads to stop.
*/
  @@ -795,13 +795,13 @@
* be added to a temporary array, and polled first after a maximum 
amount
* of time equal to pollTime (in most cases, latency will be much 
lower,
* however).
  - * 
  + *
* @param socket to add to the poller
* @param pool reprenting the memory used for the socket
*/
   public void add(long socket, long pool) {
   synchronized (addS) {
  -// Add socket to the list. Newly added sockets will wait 
  +// Add socket to the list. Newly added sockets will wait
   // at most for pollTime before being polled
   if (addCount = addS.length) {
   // Can't do anything: close the socket right away
  @@ -1108,11 +1108,11 @@
   /**
* Add the sendfile data to the sendfile poller. Note that in most 
cases,
* the initial non blocking calls to sendfile will return right 
away, and
  - * will be handled asynchronously inside the kernel. As a result, 
  + * will be handled asynchronously inside the kernel. As a result,
* the poller will never be used.
  - * 
  + *
* @param data containing the reference to the data which should be 
snet
  - * @return true if all the data has been sent right away, and false 
  + * @return true if all the data has been sent right away, and false
*  otherwise
*/
   public boolean add(SendfileData data) {
  @@ -1135,7 +1135,7 @@
   return false;
   } else {
   // Break the loop and add the socket to poller.
  -break;
  +break;
   }
   } else {
   data.pos = data.pos + nw;
  @@ -1152,7 +1152,7 @@
   log.error(sm.getString(endpoint.sendfile.error), e);
   return false;
   }
  -// Add socket to the list. Newly added sockets will wait 
  +// Add socket to the list. Newly added sockets will wait
   // at most for pollTime before being polled
   synchronized (addS) {
   addS.add(sendfileData);
  @@ -1163,7 +1163,7 @@
   
   /**
* Remove socket from the poller.
  - * 
  + *
* @param data the sendfile data which should be removed
*/
   protected void remove(SendfileData data) {
  

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-26 Thread funkman
funkman 2005/05/26 08:29:55

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  bonehead move - I don't need to concatenate an empty string to a string
  
  Revision  ChangesPath
  1.34  +1 -1  
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.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- AprEndpoint.java  26 May 2005 15:21:04 -  1.33
  +++ AprEndpoint.java  26 May 2005 15:29:55 -  1.34
  @@ -390,7 +390,7 @@
   if (address == null) {
   addressStr = null;
   } else {
  -addressStr =  + address.getHostAddress();
  +addressStr = address.getHostAddress();
   }
   long inetAddress = Address.info(addressStr, Socket.APR_INET,
   port, 0, rootPool);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-26 Thread mturk
mturk   2005/05/26 11:34:50

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Set TCP_DEFER_ACCEPT socket option. This dramatically improves
  performance on linux by more then 20% for small files because the
  accept is not fired untill data is present.
  
  Revision  ChangesPath
  1.35  +4 -0  
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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- AprEndpoint.java  26 May 2005 15:29:55 -  1.34
  +++ AprEndpoint.java  26 May 2005 18:34:50 -  1.35
  @@ -407,6 +407,10 @@
   log.warn(sm.getString(endpoint.sendfile.nosupport));
   useSendfile = false;
   }
  +
  +// Delay accepting of new connections until data is available
  +// TODO: Make that configurable   
  + Socket.optSet(serverSock, Socket.APR_TCP_DEFER_ACCEPT, 1);
   
   initialized = true;
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-26 Thread Remy Maucherat

[EMAIL PROTECTED] wrote:

mturk   2005/05/26 11:34:50

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Set TCP_DEFER_ACCEPT socket option. This dramatically improves
  performance on linux by more then 20% for small files because the
  accept is not fired untill data is present.


It doesn't change anything for me performance wise. It seems to add some 
robustness, so it doesn't need to be configurable.


Rémy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-23 Thread mturk
mturk   2005/05/22 23:04:02

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Fix checking for return value from Poll.poll. Now when the native is
  fixed the correct value is returned in case of timeup. Also reset the
  addCount if the poller is recycled.
  
  Revision  ChangesPath
  1.30  +24 -12
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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- AprEndpoint.java  18 May 2005 16:01:46 -  1.29
  +++ AprEndpoint.java  23 May 2005 06:04:02 -  1.30
  @@ -780,6 +780,7 @@
   keepAliveCount = 0;
   addS = new long[pollerSize];
   addP = new long[pollerSize];
  +addCount = 0;
   }
   
   /**
  @@ -872,12 +873,17 @@
   getWorkerThread().assign(desc[n*4+1], 
desc[n*4+2]);
   }
   maintainTime += pollTime;
  -} else if (rv  -1) {
  -log.error(sm.getString(endpoint.poll.fail));
  -// Handle poll critical failure
  -synchronized (this) {
  -destroy();
  -init();
  +} else if (rv  0) {
  +/* Any non timeup error is critical */
  +if (Status.APR_STATUS_IS_TIMEUP(-rv))
  +rv = 0;
  +else {
  +log.error(sm.getString(endpoint.poll.fail));
  +// Handle poll critical failure
  +synchronized (this) {
  +destroy();
  +init();
  +}
   }
   }
   if (rv == 0 || maintainTime  100L) {
  @@ -1252,14 +1258,20 @@
   getWorkerThread().assign(desc[n*4+1], 
state.pool);
   }
   }
  -} else if (rv  -1) {
  -log.error(sm.getString(endpoint.poll.fail));
  -// Handle poll critical failure
  -synchronized (this) {
  -destroy();
  -init();
  +} else if (rv  0) {
  +/* Any non timeup error is critical */
  +if (Status.APR_STATUS_IS_TIMEUP(-rv))
  +rv = 0;
  +else {
  +log.error(sm.getString(endpoint.poll.fail));
  +// Handle poll critical failure
  +synchronized (this) {
  +destroy();
  +init();
  +}
   }
   }
  +/* TODO: See if we need to call the maintain for 
sendfile poller */
   } catch (Throwable t) {
   log.error(sm.getString(endpoint.poll.error), t);
   }
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-18 Thread remm
remm2005/05/18 02:02:32

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Remove a useless synchronized, and add some javadoc.
  
  Revision  ChangesPath
  1.28  +31 -4 
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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AprEndpoint.java  17 May 2005 12:20:20 -  1.27
  +++ AprEndpoint.java  18 May 2005 09:02:32 -  1.28
  @@ -43,7 +43,10 @@
* liSendfile thread/li
* liWorker threads pool/li
* /ul
  - *
  + * 
  + * When switching to Java 5, there's an opportunity to use the virtual 
  + * machine's thread pool.
  + * 
* @author Mladen Turk
* @author Remy Maucherat
*/
  @@ -372,7 +375,8 @@
   /**
* Initialize the endpoint.
*/
  -public void init() throws Exception {
  +public void init()
  +throws Exception {
   
   if (initialized)
   return;
  @@ -409,7 +413,11 @@
   }
   
   
  -public void start() throws Exception {
  +/**
  + * Start the APR endpoint, creating acceptor, poller and sendfile 
threads.
  + */
  +public void start()
  +throws Exception {
   // Initialize socket if not done before
   if (!initialized) {
   init();
  @@ -443,6 +451,9 @@
   }
   
   
  +/**
  + * Pause the endpoint, which will make it stop accepting new sockets.
  + */
   public void pause() {
   if (running  !paused) {
   paused = true;
  @@ -450,12 +461,21 @@
   }
   }
   
  +
  +/**
  + * Resume the endpoint, which will make it start accepting new sockets 
  + * again.
  + */
   public void resume() {
   if (running) {
   paused = false;
   }
   }
   
  +
  +/**
  + * Stop the endpoint. This will cause all processing threads to stop.
  + */
   public void stop() {
   if (running) {
   running = false;
  @@ -468,6 +488,10 @@
   }
   }
   
  +
  +/**
  + * Deallocate APR memory pools, and close server socket.
  + */
   public void destroy() throws Exception {
   if (running) {
   stop();
  @@ -540,6 +564,9 @@
   }
   
   
  +/**
  + * Process the specified connection.
  + */
   protected boolean processSocket(long socket, long pool) {
   // Process the connection
   int step = 1;
  @@ -731,7 +758,7 @@
* Create the poller. With some versions of APR, the maximum poller 
size will
* be 62 (reocmpiling APR is necessary to remove this limitation).
*/
  -protected synchronized void init() {
  +protected void init() {
   pool = Pool.create(serverSockPool);
   try {
   serverPollset = Poll.create(pollerSize, pool, 0, soTimeout * 
1000);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-18 Thread mturk
mturk   2005/05/18 09:01:46

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Fix typo. data.fdpool is APR pool not APR pollset.
  
  Revision  ChangesPath
  1.29  +1 -1  
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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- AprEndpoint.java  18 May 2005 09:02:32 -  1.28
  +++ AprEndpoint.java  18 May 2005 16:01:46 -  1.29
  @@ -1132,7 +1132,7 @@
   data.pos = data.pos + nw;
   if (data.pos = data.end) {
   // Entire file has been send
  -Poll.destroy(data.fdpool);
  +Pool.destroy(data.fdpool);
   // Set back socket to blocking mode
   Socket.optSet(data.socket, 
Socket.APR_SO_NONBLOCK, 0);
   return true;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-18 Thread Remy Maucherat
[EMAIL PROTECTED] wrote:
mturk   2005/05/18 09:01:46
  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Fix typo. data.fdpool is APR pool not APR pollset.

  -Poll.destroy(data.fdpool);
  +Pool.destroy(data.fdpool);
Lol, sorry about that one ... It didn't crash on Windows, for some reason ;)
Rémy
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-17 Thread remm
remm2005/05/17 05:20:20

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Add javadocs.
  - Fix sync on the arrylist for sendfile (in the case where stuff is added to 
the
array list, which I haven't seen happen yet).
  
  Revision  ChangesPath
  1.27  +62 -24
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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- AprEndpoint.java  14 May 2005 15:42:30 -  1.26
  +++ AprEndpoint.java  17 May 2005 12:20:20 -  1.27
  @@ -727,6 +727,10 @@
   protected long[] addP;
   protected int addCount = 0;
   
  +/**
  + * Create the poller. With some versions of APR, the maximum poller 
size will
  + * be 62 (reocmpiling APR is necessary to remove this limitation).
  + */
   protected synchronized void init() {
   pool = Pool.create(serverSockPool);
   try {
  @@ -751,10 +755,22 @@
   addP = new long[pollerSize];
   }
   
  +/**
  + * Destroy the poller.
  + */
   protected void destroy() {
   Pool.destroy(pool);
   }
   
  +/**
  + * Add specified socket and associated pool to the poller. The 
socket will
  + * be added to a temporary array, and polled first after a maximum 
amount
  + * of time equal to pollTime (in most cases, latency will be much 
lower,
  + * however).
  + * 
  + * @param socket to add to the poller
  + * @param pool reprenting the memory used for the socket
  + */
   public void add(long socket, long pool) {
   synchronized (addS) {
   // Add socket to the list. Newly added sockets will wait 
  @@ -1018,6 +1034,10 @@
   
   protected ArrayList addS;
   
  +/**
  + * Create the sendfile poller. With some versions of APR, the 
maximum poller size will
  + * be 62 (reocmpiling APR is necessary to remove this limitation).
  + */
   protected void init() {
   pool = Pool.create(serverSockPool);
   try {
  @@ -1041,11 +1061,24 @@
   addS = new ArrayList();
   }
   
  +/**
  + * Destroy the poller.
  + */
   protected void destroy() {
   sendfileData.clear();
   Pool.destroy(pool);
   }
   
  +/**
  + * Add the sendfile data to the sendfile poller. Note that in most 
cases,
  + * the initial non blocking calls to sendfile will return right 
away, and
  + * will be handled asynchronously inside the kernel. As a result, 
  + * the poller will never be used.
  + * 
  + * @param data containing the reference to the data which should be 
snet
  + * @return true if all the data has been sent right away, and false 
  + *  otherwise
  + */
   public boolean add(SendfileData data) {
   // Initialize fd from data given
   try {
  @@ -1091,16 +1124,19 @@
   return false;
   }
   
  -public void remove(long socket) {
  -synchronized (this) {
  -int rv = Poll.remove(sendfilePollset, socket);
  -if (rv == Status.APR_SUCCESS) {
  -sendfileCount--;
  -}
  -// Set the socket to blocking mode again
  -Socket.optSet(socket, Socket.APR_SO_NONBLOCK, 0);
  -sendfileData.remove(new Long(socket));
  -}
  +/**
  + * Remove socket from the poller.
  + * 
  + * @param data the sendfile data which should be removed
  + */
  +protected void remove(SendfileData data) {
  +int rv = Poll.remove(sendfilePollset, data.socket);
  +if (rv == Status.APR_SUCCESS) {
  +sendfileCount--;
  +}
  +// Set the socket to blocking mode again
  +Socket.optSet(data.socket, Socket.APR_SO_NONBLOCK, 0);
  +sendfileData.remove(data);
   }
   
   /**
  @@ -1132,19 +1168,21 @@
   try {
   // Add socket to the poller
   if (addS.size()  0) {
  -for (int i = 0; i  addS.size(); i++) {
  -SendfileData data = (SendfileData) addS.get(i);
  -int rv = Poll.add(sendfilePollset, data.socket, 
0, Poll.APR_POLLOUT);
  -if (rv == Status.APR_SUCCESS) {
  -

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-14 Thread remm
remm2005/05/14 08:42:30

  Modified:util/java/org/apache/tomcat/util/net/res
LocalStrings.properties
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Disable sendfile if not supported, as submitted by Bill and Mladen.
  
  Revision  ChangesPath
  1.9   +1 -0  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- LocalStrings.properties   3 May 2005 09:36:58 -   1.8
  +++ LocalStrings.properties   14 May 2005 15:42:30 -  1.9
  @@ -19,3 +19,4 @@
   endpoint.poll.error=Unexpected poller error
   endpoint.sendfile.error=Unexpected sendfile error
   endpoint.sendfile.addfail=Sednfile failure with status {0}
  +endpoint.sendfile.nosupport=Disabling sendfile, since either the APR version 
or the system doesn't support it
  
  
  
  1.26  +7 -0  
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- AprEndpoint.java  11 May 2005 11:23:26 -  1.25
  +++ AprEndpoint.java  14 May 2005 15:42:30 -  1.26
  @@ -26,6 +26,7 @@
   import org.apache.tomcat.jni.Address;
   import org.apache.tomcat.jni.Error;
   import org.apache.tomcat.jni.File;
  +import org.apache.tomcat.jni.Library;
   import org.apache.tomcat.jni.Poll;
   import org.apache.tomcat.jni.Pool;
   import org.apache.tomcat.jni.Socket;
  @@ -396,6 +397,12 @@
   Socket.bind(serverSock, inetAddress);
   // Start listening on the server socket
   Socket.listen(serverSock, backlog);
  +
  +// Sendfile usage on systems which don't support it cause major 
problems
  +if (useSendfile  !Library.APR_HAS_SENDFILE) {
  +log.warn(sm.getString(endpoint.sendfile.nosupport));
  +useSendfile = false;
  +} 
   
   initialized = true;
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-05-03 Thread remm
remm2005/05/03 02:36:58

  Modified:util/java/org/apache/tomcat/util/net/res
LocalStrings.properties
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Add missing logging.
  
  Revision  ChangesPath
  1.8   +1 -0  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LocalStrings.properties   24 Apr 2005 13:18:28 -  1.7
  +++ LocalStrings.properties   3 May 2005 09:36:58 -   1.8
  @@ -12,6 +12,7 @@
   endpoint.err.close=Caught exception trying to close socket
   endpoint.noProcessor=No Processors - worker thread dead!
   
  +endpoint.accept.fail=Socket accept failed
   endpoint.poll.limitedpollsize=Failed to create poller with specified size, 
uses 62 instead
   endpoint.poll.initfail=Poller creation failed
   endpoint.poll.fail=Critical poller failure, restarting poller
  
  
  
  1.24  +1 -2  
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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- AprEndpoint.java  28 Apr 2005 12:29:51 -  1.23
  +++ AprEndpoint.java  3 May 2005 09:36:58 -   1.24
  @@ -686,8 +686,7 @@
   // Hand this socket off to an appropriate processor
   workerThread.assign(socket, pool);
   } catch (Exception e) {
  -// FIXME: proper logging
  -e.printStackTrace();
  +log.error(sm.getString(endpoint.accept.fail), e);
   }
   
   // The processor will recycle itself when it finishes
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-28 Thread remm
remm2005/04/28 05:29:51

  Modified:catalina/src/share/org/apache/catalina/connector
Connector.java LocalStrings.properties
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Use APR if present (oops for SSL mode, where right now the protocol class 
would have to be specified). I'm still unsure about the APRized AJP (motivation
is a bit lacking, although it would be good for straight comparisons).
  - Useless code removal.
  
  Revision  ChangesPath
  1.17  +55 -9 
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Connector.java
  
  Index: Connector.java
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Connector.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- Connector.java29 Jan 2005 19:44:43 -  1.16
  +++ Connector.java28 Apr 2005 12:29:51 -  1.17
  @@ -17,6 +17,7 @@
   
   package org.apache.catalina.connector;
   
  +import java.lang.reflect.Method;
   import java.net.URLEncoder;
   import java.util.HashMap;
   
  @@ -548,9 +549,13 @@
   public String getProtocol() {
   
   if (org.apache.coyote.http11.Http11Protocol.equals
  +(getProtocolHandlerClassName())
  +|| org.apache.coyote.http11.Http11AprProtocol.equals
   (getProtocolHandlerClassName())) {
   return HTTP/1.1;
   } else if (org.apache.jk.server.JkCoyoteHandler.equals
  +   (getProtocolHandlerClassName())
  +   || org.apache.coyote.ajp.AjpAprProtocol.equals
  (getProtocolHandlerClassName())) {
   return AJP/1.3;
   }
  @@ -566,14 +571,55 @@
*/
   public void setProtocol(String protocol) {
   
  -if (HTTP/1.1.equals(protocol)) {
  -setProtocolHandlerClassName
  -(org.apache.coyote.http11.Http11Protocol);
  -} else if (AJP/1.3.equals(protocol)) {
  -setProtocolHandlerClassName
  -(org.apache.jk.server.JkCoyoteHandler);
  -} else if (protocol != null) {
  -setProtocolHandlerClassName(protocol);
  +// Test APR support
  +boolean apr = false;
  +try {
  +String methodName = initialize;
  +Class paramTypes[] = new Class[1];
  +paramTypes[0] = String.class;
  +Object paramValues[] = new Object[1];
  +paramValues[0] = null;
  +Method method = Class.forName(org.apache.tomcat.jni.Library)
  +.getMethod(methodName, paramTypes);
  +method.invoke(null, paramValues);
  +apr = true;
  +} catch (Throwable t) {
  +if (!log.isDebugEnabled()) {
  +log.info(sm.getString(coyoteConnector.noApr, 
  +System.getProperty(java.library.path)));
  +} else {
  +log.debug(sm.getString(coyoteConnector.noApr, 
  +System.getProperty(java.library.path)), t);
  +}
  +}
  +
  +if (apr) {
  +if (HTTP/1.1.equals(protocol)) {
  +setProtocolHandlerClassName
  +(org.apache.coyote.http11.Http11AprProtocol);
  +} else if (AJP/1.3.equals(protocol)) {
  +/*
  +setProtocolHandlerClassName
  +(org.apache.coyote.ajp.AjpAprProtocol);
  +*/
  +setProtocolHandlerClassName
  +(org.apache.jk.server.JkCoyoteHandler);
  +} else if (protocol != null) {
  +setProtocolHandlerClassName(protocol);
  +} else {
  +setProtocolHandlerClassName
  +(org.apache.coyote.http11.Http11AprProtocol);
  +}
  +} else {
  +if (HTTP/1.1.equals(protocol)) {
  +setProtocolHandlerClassName
  +(org.apache.coyote.http11.Http11Protocol);
  +} else if (AJP/1.3.equals(protocol)) {
  +setProtocolHandlerClassName
  +(org.apache.jk.server.JkCoyoteHandler);
  +} else if (protocol != null) {
  +setProtocolHandlerClassName(protocol);
  +}
   }
   
   }
  
  
  
  1.7   +3 -0  
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalStrings.properties   29 Jan 2005 19:44:43 -  

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-24 Thread remm
remm2005/04/24 03:28:38

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Negativa values are now ok (apparently) for poll. (fixes a regression 
caused by yesterday's poll.c change)
  
  Revision  ChangesPath
  1.20  +0 -14 
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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- AprEndpoint.java  23 Apr 2005 18:59:52 -  1.19
  +++ AprEndpoint.java  24 Apr 2005 10:28:38 -  1.20
  @@ -836,13 +836,6 @@
   getWorkerThread().assign(desc[n*4+1], 
desc[n*4+2]);
   }
   maintainTime += pollTime;
  -} else if (rv  0) {
  -// FIXME: Log with WARN at least
  -// Handle poll critical failure
  -synchronized (this) {
  -destroy();
  -init();
  -}
   }
   if (rv == 0 || maintainTime  100L) {
   synchronized (this) {
  @@ -1186,13 +1179,6 @@
   getWorkerThread().assign(desc[n*4+1], 
state.pool);
   }
   }
  -} else if (rv  0) {
  -// Handle poll critical failure
  -// FIXME: Log with WARN at least
  -synchronized (this) {
  -destroy();
  -init();
  -}
   }
   } catch (Throwable t) {
   // FIXME: Proper logging
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-24 Thread remm
remm2005/04/24 03:40:48

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Probably a more sensible fix :)
  
  Revision  ChangesPath
  1.21  +14 -0 
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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- AprEndpoint.java  24 Apr 2005 10:28:38 -  1.20
  +++ AprEndpoint.java  24 Apr 2005 10:40:48 -  1.21
  @@ -836,6 +836,13 @@
   getWorkerThread().assign(desc[n*4+1], 
desc[n*4+2]);
   }
   maintainTime += pollTime;
  +} else if (rv  -1) {
  +// FIXME: Log with WARN at least
  +// Handle poll critical failure
  +synchronized (this) {
  +destroy();
  +init();
  +}
   }
   if (rv == 0 || maintainTime  100L) {
   synchronized (this) {
  @@ -1179,6 +1186,13 @@
   getWorkerThread().assign(desc[n*4+1], 
state.pool);
   }
   }
  +} else if (rv  -1) {
  +// Handle poll critical failure
  +// FIXME: Log with WARN at least
  +synchronized (this) {
  +destroy();
  +init();
  +}
   }
   } catch (Throwable t) {
   // FIXME: Proper logging
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-24 Thread remm
remm2005/04/24 06:18:28

  Modified:util/java/org/apache/tomcat/util/net/res
LocalStrings.properties
   util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Proper logging.
  
  Revision  ChangesPath
  1.7   +8 -1  
jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===
  RCS file: 
/home/cvs/jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net/res/LocalStrings.properties,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LocalStrings.properties   29 Jan 2005 19:29:55 -  1.6
  +++ LocalStrings.properties   24 Apr 2005 13:18:28 -  1.7
  @@ -10,4 +10,11 @@
   endpoint.warn.nullSocket=Null socket returned by accept
   endpoint.debug.unlock=Caught exception trying to unlock accept on port {0}
   endpoint.err.close=Caught exception trying to close socket
  -endpoint.noProcessor=No Processors - worker thread dead!
  \ No newline at end of file
  +endpoint.noProcessor=No Processors - worker thread dead!
  +
  +endpoint.poll.limitedpollsize=Failed to create poller with specified size, 
uses 62 instead
  +endpoint.poll.initfail=Poller creation failed
  +endpoint.poll.fail=Critical poller failure, restarting poller
  +endpoint.poll.error=Unexpected poller error
  +endpoint.sendfile.error=Unexpected sendfile error
  +endpoint.sendfile.addfail=Sednfile failure with status {0}
  
  
  
  1.22  +35 -57
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AprEndpoint.java  24 Apr 2005 10:40:48 -  1.21
  +++ AprEndpoint.java  24 Apr 2005 13:18:28 -  1.22
  @@ -19,7 +19,6 @@
   import java.net.InetAddress;
   import java.util.HashMap;
   import java.util.Stack;
  -import java.util.Vector;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -94,12 +93,6 @@
   
   
   /**
  - * All processors which have been created.
  - */
  -protected Vector created = new Vector();
  -
  -
  -/**
* Running state of the endpoint.
*/
   protected volatile boolean running = false;
  @@ -395,33 +388,29 @@
   if (initialized)
   return;
   
  -try {
  -// Initialize APR
  -Library.initialize(null);
  -// Create the root APR memory pool
  -rootPool = Pool.create(0);
  -// Create the pool for the server socket
  -serverSockPool = Pool.create(rootPool);
  -// Create the APR address that will be bound
  -String addressStr = null;
  -if (address == null) {
  -addressStr = null;
  -} else {
  -addressStr =  + address;
  -}
  -long inetAddress = Address.info(addressStr, Socket.APR_INET,
  -   port, 0, rootPool);
  -// Create the APR server socket
  -serverSock = Socket.create(Socket.APR_INET, Socket.SOCK_STREAM,
  -   Socket.APR_PROTO_TCP, rootPool);
  -// Bind the server socket
  -Socket.bind(serverSock, inetAddress);
  -// Start listening on the server socket
  -Socket.listen(serverSock, backlog);
  -} catch (Exception e) {
  -// FIXME: proper logging
  -throw e;
  -}
  +// Initialize APR
  +Library.initialize(null);
  +// Create the root APR memory pool
  +rootPool = Pool.create(0);
  +// Create the pool for the server socket
  +serverSockPool = Pool.create(rootPool);
  +// Create the APR address that will be bound
  +String addressStr = null;
  +if (address == null) {
  +addressStr = null;
  +} else {
  +addressStr =  + address;
  +}
  +long inetAddress = Address.info(addressStr, Socket.APR_INET,
  +port, 0, rootPool);
  +// Create the APR server socket
  +serverSock = Socket.create(Socket.APR_INET, Socket.SOCK_STREAM,
  +Socket.APR_PROTO_TCP, rootPool);
  +// Bind the server socket
  +Socket.bind(serverSock, inetAddress);
  +// Start listening on the server socket
  +Socket.listen(serverSock, backlog);
  +
   initialized = true;
   
   }
  @@ -632,7 +621,6 @@
   
   Worker workerThread = new Worker();
   workerThread.start();
  -

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-23 Thread mturk
mturk   2005/04/23 08:57:24

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Make Senfile usable. Sendfile should be added to the poller, only
  if it returns EAGAIN status. In any other case the poller will break.
  
  Revision  ChangesPath
  1.15  +31 -9 
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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- AprEndpoint.java  20 Apr 2005 16:13:23 -  1.14
  +++ AprEndpoint.java  23 Apr 2005 15:57:24 -  1.15
  @@ -839,7 +839,6 @@
   } else if (rv  0) {
   // FIXME: Log with WARN at least
   // Handle poll critical failure
  -Pool.clear(serverSockPool);
   synchronized (this) {
   destroy();
   init();
  @@ -1023,7 +1022,6 @@
   protected long pool = 0;
   protected long[] desc;
   protected HashMap sendfileData;
  -
   protected void init() {
   pool = Pool.create(serverSockPool);
   try {
  @@ -1063,12 +1061,36 @@
| File.APR_FOPEN_SENDFILE_ENABLED | 
File.APR_FOPEN_BINARY,
0, data.fdpool);
   data.pos = data.start;
  +// Set the socket to nonblocking mode
  +Socket.optSet(socket, Socket.APR_SO_NONBLOCK, 1);
  +int nw = Socket.sendfile(socket, data.fd, null, null,
  + data.pos, (int)data.end, 0);
  +if (nw  0) {
  +if (!Status.APR_STATUS_IS_EAGAIN(-nw)) {
  +Poll.destroy(data.pool);
  +return;
  +}
  +}
  +else {
  +data.pos = data.pos + nw;
  +if (data.pos = data.end) {
  +// Entire file has been send
  +Poll.destroy(data.pool);
  +return;
  +}
  +else {
  +//FIXME: Ether EAGAIN of full data should be returned
  +Poll.destroy(data.pool);
  +return;
  +}
  +}
   } catch (Error e) {
   // FIXME: more appropriate logging
   e.printStackTrace();
   return;
   }
   synchronized (this) {
  +// Add socket to the poller
   sendfileData.put(new Long(socket), data);
   int rv = Poll.add(sendfilePollset, socket, 0, 
Poll.APR_POLLOUT);
   if (rv == Status.APR_SUCCESS) {
  @@ -1088,6 +1110,8 @@
   if (rv == Status.APR_SUCCESS) {
   sendfileCount--;
   }
  +// Set the socket to blocking mode again
  +Socket.optSet(socket, Socket.APR_SO_NONBLOCK, 0);
   sendfileData.remove(new Long(socket));
   }
   }
  @@ -1138,18 +1162,18 @@
   continue;
   }
   // Write some data using sendfile
  -int nw = Socket.sendfilet(desc[n*4+1], state.fd,
  -  null, null, state.pos,
  -  (int) (state.end - 
state.pos), 0, 0);
  +int nw = Socket.sendfile(desc[n*4+1], state.fd,
  + null, null, state.pos,
  + (int) (state.end - 
state.pos), 0);
   if (nw  0) {
   // Close socket and clear pool
   remove(desc[n*4+1]);
  -// Destroy file descriptor pool, which 
should close the file
  -Pool.destroy(state.fdpool);
   // Close the socket, as the reponse would be 
incomplete
  +// This will close the file too.
   Pool.destroy(state.pool);
   continue;
   }
  +
   state.pos = state.pos + nw;
   if (state.pos = state.end) {
   remove(desc[n*4+1]);
  @@ -1163,7 +1187,6 @@
   } else if (rv  0) {
  

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-23 Thread mturk
mturk   2005/04/23 10:05:31

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Fix partial results from sendfile. Do not break the loop while the
  sendfile will not block.
  
  Revision  ChangesPath
  1.16  +18 -17
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.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AprEndpoint.java  23 Apr 2005 15:57:24 -  1.15
  +++ AprEndpoint.java  23 Apr 2005 17:05:31 -  1.16
  @@ -1063,25 +1063,26 @@
   data.pos = data.start;
   // Set the socket to nonblocking mode
   Socket.optSet(socket, Socket.APR_SO_NONBLOCK, 1);
  -int nw = Socket.sendfile(socket, data.fd, null, null,
  - data.pos, (int)data.end, 0);
  -if (nw  0) {
  -if (!Status.APR_STATUS_IS_EAGAIN(-nw)) {
  -Poll.destroy(data.pool);
  -return;
  -}
  -}
  -else {
  -data.pos = data.pos + nw;
  -if (data.pos = data.end) {
  -// Entire file has been send
  -Poll.destroy(data.pool);
  -return;
  +while (true) {
  +int nw = Socket.sendfile(socket, data.fd, null, null,
  + data.pos, (int)data.end, 0);
  +if (nw  0) {
  +if (!Status.APR_STATUS_IS_EAGAIN(-nw)) {
  +Poll.destroy(data.pool);
  +return;
  +}
  +else {
  +// Break the loop and add the socket to poller.
  +break;
  +}
   }
   else {
  -//FIXME: Ether EAGAIN of full data should be returned
  -Poll.destroy(data.pool);
  -return;
  +data.pos = data.pos + nw;
  +if (data.pos = data.end) {
  +// Entire file has been send
  +Poll.destroy(data.pool);
  +return;
  +}
   }
   }
   } catch (Error e) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-23 Thread remm
remm2005/04/23 10:36:57

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - It works great (very good performance, seems reliable seen from ab), so 
attempt to use sendfile by default.
  - So far, I haven't seen a socket going to the poller, but as I'm doing 
localhost testing, it might be normal.
  
  Revision  ChangesPath
  1.18  +1 -1  
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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- AprEndpoint.java  23 Apr 2005 17:33:40 -  1.17
  +++ AprEndpoint.java  23 Apr 2005 17:36:57 -  1.18
  @@ -284,7 +284,7 @@
   /**
* Use endfile for sending static files.
*/
  -protected boolean useSendfile = false;
  +protected boolean useSendfile = true;
   public void setUseSendfile(boolean useSendfile) { this.useSendfile = 
useSendfile; }
   public boolean getUseSendfile() { return useSendfile; }
   
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-23 Thread remm
remm2005/04/23 11:59:52

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Convert to long.
  
  Revision  ChangesPath
  1.19  +6 -7  
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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- AprEndpoint.java  23 Apr 2005 17:36:57 -  1.18
  +++ AprEndpoint.java  23 Apr 2005 18:59:52 -  1.19
  @@ -1064,14 +1064,13 @@
   // Set the socket to nonblocking mode
   Socket.optSet(socket, Socket.APR_SO_NONBLOCK, 1);
   while (true) {
  -int nw = Socket.sendfile(socket, data.fd, null, null,
  - data.pos, (int)data.end, 0);
  +long nw = Socket.sendfile(socket, data.fd, null, null,
  + data.pos, data.end, 0);
   if (nw  0) {
  -if (!Status.APR_STATUS_IS_EAGAIN(-nw)) {
  +if (!Status.APR_STATUS_IS_EAGAIN((int) -nw)) {
   Poll.destroy(data.pool);
   return false;
  -}
  -else {
  +} else {
   // Break the loop and add the socket to poller.
   break;
   }
  @@ -1165,9 +1164,9 @@
   continue;
   }
   // Write some data using sendfile
  -int nw = Socket.sendfile(desc[n*4+1], state.fd,
  +long nw = Socket.sendfile(desc[n*4+1], state.fd,
null, null, state.pos,
  - (int) (state.end - 
state.pos), 0);
  + state.end - state.pos, 
0);
   if (nw  0) {
   // Close socket and clear pool
   remove(desc[n*4+1]);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-19 Thread mturk
mturk   2005/04/19 09:36:19

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Use Poll.maintain for removing timed out sockets. Also use remove
  flag for Poll.poll to skip calling extra JNI function for common case.
  
  Revision  ChangesPath
  1.10  +65 -38
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AprEndpoint.java  18 Apr 2005 16:47:47 -  1.9
  +++ AprEndpoint.java  19 Apr 2005 16:36:19 -  1.10
  @@ -286,15 +286,15 @@
*/
   protected int keepAliveCount = 0;
   public int getKeepAliveCount() { return keepAliveCount; }
  -
  -
  +
  +
   /**
* Number of sendfile sockets.
*/
   protected int sendfileCount = 0;
   public int getSendfileCount() { return sendfileCount; }
  -
  -
  +
  +
   /**
* The socket poller.
*/
  @@ -307,8 +307,8 @@
*/
   protected Sendfile sendfile = null;
   public Sendfile getSendfile() { return sendfile; }
  -
  -
  +
  +
   /**
* Dummy maxSpareThreads property.
*/
  @@ -740,30 +740,46 @@
   try {
   serverPollset = Poll.create(pollerSize, pool, 0, soTimeout * 
1000);
   } catch (Error e) {
  -// FIXME: more appropriate logging
  -e.printStackTrace();
  +if (Status.APR_STATUS_IS_EINVAL(e.getError())) {
  +try {
  +/* Use WIN32 maximum poll size */
  +pollerSize = 62;
  +serverPollset = Poll.create(pollerSize, pool, 0, 
soTimeout * 1000);
  +} catch (Error err) {
  +// FIXME: more appropriate logging
  +err.printStackTrace();
  +}
  +} else {
  +// FIXME: more appropriate logging
  +e.printStackTrace();
  +}
   }
   desc = new long[pollerSize * 4];
  +keepAliveCount = 0;
   }
   
   protected void destroy() {
   Pool.destroy(pool);
   }
  -
  +
   public void add(long socket, long pool) {
  -int rv = Poll.add(serverPollset, socket, pool, Poll.APR_POLLIN);
  -if (rv == Status.APR_SUCCESS) {
  -keepAliveCount++;
  -} else {
  -// Can't do anything: close the socket right away
  -Pool.destroy(pool);
  +synchronized (this) {
  +int rv = Poll.add(serverPollset, socket, pool, 
Poll.APR_POLLIN);
  +if (rv == Status.APR_SUCCESS) {
  +keepAliveCount++;
  +} else {
  +// Can't do anything: close the socket right away
  +Pool.destroy(pool);
  +}
   }
   }
   
   public void remove(long socket) {
  -int rv = Poll.remove(serverPollset, socket);
  -if (rv == Status.APR_SUCCESS) {
  -keepAliveCount--;
  +synchronized (this) {
  +int rv = Poll.remove(serverPollset, socket);
  +if (rv == Status.APR_SUCCESS) {
  +keepAliveCount--;
  +}
   }
   }
   
  @@ -775,7 +791,7 @@
   
   // Loop until we receive a shutdown command
   while (running) {
  -
  +long maintainTime = 0;
   // Loop if endpoint is paused
   while (paused) {
   try {
  @@ -795,11 +811,9 @@
   
   try {
   // Pool for the specified interval
  -int rv = Poll.poll(serverPollset, pollTime, desc);
  +int rv = Poll.poll(serverPollset, pollTime, desc, true);
   if (rv  0) {
   for (int n = 0; n  rv; n++) {
  -// Remove the socket from the pollset
  -remove(desc[n*4+1]);
   // Check for failed sockets
   if (((desc[n*4]  Poll.APR_POLLHUP) == 
Poll.APR_POLLHUP)
   || ((desc[n*4]  Poll.APR_POLLERR) == 
Poll.APR_POLLERR)) {
  @@ -810,6 +824,7 @@
   // Hand this socket off to a worker
   getWorkerThread().assign(desc[n*4+1], 
desc[n*4+2]);
   }
  +maintainTime += pollTime;
 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-19 Thread remm
remm2005/04/19 09:46:12

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Add a few FIXME about polling.
  - Copy over the poller initialization code for sendfile.
  
  Revision  ChangesPath
  1.11  +18 -3 
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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- AprEndpoint.java  19 Apr 2005 16:36:19 -  1.10
  +++ AprEndpoint.java  19 Apr 2005 16:46:12 -  1.11
  @@ -742,7 +742,9 @@
   } catch (Error e) {
   if (Status.APR_STATUS_IS_EINVAL(e.getError())) {
   try {
  -/* Use WIN32 maximum poll size */
  +// Use WIN32 maximum poll size
  +// FIXME: Add WARN level logging about this, as 
scalability will
  +// be limited
   pollerSize = 62;
   serverPollset = Poll.create(pollerSize, pool, 0, 
soTimeout * 1000);
   } catch (Error err) {
  @@ -1018,8 +1020,21 @@
   try {
   sendfilePollset = Poll.create(sendfileSize, pool, 0, 
soTimeout * 1000);
   } catch (Error e) {
  -// FIXME: more appropriate logging
  -e.printStackTrace();
  +if (Status.APR_STATUS_IS_EINVAL(e.getError())) {
  +try {
  +// Use WIN32 maximum poll size
  +// FIXME: Add WARN level logging about this, as 
scalability will
  +// be limited
  +sendfileSize = 62;
  +sendfilePollset = Poll.create(sendfileSize, pool, 0, 
soTimeout * 1000);
  +} catch (Error err) {
  +// FIXME: more appropriate logging
  +err.printStackTrace();
  +}
  +} else {
  +// FIXME: more appropriate logging
  +e.printStackTrace();
  +}
   }
   desc = new long[sendfileSize * 4];
   sendfileData = new HashMap(sendfileSize);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-19 Thread mturk
mturk   2005/04/19 11:56:58

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Update keepAliveCount after poll and maintain.
  
  Revision  ChangesPath
  1.12  +2 -0  
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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AprEndpoint.java  19 Apr 2005 16:46:12 -  1.11
  +++ AprEndpoint.java  19 Apr 2005 18:56:58 -  1.12
  @@ -815,6 +815,7 @@
   // Pool for the specified interval
   int rv = Poll.poll(serverPollset, pollTime, desc, true);
   if (rv  0) {
  +keepAliveCount -= rv;
   for (int n = 0; n  rv; n++) {
   // Check for failed sockets
   if (((desc[n*4]  Poll.APR_POLLHUP) == 
Poll.APR_POLLHUP)
  @@ -842,6 +843,7 @@
   maintainTime = 0;
   }
   if (rv  0) {
  +keepAliveCount -= rv;
   for (int n = 0; n  rv; n++) {
   // Close socket and clear pool
   Pool.destroy(desc[n*4+2]);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-19 Thread remm
remm2005/04/19 17:13:25

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Sendfile fixes (does not work yet, as the poller does really weird things).
  
  Revision  ChangesPath
  1.13  +15 -17
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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- AprEndpoint.java  19 Apr 2005 18:56:58 -  1.12
  +++ AprEndpoint.java  20 Apr 2005 00:13:24 -  1.13
  @@ -988,7 +988,7 @@
   /**
* SendfileData class.
*/
  -public class SendfileData {
  +public static class SendfileData {
   // File
   public String fileName;
   public long fd;
  @@ -1015,7 +1015,6 @@
   protected long pool = 0;
   protected long[] desc;
   protected HashMap sendfileData;
  -protected SendfileData[] state;
   
   protected void init() {
   pool = Pool.create(serverSockPool);
  @@ -1040,7 +1039,6 @@
   }
   desc = new long[sendfileSize * 4];
   sendfileData = new HashMap(sendfileSize);
  -state = new SendfileData[sendfileSize];
   }
   
   protected void destroy() {
  @@ -1117,41 +1115,41 @@
   int rv = Poll.poll(sendfilePollset, pollTime, desc, 
false);
   if (rv  0) {
   for (int n = 0; n  rv; n++) {
  +// Get the sendfile state
  +SendfileData state =
  +(SendfileData) sendfileData.get(new 
Long(desc[n*4+1]));
   // Problem events
   if (((desc[n*4]  Poll.APR_POLLHUP) == 
Poll.APR_POLLHUP)
   || ((desc[n*4]  Poll.APR_POLLERR) == 
Poll.APR_POLLERR)) {
   // Close socket and clear pool
   remove(desc[n*4+1]);
   // Destroy file descriptor pool, which 
should close the file
  -Pool.destroy(state[n].fdpool);
  +Pool.destroy(state.fdpool);
   // Close the socket, as the reponse would be 
incomplete
  -Pool.destroy(state[n].pool);
  +Pool.destroy(state.pool);
   continue;
   }
  -// Get the sendfile state
  -state[n] =
  -(SendfileData) sendfileData.get(new 
Long(desc[n*4+1]));
   // Write some data using sendfile
  -int nw = Socket.sendfilet(desc[n*4+1], 
state[n].fd,
  -  null, null, 
state[n].pos,
  -  (int) (state[n].end - 
state[n].pos), 0, 0);
  +int nw = Socket.sendfilet(desc[n*4+1], state.fd,
  +  null, null, state.pos,
  +  (int) (state.end - 
state.pos), 0, 0);
   if (nw  0) {
   // Close socket and clear pool
   remove(desc[n*4+1]);
   // Destroy file descriptor pool, which 
should close the file
  -Pool.destroy(state[n].fdpool);
  +Pool.destroy(state.fdpool);
   // Close the socket, as the reponse would be 
incomplete
  -Pool.destroy(state[n].pool);
  +Pool.destroy(state.pool);
   continue;
   }
  -state[n].pos = state[n].pos + nw;
  -if (state[n].pos = state[n].end) {
  +state.pos = state.pos + nw;
  +if (state.pos = state.end) {
   remove(desc[n*4+1]);
   // Destroy file descriptor pool, which 
should close the file
  -Pool.destroy(state[n].fdpool);
  +Pool.destroy(state.fdpool);
   // If all done hand this socket off to a 
worker for
   // processing of further requests
  -

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-18 Thread mturk
mturk   2005/04/18 06:57:12

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  Fix pool usage.
  Use indexed descriptors for obtaining poll params and data.
  It spares 3 JNI calls for each polled socket.
  
  Revision  ChangesPath
  1.8   +83 -91
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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- AprEndpoint.java  15 Apr 2005 17:19:52 -  1.7
  +++ AprEndpoint.java  18 Apr 2005 13:57:12 -  1.8
  @@ -53,7 +53,7 @@
   
   protected static Log log = LogFactory.getLog(AprEndpoint.class);
   
  -protected static StringManager sm = 
  +protected static StringManager sm =
   StringManager.getManager(org.apache.tomcat.util.net.res);
   
   
  @@ -70,27 +70,27 @@
* The acceptor thread.
*/
   protected Thread acceptorThread = null;
  -
  -
  +
  +
   /**
* The socket poller.
*/
   protected Poller poller = null;
  -
  -
  +
  +
   /**
* The socket poller thread.
*/
   protected Thread pollerThread = null;
  -
  -
  +
  +
   /**
* The sendfile thread.
*/
   // FIXME: Add senfile support
   protected Thread sendfileThread = null;
  -
  -
  +
  +
   /**
* Available processors.
*/
  @@ -108,14 +108,14 @@
* Running state of the endpoint.
*/
   protected volatile boolean running = false;
  -
  -
  +
  +
   /**
* Will be set to true whenever the endpoint is paused.
*/
   protected volatile boolean paused = false;
  -
  -
  +
  +
   /**
* Track the initialization state of the endpoint.
*/
  @@ -126,14 +126,14 @@
* Current worker threads busy count.
*/
   protected int curThreadsBusy = 0;
  -
  +
   
   /**
* Current worker threads count.
*/
   protected int curThreads = 0;
  -
  -
  +
  +
   /**
* Sequence number used to generate thread names.
*/
  @@ -144,14 +144,14 @@
* Root APR memory pool.
*/
   protected long rootPool = 0;
  -
  -
  +
  +
   /**
* Server socket pointer.
*/
   protected long serverSock = 0;
  -
  -
  +
  +
   /**
* APR memory pool for the server socket.
*/
  @@ -167,8 +167,8 @@
   protected int maxThreads = 20;
   public void setMaxThreads(int maxThreads) { this.maxThreads = 
maxThreads; }
   public int getMaxThreads() { return maxThreads; }
  -
  -
  +
  +
   /**
* Priority of the acceptor and poller threads.
*/
  @@ -192,7 +192,7 @@
   public int getPort() { return port; }
   public void setPort(int port ) { this.port=port; }
   
  -
  +
   /**
* Address for the server socket.
*/
  @@ -200,7 +200,7 @@
   public InetAddress getAddress() { return address; }
   public void setAddress(InetAddress address) { this.address = address; }
   
  -
  +
   /**
* Handling of accepted sockets.
*/
  @@ -260,7 +260,7 @@
   public void setPollTime(int pollTime) { this.pollTime = pollTime; }
   
   
  -/** 
  +/**
* The default is true - the created threads will be
*  in daemon mode. If set to false, the control thread
*  will not be daemon - and will keep the process alive.
  @@ -277,15 +277,15 @@
   public void setName(String name) { this.name = name; }
   public String getName() { return name; }
   
  -
  +
   /**
* Number of keepalive sockets.
*/
   protected int keepAliveCount = 0;
   public int getKeepAliveCount() { return keepAliveCount; }
   public void setKeepAliveCount(int keepAliveCount) { this.keepAliveCount 
= keepAliveCount; }
  -
  -
  +
  +
   /**
* Dummy maxSpareThreads property.
*/
  @@ -303,9 +303,9 @@
   
   /**
* Return the APR memory pool for the server socket, to be used by 
handler
  - * which would need to allocate things like pollers, while having 
  + * which would need to allocate things like pollers, while having
* consistent resource handling.
  - * 
  + *
* @return the id for the server socket pool
*/
   public long getServerSocketPool() {
  @@ -315,7 +315,7 @@
   
   /**
* Return the amount of threads that are managed by the pool.
  - * 
  + *
* @return the amount of threads that are managed by the pool
*/
   public int getCurrentThreadCount() {
  @@ -325,17 +325,17 @@
   
   /**
* Return the amount of threads 

cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-15 Thread remm
remm2005/04/15 02:23:37

  Modified:util/java/org/apache/tomcat/util/net AprEndpoint.java
  Log:
  - Fix package name for the bundle (caused by a last minute move of the class).
  
  Revision  ChangesPath
  1.3   +1 -1  
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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AprEndpoint.java  14 Apr 2005 23:32:54 -  1.2
  +++ AprEndpoint.java  15 Apr 2005 09:23:37 -  1.3
  @@ -53,7 +53,7 @@
   protected static Log log = LogFactory.getLog(AprEndpoint.class);
   
   protected static StringManager sm = 
  -StringManager.getManager(org.apache.tomcat.util.apr.res);
  +StringManager.getManager(org.apache.tomcat.util.net.res);
   
   
   // - 
Fields
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java

2005-04-15 Thread remm
remm2005/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  ChangesPath
  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 -  1.5
  +++ AprEndpoint.java  15 Apr 2005 16:37:39 -  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
  -