You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2017/05/11 13:41:15 UTC

[trafficserver] 07/11: Wccp: CV-1268012

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

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

commit b95b27508c507025f9d374c813e91aba9f01da84
Author: Alan M. Carroll <am...@apache.org>
AuthorDate: Wed May 10 12:31:04 2017 -0500

    Wccp: CV-1268012
---
 lib/wccp/WccpEndPoint.cc | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/lib/wccp/WccpEndPoint.cc b/lib/wccp/WccpEndPoint.cc
index 8aec934..526856f 100644
--- a/lib/wccp/WccpEndPoint.cc
+++ b/lib/wccp/WccpEndPoint.cc
@@ -71,7 +71,7 @@ Impl::open(uint addr)
 {
   struct sockaddr saddr;
   sockaddr_in &in_addr = reinterpret_cast<sockaddr_in &>(saddr);
-  int fd;
+  ats_scoped_fd fd;
 
   if (ts::NO_FD != m_fd) {
     log(LVL_INFO, "Attempted to open already open WCCP Endpoint");
@@ -125,7 +125,7 @@ Impl::open(uint addr)
   }
 #endif
 
-  m_fd = fd;
+  m_fd = fd.release();
   return 0;
 }
 
@@ -432,20 +432,18 @@ CacheImpl::GroupData::processUp()
   } else {
     // Look for the pid file
     ats_scoped_fd fd = open(proc_pid_path, O_RDONLY);
-    if (fd > 0) {
+    if (fd >= 0) {
       char buffer[256];
       ssize_t read_count = read(fd, buffer, sizeof(buffer) - 1);
-      close(fd);
       if (read_count > 0) {
         buffer[read_count] = '\0';
         int pid            = atoi(buffer);
         if (pid > 0) {
           // If the process is still running, it has an entry in the proc file system, (Linux only)
           sprintf(buffer, "/proc/%d/status", pid);
-          fd = open(buffer, O_RDONLY);
-          if (fd > 0) {
+          ats_scoped_fd fd2 = open(buffer, O_RDONLY);
+          if (fd2 >= 0) {
             zret = true;
-            close(fd);
           }
         }
       }

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.