rbb         99/03/15 06:26:56

  Modified:    pthreads/src/include buff.h httpd.h
               pthreads/src/main buff.c http_core.c http_protocol.c
                        util_script.c
               pthreads/src/modules/proxy proxy_cache.c proxy_ftp.c
                        proxy_http.c proxy_util.c
               pthreads/src/modules/standard mod_cgi.c mod_mime_magic.c
  Log:
  Changing the timeout logic a bit.  Moved the timeouts into recvwithtimeout
  and sendwithtimeout.  Which I implemented on UNIX platforms.  This brings
  us a bit more in line with the Win32 code.  This also removes that ugliness
  with errno in the last timing patch.
  
  Revision  Changes    Path
  1.3       +4 -3      apache-apr/pthreads/src/include/buff.h
  
  Index: buff.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/include/buff.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- buff.h    1999/02/07 06:29:21     1.2
  +++ buff.h    1999/03/15 14:26:48     1.3
  @@ -161,10 +161,10 @@
   
   /* I/O */
   API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte);
  -API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb);
  +API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb, time_t sec);
   API_EXPORT(int) ap_blookc(char *buff, BUFF *fb);
   API_EXPORT(int) ap_bskiplf(BUFF *fb);
  -API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte);
  +API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte, time_t sec);
   API_EXPORT(int) ap_bflush(BUFF *fb);
   API_EXPORT(int) ap_bputs(const char *x, BUFF *fb);
   API_EXPORT(int) ap_bvputs(BUFF *fb,...);
  @@ -222,7 +222,8 @@
                                        BUFF **pipe_err);
   
   /* enable non-blocking operations */
  -API_EXPORT(int) ap_bnonblock(BUFF *fb, int direction);
  +API_EXPORT(int) ap_bnonblock(int fd);
  +API_EXPORT(int) ap_bblock(int fd);
   /* and get an fd to select() on */
   API_EXPORT(int) ap_bfileno(BUFF *fb, int direction);
   
  
  
  
  1.11      +1 -1      apache-apr/pthreads/src/include/httpd.h
  
  Index: httpd.h
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/include/httpd.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- httpd.h   1999/03/07 00:47:44     1.10
  +++ httpd.h   1999/03/15 14:26:48     1.11
  @@ -263,7 +263,7 @@
   
   /* The timeout for waiting for keepalive timeout until next request */
   #ifndef DEFAULT_KEEPALIVE_TIMEOUT
  -#define DEFAULT_KEEPALIVE_TIMEOUT 15000
  +#define DEFAULT_KEEPALIVE_TIMEOUT 300
   #endif
   
   /* The number of requests to entertain per connection */
  
  
  
  1.4       +113 -45   apache-apr/pthreads/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/buff.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- buff.c    1999/02/24 20:30:16     1.3
  +++ buff.c    1999/03/15 14:26:49     1.4
  @@ -125,7 +125,7 @@
     select() sometimes returns 1 even though the write will block. We must 
