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

zwoop 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 69b5748  correctly handle return value 0 from recv()
69b5748 is described below

commit 69b5748e8b8fba8d9638fcef839118d2036c3bdd
Author: Zizhong Zhang <[email protected]>
AuthorDate: Mon Apr 22 19:50:06 2019 -0700

    correctly handle return value 0 from recv()
---
 iocore/dns/DNS.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index 509ae29..b2629b7 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -808,10 +808,10 @@ DNSHandler::recv_dns(int /* event ATS_UNUSED */, Event * 
/* e ATS_UNUSED */)
           // 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) {
+          if (res == -EAGAIN || res == 1) {
             break;
           }
-          if (res < 0) {
+          if (res <= 0) {
             goto Lerror;
           }
           // reading total size
@@ -830,10 +830,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 || res == 0) {
+        if (res == -EAGAIN) {
           break;
         }
-        if (res < 0) {
+        if (res <= 0) {
           goto Lerror;
         }
         Debug("dns", "received packet size = %d over TCP", res);

Reply via email to