test: add test case for cname
This commit is contained in:
@@ -1244,10 +1244,6 @@ int dns_get_domain(struct dns_rrs *rrs, char *domain, int maxsize, int *qtype, i
|
||||
{
|
||||
struct dns_context context;
|
||||
|
||||
if (rrs->type != DNS_T_CNAME) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
_dns_init_context_by_rrs(rrs, &context);
|
||||
return _dns_get_qr_head(&context, domain, maxsize, qtype, qclass);
|
||||
}
|
||||
|
||||
@@ -6110,6 +6110,23 @@ static void _dns_server_tcp_idle_check(void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef TEST
|
||||
static void _dns_server_check_need_exit(void)
|
||||
{
|
||||
static int parent_pid = 0;
|
||||
if (parent_pid == 0) {
|
||||
parent_pid = getppid();
|
||||
}
|
||||
|
||||
if (parent_pid != getppid()) {
|
||||
tlog(TLOG_WARN, "parent process exit, exit too.");
|
||||
dns_server_stop();
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define _dns_server_check_need_exit()
|
||||
#endif
|
||||
|
||||
static void _dns_server_period_run_second(void)
|
||||
{
|
||||
static unsigned int sec = 0;
|
||||
@@ -6152,6 +6169,7 @@ static void _dns_server_period_run_second(void)
|
||||
}
|
||||
|
||||
_dns_server_tcp_idle_check();
|
||||
_dns_server_check_need_exit();
|
||||
|
||||
if (sec % IPV6_READY_CHECK_TIME == 0 && is_ipv6_ready == 0) {
|
||||
_dns_server_check_ipv6_ready();
|
||||
@@ -6812,6 +6830,8 @@ int dns_server_init(void)
|
||||
int epollfd = -1;
|
||||
int ret = -1;
|
||||
|
||||
_dns_server_check_need_exit();
|
||||
|
||||
if (server.epoll_fd > 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -745,11 +745,10 @@ int main(int argc, char *argv[])
|
||||
goto errout;
|
||||
}
|
||||
|
||||
atexit(_smartdns_exit);
|
||||
smartdns_test_notify(1);
|
||||
|
||||
return _smartdns_run();
|
||||
|
||||
ret = _smartdns_run();
|
||||
_smartdns_exit();
|
||||
return ret;
|
||||
errout:
|
||||
smartdns_test_notify(2);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user