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

[trafficserver] 02/02: fix unpredictable diskok within CacheProcessor::start_internal

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

zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 28c3975bc3f98e64954474d3019385d7bf04b8db
Author: Oknet Xu <xu...@skyguard.com.cn>
AuthorDate: Fri Mar 2 17:52:34 2018 +0800

    fix unpredictable diskok within CacheProcessor::start_internal
    
    (cherry picked from commit 30107ba960772d892e64d05c331dbbffbbcf4250)
---
 iocore/cache/Cache.cc | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 1b6edd6..f74657f 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -622,7 +622,6 @@ CacheProcessor::start_internal(int flags)
   fix                  = !!(flags & PROCESSOR_FIX);
   check                = (flags & PROCESSOR_CHECK) != 0;
   start_done           = 0;
-  int diskok           = 1;
   Span *sd;
 
   /* read the config file and create the data structures corresponding
@@ -666,22 +665,22 @@ CacheProcessor::start_internal(int flags)
       fd = open(path, DEFAULT_CACHE_OPTIONS | O_CREAT, 0644);
 
     if (fd >= 0) {
+      bool diskok = true;
       if (!sd->file_pathname) {
         if (!check) {
           if (ftruncate(fd, blocks * STORE_BLOCK_SIZE) < 0) {
             Warning("unable to truncate cache file '%s' to %" PRId64 " blocks", path, blocks);
-            diskok = 0;
+            diskok = false;
           }
         } else { // read-only mode checks
           struct stat sbuf;
-          diskok = 0;
           if (-1 == fstat(fd, &sbuf)) {
             fprintf(stderr, "Failed to stat cache file for directory %s\n", path);
+            diskok = false;
           } else if (blocks != sbuf.st_size / STORE_BLOCK_SIZE) {
             fprintf(stderr, "Cache file for directory %s is %" PRId64 " bytes, expected %" PRId64 "\n", path, sbuf.st_size,
                     blocks * static_cast<int64_t>(STORE_BLOCK_SIZE));
-          } else {
-            diskok = 1;
+            diskok = false;
           }
         }
       }

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