Skip to content

Commit

Permalink
Add test for #1726.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Mar 28, 2017
1 parent d2a8a52 commit f2b5a8f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/vibe.core.net.1726/dub.sdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name "tests"
description "TCP disconnect task issue"
dependency "vibe-d:core" path="../../"
versions "VibeDefaultMain"
53 changes: 53 additions & 0 deletions tests/vibe.core.net.1726/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import vibe.core.core;
import vibe.core.net;
import core.time : msecs;
import vibe.core.log;

shared static this()
{
bool done = false;
auto buf = new ubyte[512*1024*1024];

listenTCP(11375,(conn) {
bool read_ex = false;
bool write_ex = false;
auto rt = runTask!TCPConnection((conn) {
try {
conn.read(buf);
assert(false, "Expected read() to throw an exception.");
} catch (Exception) {
read_ex = true;
conn.close();
logInfo("read out");
} // expected
}, conn);
auto wt = runTask!TCPConnection((conn) {
try {
conn.write(buf);
assert(false, "Expected read() to throw an exception.");
} catch (Exception) {
write_ex = true;
conn.close();
logInfo("write out");
} // expected
}, conn);

rt.join();
wt.join();
assert(read_ex, "No read exception thrown");
assert(write_ex, "No write exception thrown");
done = true;
});


runTask({
try {
auto conn = connectTCP("127.0.0.1", 11375);
conn.close();
} catch (Exception e) assert(false, e.msg);
sleep(50.msecs);
assert(done, "Not done");

exitEventLoop();
});
}

0 comments on commit f2b5a8f

Please sign in to comment.