You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ma...@hyperreal.org on 1999/10/31 10:13:23 UTC

cvs commit: apache-2.0/src/main buff.c http_protocol.c

manoj       99/10/31 01:13:23

  Modified:    src      CHANGES
               src/include buff.h
               src/main buff.c http_protocol.c
  Log:
  Finish removing references to errno from buff, by introducing
  ap_berror() to return the status from calls that don't return an
  ap_status_t.
  
  Revision  Changes    Path
  1.16      +2 -2      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -d -u -r1.15 -r1.16
  --- CHANGES	1999/10/30 02:06:31	1.15
  +++ CHANGES	1999/10/31 09:13:20	1.16
  @@ -1,7 +1,7 @@
   Changes with Apache 2.0-dev
   
  -  *) Large sections of buff, including the APIs, have been converted to
  -     no longer use errno. [Manoj Kasichainula]
  +  *) buff.c has been converted to no longer use errno.
  +     [Manoj Kasichainula]
   
     *) mod_speling runs in 2.0-dev now: a bug in readdir_r handling and
        interface adaption to APR functions did it. [Martin Kraemer]
  
  
  
  1.11      +6 -0      apache-2.0/src/include/buff.h
  
  Index: buff.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/include/buff.h,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -d -u -r1.10 -r1.11
  --- buff.h	1999/10/31 09:02:52	1.10
  +++ buff.h	1999/10/31 09:13:21	1.11
  @@ -129,6 +129,11 @@
   struct buff_struct {
       int flags;			/* flags */
       ap_status_t saved_errno;	/* saved errno */
  +    ap_status_t berrno;         /* errno for the functions that don't return
  +                                   an ap_status_t. This is separate from
  +                                   saved_errno. A broken call, e.g. ap_bgets
  +                                   on an unbuffered stream, shouldn't change
  +                                   the saved error from I/O */
       unsigned char *inptr;	/* pointer to next location to read */
       int incnt;			/* number of bytes left to read from input buffer;
   				 * always 0 if had a read error  */
  @@ -180,6 +185,7 @@
   API_EXPORT(void) ap_bonerror(BUFF *fb,
                                void (*error) (BUFF *, int, void *, ap_status_t),
                                void *data);
  +API_EXPORT(ap_status_t) ap_berror(BUFF *fb);
   
   /* I/O */
   API_EXPORT(ap_status_t) ap_bread(BUFF *fb, void *buf, ap_size_t nbyte,
  
  
  
  1.23      +22 -13    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.22
  retrieving revision 1.23
  diff -u -d -u -r1.22 -r1.23
  --- buff.c	1999/10/31 09:02:53	1.22
  +++ buff.c	1999/10/31 09:13:22	1.23
  @@ -55,14 +55,10 @@
    *
    */
   
  -/* TODO: Everything involving errno in here is a hack to manage the
  - * transition from errnohood to nonerrnohood - manoj */
  -
   #include "httpd.h"
   #include "http_main.h"
   #include "http_log.h"
   
  -#include <errno.h>
   #include <stdio.h>
   #include <stdarg.h>
   #include <string.h>
  @@ -210,6 +206,7 @@
   	}
   	return iol_setopt(fb->iol, AP_IOL_TIMEOUT, optval);
       }
  +    fb->berrno = APR_EINVAL;
       return APR_EINVAL;
   }
   
  @@ -228,6 +225,7 @@
       case BO_TIMEOUT:
   	return iol_getopt(fb->iol, AP_IOL_TIMEOUT, optval);
       }
  +    fb->berrno = APR_EINVAL;
       return APR_EINVAL;
   }
   
  @@ -322,6 +320,7 @@
   	fb->flags |= B_EOF;
       }
       else if (rv != APR_SUCCESS) {
  +	fb->berrno = rv;
   	fb->saved_errno = rv;
   	if (rv != APR_EAGAIN) {
   	    doerror(fb, B_RD);
  @@ -447,11 +446,10 @@
   
   /* Can't do bgets on an unbuffered stream */
       if (!(fb->flags & B_RD)) {
  -	errno = EINVAL;
  +	fb->berrno = APR_EINVAL;
   	return -1;
       }
       if (fb->flags & B_RDERR) {
  -	errno = fb->saved_errno;
   	return -1;
       }
   
  @@ -466,7 +464,6 @@
   		break;
   	    rv = read_with_errors(fb, fb->inptr, fb->bufsiz, &i);
   	    if (rv != APR_SUCCESS) {
  -                errno = rv;
   		buff[ct] = '\0';
   		return ct ? ct : -1;
   	    }
  @@ -537,7 +534,6 @@
       if (rv == APR_SUCCESS) {
           return bytes_written;
       }
  -    errno = rv;
       return -1;
   }
   
  @@ -552,7 +548,7 @@
   
       rv = ap_bread(fb, buf, 1, &i);
       if (rv == APR_SUCCESS && i == 0)
  -	errno = 0;		/* no error; EOF */
  +        fb->berrno = APR_SUCCESS;       /* no error; EOF */
       if (i != 1)
   	return EOF;
       else
  @@ -837,6 +833,7 @@
       ap_ssize_t n;       /* Placeholder; not ever used */
   
       if ((fb->flags & (B_EOUT | B_WR)) != B_WR) {
  +        fb->berrno = APR_EINVAL;
           return APR_EINVAL;
       }
       if ((fb->flags & B_WRERR) != 0) {
  @@ -878,10 +875,13 @@
    */
   API_EXPORT(int) ap_bputs(const char *x, BUFF *fb)
   {
  +    ap_status_t rv;
       int i, j = strlen(x);
  -    (void) ap_bwrite(fb, x, j, &i);
  -    if (i != j)
  +    rv = ap_bwrite(fb, x, j, &i);
  +    if (i != j) {
  +        fb->berrno = rv;
   	return -1;
  +    }
       else
   	return j;
   }
  @@ -927,6 +927,11 @@
       BUFF *fb;
   };
   
  +API_EXPORT(ap_status_t) ap_berror(BUFF *fb)
  +{
  +    return fb->berrno;
  +}
  +
   static int bprintf_flush(ap_vformatter_buff_t *vbuff)
   {
       struct bprintf_data *b = (struct bprintf_data *)vbuff;
  @@ -950,8 +955,10 @@
       struct bprintf_data b;
   
       /* XXX: only works with buffered writes */
  -    if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR)
  +    if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) {
  +        fb->berrno = APR_EINVAL;
   	return -1;
  +    }
       b.vbuff.curpos = (char *)&fb->outbase[fb->outcnt];
       b.vbuff.endpos = (char *)&fb->outbase[fb->bufsiz];
       b.fb = fb;
  @@ -970,8 +977,10 @@
       int res;
   
       /* XXX: only works with buffered writes */
  -    if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR)
  +    if ((fb->flags & (B_WRERR | B_EOUT | B_WR)) != B_WR) {
  +        fb->berrno = APR_EINVAL;
   	return -1;
  +    }
       b.vbuff.curpos = (char *)&fb->outbase[fb->outcnt];
       b.vbuff.endpos = (char *)&fb->outbase[fb->bufsiz];
       b.fb = fb;
  
  
  
  1.31      +8 -5      apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -d -u -r1.30 -r1.31
  --- http_protocol.c	1999/10/31 09:02:53	1.30
  +++ http_protocol.c	1999/10/31 09:13:22	1.31
  @@ -2212,7 +2212,8 @@
   
       if (ap_bputc(c, r->connection->client) < 0) {
           if (!r->connection->aborted) {
  -            ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r,
  +            ap_log_rerror(APLOG_MARK, APLOG_INFO,
  +                ap_berror(r->connection->client), r,
                   "client stopped connection before rputc completed");
               ap_bsetflag(r->connection->client, B_EOUT, 1);
               r->connection->aborted = 1;
  @@ -2233,7 +2234,8 @@
       rcode = ap_bputs(str, r->connection->client);
       if (rcode < 0) {
           if (!r->connection->aborted) {
  -            ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r,
  +            ap_log_rerror(APLOG_MARK, APLOG_INFO,
  +                ap_berror(r->connection->client), r,
                   "client stopped connection before rputs completed");
               ap_bsetflag(r->connection->client, B_EOUT, 1);
               r->connection->aborted = 1;
  @@ -2277,7 +2279,8 @@
   
       if (n < 0) {
           if (!r->connection->aborted) {
  -            ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r,
  +            ap_log_rerror(APLOG_MARK, APLOG_INFO,
  +                ap_berror(r->connection->client), r,
                   "client stopped connection before vrprintf completed");
               ap_bsetflag(r->connection->client, B_EOUT, 1);
               r->connection->aborted = 1;
  @@ -2302,7 +2305,8 @@
   
       if (n < 0) {
           if (!r->connection->aborted) {
  -            ap_log_rerror(APLOG_MARK, APLOG_INFO, errno, r,
  +            ap_log_rerror(APLOG_MARK, APLOG_INFO,
  +                ap_berror(r->connection->client), r,
                   "client stopped connection before rprintf completed");
               ap_bsetflag(r->connection->client, B_EOUT, 1);
               r->connection->aborted = 1;
  @@ -2360,7 +2364,6 @@
               ap_bsetflag(r->connection->client, B_EOUT, 1);
               r->connection->aborted = 1;
           }
  -        errno = rv;
           return EOF;
       }
       return 0;