Commit 9c114104 authored by Greg Ames's avatar Greg Ames
Browse files

Reduce CPU consumption in conv_10 function, used to format "%d" by apr_*printf

This includes two changes to APR:
  * new functions apr_itoa, apr_ltoa, and apr_off_t_toa
    that provide itoa-type functionality based on pools
  * Inline code in inet_ntop4 to replace sprintf for converting
    binary IP addresses into dotted-decimal format

and two changes to Apache:
  * use the apr_itoa functions in setting the content length,
    in place of apr_psprintf
  * use the apr_itoa functions to replace frequent uses of
    'sprintf("%d",...)' in mod_log_config.

Submitted by: Brian Pane
Reviewed by:  Dean Gaudet, Greg Ames


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89686 13f79535-47bb-0310-9956-ffa450edef68
parent 41aab6e0
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.22-dev

  *) Use new APR number conversion functions to reduce CPU consumption 
     when setting the content length, and in mod_log_config.
     [Brian Pane]
     
  *) Fix problem reported by Taketo Kabe <kabe@sra-tohoku.co.jp>
     where HEAD response headers were being repeated twice for
     files greater than 32K bytes (4*AP_MIN_BYTES_TO_WRITE). This
+2 −2
Original line number Diff line number Diff line
@@ -284,7 +284,7 @@ typedef struct {

static char *format_integer(apr_pool_t *p, int i)
{
    return apr_psprintf(p, "%d", i);
    return apr_itoa(p, i);
}

static char *pfmt(apr_pool_t *p, int i)
@@ -381,7 +381,7 @@ static const char *clf_log_bytes_sent(request_rec *r, char *a)
        return "-";
    }
    else {
	return apr_psprintf(r->pool, "%ld", r->bytes_sent);
	return apr_ltoa(r->pool, r->bytes_sent);
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ AP_DECLARE(void) ap_set_content_length(request_rec *r, apr_off_t clength)
{
    r->clength = clength;
    apr_table_setn(r->headers_out, "Content-Length",
                   apr_psprintf(r->pool, "%" APR_OFF_T_FMT, clength));
		   apr_off_t_toa(r->pool, clength));
}

/*