openwrt: save cache to disk when reboot system
This commit is contained in:
@@ -4811,7 +4811,7 @@ static int _dns_server_tcp_process_one_request(struct dns_server_conn_tcp_client
|
||||
request_len = ntohs(*((unsigned short *)(request_data)));
|
||||
|
||||
if (request_len >= sizeof(tcpclient->recvbuff.buf)) {
|
||||
tlog(TLOG_ERROR, "request length is invalid.");
|
||||
tlog(TLOG_DEBUG, "request length is invalid.");
|
||||
return RECV_ERROR_FAIL;
|
||||
}
|
||||
|
||||
@@ -4864,7 +4864,7 @@ static int _dns_server_tcp_process_requests(struct dns_server_conn_tcp_client *t
|
||||
request_ret = _dns_server_tcp_process_one_request(tcpclient);
|
||||
if (request_ret < 0) {
|
||||
/* failed */
|
||||
tlog(TLOG_ERROR, "process one request failed.");
|
||||
tlog(TLOG_DEBUG, "process one request failed.");
|
||||
return RECV_ERROR_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -380,6 +380,7 @@ static int _smartdns_init(void)
|
||||
{
|
||||
int ret = 0;
|
||||
const char *logfile = _smartdns_log_path();
|
||||
int i = 0;
|
||||
|
||||
ret = tlog_init(logfile, dns_conf_log_size, dns_conf_log_num, 0, 0);
|
||||
if (ret != 0) {
|
||||
@@ -401,11 +402,19 @@ static int _smartdns_init(void)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
if (dns_conf_server_num <= 0) {
|
||||
if (_smartdns_load_from_resolv() != 0) {
|
||||
tlog(TLOG_ERROR, "load dns from resolv failed.");
|
||||
goto errout;
|
||||
for (i = 0; i < 60 && dns_conf_server_num <= 0; i++) {
|
||||
ret = _smartdns_load_from_resolv();
|
||||
if (ret == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tlog(TLOG_DEBUG, "load dns from resolv failed, retry after 1s, retry times %d.", i + 1);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
if (dns_conf_server_num <= 0) {
|
||||
tlog(TLOG_ERROR, "no dns server found, exit...");
|
||||
goto errout;
|
||||
}
|
||||
|
||||
ret = fast_ping_init();
|
||||
|
||||
Reference in New Issue
Block a user