From 4e209968feddb564463d0dfca44905116a48b827 Mon Sep 17 00:00:00 2001 From: Bram Matthys Date: Thu, 30 Dec 2021 14:47:29 +0100 Subject: [PATCH] Fix hang on "Loading IRCd configuration" if DNS is not working correctly. For example if the 1st DNS resolver is refusing or ignoring requests. We forgot to call unrealdns_timeout() in the waiting loop, so DNS requests never timed out and c-ares didn't try the 2nd/3rd server either. Issue reported by Elodie. --- include/h.h | 1 + src/dns.c | 2 +- src/ircd.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/h.h b/include/h.h index 6b380f5a4..791cbd5db 100644 --- a/include/h.h +++ b/include/h.h @@ -859,6 +859,7 @@ extern const char *cmdname_by_spamftarget(int target); extern void unrealdns_delreq_bycptr(Client *cptr); extern void unrealdns_gethostbyname_link(const char *name, ConfigItem_link *conf, int ipv4_only); extern void unrealdns_delasyncconnects(void); +extern EVENT(unrealdns_timeout); extern int is_autojoin_chan(const char *chname); extern void unreal_free_hostent(struct hostent *he); extern struct hostent *unreal_create_hostent(const char *name, const char *ip); diff --git a/src/dns.c b/src/dns.c index d8cb660ac..4335efe5f 100644 --- a/src/dns.c +++ b/src/dns.c @@ -113,7 +113,7 @@ static int unrealdns_sock_create_cb(ares_socket_t fd, int type, void *data) return ARES_SUCCESS; } -static EVENT(unrealdns_timeout) +EVENT(unrealdns_timeout) { ares_process_fd(resolver_channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); } diff --git a/src/ircd.c b/src/ircd.c index dbb5554f9..4477bdfab 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -1056,6 +1056,7 @@ int InitUnrealIRCd(int argc, char *argv[]) gettimeofday(&timeofday_tv, NULL); timeofday = timeofday_tv.tv_sec; url_socket_timeout(NULL); + unrealdns_timeout(NULL); fd_select(500); } if (config_test() < 0)