You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2018/03/25 16:05:45 UTC

[trafficserver] branch master updated: CacheTool: Fix Ubuntu build of CI

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

amc 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 82997ff  CacheTool: Fix Ubuntu build of CI
82997ff is described below

commit 82997fff49c5d4feccdec1d113bda72eba98fb1b
Author: Persia Aziz <pe...@yahoo-inc.com>
AuthorDate: Fri Mar 23 17:32:08 2018 -0500

    CacheTool: Fix Ubuntu build of CI
---
 cmd/traffic_cache_tool/CacheTool.cc | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/cmd/traffic_cache_tool/CacheTool.cc b/cmd/traffic_cache_tool/CacheTool.cc
index f1c40f6..aa7fb0d 100644
--- a/cmd/traffic_cache_tool/CacheTool.cc
+++ b/cmd/traffic_cache_tool/CacheTool.cc
@@ -240,10 +240,14 @@ Stripe::clear()
 {
   Errata zret;
   alignas(512) static char zero[CacheStoreBlocks::SCALE]; // should be all zero, it's static.
-  pwrite(_span->_fd, zero, sizeof(zero), this->_meta_pos[A][HEAD]);
-  pwrite(_span->_fd, zero, sizeof(zero), this->_meta_pos[A][FOOT]);
-  pwrite(_span->_fd, zero, sizeof(zero), this->_meta_pos[B][HEAD]);
-  pwrite(_span->_fd, zero, sizeof(zero), this->_meta_pos[B][FOOT]);
+  for (auto i : {A, B}) {
+    for (auto j : {HEAD, FOOT}) {
+      ssize_t n = pwrite(_span->_fd, zero, CacheStoreBlocks::SCALE, this->_meta_pos[i][j]);
+      if (n < CacheStoreBlocks::SCALE)
+        std::cout << "Failed to clear stripe header" << std::endl;
+    }
+  }
+
   return zret;
 }
 Stripe::Chunk::~Chunk()
@@ -607,7 +611,9 @@ Stripe::dir_probe(INK_MD5 *key, CacheDirEntry *result, CacheDirEntry **last_coll
     int fd         = _span->_fd;
     int64_t offset = stripe_offset(e);
     int64_t size   = dir_approx_size(e);
-    pread(fd, stripe_buff2, size, offset);
+    ssize_t n      = pread(fd, stripe_buff2, size, offset);
+    if (n < size)
+      std::cout << "Failed to read content from the Stripe" << std::endl;
 
     doc = reinterpret_cast<Doc *>(stripe_buff2);
     std::string hdr(doc->hdr(), doc->hlen);
@@ -750,10 +756,13 @@ Errata
 Stripe::loadDir()
 {
   Errata zret;
-  char *raw_dir = (char *)ats_memalign(ats_pagesize(), this->vol_dirlen());
-  dir           = (CacheDirEntry *)(raw_dir + this->vol_headerlen());
+  int64_t dirlen = this->vol_dirlen();
+  char *raw_dir  = (char *)ats_memalign(ats_pagesize(), dirlen);
+  dir            = (CacheDirEntry *)(raw_dir + this->vol_headerlen());
   // read directory
-  pread(this->_span->_fd, raw_dir, this->vol_dirlen(), this->_start);
+  ssize_t n = pread(this->_span->_fd, raw_dir, dirlen, this->_start);
+  if (n < dirlen)
+    std::cout << "Failed to read Dir from stripe @" << this->hashText;
   return zret;
 }
 //
@@ -1826,7 +1835,9 @@ Span::loadDevice()
             memcpy(_header.get(), buff, span_hdr_size);
           } else {
             // TODO - check the pread return
-            pread(fd, _header.get(), span_hdr_size, offset);
+            ssize_t n = pread(fd, _header.get(), span_hdr_size, offset);
+            if (n < span_hdr_size)
+              std::cout << "Failed to read the Span Header" << std::endl;
           }
           _len = _header->num_blocks;
         } else {

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