Merge pull request #72 from kubo39/res_init

Call __res_init on linux when getaddrinfo failed, fix #40
This commit is contained in:
Sönke Ludwig 2018-05-13 09:45:12 +02:00 committed by GitHub
commit abdbc91c4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -5,7 +5,7 @@ copyright "Copyright © 2012-2016 rejectedsoftware e.K."
targetType "library"
libs "anl" platform="linux"
libs "anl" "resolv" platform="linux"
libs "ws2_32" "user32" platform="windows-dmd"
dependency "taggedalgebraic" version="~>0.10.4"

View file

@ -87,6 +87,8 @@ final class EventDriverDNS_GAI(Events : EventDriverEvents, Signals : EventDriver
version (linx) hints.ai_flags |= AI_V4MAPPED;
hints.ai_family = af;
() @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);
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); } ();
if (ret != 0)
{
version (CRuntime_Glibc) version (linux) __res_init();
return DNSLookupID.invalid;
}
m_lookups[handle].callback = on_lookup_finished;
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 gai_error(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);
} catch (Exception e) assert(false, e.msg);
}