httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@locus.apache.org
Subject cvs commit: apache-2.0/src CHANGES
Date Tue, 13 Jun 2000 13:41:23 GMT
trawick     00/06/13 06:41:23

  Modified:    src/include buff.h
               src/lib/apr/i18n/unix xlate.c
               src/lib/apr/include apr_errno.h
               src/main buff.c
               src/lib/apr/misc/unix errorcodes.c
               src      CHANGES
  Log:
  ap_bwrite_xlate() now handles the case where it was passed a partial
  character at the end of the input buffer.
  
  A new APR status code was added for non-error situations where more
  input data is needed to complete the task.  ap_xlate_conv_buffer()
  returns this when it is passed a partial character at the end of the
  input buffer.  ap_bwrite_xlate() checks for this status code so it
  knows when to hold onto the partial character until the next call, at
  which point it can try to translate the entire character.
  
  Revision  Changes    Path
  1.28      +3 -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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- buff.h	2000/06/10 02:06:03	1.27
  +++ buff.h	2000/06/13 13:41:17	1.28
  @@ -190,6 +190,9 @@
                                     * translation handle; thus, we need the
                                     * untranslated version in case ap_bungetc() is
                                     * called */
  +    char partial_write[8];       /* incomplete output character; must hold the largest
  +                                    character in any charset*/
  +    size_t partial_write_len;    /* bytes held in partial_write */
   #endif /*APACHE_XLATE*/
   };
   
  
  
  
  1.7       +23 -2     apache-2.0/src/lib/apr/i18n/unix/xlate.c
  
  Index: xlate.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/i18n/unix/xlate.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- xlate.c	2000/06/02 22:34:58	1.6
  +++ xlate.c	2000/06/13 13:41:19	1.7
  @@ -253,9 +253,30 @@
           /* If everything went fine but we ran out of buffer, don't
            * report it as an error.  Caller needs to look at the two
            * bytes-left values anyway.
  +         *
  +         * There are three expected cases where rc is -1.  In each of
  +         * these cases, *inbytes_left != 0.
  +         * a) the non-error condition where we ran out of output
  +         *    buffer
  +         * b) the non-error condition where we ran out of input (i.e.,
  +         *    the last input character is incomplete)
  +         * c) the error condition where the input is invalid
            */
  -        if (translated == (size_t)-1 && *outbytes_left) {
  -            return errno;
  +        if (translated == (size_t)-1) {
  +            switch (errno) {
  +            case E2BIG:  /* out of space on output */
  +                status = 0; /* change table lookup code below if you
  +                               make this an error */
  +                break;
  +            case EINVAL: /* input character not complete (yet) */
  +                status = APR_INCOMPLETE;
  +                break;
  +            case EILSEQ: /* bad input byte */
  +                status = APR_EINVAL;
  +                break;
  +            default:
  +                status = errno;
  +            }
           }
       }
       else
  
  
  
  1.34      +1 -1      apache-2.0/src/lib/apr/include/apr_errno.h
  
  Index: apr_errno.h
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/include/apr_errno.h,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- apr_errno.h	2000/06/10 00:44:46	1.33
  +++ apr_errno.h	2000/06/13 13:41:20	1.34
  @@ -116,7 +116,7 @@
   #define APR_CHILD_DONE     (APR_OS_START_STATUS + 5)
   #define APR_CHILD_NOTDONE  (APR_OS_START_STATUS + 6)
   #define APR_TIMEUP         (APR_OS_START_STATUS + 7)
  -/* empty slot: +8 */
  +#define APR_INCOMPLETE     (APR_OS_START_STATUS + 8)
   /* empty slot: +9 */
   /* empty slot: +10 */
   /* empty slot: +11 */
  
  
  
  1.52      +61 -2     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.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- buff.c	2000/06/12 23:34:24	1.51
  +++ buff.c	2000/06/13 13:41:21	1.52
  @@ -183,6 +183,7 @@
       fb->xbufsize = 0;
       fb->write_xlate = NULL;
       fb->read_xlate = NULL;
  +    fb->partial_write_len = 0;
   #endif /*APACHE_XLATE*/
   
       fb->inptr = fb->inbase;
  @@ -963,6 +964,47 @@
   }
   
   #ifdef APACHE_XLATE
  +/* bwrite_xlate_partial() handles completion of an input char which was left
  + * incomplete on the last call to ap_bwrite_xlate(); to complete it, we'll
  + * consume additional input bytes until the input char is complete or an error 
  + * occurs; we'll assume that the output buffer (fb->xbuf) is large enough;
  + * we'll check that the buffer for the temporary character (fb->partial_write)
  + * is large enough;
  + */
  +static ap_status_t bwrite_xlate_partial(BUFF *fb, const void *buf, ap_size_t nbyte,
  +                                        ap_ssize_t *bytes_written)
  +{
  +    ap_size_t inbytes_left, outbytes_left;
  +    ap_status_t rv = APR_SUCCESS;
  +    const char *in = (const char *)buf;
  +    ap_ssize_t written;
  +    
  +    *bytes_written = 0;
  +    do {
  +        if (fb->partial_write_len >= sizeof(fb->partial_write)) {
  +            return APR_INCOMPLETE;
  +        }
  +        fb->partial_write[fb->partial_write_len] = *in;
  +        ++fb->partial_write_len;
  +        ++in;
  +        ++*bytes_written; /* only a lie if an error occurs */
  +        --nbyte;
  +        inbytes_left = fb->partial_write_len;
  +        outbytes_left = fb->xbufsize;
  +        rv = ap_xlate_conv_buffer(fb->write_xlate, fb->partial_write, 
  +                                  &inbytes_left, fb->xbuf, &outbytes_left);
  +    } while (rv == APR_INCOMPLETE && nbyte);
  +    if (rv == APR_INCOMPLETE) { /* ran out of nbyte before completing char */
  +        return APR_SUCCESS; /* hope for the rest on the next call */
  +    }
  +    if (!rv) {
  +        rv = ap_bwrite_core(fb, fb->xbuf, fb->xbufsize - outbytes_left, 
  +                            &written);
  +    }
  +    fb->partial_write_len = 0;
  +    return rv;
  +}
  +
   static ap_status_t ap_bwrite_xlate(BUFF *fb, const void *buf, ap_size_t nbyte,
                                      ap_ssize_t *bytes_written)
   {
  @@ -985,12 +1027,29 @@
           ap_assert(fb->xbuf);
       }
   
  +    if (fb->partial_write_len) {
  +        return bwrite_xlate_partial(fb, buf, nbyte, bytes_written);
  +    }
  +
       inbytes_left = nbyte;
       outbytes_left = fb->xbufsize;
       rv = ap_xlate_conv_buffer(fb->write_xlate, buf, &inbytes_left,
                                 fb->xbuf, &outbytes_left);
  -    /* TODO: handle partial character at end of input buffer
  -     */
  +    if (rv == APR_INCOMPLETE) { /* partial character at end of input */
  +        /* We need to save the final byte(s) for next time; we can't
  +         * convert it until the caller passes us the rest of the input
  +         * character.  If we don't consume the byte(s), the caller will 
  +         * just pass it to us again (without the rest of the char).
  +         */
  +        if (sizeof(fb->partial_write) > inbytes_left) {
  +            memcpy(fb->partial_write, (char *)buf + nbyte - inbytes_left, 
  +                   inbytes_left);
  +            fb->partial_write_len = inbytes_left;
  +            inbytes_left = 0;
  +            rv = 0;
  +        }
  +        /* else no room to complete the input char; fail */
  +    }
       if (rv) {
           /* the content may not be in the expected charset
            */
  
  
  
  1.21      +2 -0      apache-2.0/src/lib/apr/misc/unix/errorcodes.c
  
  Index: errorcodes.c
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/lib/apr/misc/unix/errorcodes.c,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- errorcodes.c	2000/06/01 01:01:16	1.20
  +++ errorcodes.c	2000/06/13 13:41:21	1.21
  @@ -127,6 +127,8 @@
           return "The specified child process is not done executing";
       case APR_TIMEUP:
           return "The timeout specified has expired";
  +    case APR_INCOMPLETE:
  +        return "The input data is incomplete";
       case APR_BADCH:
           return "Bad character specified on command line";
       case APR_BADARG:
  
  
  
  1.150     +4 -0      apache-2.0/src/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apache-2.0/src/CHANGES,v
  retrieving revision 1.149
  retrieving revision 1.150
  diff -u -r1.149 -r1.150
  --- CHANGES	2000/06/10 11:46:36	1.149
  +++ CHANGES	2000/06/13 13:41:22	1.150
  @@ -1,5 +1,9 @@
   Changes with Apache 2.0a5
   
  +  *) xlate: ap_xlate_conv_buffer() now tells the caller when the
  +     final input char is incomplete; ap_bwrite_xlate() now handles
  +     incomplete final input chars.  [Jeff Trawick]
  +
     *) Yet another update to saferead/halfduplex stuff -- need to ensure
        that a bhalfduplex call occurs before logging or else DNS and
        such can delay the last packet of the response.  [Dean Gaudet]
  
  
  

Mime
View raw message