bug 1344584 - proactively close streams in test_be_conservative.js to prevent leaks r?mcmanus draft
authorDavid Keeler <dkeeler@mozilla.com>
Tue, 21 Mar 2017 13:23:09 -0700
changeset 502470 6cf8d0a77385f0046e48b029bf2f878a3f294a51
parent 502328 9fb5e850ab7ab0b2b90640c604f66038407b411d
child 550165 aefad7d7701999d309ca6e08f59010afde847d1b
push id50287
push userbmo:dkeeler@mozilla.com
push dateTue, 21 Mar 2017 20:26:09 +0000
reviewersmcmanus
bugs1344584
milestone55.0a1
bug 1344584 - proactively close streams in test_be_conservative.js to prevent leaks r?mcmanus MozReview-Commit-ID: 89h5lQJum6c
netwerk/test/unit/test_be_conservative.js
--- a/netwerk/test/unit/test_be_conservative.js
+++ b/netwerk/test/unit/test_be_conservative.js
@@ -68,45 +68,46 @@ class InputStreamCallback {
             "should have been able to write entire response");
     }
     this.output.close();
     do_print("done with input stream ready");
   }
 
   stop() {
     this.stopped = true;
+    this.output.close();
   }
 }
 
 class TLSServerSecurityObserver {
   constructor(input, output) {
     this.input = input;
     this.output = output;
     this.callbacks = [];
     this.stopped = false;
   }
 
   onHandshakeDone(socket, status) {
     do_print("TLS handshake done");
     do_print(`TLS version used: ${status.tlsVersionUsed}`);
 
     if (this.stopped) {
-      do_print("handshake done callback stopped - closing streams and bailing");
-      this.input.close();
-      this.output.close();
+      do_print("handshake done callback stopped - bailing");
       return;
     }
 
     let callback = new InputStreamCallback(this.output);
     this.callbacks.push(callback);
     this.input.asyncWait(callback, 0, 0, Services.tm.currentThread);
   }
 
   stop() {
     this.stopped = true;
+    this.input.close();
+    this.output.close();
     this.callbacks.forEach((callback) => {
       callback.stop();
     });
   }
 }
 
 class ServerSocketListener {
   constructor() {