mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Merge pull request #6234 from rainers/curl_freeze
fix issue 18519 freebsd 11 + phobos + curl, timing out merged-on-behalf-of: Petar Kirov <ZombineDev@users.noreply.github.com>
This commit is contained in:
commit
35e9807bbe
1 changed files with 14 additions and 2 deletions
|
@ -195,6 +195,7 @@ version(unittest)
|
|||
private:
|
||||
string _addr;
|
||||
Tid tid;
|
||||
TcpSocket sock;
|
||||
|
||||
static void loop(shared TcpSocket listener)
|
||||
{
|
||||
|
@ -224,21 +225,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