Permalink
Browse files

log: prevent 'flush' and '.' from being logged on their own.

The system_cache_path is logged on startup and on some errors.  It has
newlines in it, used as a separator.  This means you get log lines like:

  2015/12/17 13:27:00 [info] 105645#0: \
     [ngx_pagespeed 1.10.0.0-7582] Initializing shared memory for path: \
     /home/jefftk/ngx_pagespeed/test/tmp/file-cache/
  flush
  .

This change makes us use spaces instead so you get:

  2015/12/17 13:27:00 [info] 105645#0: \
     [ngx_pagespeed 1.10.0.0-7582] Initializing shared memory for path: \
     /home/jefftk/ngx_pagespeed/test/tmp/file-cache/ flush .
  • Loading branch information...
jeffkaufman committed Dec 17, 2015
1 parent f3edc3b commit b6a955af346aa1356e167bb2ff8534038e72764d
@@ -144,11 +144,11 @@ SystemCachePath::~SystemCachePath() {
}

// static
GoogleString SystemCachePath::CacheKey(SystemRewriteOptions* config) {
GoogleString SystemCachePath::CachePath(SystemRewriteOptions* config) {
return (config->unplugged()
? "<unplugged>"
: StrCat(config->file_cache_path(),
config->enable_cache_purge() ? "\npurge\n" : "\nflush\n",
config->enable_cache_purge() ? " purge " : " flush ",
config->cache_flush_filename()));
}

@@ -59,8 +59,8 @@ class SystemCachePath {
~SystemCachePath();

// Computes a key suitable for building a map to help share common cache
// objects between vhosts.
static GoogleString CacheKey(SystemRewriteOptions* config);
// objects between vhosts. This key is given to the constructor as 'path'.
static GoogleString CachePath(SystemRewriteOptions* config);

// Per-process in-memory LRU, with any stats/thread safety wrappers, or NULL.
CacheInterface* lru_cache() { return lru_cache_; }
@@ -119,14 +119,14 @@ void SystemCaches::ShutDown(MessageHandler* message_handler) {
}

SystemCachePath* SystemCaches::GetCache(SystemRewriteOptions* config) {
GoogleString key = SystemCachePath::CacheKey(config);
GoogleString path = SystemCachePath::CachePath(config);
SystemCachePath* system_cache_path = NULL;
std::pair<PathCacheMap::iterator, bool> result = path_cache_map_.insert(
PathCacheMap::value_type(key, system_cache_path));
PathCacheMap::value_type(path, system_cache_path));
PathCacheMap::iterator iter = result.first;
if (result.second) {
iter->second = system_cache_path =
new SystemCachePath(key, config, factory_, shared_mem_runtime_);
new SystemCachePath(path, config, factory_, shared_mem_runtime_);
factory_->TakeOwnership(system_cache_path);
} else {
system_cache_path = iter->second;

0 comments on commit b6a955a

Please sign in to comment.