mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 14:10:30 +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:
|
private:
|
||||||
string _addr;
|
string _addr;
|
||||||
Tid tid;
|
Tid tid;
|
||||||
|
TcpSocket sock;
|
||||||
|
|
||||||
static void loop(shared TcpSocket listener)
|
static void loop(shared TcpSocket listener)
|
||||||
{
|
{
|
||||||
|
@ -224,21 +225,32 @@ version(unittest)
|
||||||
import std.concurrency : spawn;
|
import std.concurrency : spawn;
|
||||||
import std.socket : INADDR_LOOPBACK, InternetAddress, TcpSocket;
|
import std.socket : INADDR_LOOPBACK, InternetAddress, TcpSocket;
|
||||||
|
|
||||||
|
tlsInit = true;
|
||||||
auto sock = new TcpSocket;
|
auto sock = new TcpSocket;
|
||||||
sock.bind(new InternetAddress(INADDR_LOOPBACK, InternetAddress.PORT_ANY));
|
sock.bind(new InternetAddress(INADDR_LOOPBACK, InternetAddress.PORT_ANY));
|
||||||
sock.listen(1);
|
sock.listen(1);
|
||||||
auto addr = sock.localAddress.toString();
|
auto addr = sock.localAddress.toString();
|
||||||
auto tid = spawn(&TestServer.loop, cast(shared) sock);
|
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()
|
private ref TestServer testServer()
|
||||||
{
|
{
|
||||||
import std.concurrency : initOnce;
|
import std.concurrency : initOnce;
|
||||||
__gshared TestServer server;
|
|
||||||
return initOnce!server(startServer());
|
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)
|
private struct Request(T)
|
||||||
{
|
{
|
||||||
string hdrs;
|
string hdrs;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue