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/modules/standard mod_echo.c mod_mime_magic.c
Date Sat, 30 Oct 1999 02:06:36 GMT
manoj       99/10/29 19:06:35

  Modified:    src      CHANGES
               src/include buff.h
               src/main buff.c http_protocol.c
               src/modules/standard mod_echo.c mod_mime_magic.c
  Log:
  Change ap_bread's interface to no longer require errno.
  
  Revision  Changes    Path
  1.15      +2 -4      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -d -u -r1.14 -r1.15
  --- CHANGES	1999/10/26 22:42:33	1.14
  +++ CHANGES	1999/10/30 02:06:31	1.15
  @@ -1,9 +1,7 @@
   Changes with Apache 2.0-dev
   
  -  *) ap_bflush and ap_bclose now return ap_status_t error codes instead
  -     of returning -1 and setting errno. And error functions recorded
  -     with ap_bonerror now take a status code as an argument. [Manoj
  -     Kasichainula]
  +  *) Large sections of buff, including the APIs, have 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.7       +2 -1      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.6
  retrieving revision 1.7
  diff -u -d -u -r1.6 -r1.7
  --- buff.h	1999/10/26 22:53:55	1.6
  +++ buff.h	1999/10/30 02:06:32	1.7
  @@ -182,7 +182,8 @@
                                void *data);
   
   /* I/O */
  -API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte);
  +API_EXPORT(ap_status_t) ap_bread(BUFF *fb, void *buf, ap_size_t nbyte,
  +                                 ap_ssize_t *bytes_read);
   API_EXPORT(int) ap_bgets(char *s, int n, BUFF *fb);
   API_EXPORT(int) ap_blookc(BUFF *fb);
   API_EXPORT(int) ap_bwrite(BUFF *fb, const void *buf, int nbyte);
  
  
  
  1.19      +35 -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.18
  retrieving revision 1.19
  diff -u -d -u -r1.18 -r1.19
  --- buff.c	1999/10/26 22:42:46	1.18
  +++ buff.c	1999/10/30 02:06:32	1.19
  @@ -334,19 +334,21 @@
   /*
    * Read up to nbyte bytes into buf.
    * If fewer than byte bytes are currently available, then return those.
  - * Returns 0 for EOF, -1 for error.
    */
  -API_EXPORT(int) ap_bread(BUFF *fb, void *buf, int nbyte)
  +API_EXPORT(ap_status_t) ap_bread(BUFF *fb, void *buf, ap_size_t nbyte,
  +                                 ap_ssize_t *bytes_read)
   {
       int i, nrd;
       ap_status_t rv;
   
       if (fb->flags & B_RDERR) {
  -	errno = fb->saved_errno;
  -	return -1;
  +        *bytes_read = 0;
  +	return fb->saved_errno;
       }
  -    if (nbyte == 0)
  -	return 0;
  +    if (nbyte == 0) {
  +        *bytes_read = 0;
  +	return APR_SUCCESS;
  +    }
   
       if (!(fb->flags & B_RD)) {
   	/* Unbuffered reading.  First check if there was something in the
  @@ -356,14 +358,10 @@
   	    memcpy(buf, fb->inptr, i);
   	    fb->incnt -= i;
   	    fb->inptr += i;
  -	    return i;
  +            *bytes_read = i;
  +	    return APR_SUCCESS;
   	}
  -	rv = read_with_errors(fb, buf, nbyte, &i);
  -        if (rv == APR_SUCCESS) {
  -            return i;
  -        }
  -        errno = rv;
  -        return -1;
  +	return read_with_errors(fb, buf, nbyte, bytes_read);
       }
   
       nrd = fb->incnt;
  @@ -372,7 +370,8 @@
   	memcpy(buf, fb->inptr, nbyte);
   	fb->incnt = nrd - nbyte;
   	fb->inptr += nbyte;
  -	return nbyte;
  +        *bytes_read = nbyte;
  +	return APR_SUCCESS;
       }
   
       if (nrd > 0) {
  @@ -381,16 +380,22 @@
   	buf = nrd + (char *) buf;
   	fb->incnt = 0;
       }
  -    if (fb->flags & B_EOF)
  -	return nrd;
  +    if (fb->flags & B_EOF) {
  +        *bytes_read = nrd;
  +	return APR_SUCCESS;
  +    }
   
   /* do a single read */
       if (nbyte >= fb->bufsiz) {
   /* read directly into caller's buffer */
   	rv = read_with_errors(fb, buf, nbyte, &i);
   	if (rv != APR_SUCCESS) {
  -            errno = rv;
  -	    return nrd ? nrd : -1;
  +            *bytes_read = nrd;
  +#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  +            return rv;
  +#else
  +	    return *bytes_read ? APR_SUCCESS : rv;
  +#endif
   	}
       }
       else {
  @@ -398,8 +403,12 @@
   	fb->inptr = fb->inbase;
   	rv = read_with_errors(fb, fb->inptr, fb->bufsiz, &i);
   	if (rv != APR_SUCCESS) {
  -            errno = rv;
  -	    return nrd ? nrd : -1;
  +            *bytes_read = nrd;
  +#ifdef MIDWAY_ERROR_RETURNS_ERROR_BLAH_BLAH_BLAH
  +            return rv;
  +#else
  +	    return *bytes_read ? APR_SUCCESS : rv;
  +#endif
   	}
   	fb->incnt = i;
   	if (i > nbyte)
  @@ -408,7 +417,8 @@
   	fb->incnt -= i;
   	fb->inptr += i;
       }
  -    return nrd + i;
  +    *bytes_read = nrd + i;
  +    return APR_SUCCESS;
   }
   
   
  @@ -529,11 +539,12 @@
    */
   API_EXPORT(int) ap_bfilbuf(BUFF *fb)
   {
  -    int i;
  +    ap_status_t rv;
  +    ap_ssize_t i;
       char buf[1];
   
  -    i = ap_bread(fb, buf, 1);
  -    if (i == 0)
  +    rv = ap_bread(fb, buf, 1, &i);
  +    if (rv == APR_SUCCESS && i == 0)
   	errno = 0;		/* no error; EOF */
       if (i != 1)
   	return EOF;
  
  
  
  1.27      +21 -15    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.26
  retrieving revision 1.27
  diff -u -d -u -r1.26 -r1.27
  --- http_protocol.c	1999/10/26 22:25:02	1.26
  +++ http_protocol.c	1999/10/30 02:06:33	1.27
  @@ -1813,17 +1813,21 @@
   API_EXPORT(long) ap_get_client_block(request_rec *r, char *buffer, int bufsiz)
   {
       int c;
  -    long len_read, len_to_read;
  +    ap_size_t len_to_read;
  +    ap_ssize_t len_read;
       long chunk_start = 0;
       unsigned long max_body;
  +    ap_status_t rv;
   
       if (!r->read_chunked) {     /* Content-length read */
           len_to_read = (r->remaining > bufsiz) ? bufsiz : r->remaining;
  -        len_read = ap_bread(r->connection->client, buffer, len_to_read);
  -        if (len_read <= 0) {
  -            if (len_read < 0)
  +        rv = ap_bread(r->connection->client, buffer, len_to_read, &len_read);
  +        if (len_read == 0) {    /* error or eof */
  +            if (rv != APR_SUCCESS) {
                   r->connection->keepalive = -1;
  -            return len_read;
  +                return -1;
  +            }
  +            return 0;
           }
           r->read_length += len_read;
           r->remaining -= len_read;
  @@ -1931,8 +1935,8 @@
   
       len_to_read = (r->remaining > bufsiz) ? bufsiz : r->remaining;
   
  -    len_read = ap_bread(r->connection->client, buffer, len_to_read);
  -    if (len_read <= 0) {
  +    (void) ap_bread(r->connection->client, buffer, len_to_read, &len_read);
  +    if (len_read == 0) {        /* error or eof */
           r->connection->keepalive = -1;
           return -1;
       }
  @@ -2072,7 +2076,9 @@
       char buf[IOBUFSIZE];
       long total_bytes_sent = 0;
       long zero_timeout = 0;
  -    int n, w, o;
  +    int w, o;
  +    ap_ssize_t n;
  +    ap_status_t rv;
   
       if (length == 0) {
           return 0;
  @@ -2085,13 +2091,13 @@
   
       ap_bsetopt(fb, BO_TIMEOUT, &zero_timeout);
       while (!ap_is_aborted(r->connection)) {
  -        n = ap_bread(fb, buf, sizeof(buf));
  -        if (n <= 0) {
  -            if (n == 0) {
  +        rv = ap_bread(fb, buf, sizeof(buf), &n);
  +        if (n == 0) {
  +            if (rv == APR_SUCCESS) {    /* eof */
                   (void) ap_rflush(r);
                   break;
               }
  -            if (n == -1 && errno != EAGAIN) {
  +            if (rv != APR_EAGAIN) {
                   r->connection->aborted = 1;
                   break;
               }
  @@ -2101,9 +2107,9 @@
               }
   
               ap_bsetopt(fb, BO_TIMEOUT, &r->server->timeout);
  -            n = ap_bread(fb, buf, sizeof(buf));
  -            if (n <= 0) {
  -                if (n == 0) {
  +            rv = ap_bread(fb, buf, sizeof(buf), &n);
  +            if (n == 0) {
  +                if (rv == APR_SUCCESS) {        /* eof */
                       (void) ap_rflush(r);
                   }
                   r->connection->aborted = 1;
  
  
  
  1.12      +2 -1      apache-2.0/src/modules/standard/mod_echo.c
  
  Index: mod_echo.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_echo.c,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -d -u -r1.11 -r1.12
  --- mod_echo.c	1999/08/31 05:33:48	1.11
  +++ mod_echo.c	1999/10/30 02:06:34	1.12
  @@ -39,7 +39,8 @@
       for( ; ; )
   	{
   	int w;
  -	int r=ap_bread(c->client,buf,sizeof buf);
  +	int r;
  +        (void) ap_bread(c->client,buf,sizeof buf,&r);
   	if(r <= 0)
   	    break;
   	w=ap_bwrite(c->client,buf,r);
  
  
  
  1.7       +4 -2      apache-2.0/src/modules/standard/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/modules/standard/mod_mime_magic.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -d -u -r1.6 -r1.7
  --- mod_mime_magic.c	1999/10/22 16:01:27	1.6
  +++ mod_mime_magic.c	1999/10/30 02:06:34	1.7
  @@ -2173,6 +2173,7 @@
       struct uncompress_parms parm;
       BUFF *bout;
       ap_context_t *sub_pool;
  +    ap_status_t rv;
   
       parm.r = r;
       parm.method = method;
  @@ -2192,9 +2193,10 @@
       }
   
       *newch = (unsigned char *) ap_palloc(r->pool, n);
  -    if ((n = ap_bread(bout, *newch, n)) <= 0) {
  +    rv = ap_bread(bout, *newch, n, &n);
  +    if (n == 0) {
   	ap_destroy_pool(sub_pool);
  -	ap_log_rerror(APLOG_MARK, APLOG_ERR, errno, r,
  +	ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r,
   	    MODNAME ": read failed %s", r->filename);
   	return -1;
       }
  
  
  

Mime
View raw message