work around this.
   */
   
  -int sendwithtimeout(int sock, const char *buf, int len, int flags)
  +int sendwithtimeout(int sock, const char *buf, int len, int flags, int sec)
   {
       int iostate = 1;
       fd_set fdset;
  @@ -184,7 +184,7 @@
   }
   
   
  -int recvwithtimeout(int sock, char *buf, int len, int flags)
  +int recvwithtimeout(int sock, char *buf, int len, int flags, int sec)
   {
       int iostate = 1;
       fd_set fdset;
  @@ -227,6 +227,78 @@
       return (rv);
   }
   
  +#else
  +
  +int sendwithtimeout(int sock, const char *buf, int len, int flags, time_t 
sec)
  +{
  +    fd_set fdset;
  +    struct timeval tv;
  +    int err = EAGAIN;
  +    int rv;
  +    
  +    tv.tv_sec = sec;
  +    if (tv.tv_sec == 0) {
  +        return (send(sock, buf, len, flags));
  +    }
  +    ap_bnonblock(sock);
  +    rv = send(sock, buf, len, flags);
  +    if (rv == -1) {
  +        err = errno;
  +     if (err == EAGAIN || errno == EINTR) {
  +         FD_ZERO(&fdset);
  +         FD_SET(sock, &fdset);
  +         tv.tv_usec = 0;
  +            do {
  +             rv = select(FD_SETSIZE, NULL, &fdset, NULL, &tv);
  +         } while (rv == -1 && errno == EINTR);
  +            if (rv == -1 || rv == 0) {
  +             err = errno;
  +         }
  +         else {
  +             rv = send(sock, buf, len, flags);
  +         }
  +     }
  +    }
  +    ap_bblock(sock);
  +    return (rv);
  +}
  +
  +int recvwithtimeout(int sock, char *buf, int len, int flags, time_t sec)
  +{
  +    fd_set fdset;
  +    struct timeval tv;
  +    int err = EAGAIN;
  +    int rv;
  +
  +    tv.tv_sec = sec;
  +    if (tv.tv_sec == 0) {
  +     return (recv(sock, buf, len, flags));
  +    }
  +    ap_bnonblock(sock);
  +    rv = recv(sock, buf, len, flags);
  +    if (rv == -1) {
  +     err = errno;
  +     if (err == EAGAIN || errno == EINTR) {
  +         FD_ZERO(&fdset);
  +         FD_SET(sock, &fdset);
  +         tv.tv_usec = 0;
  +         do {
  +                rv = select(FD_SETSIZE, &fdset, NULL, NULL, &tv);
  +         } while (rv == -1 && errno == EINTR);
  +            if (rv == -1 || rv == 0) {
  +             err = errno;
  +         }
  +         else {
  +             rv = recv(sock, buf, len, flags);
  +             if (rv == -1)
  +                 err = errno;
  +         }
  +        }
  +    }
  +    ap_bblock(sock);
  +    return (rv);
  +}
  +
   #endif /* WIN32 */
   
   
  @@ -247,13 +319,13 @@
       return rv;
   }
   
  -static ap_inline int buff_read(BUFF *fb, void *buf, int nbyte)
  +static ap_inline int buff_read(BUFF *fb, void *buf, int nbyte, time_t sec)
   {
       int rv;
   
   #if defined (WIN32)
       if (fb->flags & B_SOCKET) {
  -     rv = recvwithtimeout(fb->fd_in, buf, nbyte, 0);
  +     rv = recvwithtimeout(fb->fd_in, buf, nbyte, 0, sec);
        if (rv == SOCKET_ERROR)
            errno = WSAGetLastError();
       }
  @@ -278,7 +350,7 @@
       }
       rv = ap_read(fb, buf, nbyte);
   #else
  -    rv = ap_read(fb, buf, nbyte);
  +    rv = recvwithtimeout(fb->fd_in, buf, nbyte, 0, sec);
   #endif /* WIN32 */
       return rv;
   }
  @@ -304,20 +376,20 @@
       return rv;
   }
   
  -static ap_inline int buff_write(BUFF *fb, const void *buf, int nbyte)
  +static ap_inline int buff_write(BUFF *fb, const void *buf, int nbyte, time_t 
sec)
   {
       int rv;
   
   #if defined(WIN32)
       if (fb->flags & B_SOCKET) {
  -     rv = sendwithtimeout(fb->fd, buf, nbyte, 0);
  +     rv = sendwithtimeout(fb->fd, buf, nbyte, 0, sec);
        if (rv == SOCKET_ERROR)
            errno = WSAGetLastError();
       }
       else
        rv = ap_write(fb, buf, nbyte);
   #else
  -    rv = ap_write(fb, buf, nbyte);
  +    rv = sendwithtimeout(fb->fd, buf, nbyte, 0, sec);
   #endif /* WIN32 */
       return rv;
   }
  @@ -539,12 +611,10 @@
       return value;
   }
   
  -API_EXPORT(int) ap_bnonblock(BUFF *fb, int direction)
  +API_EXPORT(int) ap_bnonblock(int fd)
   {
  -    APRFile fd;
       int fd_flags;
   
  -    fd = (direction == B_RD) ? fb->fd_in : fb->fd;
       fd_flags = fcntl(fd, F_GETFL, 0);
   #if defined(O_NONBLOCK)
       fd_flags |= O_NONBLOCK;
  @@ -561,12 +631,10 @@
   #endif
   }
   
  -API_EXPORT(int) ap_bblock(BUFF *fb, int direction)
  +API_EXPORT(int) ap_bblock(int fd)
   {
  -    APRFile fd;
       int fd_flags;
   
  -    fd = (direction == B_RD) ? fb->fd_in : fb->fd;
       fd_flags = fcntl(fd, F_GETFL, 0);
   #if defined(O_NONBLOCK)
       fd_flags &= ~O_NONBLOCK;
  @@ -599,7 +667,7 @@
   #if !defined (B_SFIO) || defined (WIN32)
   #define saferead saferead_guts
   #else
  -static int saferead(BUFF *fb, char *buf, int nbyte)
  +static int saferead(BUFF *fb, char *buf, int nbyte, time_t sec)
   {
       return sfread(fb->sf_in, buf, nbyte);
   }
  @@ -639,7 +707,7 @@
       }
   }
   
  -static ap_inline int saferead_guts(BUFF *fb, void *buf, int nbyte)
  +static ap_inline int saferead_guts(BUFF *fb, void *buf, int nbyte, time_t 
sec)
   {
       int rv;
   
  @@ -647,7 +715,7 @@
        ap_bhalfduplex(fb);
       }
       do {
  -     rv = buff_read(fb, buf, nbyte);
  +     rv = buff_read(fb, buf, nbyte, sec);
       } while (rv == -1 && errno == EINTR && !(fb->flags & B_EOUT));
       return (rv);
   }
  @@ -658,7 +726,7 @@
       int rv;
       BUFF *fb = disc->buff;
   
  -    rv = saferead_guts(fb, buf, nbyte);
  +    rv = saferead_guts(fb, buf, nbyte, 0);
   
       buf[rv] = '\0';
       f->next = 0;
  @@ -694,11 +762,11 @@
    * and then there's the SFIO case.  Note that saferead takes care
    * of EINTR.
    */
  -static int read_with_errors(BUFF *fb, void *buf, int nbyte)
  +static int read_with_errors(BUFF *fb, void *buf, int nbyte, time_t sec)
   {
       int rv;
   
  -    rv = saferead(fb, buf, nbyte);
  +    rv = saferead(fb, buf, nbyte, sec);
       if (rv == 0) {
        fb->flags |= B_EOF;
       }
  @@ -740,7 +808,7 @@
            fb->inptr += i;
            return i;
        }
  -     i = read_with_errors(fb, buf, nbyte);
  +     i = read_with_errors(fb, buf, nbyte, 0);
   #ifdef CHARSET_EBCDIC
        if (i > 0 && ap_bgetflag(fb, B_ASCII2EBCDIC))
            ascii2ebcdic(buf, buf, i);
  @@ -779,7 +847,7 @@
   /* do a single read */
       if (nbyte >= fb->bufsiz) {
   /* read directly into caller's buffer */
  -     i = read_with_errors(fb, buf, nbyte);
  +     i = read_with_errors(fb, buf, nbyte, 0);
   #ifdef CHARSET_EBCDIC
        if (i > 0 && ap_bgetflag(fb, B_ASCII2EBCDIC))
            ascii2ebcdic(buf, buf, i);
  @@ -791,7 +859,7 @@
       else {
   /* read into hold buffer, then memcpy */
        fb->inptr = fb->inbase;
  -     i = read_with_errors(fb, fb->inptr, fb->bufsiz);
  +     i = read_with_errors(fb, fb->inptr, fb->bufsiz, 0);
        if (i == -1) {
            return nrd ? nrd : -1;
        }
  @@ -829,7 +897,7 @@
    *  CR characters in the byte stream not immediately followed by a LF
    * will be preserved.
    */
  -API_EXPORT(int) ap_bgets(char *buff, int n, BUFF *fb)
  +API_EXPORT(int) ap_bgets(char *buff, int n, BUFF *fb, time_t sec)
   {
       int i, ch, ct;
   
  @@ -850,7 +918,7 @@
            fb->incnt = 0;
            if (fb->flags & B_EOF)
                break;
  -         i = read_with_errors(fb, fb->inptr, fb->bufsiz);
  +         i = read_with_errors(fb, fb->inptr, fb->bufsiz, sec);
            if (i == -1) {
                buff[ct] = '\0';
                return ct ? ct : -1;
  @@ -931,7 +999,7 @@
        if (fb->flags & B_EOF)
            return 0;
   
  -     i = read_with_errors(fb, fb->inptr, fb->bufsiz);
  +     i = read_with_errors(fb, fb->inptr, fb->bufsiz, 0);
        if (i <= 0) {
            return i;
        }
  @@ -978,7 +1046,7 @@
        fb->incnt = 0;
        if (fb->flags & B_EOF)
            return 0;
  -     i = read_with_errors(fb, fb->inptr, fb->bufsiz);
  +     i = read_with_errors(fb, fb->inptr, fb->bufsiz, 0);
        if (i <= 0)
            return i;
        fb->incnt = i;
  @@ -994,7 +1062,7 @@
       char ss[1];
   
       ss[0] = c;
  -    return ap_bwrite(fb, ss, 1);
  +    return ap_bwrite(fb, ss, 1, 0);
   }
   
   /*
  @@ -1024,7 +1092,7 @@
    *
    * Deals with calling doerror and setting bytes_sent.
    */
  -static int write_it_all(BUFF *fb, const void *buf, int nbyte)
  +static int write_it_all(BUFF *fb, const void *buf, int nbyte, time_t sec)
   {
       int i;
   
  @@ -1032,7 +1100,7 @@
        return -1;
   
       while (nbyte > 0) {
  -     i = buff_write(fb, buf, nbyte);
  +     i = buff_write(fb, buf, nbyte, sec);
        if (i < 0) {
            if (errno != EAGAIN && errno != EINTR) {
                doerror(fb, B_WR);
  @@ -1100,12 +1168,12 @@
   /* A wrapper for buff_write which deals with error conditions and
    * bytes_sent.  Also handles non-blocking writes.
    */
  -static int write_with_errors(BUFF *fb, const void *buf, int nbyte)
  +static int write_with_errors(BUFF *fb, const void *buf, int nbyte, time_t 
sec)
   {
       int rv;
   
       do
  -     rv = buff_write(fb, buf, nbyte);
  +     rv = buff_write(fb, buf, nbyte, sec);
       while (rv == -1 && errno == EINTR && !(fb->flags & B_EOUT));
       if (rv == -1) {
        if (errno != EAGAIN) {
  @@ -1131,7 +1199,7 @@
    * Can be used on non-blocking descriptors, but only if they're not chunked.
    * Deals with doerror() and bytes_sent.
    */
  -static int bcwrite(BUFF *fb, const void *buf, int nbyte)
  +static int bcwrite(BUFF *fb, const void *buf, int nbyte, time_t sec)
   {
       char chunksize[16];              /* Big enough for practically anything 
*/
   #ifndef NO_WRITEV
  @@ -1142,7 +1210,7 @@
        return -1;
   
       if (!(fb->flags & B_CHUNK)) {
  -     return write_with_errors(fb, buf, nbyte);
  +     return write_with_errors(fb, buf, nbyte, sec);
       }
   
   #ifdef NO_WRITEV
  @@ -1153,11 +1221,11 @@
       /* Chunks are an HTTP/1.1 Protocol feature. They must ALWAYS be in ASCII 
*/
       ebcdic2ascii(chunksize, chunksize, strlen(chunksize));
   #endif /*CHARSET_EBCDIC*/
  -    if (write_it_all(fb, chunksize, strlen(chunksize)) == -1)
  +    if (write_it_all(fb, chunksize, strlen(chunksize), 0) == -1)
        return -1;
  -    if (write_it_all(fb, buf, nbyte) == -1)
  +    if (write_it_all(fb, buf, nbyte, 0) == -1)
        return -1;
  -    if (write_it_all(fb, "\015\012", 2) == -1)
  +    if (write_it_all(fb, "\015\012", 2, 0) == -1)
        return -1;
       return nbyte;
   #else
  @@ -1240,7 +1308,7 @@
    * It is worth noting that if an error occurs, the buffer is in an unknown
    * state.
    */
  -API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte)
  +API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte, time_t sec)
   {
       int i, nwr, useable_bufsiz;
   #ifdef CHARSET_EBCDIC
  @@ -1270,7 +1338,7 @@
       if (!(fb->flags & B_WR)) {
   /* unbuffered write -- have to use bcwrite since we aren't taking care
    * of chunking any other way */
  -     return bcwrite(fb, buf, nbyte);
  +     return bcwrite(fb, buf, nbyte, sec);
       }
   
   #ifndef NO_WRITEV
  @@ -1313,14 +1381,14 @@
            /* it is just too painful to try to re-cram the buffer while
             * chunking
             */
  -         if (write_it_all(fb, fb->outbase, fb->outcnt) == -1) {
  +         if (write_it_all(fb, fb->outbase, fb->outcnt, 0) == -1) {
                /* we cannot continue after a chunked error */
                return -1;
            }
            fb->outcnt = 0;
            break;
        }
  -     i = write_with_errors(fb, fb->outbase, fb->outcnt);
  +     i = write_with_errors(fb, fb->outbase, fb->outcnt, 0);
        if (i <= 0) {
            return nwr ? nwr : -1;
        }
  @@ -1354,7 +1422,7 @@
       useable_bufsiz = fb->bufsiz;
       if (fb->flags & B_CHUNK) useable_bufsiz -= CHUNK_HEADER_SIZE;
       while (nbyte >= useable_bufsiz) {
  -     i = bcwrite(fb, buf, nbyte);
  +     i = bcwrite(fb, buf, nbyte, 0);
        if (i <= 0) {
            return nwr ? nwr : -1;
        }
  @@ -1383,7 +1451,7 @@
       int i;
   
       while (fb->outcnt > 0) {
  -     i = write_with_errors(fb, fb->outbase, fb->outcnt);
  +     i = write_with_errors(fb, fb->outbase, fb->outcnt, 0);
        if (i <= 0)
            return -1;
   
  @@ -1500,7 +1568,7 @@
   API_EXPORT(int) ap_bputs(const char *x, BUFF *fb)
   {
       int i, j = strlen(x);
  -    i = ap_bwrite(fb, x, j);
  +    i = ap_bwrite(fb, x, j, 0);
       if (i != j)
        return -1;
       else
  @@ -1522,7 +1590,7 @@
        if (x == NULL)
            break;
        j = strlen(x);
  -     i = ap_bwrite(fb, x, j);
  +     i = ap_bwrite(fb, x, j, 0);
        if (i != j) {
            va_end(v);
            return -1;
  
  
  
  1.9       +2 -2      apache-apr/pthreads/src/main/http_core.c
  
  Index: http_core.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_core.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- http_core.c       1999/02/24 20:30:17     1.8
  +++ http_core.c       1999/03/15 14:26:49     1.9
  @@ -1965,7 +1965,7 @@
           return err;
       }
   
  -    cmd->server->timeout = atoi(arg) * 1000;
  +    cmd->server->timeout = atoi(arg);
       return NULL;
   }
   
  @@ -1977,7 +1977,7 @@
           return err;
       }
   
  -    cmd->server->keep_alive_timeout = atoi(arg) * 1000;
  +    cmd->server->keep_alive_timeout = atoi(arg);
       return NULL;
   }
   
  
  
  
  1.9       +15 -49    apache-apr/pthreads/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/http_protocol.c,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- http_protocol.c   1999/03/04 00:06:58     1.8
  +++ http_protocol.c   1999/03/15 14:26:50     1.9
  @@ -651,7 +651,7 @@
    *       then the actual input line exceeded the buffer length,
    *       and it would be a good idea for the caller to puke 400 or 414.
    */
  -static int getline(char *s, int n, BUFF *in, int fold)
  +static int getline(char *s, int n, BUFF *in, int fold, time_t sec)
   {
       char *pos, next;
       int retval;
  @@ -660,7 +660,8 @@
       pos = s;
   
       do {
  -        retval = ap_bgets(pos, n, in);     /* retval == -1 if error, 0 if 
EOF */
  +        retval = ap_bgets(pos, n, in, sec);
  +       /* retval == -1 if error, 0 if EOF */
   
           if (retval <= 0)
               return ((retval < 0) && (total == 0)) ? -1 : total;
  @@ -780,7 +781,7 @@
        * have to block during a read.
        */
       ap_bsetflag(conn->client, B_SAFEREAD, 1);
  -    while ((len = getline(l, sizeof(l), conn->client, 0)) <= 0) {
  +    while ((len = getline(l, sizeof(l), conn->client, 0, ap_get_timeout(r))) 
<= 0) {
           if ((len < 0) || ap_bgetflag(conn->client, B_EOF)) {
               ap_bsetflag(conn->client, B_SAFEREAD, 0);
               return 0;
  @@ -853,7 +854,7 @@
        * Read header lines until we get the empty separator line, a read error,
        * the connection closes (EOF), reach the server limit, or we timeout.
        */
  -    while ((len = getline(field, sizeof(field), c->client, 1)) > 0) {
  +    while ((len = getline(field, sizeof(field), c->client, 1, 0)) > 0) {
   
           if (r->server->limit_req_fields &&
               (++fields_read > r->server->limit_req_fields)) {
  @@ -902,10 +903,8 @@
       pool *p;
       const char *expect;
       int access_status;
  -    struct pollfd *filedes;
  -    int timeout, rv;
  +    int rv;
   
  -    filedes = (struct pollfd *)malloc(sizeof(struct pollfd));
       p = ap_make_sub_pool(conn->pool);
       r = ap_pcalloc(p, sizeof(request_rec));
       r->pool            = p;
  @@ -941,38 +940,8 @@
   #endif
   
       /* Get the request... */
  -    ap_bnonblock(r->connection->client, B_RD);
  -    errno = 0;
  -    while (!read_request_line(r)) {
  -        if (errno == EAGAIN) {
  -            errno = 0;
  -            filedes->fd = ap_bfileno(r->connection->client, B_RD);
  -            filedes->events = POLLIN; 
  -            filedes->revents = 0; 
  -            timeout = ap_get_timeout(r);
  -            if ((rv = poll(filedes, 1, timeout)) == 0) {
  -                ap_bclose(r->connection->client);
  -            }
  -            else if (rv == -1) { 
  -                ap_bclose(r->connection->client);
  -                ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
  -                         "Timeout hasn't occured, but something is wrong, "
  -                         "closing the connection.");
  -            }
  -            else {    
  -                if (filedes->revents &= POLLIN) {
  -                    continue;
  -                }
  -                else {
  -                ap_bclose(r->connection->client);
  -                ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
  -                              "Event other than POLLIN, closing 
connection.");
  -                }
  -            
  -            }
  -        }
  +    if (!read_request_line(r)) {
           if (r->status == HTTP_REQUEST_URI_TOO_LARGE) {
  -
               ap_log_rerror(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, r,
                            "request failed: URI too long");
               ap_send_error_response(r, 0);
  @@ -980,11 +949,8 @@
               ap_log_transaction(r);
               return r;
           }
  -        free(filedes);
           return NULL;
       }
  -    free(filedes);
  -    ap_bblock(r->connection->client, B_RD);
       if (!r->assbackwards) {
           get_mime_headers(r);
           if (r->status != HTTP_REQUEST_TIME_OUT) {
  @@ -1758,7 +1724,7 @@
   
       if (r->remaining == 0) {    /* Start of new chunk */
   
  -        chunk_start = getline(buffer, bufsiz, r->connection->client, 0);
  +        chunk_start = getline(buffer, bufsiz, r->connection->client, 0, 0);
           if ((chunk_start <= 0) || (chunk_start >= (bufsiz - 1))
               || !isxdigit(*buffer)) {
               r->connection->keepalive = -1;
  @@ -1799,7 +1765,7 @@
           len_read = chunk_start;
   
           while ((bufsiz > 1) && ((len_read =
  -                  getline(buffer, bufsiz, r->connection->client, 1)) > 0)) {
  +                  getline(buffer, bufsiz, r->connection->client, 1, 0)) > 
0)) {
   
               if (len_read != (bufsiz - 1)) {
                   buffer[len_read++] = CR;        /* Restore footer line end  
*/
  @@ -1927,7 +1893,7 @@
           o = 0;
   
           while (n && !ap_is_aborted(r->connection)) {
  -            w = ap_bwrite(r->connection->client, &buf[o], n);
  +            w = ap_bwrite(r->connection->client, &buf[o], n, 0);
               if (w > 0) {
                total_bytes_sent += w;
                   n -= w;
  @@ -1976,8 +1942,8 @@
   
       /* Make fb unbuffered and non-blocking */
       ap_bsetflag(fb, B_RD, 0);
  -    ap_bnonblock(fb, B_RD);
       fd = ap_bfileno(fb, B_RD);
  +    ap_bnonblock(fd);
   #ifndef WIN32
       if (fd >= FD_SETSIZE) {
        ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING, NULL,
  @@ -2042,7 +2008,7 @@
           total_bytes_sent += n;
   
           while (n && !ap_is_aborted(r->connection)) {
  -            w = ap_bwrite(r->connection->client, &buf[o], n);
  +            w = ap_bwrite(r->connection->client, &buf[o], n, 0);
               if (w > 0) {
                   n -= w;
                   o += w;
  @@ -2105,7 +2071,7 @@
           }
   
           while (n && !r->connection->aborted) {
  -            w = ap_bwrite(r->connection->client, (char *) mm + offset, n);
  +            w = ap_bwrite(r->connection->client, (char *) mm + offset, n, 0);
               if (w > 0) {
                   total_bytes_sent += w;
                   n -= w;
  @@ -2156,7 +2122,7 @@
       int n;
       if (r->connection->aborted)
           return EOF;
  -    n = ap_bwrite(r->connection->client, buf, nbyte);
  +    n = ap_bwrite(r->connection->client, buf, nbyte, 0);
       SET_BYTES_SENT(r);
       return n;
   }
  @@ -2191,7 +2157,7 @@
           if (x == NULL)
               break;
           j = strlen(x);
  -        i = ap_bwrite(fb, x, j);
  +        i = ap_bwrite(fb, x, j, 0);
           if (i != j) {
               va_end(args);
               return -1;
  
  
  
  1.3       +1 -1      apache-apr/pthreads/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/main/util_script.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- util_script.c     1999/02/07 06:29:32     1.2
  +++ util_script.c     1999/03/15 14:26:50     1.3
  @@ -609,7 +609,7 @@
   
   static int getsfunc_BUFF(char *w, int len, void *fb)
   {
  -    return ap_bgets(w, len, (BUFF *) fb) > 0;
  +    return ap_bgets(w, len, (BUFF *) fb, 0) > 0;
   }
   
   API_EXPORT(int) ap_scan_script_header_err_buff(request_rec *r, BUFF *fb,
  
  
  
  1.4       +3 -3      apache-apr/pthreads/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- proxy_cache.c     1999/02/07 06:29:47     1.3
  +++ proxy_cache.c     1999/03/15 14:26:52     1.4
  @@ -548,7 +548,7 @@
    * date SP lastmod SP expire SP count SP content-length CRLF
    * dates are stored as hex seconds since 1970
    */
  -    len = ap_bgets(urlbuff, sizeof urlbuff, cachefp);
  +    len = ap_bgets(urlbuff, sizeof urlbuff, cachefp, 0);
       if (len == -1)
        return -1;
       if (len == 0 || urlbuff[len - 1] != '\n')
  @@ -566,7 +566,7 @@
       c->len = ap_proxy_hex2sec(urlbuff + 36);
   
   /* check that we have the same URL */
  -    len = ap_bgets(urlbuff, sizeof urlbuff, cachefp);
  +    len = ap_bgets(urlbuff, sizeof urlbuff, cachefp, 0);
       if (len == -1)
        return -1;
       if (len == 0 || strncmp(urlbuff, "X-URL: ", 7) != 0 ||
  @@ -577,7 +577,7 @@
        return 0;
   
   /* What follows is the message */
  -    len = ap_bgets(urlbuff, sizeof urlbuff, cachefp);
  +    len = ap_bgets(urlbuff, sizeof urlbuff, cachefp, 0);
       if (len == -1)
        return -1;
       if (len == 0 || urlbuff[len - 1] != '\n')
  
  
  
  1.3       +8 -8      apache-apr/pthreads/src/modules/proxy/proxy_ftp.c
  
  Index: proxy_ftp.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/proxy/proxy_ftp.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- proxy_ftp.c       1999/02/07 06:29:48     1.2
  +++ proxy_ftp.c       1999/03/15 14:26:52     1.3
  @@ -193,7 +193,7 @@
       int len, status;
       char linebuff[100], buff[5];
   
  -    len = ap_bgets(linebuff, sizeof linebuff, f);
  +    len = ap_bgets(linebuff, sizeof linebuff, f, 0);
       if (len == -1)
        return -1;
   /* check format */
  @@ -212,7 +212,7 @@
        memcpy(buff, linebuff, 3);
        buff[3] = ' ';
        do {
  -         len = ap_bgets(linebuff, sizeof linebuff, f);
  +         len = ap_bgets(linebuff, sizeof linebuff, f, 0);
            if (len == -1)
                return -1;
            if (linebuff[len - 1] != '\n') {
  @@ -235,7 +235,7 @@
       char *mb = msgbuf,
         *me = &msgbuf[msglen];
   
  -    len = ap_bgets(linebuff, sizeof linebuff, f);
  +    len = ap_bgets(linebuff, sizeof linebuff, f, 0);
       if (len == -1)
        return -1;
       if (len < 5 || !ap_isdigit(linebuff[0]) || !ap_isdigit(linebuff[1]) ||
  @@ -253,7 +253,7 @@
        memcpy(buff, linebuff, 3);
        buff[3] = ' ';
        do {
  -         len = ap_bgets(linebuff, sizeof linebuff, f);
  +         len = ap_bgets(linebuff, sizeof linebuff, f, 0);
            if (len == -1)
                return -1;
            if (linebuff[len - 1] != '\n') {
  @@ -320,7 +320,7 @@
       total_bytes_sent += ap_proxy_bputs2(buf, con->client, c);
   
       while (!con->aborted) {
  -     n = ap_bgets(buf, sizeof buf, f);
  +     n = ap_bgets(buf, sizeof buf, f, 0);
        if (n == -1) {          /* input error */
            if (c != NULL)
                c = ap_proxy_cache_error(c);
  @@ -382,11 +382,11 @@
        o = 0;
        total_bytes_sent += n;
   
  -     if (c != NULL && c->fp && ap_bwrite(c->fp, buf, n) != n)
  +     if (c != NULL && c->fp && ap_bwrite(c->fp, buf, n, 0) != n)
            c = ap_proxy_cache_error(c);
   
        while (n && !r->connection->aborted) {
  -         w = ap_bwrite(con->client, &buf[o], n);
  +         w = ap_bwrite(con->client, &buf[o], n, 0);
            if (w <= 0)
                break;
            n -= w;
  @@ -802,7 +802,7 @@
       /* 501 Syntax error in parameters or arguments. */
       /* 502 Command not implemented. */
       /* 530 Not logged in. */
  -    i = ap_bgets(pasv, sizeof(pasv), f);
  +    i = ap_bgets(pasv, sizeof(pasv), f, 0);
       if (i == -1) {
        ap_log_rerror(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, r,
                     "PASV: control connection is toast");
  
  
  
  1.3       +4 -4      apache-apr/pthreads/src/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/proxy/proxy_http.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- proxy_http.c      1999/02/07 06:29:48     1.2
  +++ proxy_http.c      1999/03/15 14:26:52     1.3
  @@ -354,11 +354,11 @@
   
       if (ap_should_client_block(r)) {
        while ((i = ap_get_client_block(r, buffer, sizeof buffer)) > 0)
  -         ap_bwrite(f, buffer, i);
  +         ap_bwrite(f, buffer, i, 0);
       }
       ap_bflush(f);
   
  -    len = ap_bgets(buffer, sizeof buffer - 1, f);
  +    len = ap_bgets(buffer, sizeof buffer - 1, f, 0);
       if (len == -1 || len == 0) {
        ap_bclose(f);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
  @@ -486,8 +486,8 @@
       r->sent_bodyct = 1;
   /* Is it an HTTP/0.9 respose? If so, send the extra data */
       if (backasswards) {
  -     ap_bwrite(r->connection->client, buffer, len);
  -     if (c != NULL && c->fp != NULL && ap_bwrite(c->fp, buffer, len) != len)
  +     ap_bwrite(r->connection->client, buffer, len, 0);
  +     if (c != NULL && c->fp != NULL && ap_bwrite(c->fp, buffer, len, 0) != 
len)
            c = ap_proxy_cache_error(c);
       }
   
  
  
  
  1.3       +3 -3      apache-apr/pthreads/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- proxy_util.c      1999/02/07 06:29:48     1.2
  +++ proxy_util.c      1999/03/15 14:26:52     1.3
  @@ -390,7 +390,7 @@
       pos = s;
   
       do {
  -        retval = ap_bgets(pos, n, in);     /* retval == -1 if error, 0 if 
EOF */
  +        retval = ap_bgets(pos, n, in, 0);     /* retval == -1 if error, 0 if 
EOF */
   
           if (retval <= 0)
               return ((retval < 0) && (total == 0)) ? -1 : total;
  @@ -551,7 +551,7 @@
   
        /* Write to cache first. */
           if (c != NULL && c->fp != NULL) {
  -            if (ap_bwrite(c->fp, &buf[0], n) != n) {
  +            if (ap_bwrite(c->fp, &buf[0], n, 0) != n) {
                   c = ap_proxy_cache_error(c);
               } else {
                   c->written += n;
  @@ -560,7 +560,7 @@
   
        /* Write the block to the client, detect aborted transfers */
           while (n && !con->aborted) {
  -            w = ap_bwrite(con->client, &buf[o], n);
  +            w = ap_bwrite(con->client, &buf[o], n, 0);
   
               if (w <= 0) {
                   if (c != NULL && c->fp != NULL) {
  
  
  
  1.3       +10 -10    apache-apr/pthreads/src/modules/standard/mod_cgi.c
  
  Index: mod_cgi.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/standard/mod_cgi.c,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- mod_cgi.c 1999/02/07 06:29:52     1.2
  +++ mod_cgi.c 1999/03/15 14:26:54     1.3
  @@ -208,9 +208,9 @@
            ((f = ap_pfopen(r->pool, ap_server_root_relative(r->pool, 
conf->logname),
                      "a")) == NULL)) {
        /* Soak up script output */
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, 0) > 0)
            continue;
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, 0) > 0)
            continue;
        return ret;
       }
  @@ -245,18 +245,18 @@
       if (sbuf && *sbuf)
        fprintf(f, "%s\n", sbuf);
   
  -    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
  +    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, 0) > 0) {
        fputs("%stdout\n", f);
        fputs(argsbuffer, f);
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, 0) > 0)
            fputs(argsbuffer, f);
        fputs("\n", f);
       }
   
  -    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
  +    if (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, 0) > 0) {
        fputs("%stderr\n", f);
        fputs(argsbuffer, f);
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0)
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, 0) > 0)
            fputs(argsbuffer, f);
        fputs("\n", f);
       }
  @@ -473,7 +473,7 @@
                memcpy(dbuf + dbpos, argsbuffer, dbsize);
                dbpos += dbsize;
            }
  -         if (ap_bwrite(script_out, argsbuffer, len_read) < len_read) {
  +         if (ap_bwrite(script_out, argsbuffer, len_read, 0) < len_read) {
                /* silly script stopped reading, soak up remaining message */
                while (ap_get_client_block(r, argsbuffer, HUGE_STRING_LEN) > 0) 
{
                    /* dump it */
  @@ -509,10 +509,10 @@
        if (location && location[0] == '/' && r->status == 200) {
   
            /* Soak up all the script output */
  -         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in) > 0) {
  +         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_in, 0) > 0) {
                continue;
            }
  -         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
  +         while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, 0) > 0) {
                continue;
            }
            /* This redirect needs to be a GET no matter what the original
  @@ -543,7 +543,7 @@
        }
        ap_bclose(script_in);
   
  -     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err) > 0) {
  +     while (ap_bgets(argsbuffer, HUGE_STRING_LEN, script_err, 0) > 0) {
            continue;
        }
        ap_bclose(script_err);
  
  
  
  1.6       +1 -1      apache-apr/pthreads/src/modules/standard/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: 
/home/cvs/apache-apr/pthreads/src/modules/standard/mod_mime_magic.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- mod_mime_magic.c  1999/02/07 06:29:54     1.5
  +++ mod_mime_magic.c  1999/03/15 14:26:55     1.6
  @@ -2178,7 +2178,7 @@
        return -1;
       }
   
  -    if (ap_bwrite(bin, old, n) != n) {
  +    if (ap_bwrite(bin, old, n, 0) != n) {
        ap_destroy_pool(sub_pool);
        ap_log_rerror(APLOG_MARK, APLOG_ERR, r,
                    MODNAME ": write failed.");
  
  
  

Reply via email to