OSDN Git Service

Rewrite the HTTP connection pool used by HttpURLConnection.
[android-x86/dalvik.git] / libcore / support / src / test / java / tests / support / Support_TestWebServer.java
index 6773f01..4d6b0d1 100644 (file)
@@ -225,6 +225,10 @@ public class Support_TestWebServer implements Support_HttpConstants {
         return pathToRequest;
     }
 
+    public int getNumAcceptedConnections() {
+        return acceptedConnections;
+    }
+
     /**
      * Cause the thread accepting connections on the server socket to close
      */
@@ -261,23 +265,19 @@ public class Support_TestWebServer implements Support_HttpConstants {
          */
         public synchronized void run() {
             running = true;
-            try {
-                while (running) {
-                    // Log.d(LOGTAG, "TestWebServer run() calling accept()");
+            while (running) {
+                try {
                     Socket s = ss.accept();
                     acceptedConnections++;
                     if (acceptedConnections >= acceptLimit) {
                         running = false;
                     }
-
                     new Thread(new Worker(s), "additional worker").start();
+                } catch (SocketException e) {
+                    log(e.getMessage());
+                } catch (IOException e) {
+                    log(e.getMessage());
                 }
-            } catch (SocketException e) {
-                log("SocketException in AcceptThread: probably closed during accept");
-                running = false;
-            } catch (IOException e) {
-                log("IOException in AcceptThread");
-                running = false;
             }
             log("AcceptThread terminated" + this);
         }