You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by as...@apache.org on 2008/09/08 12:50:32 UTC

svn commit: r693049 - /httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java

Author: asankha
Date: Mon Sep  8 03:50:31 2008
New Revision: 693049

URL: http://svn.apache.org/viewvc?rev=693049&view=rev
Log:
close connections cleanly before ending a run
Support new options :
  -o : Use http 1.0 instead of default http 1.1
  -t <n> : Use the socket timeout as <n> milliseconds
  -H "h1: v1","h2: v2" : Support multiple http headers to work around a CLI limitation

Modified:
    httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java

Modified: httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java?rev=693049&r1=693048&r2=693049&view=diff
==============================================================================
--- httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java (original)
+++ httpcomponents/httpcore/trunk/contrib/src/main/java/org/apache/http/contrib/benchmark/BenchmarkWorker.java Mon Sep  8 03:50:31 2008
@@ -90,11 +90,11 @@
     private final Stats stats = new Stats();
 
     public BenchmarkWorker(
-            final HttpParams params, 
-            int verbosity, 
+            final HttpParams params,
+            int verbosity,
             final HttpRequest request,
-            final HttpHost targetHost, 
-            int count, 
+            final HttpHost targetHost,
+            int count,
             boolean keepalive) {
 
         super();
@@ -160,7 +160,7 @@
                     response = this.httpexecutor.execute(this.request, conn, this.context);
                     // Finalize response
                     this.httpexecutor.postProcess(response, this.httpProcessor, this.context);
-                    
+
                 } catch (HttpException e) {
                     stats.incWriteErrors();
                     if (this.verbosity >= 2) {
@@ -225,6 +225,16 @@
                 stats.setServerName(header.getValue());
             }
         }
+
+        try {
+            conn.close();
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            stats.incFailureCount();
+            if (this.verbosity >= 2) {
+                System.err.println("I/O error: " + ex.getMessage());
+            }
+        }
     }
 
     private void verboseOutput(HttpResponse response) {