Hello.

This is a small and simple fix for cache_dir reconfiguration.


SwapDir::type() returns C strings which should be compared with
strcmp(3) instead of checking pointers for equality.

Regards,
  Dmitry
Fix cache_dir type check during reconfiguration.

SwapDir::type() returns C strings which should be compared with
strcmp(3) instead of checking pointers for equality.

=== modified file 'src/cache_cf.cc'
--- src/cache_cf.cc	2011-09-10 04:22:16 +0000
+++ src/cache_cf.cc	2011-09-19 22:11:00 +0000
@@ -1936,41 +1936,41 @@ parse_cachedir(SquidConfig::_cacheSwap *
     fs = find_fstype(type_str);
 
     if (fs < 0)
         self_destruct();
 
     /* reconfigure existing dir */
 
     for (i = 0; i < swap->n_configured; i++) {
         assert (swap->swapDirs[i].getRaw());
 
         if ((strcasecmp(path_str, dynamic_cast<SwapDir *>(swap->swapDirs[i].getRaw())->path)) == 0) {
             /* this is specific to on-fs Stores. The right
              * way to handle this is probably to have a mapping
              * from paths to stores, and have on-fs stores
              * register with that, and lookip in that in their
              * own setup logic. RBC 20041225. TODO.
              */
 
             sd = dynamic_cast<SwapDir *>(swap->swapDirs[i].getRaw());
 
-            if (sd->type() != StoreFileSystem::FileSystems().items[fs]->type()) {
+            if (strcmp(sd->type(), StoreFileSystem::FileSystems().items[fs]->type()) != 0) {
                 debugs(3, 0, "ERROR: Can't change type of existing cache_dir " <<
                        sd->type() << " " << sd->path << " to " << type_str << ". Restart required");
                 return;
             }
 
             sd->reconfigure (i, path_str);
 
             update_maxobjsize();
 
             return;
         }
     }
 
     /* new cache_dir */
     if (swap->n_configured > 63) {
         /* 7 bits, signed */
         debugs(3, DBG_CRITICAL, "WARNING: There is a fixed maximum of 63 cache_dir entries Squid can handle.");
         debugs(3, DBG_CRITICAL, "WARNING: '" << path_str << "' is one to many.");
         self_destruct();
         return;

Reply via email to