You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by mt...@apache.org on 2010/05/19 19:01:11 UTC

svn commit: r946279 - in /trafficserver/traffic/trunk/iocore: cache/Cache.cc cache/Store.cc hostdb/MultiCache.cc

Author: mturk
Date: Wed May 19 17:01:11 2010
New Revision: 946279

URL: http://svn.apache.org/viewvc?rev=946279&view=rev
Log:
TS-359 Start cleaning up DIR_SEP usage

Modified:
    trafficserver/traffic/trunk/iocore/cache/Cache.cc
    trafficserver/traffic/trunk/iocore/cache/Store.cc
    trafficserver/traffic/trunk/iocore/hostdb/MultiCache.cc

Modified: trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=946279&r1=946278&r2=946279&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Cache.cc Wed May 19 17:01:11 2010
@@ -496,7 +496,7 @@ CacheProcessor::start_internal(int flags
         Warning("It is suggested that you use raw disks if streaming and http are in the same cache");
       }
 #endif
-      strncat(path, DIR_SEP "cache.db", (sizeof(path) - strlen(path) - 1));
+      strncat(path, "/cache.db", (sizeof(path) - strlen(path) - 1));
       opts |= O_CREAT;
     }
     opts |= _O_ATTRIB_OVERLAPPED;

Modified: trafficserver/traffic/trunk/iocore/cache/Store.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Store.cc?rev=946279&r1=946278&r2=946279&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Store.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Store.cc Wed May 19 17:01:11 2010
@@ -221,16 +221,18 @@ Span::path(char *filename, ink64 * aoffs
 {
   ink_assert(!aoffset);
   Span *ds = this;
-  int l = strlen(ds->pathname);
+  int pl = strlen(ds->pathname);
   int ll = strlen(filename);
 
-  if (l + ll + 3 >= buflen)
+  if (pl + ll + 3 >= buflen)
     return -1;
   ink_strncpy(buf, ds->pathname, buflen);
   if (!ds->file_pathname) {
-    if (buf[l - 1] != '/' || buf[l - 1] != '\\')
-      strncat(buf, DIR_SEP, buflen - (strlen(buf) + sizeof(DIR_SEP) + 1));
-    strncat(buf, filename, buflen - (strlen(buf) + ll + 1));
+    if (pl && buf[pl - 1] != '/') {
+      buf[pl - 1] = '/';
+      buf[pl++] = '\0';
+    }
+    strncat(buf, filename, buflen - (pl + ll + 1));
   }
 
   return strlen(buf);

Modified: trafficserver/traffic/trunk/iocore/hostdb/MultiCache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/hostdb/MultiCache.cc?rev=946279&r1=946278&r2=946279&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/hostdb/MultiCache.cc (original)
+++ trafficserver/traffic/trunk/iocore/hostdb/MultiCache.cc Wed May 19 17:01:11 2010
@@ -545,8 +545,8 @@ MultiCacheBase::read_config(const char *
   int scratch;
   char p[PATH_NAME_MAX + 1], buf[256];
 
-  snprintf(p, PATH_NAME_MAX + 1, "%s%s%s%s%s", system_config_directory,
-               DIR_SEP, "internal", DIR_SEP, config_filename);
+  snprintf(p, PATH_NAME_MAX + 1, "%s%s%s", system_config_directory,
+           "/internal/", config_filename);
 
   int fd =::open(p, O_RDONLY);
   if (fd < 0)
@@ -580,11 +580,13 @@ MultiCacheBase::read_config(const char *
 int
 MultiCacheBase::write_config(const char *config_filename, int nominal_size, int abuckets)
 {
-  char p[PATH_NAME_MAX], buf[256];
+  char p[PATH_NAME_MAX + 1], buf[256];
   int fd, retcode = -1;
 
-  snprintf(p, sizeof(p) - 1, "%s%s%s%s%s", system_config_directory, DIR_SEP, "internal", DIR_SEP, config_filename);
-  p[sizeof(p) - 1] = 0;
+  snprintf(p, PATH_NAME_MAX + 1, "%s%s%s", system_config_directory,
+           "/internal/", config_filename);
+  // XXX: Shouldn't that be 0664?
+  //
   if ((fd =::open(p, O_CREAT | O_WRONLY | O_TRUNC, 0666)) >= 0) {
     snprintf(buf, sizeof(buf) - 1, "%d\n%d\n%d\n", nominal_size, abuckets, heap_size);
     buf[sizeof(buf) - 1] = 0;