mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-03 02:32:03 +00:00
BUG/MINOR: dns: fix ring offset calculation in dns_resolve_send()
With737d10f
("BUG/MEDIUM: dns: ensure ring offset is properly reajusted to head") relative offset calculation was fixed in dns_session_io_handler() and dns_process_req() functions. But if we compare with the changes performed in the patch that introduced the bug:d9c7188
("MEDIUM: ring: make the offset relative to the head/tail instead of absolute"), we can see that dns_resolve_send() is missing from the patch. Applying both737d10f
+ ("BUG/MINOR: dns: fix ring offset calculation on first read") to dns_resolve_send() function. With this last commit, we should be back at pred9c7188
behavior. No backport needed.
This commit is contained in:
parent
5a43db2c5d
commit
bce0c0c37a
14
src/dns.c
14
src/dns.c
@ -317,7 +317,6 @@ static void dns_resolve_send(struct dgram_conn *dgram)
|
||||
buf = &ring->buf;
|
||||
|
||||
HA_RWLOCK_RDLOCK(DNS_LOCK, &ring->lock);
|
||||
ofs = ns->dgram->ofs_req;
|
||||
|
||||
/* explanation for the initialization below: it would be better to do
|
||||
* this in the parsing function but this would occasionally result in
|
||||
@ -327,14 +326,17 @@ static void dns_resolve_send(struct dgram_conn *dgram)
|
||||
* existing messages before grabbing a reference to a location. This
|
||||
* value cannot be produced after initialization.
|
||||
*/
|
||||
if (unlikely(ofs == ~0)) {
|
||||
ofs = 0;
|
||||
HA_ATOMIC_INC(b_peek(buf, ofs));
|
||||
if (unlikely(ns->dgram->ofs_req == ~0)) {
|
||||
ns->dgram->ofs_req = b_peek_ofs(buf, 0);
|
||||
HA_ATOMIC_INC(b_orig(buf) + ns->dgram->ofs_req);
|
||||
}
|
||||
|
||||
/* we were already there, adjust the offset to be relative to
|
||||
* the buffer's head and remove us from the counter.
|
||||
*/
|
||||
ofs = ns->dgram->ofs_req - b_head_ofs(buf);
|
||||
if (ns->dgram->ofs_req < b_head_ofs(buf))
|
||||
ofs += b_size(buf);
|
||||
BUG_ON(ofs >= buf->size);
|
||||
HA_ATOMIC_DEC(b_peek(buf, ofs));
|
||||
|
||||
@ -376,12 +378,10 @@ static void dns_resolve_send(struct dgram_conn *dgram)
|
||||
fd_stop_send(fd);
|
||||
|
||||
out:
|
||||
|
||||
HA_ATOMIC_INC(b_peek(buf, ofs));
|
||||
ns->dgram->ofs_req = ofs;
|
||||
ns->dgram->ofs_req = b_peek_ofs(buf, ofs);
|
||||
HA_RWLOCK_RDUNLOCK(DNS_LOCK, &ring->lock);
|
||||
HA_SPIN_UNLOCK(DNS_LOCK, &dgram->lock);
|
||||
|
||||
}
|
||||
|
||||
/* proto_udp callback functions for a DNS resolution */
|
||||
|
Loading…
Reference in New Issue
Block a user