Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jul 2008 07:34:17 GMT
From:      MQ <antinvidia@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/125464: [patch] Apache Bench in www/apache22 doesn't work
Message-ID:  <200807100734.m6A7YHie036905@www.freebsd.org>
Resent-Message-ID: <200807100740.m6A7e1Q1064507@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         125464
>Category:       ports
>Synopsis:       [patch] Apache Bench in www/apache22 doesn't work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 10 07:40:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     MQ
>Release:        7.0-RELEASE-p2
>Organization:
>Environment:
FreeBSD q6600.macro 7.0-RELEASE-p2 FreeBSD 7.0-RELEASE-p2 #0: Wed Jun 18 06:48:16 UTC 2008     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
Apache Bench in www/apache22 doesn't work, it always encounter connection reset.
# ./ab -c3 -n100 http://localhost/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)...Send request failed!
apr_socket_recv: Connection reset by peer (54)
Total of 2 requests completed
#

This problem is caused by Apache Bench's improper use of the kqueue support in APR.
>How-To-Repeat:
cd /usr/ports/www/apache22; make BATCH=yes; cd /usr/ports/www/apache22/work/httpd-2.2.9/support; ./ab -n100 -c10 http://localhost/
>Fix:
Use the attached patch could solve this problem. But I haven't test how https connections would be influenced.

There are three pieces of modified codes. The second and third modifications can increase the performance of Apache Bench.

Patch attached with submission follows:

--- support/ab.c.orig	2008-05-28 20:58:01.000000000 +0800
+++ support/ab.c	2008-07-10 15:28:11.000000000 +0800
@@ -670,6 +670,13 @@
 
     c->state = STATE_READ;
     c->endwrite = lasttime = apr_time_now();
+	{
+		apr_pollfd_t remove_pollfd;
+		remove_pollfd.desc_type = APR_POLL_SOCKET;
+		remove_pollfd.desc.s = c->aprsock;
+		remove_pollfd.reqevents = APR_POLLOUT;
+		apr_pollset_remove(readbits, &remove_pollfd);
+	}
     {
         apr_pollfd_t new_pollfd;
         new_pollfd.desc_type = APR_POLL_SOCKET;
@@ -1676,6 +1683,7 @@
         const apr_pollfd_t *pollresults;
 
         n = concurrency;
+		apr_time_now();
         status = apr_pollset_poll(readbits, aprtimeout, &n, &pollresults);
         if (status != APR_SUCCESS)
             apr_err("apr_poll", status);
@@ -1759,22 +1767,6 @@
                     write_request(c);
                 }
             }
-
-            /*
-             * When using a select based poll every time we check the bits
-             * are reset. In 1.3's ab we copied the FD_SET's each time
-             * through, but here we're going to check the state and if the
-             * connection is in STATE_READ or STATE_CONNECTING we'll add the
-             * socket back in as APR_POLLIN.
-             */
-                if (c->state == STATE_READ) {
-                    apr_pollfd_t new_pollfd;
-                    new_pollfd.desc_type = APR_POLL_SOCKET;
-                    new_pollfd.reqevents = APR_POLLIN;
-                    new_pollfd.desc.s = c->aprsock;
-                    new_pollfd.client_data = c;
-                    apr_pollset_add(readbits, &new_pollfd);
-                }
         }
     } while (lasttime < stoptime && done < requests);
     


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200807100734.m6A7YHie036905>