Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 66dd8410cea698ad8af2319531055d1b > files > 49

apache-2.2.6-8.2mdv2008.0.src.rpm


 Author: Daniel Rench  
 Description: Patch to add -b (source address) option to ab
 Origin: http://issues.apache.org/bugzilla/show_bug.cgi?id=32524

--- support/ab.c	2006-07-12 05:55:27.000000000 +0200
+++ support/ab.c.oden	2007-04-18 17:20:43.000000000 +0200
@@ -278,6 +278,7 @@
 int proxyport = 0;      /* proxy port */
 char *connecthost;
 apr_port_t connectport;
+char *src_address;
 char *gnuplot;          /* GNUplot file */
 char *csvperc;          /* CSV Percentile file */
 char url[1024];
@@ -1102,6 +1103,7 @@
 static void start_connect(struct connection * c)
 {
     apr_status_t rv;
+    apr_sockaddr_t *from;
 
     if (!(started < requests))
     return;
@@ -1124,6 +1126,13 @@
          != APR_SUCCESS) {
         apr_err("socket nonblock", rv);
     }
+    if (src_address) {
+        if ((rv = apr_sockaddr_info_get(&from, src_address, destsa->family,
+                0, 0, c->ctx)) != APR_SUCCESS)
+                apr_err("src_address get", rv);
+        if ((rv = apr_socket_bind(c->aprsock, from)) != APR_SUCCESS)
+            apr_err("src_address bind", rv);
+    }
     c->start = apr_time_now();
 #ifdef USE_SSL
     if (is_ssl) {
@@ -1772,6 +1781,7 @@
     fprintf(stderr, "    -P attribute    Add Basic Proxy Authentication, the attributes\n");
     fprintf(stderr, "                    are a colon separated username and password.\n");
     fprintf(stderr, "    -X proxy:port   Proxyserver and port number to use\n");
+    fprintf(stderr, "    -b src_address  Set the local source address\n");
     fprintf(stderr, "    -V              Print version number and exit\n");
     fprintf(stderr, "    -k              Use HTTP KeepAlive feature\n");
     fprintf(stderr, "    -d              Do not show percentiles served table.\n");
@@ -1940,7 +1950,7 @@
 #endif
 
     apr_getopt_init(&opt, cntxt, argc, argv);
-    while ((status = apr_getopt(opt, "n:c:t:T:p:v:kVhwix:y:z:C:H:P:A:g:X:de:Sq"
+    while ((status = apr_getopt(opt, "b:n:c:t:T:p:v:kVhwix:y:z:C:H:P:A:g:X:de:Sq"
 #ifdef USE_SSL
             "Z:f:"
 #endif
@@ -1955,6 +1965,9 @@
             case 'k':
                 keepalive = 1;
                 break;
+            case 'b':
+                src_address = strdup(optarg);
+                break;
             case 'q':
                 heartbeatres = 0;
                 break;