Branch: Tag:

2009-11-20

2009-11-20 13:59:32 by Martin Stjernholm <mast@lysator.liu.se>

Don't mix cache contexts between managers with different timing functions.

Rev: server/base_server/cache.pike:1.114

1:   // This file is part of Roxen WebServer.   // Copyright © 1996 - 2009, Roxen IS. - // $Id: cache.pike,v 1.113 2009/11/19 14:17:46 mast Exp $ + // $Id: cache.pike,v 1.114 2009/11/20 13:59:32 mast Exp $      #include <roxen.h>   #include <config.h>
146: Inside #if defined(NEW_RAM_CACHE)
   //!    //! The manager-specific class to use to create @[CacheEntry] objects.    +  void clear_cache_context() {} +  //! Called to clear any thread-local state that the manager keeps to +  //! track execution times etc. This is called before a thread starts +  //! with a new request or other kind of job. +     void got_miss (string cache_name, mixed key, mapping cache_context);    //! Called when @[cache_lookup] records a cache miss.   
552: Inside #if defined(NEW_RAM_CACHE)
     protected CM_GDS_1 cm_gds_1 = CM_GDS_1 (startup_cache_size);    - protected Thread.Local cache_contexts = Thread.Local(); - // A thread local mapping to store the timestamp from got_miss so it - // can be read from the (presumably) following add_entry. - // - // In an entry with index 0 in the mapping, the time spent creating - // cache entries is accumulated. It is used to deduct the time for - // creating entries in subcaches. -  +    class CM_GDS_Time   //! Like @[CM_GDS_1] but adds support for calculating entry cost based   //! on passed time.
580: Inside #if defined(NEW_RAM_CACHE)
   }   #endif    +  protected Thread.Local cache_contexts = Thread.Local(); +  // A thread local mapping to store the timestamp from got_miss so it +  // can be read from the (presumably) following add_entry. +  // +  // In an entry with index 0 in the mapping, the time spent creating +  // cache entries is accumulated. It is used to deduct the time for +  // creating entries in subcaches. +  +  void clear_cache_context() +  { +  cache_contexts->set (([])); +  } +     protected int gettime_func();    //! Returns the current time for cost calculation. (@[format_cost]    //! assumes this is in microseconds.)
960: Inside #if defined(NEW_RAM_CACHE)
     void cache_clear_deltas()   { -  cache_contexts->set (([])); +  cache_managers->clear_cache_context();   }      mixed cache_lookup (string cache_name, mixed key, void|mapping cache_context)