#! /bin/sh /usr/share/dpatch/dpatch-run
## 082_ab_num_requests.dpatch by Stefan Fritsch <sf@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Upstream r940526, Debian bug #541158

@DPATCH@
diff -urNad trunk~/support/ab.c trunk/support/ab.c
--- trunk~/support/ab.c	2010-07-16 22:17:41.697762479 +0200
+++ trunk/support/ab.c	2010-07-16 22:17:45.661763246 +0200
@@ -628,6 +628,10 @@
 
 static void write_request(struct connection * c)
 {
+    if (started >= requests) {
+        return;
+    }
+
     do {
         apr_time_t tnow;
         apr_size_t l = c->rwrite;
@@ -690,6 +694,7 @@
         new_pollfd.client_data = c;
         apr_pollset_add(readbits, &new_pollfd);
     }
+    started++;
 }
 
 /* --------------------------------------------------------- */
@@ -1239,7 +1244,6 @@
 
     /* connected first time */
     c->state = STATE_CONNECTED;
-    started++;
 #ifdef USE_SSL
     if (c->ssl) {
         ssl_proceed_handshake(c);
@@ -1766,7 +1770,6 @@
                     }
                     else {
                         c->state = STATE_CONNECTED;
-                        started++;
 #ifdef USE_SSL
                         if (c->ssl)
                             ssl_proceed_handshake(c);
