BUG/MEDIUM: dns: Be sure to unlock DSS when existing dns_session_io_handler()
A regression was introduced when the commit cf537f687 ("BUG/MEDIUM: dns:
Properly handle error when a response consumed") was backported. When the
dns session I/O handler is called, the DSS lock is not acquired in upper
versions. But in the 2.4, DSS may be locked. So we must be sure to never
exit from the I/O handler without unlocking it.
This patch should fix the issue #2277. It is specific to 2.4, thus there is
no upstream ID. No backport needed.
diff --git a/src/dns.c b/src/dns.c
index 3277f40..e76a05c 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -659,8 +659,10 @@
/* retrieve message len */
ret = co_getblk(si_oc(si), (char *)&msg_len, 2, 0);
if (ret <= 0) {
- if (ret == -1)
+ if (ret == -1) {
+ HA_SPIN_UNLOCK(DNS_LOCK, &ds->dss->lock);
goto close;
+ }
si_cant_get(si);
break;
}
@@ -680,8 +682,10 @@
/* read available data */
ret = co_getblk(si_oc(si), ds->rx_msg.area + ds->rx_msg.offset, co_data(si_oc(si)), 0);
if (ret <= 0) {
- if (ret == -1)
+ if (ret == -1) {
+ HA_SPIN_UNLOCK(DNS_LOCK, &ds->dss->lock);
goto close;
+ }
si_cant_get(si);
break;
}
@@ -702,8 +706,10 @@
/* read from the channel until the end of the message */
ret = co_getblk(si_oc(si), ds->rx_msg.area + ds->rx_msg.offset, ds->rx_msg.len - ds->rx_msg.offset, 0);
if (ret <= 0) {
- if (ret == -1)
+ if (ret == -1) {
+ HA_SPIN_UNLOCK(DNS_LOCK, &ds->dss->lock);
goto close;
+ }
si_cant_get(si);
break;
}