httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@hyperreal.org
Subject cvs commit: apache-2.0/src/main buff.c
Date Mon, 25 Oct 1999 22:04:08 GMT
manoj       99/10/25 15:04:08

  Modified:    src/main buff.c
  Log:
  large_write now doesn't use errno internally, but exports an errnoish
  interface.
  
  Revision  Changes    Path
  1.13      +34 -24    apache-2.0/src/main/buff.c
  
  Index: buff.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/buff.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -d -u -r1.12 -r1.13
  --- buff.c	1999/10/25 21:12:34	1.12
  +++ buff.c	1999/10/25 22:04:05	1.13
  @@ -563,39 +563,44 @@
   }
   
   
  -static int writev_it_all(BUFF *fb, struct iovec *vec, int nvec)
  +static ap_status_t writev_it_all(BUFF *fb, struct iovec *vec, int nvec,
  +                                 ap_ssize_t *bytes_written)
   {
       int i;
       ap_status_t rv;
  -    ap_ssize_t bytes_written;
  -    int total;
  +    ap_ssize_t n;
   
       i = 0;
  -    total = 0;
  +    *bytes_written = 0;
       while (i < nvec) {
  -	rv = writev_with_errors(fb, vec + i, nvec - i, &bytes_written);
  +	rv = writev_with_errors(fb, vec + i, nvec - i, &n);
   	if (rv != APR_SUCCESS) {
  -            errno = rv;
  -	    return total ? total : -1;
  +/* XXX - When we decide which way to go here, the ifdef will do away. the macro
  + * is undefined by default */
  +#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  +            return rv;
  +#else
  +            return *bytes_written ? APR_SUCCESS : rv;
  +#endif
   	}
  -	total += bytes_written;
  +	*bytes_written += n;
   	if (fb->flags & B_NONBLOCK) {
  -	    return total;
  +	    return APR_SUCCESS;
   	}
   	/* recalculate to deal with partial writes */
  -	while (bytes_written > 0) {
  -            if (bytes_written < vec[i].iov_len) {
  -                vec[i].iov_base = (char *) vec[i].iov_base + bytes_written;
  -                vec[i].iov_len -= bytes_written;
  +	while (n > 0) {
  +            if (n < vec[i].iov_len) {
  +                vec[i].iov_base = (char *) vec[i].iov_base + n;
  +                vec[i].iov_len -= n;
                   break;
               }
               else {
  -                bytes_written -= vec[i].iov_len;
  +                n -= vec[i].iov_len;
                   ++i;
               }
           }
       }
  -    return total;
  +    return APR_SUCCESS;
   }
   
   
  @@ -609,7 +614,8 @@
   {
       struct iovec vec[2];
       int nvec;
  -    int rv;
  +    ap_status_t rv;
  +    ap_ssize_t bytes_written;
   
       ap_assert(nbyte > 0);
       if (fb->outcnt) {
  @@ -624,19 +630,23 @@
   	vec[0].iov_len = nbyte;
   	nvec = 1;
       }
  -    rv = writev_it_all(fb, vec, nvec);
  -    if (rv <= 0) {
  -	return rv;
  +    rv = writev_it_all(fb, vec, nvec, &bytes_written);
  +    if (bytes_written == 0) {   /* error or eof */
  +        if (rv == APR_SUCCESS) {
  +	    return 0;
  +        }
  +        errno = rv;
  +        return -1;
       }
  -    if (rv < fb->outcnt) {
  +    if (bytes_written < fb->outcnt) {
   	/* shift bytes forward in buffer */
  -	memmove(fb->outbase, fb->outbase + rv, fb->outcnt - rv);
  -	fb->outcnt -= rv;
  +	fb->outcnt -= bytes_written;
  +	memmove(fb->outbase, fb->outbase + bytes_written, fb->outcnt);
   	return 0;
       }
  -    rv -= fb->outcnt;
  +    bytes_written -= fb->outcnt;
       fb->outcnt = 0;
  -    return rv;
  +    return bytes_written;
   }
   
   
  
  
  

Mime
View raw message