tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/util/java/org/apache/tomcat/util/net AprEndpoint.java
Date Sat, 02 Jul 2005 17:18:46 GMT
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  Changes    Path
  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 -0000	1.17
  +++ Http11AprProcessor.java	2 Jul 2005 17:18:46 -0000	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 -0000	1.53
  +++ AprEndpoint.java	2 Jul 2005 17:18:46 -0000	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) {
  +                                	// Destroy file descriptor pool, which should close the
file
  +                                	Pool.destroy(state.fdpool);
  +                                	Socket.timeoutSet(state.socket, soTimeout * 1000);
  +                                	// If all done hand this socket off to a worker for
  +                                	// processing of further requests
  +                                	getWorkerThread().assign(state.socket);
  +                                }
  +                                else {
  +                                	// Close the socket since this is
  +                                	// the end of not keep-alive request.
  +                                	Socket.destroy(state.socket);	
  +                                }
                               }
                           }
                       } else if (rv < 0) {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message