Merge pull request #72 from kubo39/res_init
Call __res_init on linux when getaddrinfo failed, fix #40
This commit is contained in:
commit
abdbc91c4b
2
dub.sdl
2
dub.sdl
|
@ -5,7 +5,7 @@ copyright "Copyright © 2012-2016 rejectedsoftware e.K."
|
||||||
|
|
||||||
targetType "library"
|
targetType "library"
|
||||||
|
|
||||||
libs "anl" platform="linux"
|
libs "anl" "resolv" platform="linux"
|
||||||
libs "ws2_32" "user32" platform="windows-dmd"
|
libs "ws2_32" "user32" platform="windows-dmd"
|
||||||
|
|
||||||
dependency "taggedalgebraic" version="~>0.10.4"
|
dependency "taggedalgebraic" version="~>0.10.4"
|
||||||
|
|
|
@ -87,6 +87,8 @@ final class EventDriverDNS_GAI(Events : EventDriverEvents, Signals : EventDriver
|
||||||
version (linx) hints.ai_flags |= AI_V4MAPPED;
|
version (linx) hints.ai_flags |= AI_V4MAPPED;
|
||||||
hints.ai_family = af;
|
hints.ai_family = af;
|
||||||
() @trusted { lookup.retcode = getaddrinfo(lookup.name.toStringz(), null, af == AddressFamily.UNSPEC ? null : &hints, &lookup.result); } ();
|
() @trusted { lookup.retcode = getaddrinfo(lookup.name.toStringz(), null, af == AddressFamily.UNSPEC ? null : &hints, &lookup.result); } ();
|
||||||
|
if (lookup.retcode == -1)
|
||||||
|
version (CRuntime_Glibc) version (linux) __res_init();
|
||||||
events.trigger(event, true);
|
events.trigger(event, true);
|
||||||
debug (EventCoreLogDNS) print("lookup %s finished", lookup.name);
|
debug (EventCoreLogDNS) print("lookup %s finished", lookup.name);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +191,10 @@ final class EventDriverDNS_GAIA(Events : EventDriverEvents, Signals : EventDrive
|
||||||
auto ret = () @trusted { return getaddrinfo_a(GAI_NOWAIT, &res, 1, &evt); } ();
|
auto ret = () @trusted { return getaddrinfo_a(GAI_NOWAIT, &res, 1, &evt); } ();
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
|
{
|
||||||
|
version (CRuntime_Glibc) version (linux) __res_init();
|
||||||
return DNSLookupID.invalid;
|
return DNSLookupID.invalid;
|
||||||
|
}
|
||||||
|
|
||||||
m_lookups[handle].callback = on_lookup_finished;
|
m_lookups[handle].callback = on_lookup_finished;
|
||||||
m_events.loop.m_waiterCount++;
|
m_events.loop.m_waiterCount++;
|
||||||
|
@ -252,6 +257,8 @@ version (linux) extern(C) {
|
||||||
int getaddrinfo_a(int mode, gaicb** list, int nitems, sigevent *sevp);
|
int getaddrinfo_a(int mode, gaicb** list, int nitems, sigevent *sevp);
|
||||||
int gai_error(gaicb *req);
|
int gai_error(gaicb *req);
|
||||||
int gai_cancel(gaicb *req);
|
int gai_cancel(gaicb *req);
|
||||||
|
|
||||||
|
int __res_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -349,5 +356,3 @@ private void passToDNSCallback()(DNSLookupID id, scope DNSLookupCallback cb, DNS
|
||||||
freeaddrinfo(ai_orig);
|
freeaddrinfo(ai_orig);
|
||||||
} catch (Exception e) assert(false, e.msg);
|
} catch (Exception e) assert(false, e.msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue