mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-28 13:49:01 +08:00
Set DNS error on UDP send error
This commit is contained in:
parent
b42ea6cd3c
commit
6990040626
15
src/dns.c
15
src/dns.c
@ -192,7 +192,7 @@ static void dns_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
(void) fn_data;
|
||||
}
|
||||
|
||||
static void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
|
||||
static bool mg_dns_send(struct mg_connection *c, const struct mg_str *name,
|
||||
uint16_t txnid, bool ipv6) {
|
||||
struct {
|
||||
struct mg_dns_header header;
|
||||
@ -216,14 +216,7 @@ static void mg_dns_send(struct mg_connection *c, const struct mg_str *name,
|
||||
if (ipv6) pkt.data[n - 3] = 0x1c; // AAAA query
|
||||
// memcpy(&pkt.data[n], "\xc0\x0c\x00\x1c\x00\x01", 6); // AAAA query
|
||||
// n += 6;
|
||||
mg_send(c, &pkt, sizeof(pkt.header) + n);
|
||||
#if 0
|
||||
// Immediately after A query, send AAAA query. Whatever reply comes first,
|
||||
// we'll use it. Note: we cannot send two queries in a single packet.
|
||||
// https://stackoverflow.com/questions/4082081/requesting-a-and-aaaa-records-in-single-dns-query
|
||||
pkt.data[n - 3] = 0x1c; // AAAA query
|
||||
mg_send(c, &pkt, sizeof(pkt.header) + n);
|
||||
#endif
|
||||
return mg_send(c, &pkt, sizeof(pkt.header) + n);
|
||||
}
|
||||
|
||||
static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms,
|
||||
@ -252,7 +245,9 @@ static void mg_sendnsreq(struct mg_connection *c, struct mg_str *name, int ms,
|
||||
c->is_resolving = 1;
|
||||
MG_VERBOSE(("%lu resolving %.*s @ %s, txnid %hu", c->id, (int) name->len,
|
||||
name->ptr, mg_ntoa(&dnsc->c->rem, buf, sizeof(buf)), d->txnid));
|
||||
mg_dns_send(dnsc->c, name, d->txnid, ipv6);
|
||||
if (!mg_dns_send(dnsc->c, name, d->txnid, ipv6)) {
|
||||
mg_error(dnsc->c, "DNS send");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user