X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fmodules%2Fc-ares-dns%2Fserv_c-ares-dns.c;h=94592a161ea4ecc06b40c7efc5529207b77c02e5;hb=9563ce7303d1d0d20b963d643f9afc06b53c8e4d;hp=8d65462602e291d9951e18d846545288e66b8a88;hpb=c02a4e1f41d2b1d31a33fa0d1560b226f912693d;p=citadel.git diff --git a/citadel/modules/c-ares-dns/serv_c-ares-dns.c b/citadel/modules/c-ares-dns/serv_c-ares-dns.c index 8d6546260..94592a161 100644 --- a/citadel/modules/c-ares-dns/serv_c-ares-dns.c +++ b/citadel/modules/c-ares-dns/serv_c-ares-dns.c @@ -72,8 +72,8 @@ static void HostByAddrCb(void *data, AsyncIO *IO = data; EV_DNS_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); - EV_DNS_LOGT_STOP(DNS.timeout); + EV_DNS_LOGT_STOP(DNS.timeout); ev_timer_stop (event_base, &IO->DNS.timeout); IO->DNS.Query->DNSStatus = status; @@ -268,9 +268,10 @@ void QueryCb(void *arg, { AsyncIO *IO = arg; + SetEVState(IO, eCaresStart); EV_DNS_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); - EV_DNS_LOGT_STOP(DNS.timeout); + EV_DNS_LOGT_STOP(DNS.timeout); ev_timer_stop (event_base, &IO->DNS.timeout); IO->DNS.Query->DNSStatus = status; @@ -280,7 +281,11 @@ void QueryCb(void *arg, EV_DNS_syslog(LOG_DEBUG, "C-ARES: Failed by: %s error %s\n", __FUNCTION__, ares_strerror(status)); - StrBufPlain(IO->ErrMsg, ares_strerror(status), -1); + StrBufPrintf(IO->ErrMsg, + "%s-lookup %s - %s", + IO->DNS.Query->QueryTYPE, + (IO->DNS.Query->QStr != NULL)? IO->DNS.Query->QStr : "", + ares_strerror(status)); IO->DNS.Query->DNSStatus = status; } @@ -294,22 +299,31 @@ void QueryCb(void *arg, void QueryCbDone(AsyncIO *IO) { + SetEVState(IO, eCaresDoneIO); EV_DNS_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); + EV_DNS_LOGT_STOP(DNS.timeout); + ev_timer_stop (event_base, &IO->DNS.timeout); + EV_DNS_LOGT_STOP(unwind_stack); ev_idle_stop(event_base, &IO->unwind_stack); } void DestructCAres(AsyncIO *IO) { - EV_DNS_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); - EV_DNS_LOGT_STOP(DNS.timeout); + SetEVState(IO, eCaresX); + EVNC_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); - EV_DNS_LOG_STOP(DNS.recv_event); + EVNC_syslog(LOG_DEBUG, "C-ARES: - stopping %s %d %p \n", "DNS.recv_event", IO->DNS.recv_event.fd, &IO->DNS.recv_event); ev_io_stop(event_base, &IO->DNS.recv_event); - EV_DNS_LOG_STOP(DNS.send_event); + + EVNC_syslog(LOG_DEBUG, "C-ARES: - stopping %s %d %p\n", "DNS.send_event", IO->DNS.send_event.fd, &IO->DNS.send_event); ev_io_stop(event_base, &IO->DNS.send_event); + + EVNC_syslog(LOG_DEBUG, "C-ARES: - stopping %s %p\n", "DNS.timeout", &IO->DNS.send_event); ev_timer_stop (event_base, &IO->DNS.timeout); + + EVNC_syslog(LOG_DEBUG, "C-ARES: - stopping %s %p\n", "DNS.unwind_stack", &IO->unwind_stack); ev_idle_stop(event_base, &IO->unwind_stack); ares_destroy_options(&IO->DNS.Options); } @@ -369,13 +383,16 @@ void QueueGetHostByNameDone(void *Ctx, IO->DNS.Query->VParsedDNSReply = hostent; IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_hostent; + EV_DNS_LOGT_STOP(DNS.timeout); + ev_timer_stop (event_base, &IO->DNS.timeout); + ev_idle_init(&IO->unwind_stack, IO_postdns_callback); IO->unwind_stack.data = IO; EV_DNS_LOGT_INIT(unwind_stack); EV_DNS_LOGT_START(unwind_stack); ev_idle_start(event_base, &IO->unwind_stack); - ev_timer_stop (event_base, &IO->DNS.timeout); + } void QueueGetHostByName(AsyncIO *IO, @@ -405,6 +422,17 @@ void QueueGetHostByName(AsyncIO *IO, } +const char* QT[] = { + "A", + "AAAA", + "MX", + "NS", + "TXT", + "SRV", + "CNAME", + "PTR" +}; + int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, @@ -419,6 +447,7 @@ int QueueQuery(ns_type Type, IO->DNS.Query = QueryParts; IO->DNS.Query->PostDNS = PostDNS; IO->DNS.Start = IO->Now; + IO->DNS.Query->QStr = name; InitC_ares_dns(IO); @@ -429,35 +458,41 @@ int QueueQuery(ns_type Type, switch(Type) { case ns_t_a: IO->DNS.Query->DNS_CB = ParseAnswerA; + IO->DNS.Query->QueryTYPE = QT[0]; break; case ns_t_aaaa: IO->DNS.Query->DNS_CB = ParseAnswerAAAA; + IO->DNS.Query->QueryTYPE = QT[1]; break; case ns_t_mx: IO->DNS.Query->DNS_CB = ParseAnswerMX; + IO->DNS.Query->QueryTYPE = QT[2]; break; case ns_t_ns: IO->DNS.Query->DNS_CB = ParseAnswerNS; + IO->DNS.Query->QueryTYPE = QT[3]; break; case ns_t_txt: IO->DNS.Query->DNS_CB = ParseAnswerTXT; + IO->DNS.Query->QueryTYPE = QT[4]; break; case ns_t_srv: IO->DNS.Query->DNS_CB = ParseAnswerSRV; + IO->DNS.Query->QueryTYPE = QT[5]; break; case ns_t_cname: IO->DNS.Query->DNS_CB = ParseAnswerCNAME; + IO->DNS.Query->QueryTYPE = QT[6]; break; case ns_t_ptr: - - + IO->DNS.Query->QueryTYPE = QT[7]; if (inet_pton(AF_INET, name, &address_b) == 1) { length = sizeof(struct in_addr); family = AF_INET;