mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
fix issue 18519 freebsd 11 + phobos + curl, timing out
stop the TestServer waiting in accept() before thread_joinall
This commit is contained in:
parent
93dc74be78
commit
b8e5bca94b
1 changed files with 14 additions and 2 deletions
|
@ -185,6 +185,7 @@ version(unittest)
|
|||
private:
|
||||
string _addr;
|
||||
Tid tid;
|
||||
TcpSocket sock;
|
||||
|
||||
static void loop(shared TcpSocket listener)
|
||||
{
|
||||
|
@ -214,21 +215,32 @@ version(unittest)
|
|||
import std.concurrency : spawn;
|
||||
import std.socket : INADDR_LOOPBACK, InternetAddress, TcpSocket;
|
||||
|
||||
tlsInit = true;
|
||||
auto sock = new TcpSocket;
|
||||
sock.bind(new InternetAddress(INADDR_LOOPBACK, InternetAddress.PORT_ANY));
|
||||
sock.listen(1);
|
||||
auto addr = sock.localAddress.toString();
|
||||
auto tid = spawn(&TestServer.loop, cast(shared) sock);
|
||||
return TestServer(addr, tid);
|
||||
return TestServer(addr, tid, sock);
|
||||
}
|
||||
|
||||
__gshared TestServer server;
|
||||
bool tlsInit;
|
||||
|
||||
private ref TestServer testServer()
|
||||
{
|
||||
import std.concurrency : initOnce;
|
||||
__gshared TestServer server;
|
||||
return initOnce!server(startServer());
|
||||
}
|
||||
|
||||
static ~this()
|
||||
{
|
||||
// terminate server from a thread local dtor of the thread that started it,
|
||||
// because thread_joinall is called before shared module dtors
|
||||
if (tlsInit && server.sock)
|
||||
server.sock.close();
|
||||
}
|
||||
|
||||
private struct Request(T)
|
||||
{
|
||||
string hdrs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue