Skip to content

Commit f44094f

Browse files
committed
test: add ListenConnections disconnect coverage
1 parent e8de5c7 commit f44094f

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

test/mp/test/listen_tests.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,21 @@ KJ_TEST("ListenConnections accepts multiple connections")
289289
KJ_EXPECT(client3->client->add(3, 4) == 7);
290290
}
291291

292+
KJ_TEST("ListenConnections survives a client that disconnects before being accepted")
293+
{
294+
ListenSetup server;
295+
296+
// Connect and close before the server has a chance to accept() the
297+
// connection.
298+
int fd = server.listener.MakeConnectedSocket();
299+
close(fd);
300+
301+
// The server should still accept and serve later clients.
302+
auto client = std::make_unique<ClientSetup>(server.listener.MakeConnectedSocket());
303+
server.WaitForConnectedCount(1);
304+
KJ_EXPECT(client->client->add(1, 2) == 3);
305+
}
306+
292307
} // namespace
293308
} // namespace test
294309
} // namespace mp

0 commit comments

Comments
 (0)