You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/02/16 16:51:32 UTC

[trafficserver] branch master updated: Don't read DNS responses until we get at least two bytes

This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 08b9ade  Don't read DNS responses until we get at least two bytes
08b9ade is described below

commit 08b9ade0485ee0e0fdcbeef46356df9cfd6c5b0b
Author: Zizhong Zhang <zi...@linkedin.com>
AuthorDate: Fri Feb 9 15:48:06 2018 -0800

    Don't read DNS responses until we get at least two bytes
---
 iocore/dns/DNS.cc | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index 641543e..74b80a6 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -808,6 +808,15 @@ DNSHandler::recv_dns(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
           dnsc->tcp_data.buf_ptr = make_ptr(dnsBufAllocator.alloc());
         }
         if (dnsc->tcp_data.total_length == 0) {
+          // see if TS gets a two-byte size
+          uint16_t tmp = 0;
+          res          = socketManager.recv(dnsc->fd, &tmp, sizeof(tmp), MSG_PEEK);
+          if (res == -EAGAIN || res == 0 || res == 1) {
+            break;
+          }
+          if (res < 0) {
+            goto Lerror;
+          }
           // reading total size
           res = socketManager.recv(dnsc->fd, &(dnsc->tcp_data.total_length), sizeof(dnsc->tcp_data.total_length), 0);
           if (res == -EAGAIN) {
@@ -824,10 +833,10 @@ DNSHandler::recv_dns(int /* event ATS_UNUSED */, Event * /* e ATS_UNUSED */)
         // continue reading data
         void *buf_start = (char *)dnsc->tcp_data.buf_ptr->buf + dnsc->tcp_data.done_reading;
         res             = socketManager.recv(dnsc->fd, buf_start, dnsc->tcp_data.total_length - dnsc->tcp_data.done_reading, 0);
-        if (res == -EAGAIN) {
+        if (res == -EAGAIN || res == 0) {
           break;
         }
-        if (res <= 0) {
+        if (res < 0) {
           goto Lerror;
         }
         Debug("dns", "received packet size = %d over TCP", res);

-- 
To stop receiving notification emails like this one, please contact
bcall@apache.org.