You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by st...@locus.apache.org on 2000/02/18 03:53:12 UTC

cvs commit: apache-2.0/src/modules/standard mod_rewrite.c

stoddard    00/02/17 18:53:12

  Modified:    src/lib/apr/file_io/win32 fileio.h readwrite.c
               src/lib/apr/include apr_file_io.h
               src/main iol_file.c
               src/modules/standard mod_rewrite.c
  Log:
  Have seperate variable on ap_writev to set the number of iovecs passed in
  and pass back the number of bytes written. Use ap_iovec_t on the call rather
  than struct iovec (I may reverse this tomorrow :-). Whatever we do, the network_io
  and file_io calls need to use iovecs consistently, which isn't the case now.
  
  Revision  Changes    Path
  1.6       +1 -1      apache-2.0/src/lib/apr/file_io/win32/fileio.h
  
  Index: fileio.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/fileio.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- fileio.h	2000/01/11 23:21:29	1.5
  +++ fileio.h	2000/02/18 02:53:11	1.6
  @@ -122,7 +122,7 @@
   
   struct iovec_t {
       ap_context_t *cntxt;
  -    struct iovec *iov;
  +    struct iovec *theiov;
   };
   
   ap_status_t file_cleanup(void *);
  
  
  
  1.11      +7 -6      apache-2.0/src/lib/apr/file_io/win32/readwrite.c
  
  Index: readwrite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/file_io/win32/readwrite.c,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- readwrite.c	2000/02/01 00:40:40	1.10
  +++ readwrite.c	2000/02/18 02:53:11	1.11
  @@ -117,19 +117,20 @@
   /*
    * Too bad WriteFileGather() is not supported on 95&98 (or NT prior to SP2) 
    */
  -ap_status_t ap_writev(struct file_t *thefile, const struct iovec_t *vec, ap_ssize_t *iocnt)
  +ap_status_t ap_writev(struct file_t *thefile, const ap_iovec_t *vec, ap_size_t nvec, 
  +                      ap_ssize_t *nbytes)
   {
       int i;
       DWORD bwrote = 0;
  -    int numvec = *iocnt;
  -    *iocnt = 0;
  +    struct iovec *iov = vec->theiov;
   
  -    for (i = 0; i < numvec; i++) {
  +    *nbytes = 0;
  +    for (i = 0; i < nvec; i++) {
           if (!WriteFile(thefile->filehand,
  -                       vec->iov[i].iov_base, vec->iov[i].iov_len, &bwrote, NULL)) {
  +                       iov[i].iov_base, iov[i].iov_len, &bwrote, NULL)) {
               return GetLastError();
           }
  -        *iocnt += bwrote;
  +        *nbytes += bwrote;
       }
       return APR_SUCCESS;
   }
  
  
  
  1.29      +1 -1      apache-2.0/src/lib/apr/include/apr_file_io.h
  
  Index: apr_file_io.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_file_io.h,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- apr_file_io.h	2000/01/10 15:35:48	1.28
  +++ apr_file_io.h	2000/02/18 02:53:11	1.29
  @@ -136,7 +136,7 @@
   
   ap_status_t ap_read(ap_file_t *, void *, ap_ssize_t *);
   ap_status_t ap_write(ap_file_t *, void *, ap_ssize_t *);
  -ap_status_t ap_writev(ap_file_t *, const ap_iovec_t *, ap_ssize_t *);
  +ap_status_t ap_writev(ap_file_t *, const ap_iovec_t *vec, ap_size_t nvec, ap_ssize_t *nbytes);
   ap_status_t ap_putc(char, ap_file_t *);
   ap_status_t ap_getc(char *, ap_file_t *);
   ap_status_t ap_ungetc(char, ap_file_t *);
  
  
  
  1.8       +15 -85    apache-2.0/src/main/iol_file.c
  
  Index: iol_file.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/iol_file.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- iol_file.c	2000/01/28 18:01:26	1.7
  +++ iol_file.c	2000/02/18 02:53:12	1.8
  @@ -60,92 +60,9 @@
   #include "ap_iol.h"
   #include <malloc.h>
   
  -#if 0
  -/* This is the non-APRed iol_file */
  -#include <sys/uio.h>
   
   typedef struct {
       ap_iol iol;
  -    int fd;
  -} iol_file;
  -
  -#define method(syscall, args)	\
  -    static ap_status_t file_##syscall args \
  -    { \
  -	iol_file *iol = (iol_file *)viol; \
  -	int rv; \
  -	/* try writing, ignoring EINTR, the upper layer has to handle \
  -	    partial read/writes anyhow, so we can return early */ \
  -	do { \
  -	    rv = syscall(iol->fd, arg1, arg2); \
  -	} while (rv == -1 && errno == EINTR); \
  -        if (rv >= 0) { \
  -            *nbytes = rv;
  -            return APR_SUCCESS; \
  -        } \
  -        *nbytes = 0;
  -	return errno; \
  -    }
  -
  -method(write, (ap_iol *viol, const char *arg1, ap_size_t arg2,
  -               ap_ssize_t *nbytes))
  -method(writev, (ap_iol *viol, const struct iovec *arg1, int arg2, ap_ssize_t *nbytes))
  -method(read, (ap_iol *viol, char *arg1, ap_size_t arg2, ap_ssize_t *nbytes))
  -
  -
  -static ap_status_t file_close(ap_iol *viol)
  -{
  -    iol_file *iol = (iol_file *)viol;
  -    int rv;
  -    int saved_errno;
  -
  -    rv = close(iol->fd);
  -    saved_errno = errno;
  -    free(iol);
  -    if (rv == 0) {
  -        return APR_SUCCESS;
  -    }
  -    return saved_errno;
  -}
  -
  -static ap_status_t file_setopt(ap_iol *viol, ap_iol_option opt,
  -                               const void *value)
  -{
  -    return APR_EINVAL;
  -}
  -
  -static ap_status_t file_getopt(ap_iol *viol, ap_iol_option opt, void *value)
  -{
  -    return APR_EINVAL;
  -}
  -
  -static const ap_iol_methods file_methods = {
  -    file_close,
  -    file_write,
  -    file_writev,
  -    file_read,
  -    file_setopt,
  -    file_getopt
  -};
  -
  -ap_iol *ap_open_file(const char *name, int flags, int mask)
  -{
  -    int rv;
  -    iol_file *iol;
  -
  -    rv = open(name, flags, mask);
  -    if (rv < 0) {
  -	return NULL;
  -    }
  -    iol = malloc(sizeof(iol_file));
  -    iol->iol.methods = &file_methods;
  -    iol->fd = rv;
  -    return (ap_iol *)iol;
  -}
  -#else
  -
  -typedef struct {
  -    ap_iol iol;
       ap_file_t *file;
   } iol_file;
   
  @@ -167,9 +84,22 @@
       }
   
   method(ap_write, (ap_iol *viol, const char *arg1, ap_size_t arg2, ap_ssize_t *nbytes))
  -method(ap_writev, (ap_iol *viol, const struct iovec *arg1, int arg2, ap_ssize_t *nbytes))
   method(ap_read, (ap_iol *viol, char *arg1, ap_size_t arg2, ap_ssize_t *nbytes))
   
  +static ap_status_t file_ap_writev(ap_iol *viol, const ap_iovec_t *vec, ap_size_t nvec, 
  +                                  ap_ssize_t *nbytes) 
  +{
  +    ap_status_t rv;
  +    iol_file *iol = (iol_file *) viol;
  +    do {
  +        rv = ap_writev(iol->file, vec, nvec, nbytes);
  +    } while (rv == APR_EINTR);
  +    if (rv != APR_SUCCESS) {
  +        *nbytes = 0;
  +    }
  +    return rv;
  +}
  +
   
   /* This function will clean-up the iol struct and close the file... */
   static ap_status_t file_close(ap_iol *viol)
  @@ -213,4 +143,4 @@
       iol->file = file;
       return (ap_iol *)iol;
   }
  -#endif
  +
  
  
  
  1.13      +13 -10    apache-2.0/src/modules/standard/mod_rewrite.c
  
  Index: mod_rewrite.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_rewrite.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- mod_rewrite.c	2000/01/19 02:42:14	1.12
  +++ mod_rewrite.c	2000/02/18 02:53:12	1.13
  @@ -2960,10 +2960,12 @@
       char buf[LONG_STRING_LEN];
       char c;
       int i;
  -    int size_val;
  +    ap_size_t nbytes;
  +
   #ifndef NO_WRITEV
       ap_iovec_t *iov;
       struct iovec iova[2];
  +    ap_size_t niov;
   #endif
   
       /* when `RewriteEngine off' was used in the per-server
  @@ -2989,21 +2991,21 @@
       iova[1].iov_len = 1;
   
       ap_make_iov(&iov, iova, r->pool);
  -    size_val = 2;
  -    ap_writev(fpin, iov, &size_val);
  +    niov = 2;
  +    ap_writev(fpin, iov, niov, &nbytes);
   #endif
   
       /* read in the response value */
       i = 0;
  -    size_val = 1;
  -    ap_read(fpout, &c, &size_val);
  -    while (size_val == 1 && (i < LONG_STRING_LEN-1)) {
  +    nbytes = 1;
  +    ap_read(fpout, &c, &nbytes);
  +    while (nbytes == 1 && (i < LONG_STRING_LEN-1)) {
           if (c == '\n') {
               break;
           }
           buf[i++] = c;
   
  -        ap_read(fpout, &c, &size_val);
  +        ap_read(fpout, &c, &nbytes);
       }
       buf[i] = '\0';
   
  @@ -3189,7 +3191,8 @@
       char type[20];
       char redir[20];
       va_list ap;
  -    int i, size_val;
  +    int i;
  +    ap_size_t nbytes;
       request_rec *req;
       char *ruser;
       const char *rhost;
  @@ -3258,8 +3261,8 @@
                   type, redir, level, str2);
   
       fd_lock(r, conf->rewritelogfp);
  -    size_val = strlen(str3);
  -    ap_write(conf->rewritelogfp, str3, &size_val);
  +    nbytes = strlen(str3);
  +    ap_write(conf->rewritelogfp, str3, &nbytes);
       fd_unlock(r, conf->rewritelogfp);
   
       va_end(ap);