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, 23 Apr 2005 17:05:31 GMT
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  Changes    Path
  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 -0000	1.15
  +++ AprEndpoint.java	23 Apr 2005 17:05:31 -0000	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: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message