From 5268c0a9bf8202336b9e3e8b86f45d9d010f2811 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 25 Dec 2011 16:51:17 +0100 Subject: [PATCH] Move c-ares related data into its own Sub-Struct --- citadel/event_client.c | 18 +- citadel/event_client.h | 29 ++- citadel/modules/c-ares-dns/serv_c-ares-dns.c | 240 +++++++++---------- citadel/modules/network/serv_networkclient.c | 2 +- citadel/modules/pop3client/serv_pop3client.c | 2 +- citadel/modules/smtp/serv_smtpeventclient.c | 8 +- 6 files changed, 152 insertions(+), 147 deletions(-) diff --git a/citadel/event_client.c b/citadel/event_client.c index d87d6697f..27e8a8146 100644 --- a/citadel/event_client.c +++ b/citadel/event_client.c @@ -259,11 +259,11 @@ void ShutDownCLient(AsyncIO *IO) ev_cleanup_stop(event_base, &IO->abort_by_shutdown); StopClientWatchers(IO); - if (IO->DNSChannel != NULL) { - ares_destroy(IO->DNSChannel); - ev_io_stop(event_base, &IO->dns_recv_event); - ev_io_stop(event_base, &IO->dns_send_event); - IO->DNSChannel = NULL; + if (IO->DNS.Channel != NULL) { + ares_destroy(IO->DNS.Channel); + ev_io_stop(event_base, &IO->DNS.recv_event); + ev_io_stop(event_base, &IO->DNS.send_event); + IO->DNS.Channel = NULL; } assert(IO->Terminate); IO->Terminate(IO); @@ -683,12 +683,12 @@ IO_postdns_callback(struct ev_loop *loop, ev_idle *watcher, int revents) AsyncIO *IO = watcher->data; EV_syslog(LOG_DEBUG, "event: %s\n", __FUNCTION__); become_session(IO->CitContext); - assert(IO->DNSFail); - assert(IO->DNSQuery->PostDNS); - switch (IO->DNSQuery->PostDNS(IO)) + assert(IO->DNS.Fail); + assert(IO->DNS.Query->PostDNS); + switch (IO->DNS.Query->PostDNS(IO)) { case eAbort: - switch (IO->DNSFail(IO)) { + switch (IO->DNS.Fail(IO)) { case eAbort: ShutDownCLient(IO); default: diff --git a/citadel/event_client.h b/citadel/event_client.h index 7210fcb41..0b71c743e 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -78,6 +78,21 @@ typedef struct _evcurl_request_data long httpcode; } evcurl_request_data; +/* DNS Related */ +typedef struct __evcares_data { + ev_io recv_event, + send_event; + ev_timer timeout; /* timeout while requesting ips */ +#ifdef DEBUG_CARES + short int SourcePort; +#endif + struct ares_options Options; + ares_channel Channel; + DNSQueryParts *Query; + + IO_CallBack Fail; /* the dns lookup didn't work out. */ +} evcares_data; + struct AsyncIO { long ID; eNextState NextState; @@ -112,23 +127,13 @@ struct AsyncIO { Terminate, /* shutting down... */ Timeout, /* Timeout handler; may also be connection timeout */ ConnFail, /* What to do when one connection failed? */ - DNSFail, /* the dns lookup didn't work out. */ ShutdownAbort,/* we're going down. make your piece. */ NextDBOperation; /* Perform Database IO */ IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */ - /* DNS Related */ - ev_io dns_recv_event, - dns_send_event; - ev_timer dns_timeout; /* timeout while requesting ips */ -#ifdef DEBUG_CARES - short int DnsSourcePort; -#endif - struct ares_options DNSOptions; - ares_channel DNSChannel; - DNSQueryParts *DNSQuery; - + evcares_data DNS; + evcurl_request_data HttpReq; /* Saving / loading a message async from / to disk */ 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 8a18b3259..642abb260 100644 --- a/citadel/modules/c-ares-dns/serv_c-ares-dns.c +++ b/citadel/modules/c-ares-dns/serv_c-ares-dns.c @@ -72,14 +72,14 @@ static void HostByAddrCb(void *data, #ifdef DEBUG_CARES EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - ev_timer_stop (event_base, &IO->dns_timeout); + ev_timer_stop (event_base, &IO->DNS.timeout); - IO->DNSQuery->DNSStatus = status; + IO->DNS.Query->DNSStatus = status; if (status != ARES_SUCCESS) { StrBufPlain(IO->ErrMsg, ares_strerror(status), -1); return; } - IO->DNSQuery->Data = hostent; + IO->DNS.Query->Data = hostent; /// TODO: howto free this?? } @@ -90,17 +90,17 @@ static void ParseAnswerA(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_a_reply(abuf, alen, &host, NULL, NULL); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_a_reply(abuf, alen, &host, NULL, NULL); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } - IO->DNSQuery->VParsedDNSReply = host; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_hostent; + IO->DNS.Query->VParsedDNSReply = host; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_hostent; } @@ -111,17 +111,17 @@ static void ParseAnswerAAAA(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } - IO->DNSQuery->VParsedDNSReply = host; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_hostent; + IO->DNS.Query->VParsedDNSReply = host; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_hostent; } @@ -133,19 +133,19 @@ static void ParseAnswerCNAME(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_a_reply(abuf, alen, &host, NULL, NULL); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_a_reply(abuf, alen, &host, NULL, NULL); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } // a CNAME lookup always returns a single record but - IO->DNSQuery->VParsedDNSReply = host; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_hostent; + IO->DNS.Query->VParsedDNSReply = host; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_hostent; } @@ -156,18 +156,18 @@ static void ParseAnswerMX(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_mx_reply(abuf, alen, &mx_out); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_mx_reply(abuf, alen, &mx_out); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } - IO->DNSQuery->VParsedDNSReply = mx_out; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_data; + IO->DNS.Query->VParsedDNSReply = mx_out; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_data; } @@ -178,17 +178,17 @@ static void ParseAnswerNS(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_ns_reply(abuf, alen, &host); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_ns_reply(abuf, alen, &host); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } - IO->DNSQuery->VParsedDNSReply = host; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_hostent; + IO->DNS.Query->VParsedDNSReply = host; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_hostent; } @@ -199,18 +199,18 @@ static void ParseAnswerSRV(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_srv_reply(abuf, alen, &srv_out); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_srv_reply(abuf, alen, &srv_out); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } - IO->DNSQuery->VParsedDNSReply = srv_out; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_data; + IO->DNS.Query->VParsedDNSReply = srv_out; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_data; } @@ -221,17 +221,17 @@ static void ParseAnswerTXT(AsyncIO *IO, unsigned char* abuf, int alen) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - if (IO->DNSQuery->VParsedDNSReply != NULL) - IO->DNSQuery->DNSReplyFree(IO->DNSQuery->VParsedDNSReply); - IO->DNSQuery->VParsedDNSReply = NULL; + if (IO->DNS.Query->VParsedDNSReply != NULL) + IO->DNS.Query->DNSReplyFree(IO->DNS.Query->VParsedDNSReply); + IO->DNS.Query->VParsedDNSReply = NULL; - IO->DNSQuery->DNSStatus = ares_parse_txt_reply(abuf, alen, &txt_out); - if (IO->DNSQuery->DNSStatus != ARES_SUCCESS) { - StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNSQuery->DNSStatus), -1); + IO->DNS.Query->DNSStatus = ares_parse_txt_reply(abuf, alen, &txt_out); + if (IO->DNS.Query->DNSStatus != ARES_SUCCESS) { + StrBufPlain(IO->ErrMsg, ares_strerror(IO->DNS.Query->DNSStatus), -1); return; } - IO->DNSQuery->VParsedDNSReply = txt_out; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_data; + IO->DNS.Query->VParsedDNSReply = txt_out; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_data; } void QueryCb(void *arg, @@ -244,17 +244,17 @@ void QueryCb(void *arg, #ifdef DEBUG_CARES EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - ev_timer_stop (event_base, &IO->dns_timeout); + ev_timer_stop (event_base, &IO->DNS.timeout); - IO->DNSQuery->DNSStatus = status; + IO->DNS.Query->DNSStatus = status; if (status == ARES_SUCCESS) - IO->DNSQuery->DNS_CB(arg, abuf, alen); + IO->DNS.Query->DNS_CB(arg, abuf, alen); else { EV_syslog(LOG_DEBUG, "C-ARES: Failed by: %s error %s\n", __FUNCTION__, ares_strerror(status)); StrBufPlain(IO->ErrMsg, ares_strerror(status), -1); - IO->DNSQuery->DNSStatus = status; + IO->DNS.Query->DNSStatus = status; } ev_idle_init(&IO->unwind_stack, @@ -277,20 +277,20 @@ void InitC_ares_dns(AsyncIO *IO) { int optmask = 0; #ifdef DEBUG_CARES - EV_syslog(LOG_DEBUG, "C-ARES: %s %p\n", __FUNCTION__, IO->DNSChannel); + EV_syslog(LOG_DEBUG, "C-ARES: %s %p\n", __FUNCTION__, IO->DNS.Channel); #endif - if (IO->DNSChannel == NULL) { + if (IO->DNS.Channel == NULL) { optmask |= ARES_OPT_SOCK_STATE_CB; - IO->DNSOptions.sock_state_cb = SockStateCb; - IO->DNSOptions.sock_state_cb_data = IO; - ares_init_options(&IO->DNSChannel, &IO->DNSOptions, optmask); + IO->DNS.Options.sock_state_cb = SockStateCb; + IO->DNS.Options.sock_state_cb_data = IO; + ares_init_options(&IO->DNS.Channel, &IO->DNS.Options, optmask); } - IO->DNSQuery->DNSStatus = 0; + IO->DNS.Query->DNSStatus = 0; } static void -DNS_timeouttrigger_callback(struct ev_loop *loop, ev_timer *watcher, int revents) +DNStimeouttrigger_callback(struct ev_loop *loop, ev_timer *watcher, int revents) { AsyncIO *IO = watcher->data; struct timeval tv, MaxTV; @@ -299,7 +299,7 @@ DNS_timeouttrigger_callback(struct ev_loop *loop, ev_timer *watcher, int revents memset(&MaxTV, 0, sizeof(MaxTV)); memset(&tv, 0, sizeof(tv)); MaxTV.tv_sec = 30; - NextTV = ares_timeout(IO->DNSChannel, &MaxTV, &tv); + NextTV = ares_timeout(IO->DNS.Channel, &MaxTV, &tv); if ((NextTV->tv_sec != MaxTV.tv_sec) || (NextTV->tv_usec != MaxTV.tv_usec)) @@ -310,8 +310,8 @@ DNS_timeouttrigger_callback(struct ev_loop *loop, ev_timer *watcher, int revents #endif FD_ZERO(&readers); FD_ZERO(&writers); - ares_fds(IO->DNSChannel, &readers, &writers); - ares_process(IO->DNSChannel, &readers, &writers); + ares_fds(IO->DNS.Channel, &readers, &writers); + ares_process(IO->DNS.Channel, &readers, &writers); } } @@ -325,9 +325,9 @@ void QueueGetHostByNameDone(void *Ctx, EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - IO->DNSQuery->DNSStatus = status; - IO->DNSQuery->VParsedDNSReply = hostent; - IO->DNSQuery->DNSReplyFree = (FreeDNSReply) ares_free_hostent; + IO->DNS.Query->DNSStatus = status; + IO->DNS.Query->VParsedDNSReply = hostent; + IO->DNS.Query->DNSReplyFree = (FreeDNSReply) ares_free_hostent; ev_idle_init(&IO->unwind_stack, IO_postdns_callback); @@ -339,22 +339,22 @@ void QueueGetHostByName(AsyncIO *IO, const char *Hostname, DNSQueryParts *QueryP { #ifdef DEBUG_CARES EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); - IO->DnsSourcePort = 0; + IO->DNS.SourcePort = 0; #endif - IO->DNSQuery = QueryParts; - IO->DNSQuery->PostDNS = PostDNS; + IO->DNS.Query = QueryParts; + IO->DNS.Query->PostDNS = PostDNS; InitC_ares_dns(IO); - ev_timer_init(&IO->dns_timeout, DNS_timeouttrigger_callback, 10, 1); - IO->dns_timeout.data = IO; - ares_gethostbyname(IO->DNSChannel, + ev_timer_init(&IO->DNS.timeout, DNStimeouttrigger_callback, 10, 1); + IO->DNS.timeout.data = IO; + ares_gethostbyname(IO->DNS.Channel, Hostname, AF_INET6, /* it falls back to ipv4 in doubt... */ QueueGetHostByNameDone, IO); - ev_timer_start(event_base, &IO->dns_timeout); + ev_timer_start(event_base, &IO->DNS.timeout); } int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *QueryParts, IO_CallBack PostDNS) @@ -363,44 +363,44 @@ int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *Query char address_b[sizeof(struct in6_addr)]; #ifdef DEBUG_CARES - IO->DnsSourcePort = 0; + IO->DNS.SourcePort = 0; #endif - IO->DNSQuery = QueryParts; - IO->DNSQuery->PostDNS = PostDNS; + IO->DNS.Query = QueryParts; + IO->DNS.Query->PostDNS = PostDNS; InitC_ares_dns(IO); - ev_timer_init(&IO->dns_timeout, DNS_timeouttrigger_callback, 10, 1); - IO->dns_timeout.data = IO; + ev_timer_init(&IO->DNS.timeout, DNStimeouttrigger_callback, 10, 1); + IO->DNS.timeout.data = IO; switch(Type) { case ns_t_a: - IO->DNSQuery->DNS_CB = ParseAnswerA; + IO->DNS.Query->DNS_CB = ParseAnswerA; break; case ns_t_aaaa: - IO->DNSQuery->DNS_CB = ParseAnswerAAAA; + IO->DNS.Query->DNS_CB = ParseAnswerAAAA; break; case ns_t_mx: - IO->DNSQuery->DNS_CB = ParseAnswerMX; + IO->DNS.Query->DNS_CB = ParseAnswerMX; break; case ns_t_ns: - IO->DNSQuery->DNS_CB = ParseAnswerNS; + IO->DNS.Query->DNS_CB = ParseAnswerNS; break; case ns_t_txt: - IO->DNSQuery->DNS_CB = ParseAnswerTXT; + IO->DNS.Query->DNS_CB = ParseAnswerTXT; break; case ns_t_srv: - IO->DNSQuery->DNS_CB = ParseAnswerSRV; + IO->DNS.Query->DNS_CB = ParseAnswerSRV; break; case ns_t_cname: - IO->DNSQuery->DNS_CB = ParseAnswerCNAME; + IO->DNS.Query->DNS_CB = ParseAnswerCNAME; break; case ns_t_ptr: @@ -416,8 +416,8 @@ int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *Query return -1; } - ares_gethostbyaddr(IO->DNSChannel, address_b, length, family, HostByAddrCb, IO); - ev_timer_start(event_base, &IO->dns_timeout); + ares_gethostbyaddr(IO->DNS.Channel, address_b, length, family, HostByAddrCb, IO); + ev_timer_start(event_base, &IO->DNS.timeout); #ifdef DEBUG_CARES EV_syslog(LOG_DEBUG, "C-ARES: %s X1\n", __FUNCTION__); #endif @@ -432,8 +432,8 @@ int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, DNSQueryParts *Query #ifdef DEBUG_CARES EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - ares_query(IO->DNSChannel, name, ns_c_in, Type, QueryCb, IO); - ev_timer_start(event_base, &IO->dns_timeout); + ares_query(IO->DNS.Channel, name, ns_c_in, Type, QueryCb, IO); + ev_timer_start(event_base, &IO->DNS.timeout); return 1; } @@ -452,7 +452,7 @@ static void DNS_send_callback(struct ev_loop *loop, ev_io *watcher, int revents) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - ares_process_fd(IO->DNSChannel, ARES_SOCKET_BAD, IO->dns_send_event.fd); + ares_process_fd(IO->DNS.Channel, ARES_SOCKET_BAD, IO->DNS.send_event.fd); } static void DNS_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents) { @@ -462,7 +462,7 @@ static void DNS_recv_callback(struct ev_loop *loop, ev_io *watcher, int revents) EV_syslog(LOG_DEBUG, "C-ARES: %s\n", __FUNCTION__); #endif - ares_process_fd(IO->DNSChannel, IO->dns_recv_event.fd, ARES_SOCKET_BAD); + ares_process_fd(IO->DNS.Channel, IO->DNS.recv_event.fd, ARES_SOCKET_BAD); } void SockStateCb(void *data, int sock, int read, int write) @@ -474,43 +474,43 @@ void SockStateCb(void *data, int sock, int read, int write) struct sockaddr_in sin = {}; socklen_t slen; slen = sizeof(sin); - if ((IO->DnsSourcePort == 0) && + if ((IO->DNS.SourcePort == 0) && (getsockname(sock, &sin, &slen) == 0)) { - IO->DnsSourcePort = ntohs(sin.sin_port); + IO->DNS.SourcePort = ntohs(sin.sin_port); } EV_syslog(LOG_DEBUG, "C-ARES: %s %d|%d Sock %d port %hu\n", __FUNCTION__, read, write, sock, - IO->DnsSourcePort); + IO->DNS.SourcePort); } #endif if (read) { - if ((IO->dns_recv_event.fd != sock) && - (IO->dns_recv_event.fd != 0)) { - ev_io_stop(event_base, &IO->dns_recv_event); + if ((IO->DNS.recv_event.fd != sock) && + (IO->DNS.recv_event.fd != 0)) { + ev_io_stop(event_base, &IO->DNS.recv_event); } - IO->dns_recv_event.fd = sock; - ev_io_init(&IO->dns_recv_event, DNS_recv_callback, IO->dns_recv_event.fd, EV_READ); - IO->dns_recv_event.data = IO; - ev_io_start(event_base, &IO->dns_recv_event); + IO->DNS.recv_event.fd = sock; + ev_io_init(&IO->DNS.recv_event, DNS_recv_callback, IO->DNS.recv_event.fd, EV_READ); + IO->DNS.recv_event.data = IO; + ev_io_start(event_base, &IO->DNS.recv_event); } if (write) { - if ((IO->dns_send_event.fd != sock) && - (IO->dns_send_event.fd != 0)) { - ev_io_stop(event_base, &IO->dns_send_event); + if ((IO->DNS.send_event.fd != sock) && + (IO->DNS.send_event.fd != 0)) { + ev_io_stop(event_base, &IO->DNS.send_event); } - IO->dns_send_event.fd = sock; - ev_io_init(&IO->dns_send_event, DNS_send_callback, IO->dns_send_event.fd, EV_WRITE); - IO->dns_send_event.data = IO; - ev_io_start(event_base, &IO->dns_send_event); + IO->DNS.send_event.fd = sock; + ev_io_init(&IO->DNS.send_event, DNS_send_callback, IO->DNS.send_event.fd, EV_WRITE); + IO->DNS.send_event.data = IO; + ev_io_start(event_base, &IO->DNS.send_event); } if ((read == 0) && (write == 0)) { - ev_io_stop(event_base, &IO->dns_recv_event); - ev_io_stop(event_base, &IO->dns_send_event); + ev_io_stop(event_base, &IO->DNS.recv_event); + ev_io_stop(event_base, &IO->DNS.send_event); } } diff --git a/citadel/modules/network/serv_networkclient.c b/citadel/modules/network/serv_networkclient.c index 3098ce474..338425e76 100644 --- a/citadel/modules/network/serv_networkclient.c +++ b/citadel/modules/network/serv_networkclient.c @@ -807,7 +807,7 @@ void RunNetworker(AsyncNetworker *NW) NW->IO.Terminate = NWC_Terminate; NW->IO.LineReader = NWC_ReadServerStatus; NW->IO.ConnFail = NWC_ConnFail; - NW->IO.DNSFail = NWC_DNSFail; + NW->IO.DNS.Fail = NWC_DNSFail; NW->IO.Timeout = NWC_Timeout; NW->IO.ShutdownAbort = NWC_Shutdown; diff --git a/citadel/modules/pop3client/serv_pop3client.c b/citadel/modules/pop3client/serv_pop3client.c index efe1c8d8c..e20f16f70 100644 --- a/citadel/modules/pop3client/serv_pop3client.c +++ b/citadel/modules/pop3client/serv_pop3client.c @@ -852,7 +852,7 @@ int pop3_do_fetching(pop3aggr *cpptr) cpptr->IO.Terminate = POP3_C_Terminate; cpptr->IO.LineReader = POP3_C_ReadServerStatus; cpptr->IO.ConnFail = POP3_C_ConnFail; - cpptr->IO.DNSFail = POP3_C_DNSFail; + cpptr->IO.DNS.Fail = POP3_C_DNSFail; cpptr->IO.Timeout = POP3_C_Timeout; cpptr->IO.ShutdownAbort = POP3_C_Shutdown; diff --git a/citadel/modules/smtp/serv_smtpeventclient.c b/citadel/modules/smtp/serv_smtpeventclient.c index efc274d37..8e0d09132 100644 --- a/citadel/modules/smtp/serv_smtpeventclient.c +++ b/citadel/modules/smtp/serv_smtpeventclient.c @@ -361,13 +361,13 @@ eNextState smtp_resolve_mx_record_done(AsyncIO *IO) while ((pp != NULL) && (*pp != NULL) && ((*pp)->Next != NULL)) pp = &(*pp)->Next; - if ((IO->DNSQuery->DNSStatus == ARES_SUCCESS) && - (IO->DNSQuery->VParsedDNSReply != NULL)) + if ((IO->DNS.Query->DNSStatus == ARES_SUCCESS) && + (IO->DNS.Query->VParsedDNSReply != NULL)) { /* ok, we found mx records. */ SendMsg->IO.ErrMsg = SendMsg->MyQEntry->StatusMessage; SendMsg->CurrMX = SendMsg->AllMX - = IO->DNSQuery->VParsedDNSReply; + = IO->DNS.Query->VParsedDNSReply; while (SendMsg->CurrMX) { int i; for (i = 0; i < 2; i++) { @@ -457,7 +457,7 @@ SmtpOutMsg *new_smtp_outmsg(OneQueItem *MyQItem, SendMsg->IO.Terminate = SMTP_C_Terminate; SendMsg->IO.LineReader = SMTP_C_ReadServerStatus; SendMsg->IO.ConnFail = SMTP_C_ConnFail; - SendMsg->IO.DNSFail = SMTP_C_DNSFail; + SendMsg->IO.DNS.Fail = SMTP_C_DNSFail; SendMsg->IO.Timeout = SMTP_C_Timeout; SendMsg->IO.ShutdownAbort = SMTP_C_Shutdown; -- 2.30.2