dns_client: fix crash issue when upstream response delay is lower than 1ms
This commit is contained in:
@@ -3135,11 +3135,13 @@ int dns_client_query(const char *domain, int qtype, dns_client_callback callback
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&client.domain_map_lock);
|
||||
if (list_empty(&client.dns_request_list)) {
|
||||
pthread_cond_signal(&client.run_cond);
|
||||
}
|
||||
if (hash_hashed(&query->domain_node)) {
|
||||
if (list_empty(&client.dns_request_list)) {
|
||||
pthread_cond_signal(&client.run_cond);
|
||||
}
|
||||
|
||||
list_add_tail(&query->dns_request_list, &client.dns_request_list);
|
||||
list_add_tail(&query->dns_request_list, &client.dns_request_list);
|
||||
}
|
||||
pthread_mutex_unlock(&client.domain_map_lock);
|
||||
|
||||
tlog(TLOG_INFO, "send request %s, qtype %d, id %d\n", domain, qtype, query->sid);
|
||||
|
||||
@@ -908,7 +908,7 @@ static int _dns_server_reply_udp(struct dns_request *request, struct dns_server_
|
||||
struct iovec iovec[1];
|
||||
struct msghdr msg;
|
||||
struct cmsghdr *cmsg;
|
||||
char msg_control[256];
|
||||
char msg_control[64];
|
||||
|
||||
if (atomic_read(&server.run) == 0 || inpacket == NULL || inpacket_len <= 0) {
|
||||
return -1;
|
||||
@@ -916,6 +916,7 @@ static int _dns_server_reply_udp(struct dns_request *request, struct dns_server_
|
||||
|
||||
iovec[0].iov_base = inpacket;
|
||||
iovec[0].iov_len = inpacket_len;
|
||||
memset(msg_control, 0, sizeof(msg_control));
|
||||
msg.msg_iov = iovec;
|
||||
msg.msg_iovlen = 1;
|
||||
msg.msg_control = msg_control;
|
||||
|
||||
Reference in New Issue
Block a user