From nobody@FreeBSD.org  Thu Jul 10 07:34:18 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 343801065670
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Jul 2008 07:34:18 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 1D4EF8FC17
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Jul 2008 07:34:18 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.2/8.14.2) with ESMTP id m6A7YHxv036906
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 10 Jul 2008 07:34:17 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.2/8.14.1/Submit) id m6A7YHie036905;
	Thu, 10 Jul 2008 07:34:17 GMT
	(envelope-from nobody)
Message-Id: <200807100734.m6A7YHie036905@www.freebsd.org>
Date: Thu, 10 Jul 2008 07:34:17 GMT
From: MQ <antinvidia@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [patch] Apache Bench in www/apache22 doesn't work
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         125464
>Category:       ports
>Synopsis:       www/apache22 [patch] Apache Bench doesn't work
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pgollucci
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 10 07:40:01 UTC 2008
>Closed-Date:    Wed Jun 10 06:16:35 UTC 2009
>Last-Modified:  Wed Jun 10 06:16:35 UTC 2009
>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:
Responsible-Changed-From-To: freebsd-ports-bugs->clement 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Thu Jul 10 07:40:12 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125464 
Responsible-Changed-From-To: clement->pgollucci 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Fri Aug 22 18:37:00 UTC 2008 
Responsible-Changed-Why:  
I'll follow up on the dev@httpd.a.o list 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125464 
Responsible-Changed-From-To: pgollucci->apache 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Sat Dec 27 20:26:12 UTC 2008 
Responsible-Changed-Why:  
apache team 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125464 
State-Changed-From-To: open->feedback 
State-Changed-By: pgollucci 
State-Changed-When: Sat May 16 03:29:18 UTC 2009 
State-Changed-Why:  
at least part of this was applied, is this still an issue?  Its going to 
be a mess to sort it out and send it up stream, so I'm hoping its not 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125464 
Responsible-Changed-From-To: apache->pgollucci 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Sat May 16 03:30:35 UTC 2009 
Responsible-Changed-Why:  
started this one 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125464 
State-Changed-From-To: feedback->closed 
State-Changed-By: pgollucci 
State-Changed-When: Wed Jun 10 06:16:34 UTC 2009 
State-Changed-Why:  
feedbacktimeout 

http://www.freebsd.org/cgi/query-pr.cgi?pr=125464 
>Unformatted:
