From e7cba6887973e708509a669b4db6871b354f39fb Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Sat, 27 Jan 2018 19:13:53 +0200 Subject: [PATCH] tests: extract pointer to kj::AsyncIoStream Fixes a crash that happens on g++ 6.3 under debian but not g++ 7.2.1 under arch. Instead of trying to move kj::AsyncIoStream between each promise handler, just extract and use the raw pointer and let attach() clean up the Own<> at the end --- test/test-server.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/test-server.cpp b/test/test-server.cpp index 19ea8d8..6595b24 100644 --- a/test/test-server.cpp +++ b/test/test-server.cpp @@ -119,19 +119,20 @@ TEST_F(ServerTest, HttpWebsocketRST) { static char buffer[256]; network().parseAddress("localhost:8080").then([this](kj::Own&& addr){ return addr->connect().attach(kj::mv(addr)).then([this](kj::Own&& stream){ - return stream->write(WS, strlen(WS)).then(kj::mvCapture(kj::mv(stream), [this](kj::Own&& stream){ + kj::AsyncIoStream* s = stream.get(); + return s->write(WS, strlen(WS)).then([this,s](){ // Read the websocket header response, ensure the client has been registered - return stream->tryRead(buffer, 64, 256).then(kj::mvCapture(kj::mv(stream), [this](kj::Own&& stream, size_t sz){ + return s->tryRead(buffer, 64, 256).then([this,s](size_t sz){ EXPECT_LE(64, sz); EXPECT_NE(nullptr, mockLaminar.client); // agressively abort the connection struct linger so_linger; so_linger.l_onoff = 1; so_linger.l_linger = 0; - stream->setsockopt(SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger)); + s->setsockopt(SOL_SOCKET, SO_LINGER, &so_linger, sizeof(so_linger)); return kj::Promise(kj::READY_NOW); - })); - })); + }); + }).attach(kj::mv(stream)); }); }).wait(ws()); ws().poll();