Skip to content

Commit

Permalink
Add test for issue #1429.
Browse files Browse the repository at this point in the history
UDP receive timeout doesn't work for the libevent driver.

(cherry picked from commit 443e071)
  • Loading branch information
s-ludwig committed Feb 20, 2016
1 parent a9c5374 commit 6997dc3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/vibe.core.net.1429/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"
29 changes: 29 additions & 0 deletions tests/vibe.core.net.1429/source/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import vibe.core.core;
import vibe.core.log : logInfo;
import vibe.core.net;
import core.time : msecs;
import std.datetime : Clock, UTC;

shared static this()
{
auto udp = listenUDP(11429, "127.0.0.1");

runTask({
sleep(500.msecs);
assert(false, "Receive call did not return in a timely manner. Killing process.");
});

runTask({
auto start = Clock.currTime(UTC());
try {
udp.recv(100.msecs);
assert(false, "Timeout did not occur.");
} catch (Exception e) {
auto duration = Clock.currTime(UTC()) - start;
assert(duration >= 99.msecs, "Timeout occurred too early");
assert(duration >= 99.msecs && duration < 150.msecs, "Timeout occurred too late.");
logInfo("UDP receive timeout test was successful.");
exitEventLoop();
}
});
}

0 comments on commit 6997dc3

Please sign in to comment.