From d586f119fa588a590a4ba2b74c8c210de710e3e7 Mon Sep 17 00:00:00 2001 From: Nayeem Rahman Date: Sat, 9 Nov 2019 19:40:22 +0000 Subject: net: Check for closing status when iterating Listener (#3309) std/http/server.ts: Use listener.next() instead of listener.accept() --- std/http/server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'std/http/server.ts') diff --git a/std/http/server.ts b/std/http/server.ts index deedb0f12..ce32511b1 100644 --- a/std/http/server.ts +++ b/std/http/server.ts @@ -371,7 +371,9 @@ export class Server implements AsyncIterable { ): AsyncIterableIterator { if (this.closing) return; // Wait for a new connection. - const conn = await this.listener.accept(); + const { value, done } = await this.listener.next(); + if (done) return; + const conn = value as Conn; // Try to accept another connection and add it to the multiplexer. mux.add(this.acceptConnAndIterateHttpRequests(mux)); // Yield the requests that arrive on the just-accepted connection. -- cgit v1.2.3