-
Notifications
You must be signed in to change notification settings - Fork 284
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid double-resumption of task on active connection close. Fixes #1376.
With a concurrent read operation, the libevent active TCP connection close function could result in a double-resumption of the read task, if the close happened in the same event loop round as a read-ready or close event on the socket.
- Loading branch information
Showing
3 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import vibe.core.core; | ||
import vibe.core.net; | ||
import core.time : msecs; | ||
|
||
shared static this() | ||
{ | ||
listenTCP(11375,(conn){ | ||
auto td = runTask({ | ||
ubyte [3] buf; | ||
try { | ||
conn.read(buf); | ||
assert(false, "Expected read() to throw an exception."); | ||
} catch (Exception) {} // expected | ||
}); | ||
conn.close(); | ||
}); | ||
|
||
runTask({ | ||
auto conn = connectTCP("127.0.0.1", 11375); | ||
conn.write("a"); | ||
conn.close(); | ||
|
||
conn = connectTCP("127.0.0.1", 11375); | ||
conn.close(); | ||
|
||
sleep(50.msecs); | ||
exitEventLoop(); | ||
}); | ||
} |