mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
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
This commit is contained in:
parent
3b267967cf
commit
e7cba68879
@ -119,19 +119,20 @@ TEST_F(ServerTest, HttpWebsocketRST) {
|
|||||||
static char buffer[256];
|
static char buffer[256];
|
||||||
network().parseAddress("localhost:8080").then([this](kj::Own<kj::NetworkAddress>&& addr){
|
network().parseAddress("localhost:8080").then([this](kj::Own<kj::NetworkAddress>&& addr){
|
||||||
return addr->connect().attach(kj::mv(addr)).then([this](kj::Own<kj::AsyncIoStream>&& stream){
|
return addr->connect().attach(kj::mv(addr)).then([this](kj::Own<kj::AsyncIoStream>&& stream){
|
||||||
return stream->write(WS, strlen(WS)).then(kj::mvCapture(kj::mv(stream), [this](kj::Own<kj::AsyncIoStream>&& 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
|
// 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<kj::AsyncIoStream>&& stream, size_t sz){
|
return s->tryRead(buffer, 64, 256).then([this,s](size_t sz){
|
||||||
EXPECT_LE(64, sz);
|
EXPECT_LE(64, sz);
|
||||||
EXPECT_NE(nullptr, mockLaminar.client);
|
EXPECT_NE(nullptr, mockLaminar.client);
|
||||||
// agressively abort the connection
|
// agressively abort the connection
|
||||||
struct linger so_linger;
|
struct linger so_linger;
|
||||||
so_linger.l_onoff = 1;
|
so_linger.l_onoff = 1;
|
||||||
so_linger.l_linger = 0;
|
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<void>(kj::READY_NOW);
|
return kj::Promise<void>(kj::READY_NOW);
|
||||||
}));
|
});
|
||||||
}));
|
}).attach(kj::mv(stream));
|
||||||
});
|
});
|
||||||
}).wait(ws());
|
}).wait(ws());
|
||||||
ws().poll();
|
ws().poll();
|
||||||
|
Loading…
Reference in New Issue
Block a user