httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stodd...@apache.org
Subject cvs commit: httpd-2.0/server protocol.c
Date Fri, 16 Mar 2001 04:17:39 GMT
stoddard    01/03/15 20:17:38

  Modified:    .        CHANGES
               server   protocol.c
  Log:
  Avoid using sscanf to determine the HTTP protocol number in
  the common case because sscanf is a performance hog. From
  Mike Abbot's Accelerating Apache patch number 6.
  
  Submitted by: Mike Abbot <mja@trudge.engr.sgi.com>
  Reviewed by: Bill Stoddard
  
  Revision  Changes    Path
  1.132     +4 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.131
  retrieving revision 1.132
  diff -u -r1.131 -r1.132
  --- CHANGES	2001/03/15 22:09:26	1.131
  +++ CHANGES	2001/03/16 04:17:37	1.132
  @@ -1,4 +1,8 @@
   Changes with Apache 2.0.15-dev
  +  *) Avoid using sscanf to determine the HTTP protocol number in
  +     the common case because sscanf is a performance hog. From
  +     Mike Abbot's Accelerating Apache patch number 6.
  +     [Mike Abbot <mja@trudge.engr.sgi.com>, Bill Stoddard]
   
     *) Fix a security exposure in mod_access.  Previously when IPv6 
        listening sockets were used, allow/deny-from-IPv4-address rules 
  
  
  
  1.5       +22 -9     httpd-2.0/server/protocol.c
  
  Index: protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/protocol.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- protocol.c	2001/03/07 17:01:28	1.4
  +++ protocol.c	2001/03/16 04:17:38	1.5
  @@ -664,6 +664,8 @@
       char l[DEFAULT_LIMIT_REQUEST_LINE + 2]; /* getline's two extra for \n\0 */
       const char *ll = l;
       const char *uri;
  +    const char *pro;
  +
   #if 0
       conn_rec *conn = r->connection;
   #endif
  @@ -739,16 +741,27 @@
           return 0;
       }
   
  -    r->assbackwards = (ll[0] == '\0');
  -    r->protocol = apr_pstrdup(r->pool, ll[0] ? ll : "HTTP/0.9");
  -/* XXX If we want to keep track of the Method, the protocol module should do
  - * it.  That support isn't in the scoreboard yet.  Hopefully next week 
  - * sometime.   rbb
  -    ap_update_connection_status(conn->id, "Protocol", r->protocol); 
  - */
  +    if (ll[0]) {
  +        r->assbackwards = 0;
  +        pro = ll;
  +        len = strlen(ll);
  +    } else {
  +        r->assbackwards = 1;
  +        pro = "HTTP/0.9";
  +        len = 8;
  +    }
  +    r->protocol = apr_pstrndup(r->pool, pro, len);
  +
  +    /* XXX ap_update_connection_status(conn->id, "Protocol", r->protocol); */
   
  -    if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor)
  -      && minor < HTTP_VERSION(1,0))	/* don't allow HTTP/0.1000 */
  +    /* Avoid sscanf in the common case */
  +    if (len == 8 &&
  +        pro[0] == 'H' && pro[1] == 'T' && pro[2] == 'T' && pro[3]
== 'P' &&
  +        pro[4] == '/' && apr_isdigit(pro[5]) && pro[6] == '.' &&
  +        apr_isdigit(pro[7])) {
  + 	r->proto_num = HTTP_VERSION(pro[5] - '0', pro[7] - '0');
  +    } else if (2 == sscanf(r->protocol, "HTTP/%u.%u", &major, &minor)
  +               && minor < HTTP_VERSION(1,0))	/* don't allow HTTP/0.1000 */
   	r->proto_num = HTTP_VERSION(major, minor);
       else
   	r->proto_num = HTTP_VERSION(1,0);
  
  
  

Mime
View raw message