http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/I_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/I_HostDBProcessor.h 
b/iocore/hostdb/I_HostDBProcessor.h
index ab1f3ed..bcdc3a0 100644
--- a/iocore/hostdb/I_HostDBProcessor.h
+++ b/iocore/hostdb/I_HostDBProcessor.h
@@ -28,15 +28,15 @@
 #include "SRV.h"
 
 // Event returned on a lookup
-#define EVENT_HOST_DB_LOOKUP                 (HOSTDB_EVENT_EVENTS_START+0)
-#define EVENT_HOST_DB_IP_REMOVED             (HOSTDB_EVENT_EVENTS_START+1)
-#define EVENT_HOST_DB_GET_RESPONSE           (HOSTDB_EVENT_EVENTS_START+2)
+#define EVENT_HOST_DB_LOOKUP (HOSTDB_EVENT_EVENTS_START + 0)
+#define EVENT_HOST_DB_IP_REMOVED (HOSTDB_EVENT_EVENTS_START + 1)
+#define EVENT_HOST_DB_GET_RESPONSE (HOSTDB_EVENT_EVENTS_START + 2)
 
-#define EVENT_SRV_LOOKUP                 (SRV_EVENT_EVENTS_START+0)
-#define EVENT_SRV_IP_REMOVED             (SRV_EVENT_EVENTS_START+1)
-#define EVENT_SRV_GET_RESPONSE           (SRV_EVENT_EVENTS_START+2)
+#define EVENT_SRV_LOOKUP (SRV_EVENT_EVENTS_START + 0)
+#define EVENT_SRV_IP_REMOVED (SRV_EVENT_EVENTS_START + 1)
+#define EVENT_SRV_GET_RESPONSE (SRV_EVENT_EVENTS_START + 2)
 
-#define HOST_DB_MAX_ROUND_ROBIN_INFO         16
+#define HOST_DB_MAX_ROUND_ROBIN_INFO 16
 
 #define HOST_DB_SRV_PREFIX "_http._tcp."
 //
@@ -85,10 +85,8 @@ makeHostHash(const char *string)
 // is treated as opacque by the database.
 //
 
-union HostDBApplicationInfo
-{
-  struct application_data_allotment
-  {
+union HostDBApplicationInfo {
+  struct application_data_allotment {
     unsigned int application1;
     unsigned int application2;
   } allotment;
@@ -106,55 +104,62 @@ union HostDBApplicationInfo
   // fail_count         - Number of times we tried and    //
   //                       and failed to contact the host //
   //////////////////////////////////////////////////////////
-  struct http_server_attr
-  {
-    unsigned int http_version:3;
-    unsigned int pipeline_max:7;
-    unsigned int keepalive_timeout:6;
-    unsigned int fail_count:8;
-    unsigned int unused1:8;
-    unsigned int last_failure:32;
+  struct http_server_attr {
+    unsigned int http_version : 3;
+    unsigned int pipeline_max : 7;
+    unsigned int keepalive_timeout : 6;
+    unsigned int fail_count : 8;
+    unsigned int unused1 : 8;
+    unsigned int last_failure : 32;
   } http_data;
 
-  enum HttpVersion_t
-  {
+  enum HttpVersion_t {
     HTTP_VERSION_UNDEFINED = 0,
     HTTP_VERSION_09 = 1,
     HTTP_VERSION_10 = 2,
-    HTTP_VERSION_11 = 3
+    HTTP_VERSION_11 = 3,
   };
 
-  struct application_data_rr
-  {
+  struct application_data_rr {
     int offset;
   } rr;
 };
 
 struct HostDBRoundRobin;
 
-struct SRVInfo
-{
-  unsigned int srv_offset:16;
-  unsigned int srv_weight:16;
-  unsigned int srv_priority:16;
-  unsigned int srv_port:16;
+struct SRVInfo {
+  unsigned int srv_offset : 16;
+  unsigned int srv_weight : 16;
+  unsigned int srv_priority : 16;
+  unsigned int srv_port : 16;
   unsigned int key;
 };
 
-struct HostDBInfo
-{
+struct HostDBInfo {
   /** Internal IP address data.
       This is at least large enough to hold an IPv6 address.
   */
-  sockaddr* ip()  { return &data.ip.sa; }
-  sockaddr const* ip() const { return &data.ip.sa; }
+  sockaddr *
+  ip()
+  {
+    return &data.ip.sa;
+  }
+  sockaddr const *
+  ip() const
+  {
+    return &data.ip.sa;
+  }
 
   char *hostname();
   char *srvname(HostDBRoundRobin *rr);
   HostDBRoundRobin *rr();
 
   /** Indicate that the HostDBInfo is BAD and should be deleted. */
-  void bad() { full = 0; }
+  void
+  bad()
+  {
+    full = 0;
+  }
 
   /**
     Application specific data. NOTE: We need an integral number of these
@@ -164,36 +169,45 @@ struct HostDBInfo
   */
   HostDBApplicationInfo app;
 
-  unsigned int ip_interval()
+  unsigned int
+  ip_interval()
   {
     return (hostdb_current_interval - ip_timestamp) & 0x7FFFFFFF;
   }
 
-  int ip_time_remaining()
+  int
+  ip_time_remaining()
   {
     return static_cast<int>(ip_timeout_interval) - 
static_cast<int>(this->ip_interval());
   }
 
-  bool is_ip_stale() {
-    return ip_timeout_interval >= 2 * hostdb_ip_stale_interval &&
-      ip_interval() >= hostdb_ip_stale_interval
-      ;
+  bool
+  is_ip_stale()
+  {
+    return ip_timeout_interval >= 2 * hostdb_ip_stale_interval && 
ip_interval() >= hostdb_ip_stale_interval;
   }
 
-  bool is_ip_timeout() {
+  bool
+  is_ip_timeout()
+  {
     return ip_timeout_interval && ip_interval() >= ip_timeout_interval;
   }
 
-  bool is_ip_fail_timeout() {
+  bool
+  is_ip_fail_timeout()
+  {
     return ip_interval() >= hostdb_ip_fail_timeout_interval;
   }
 
-  void refresh_ip()
+  void
+  refresh_ip()
   {
     ip_timestamp = hostdb_current_interval;
   }
 
-  bool serve_stale_but_revalidate() {
+  bool
+  serve_stale_but_revalidate()
+  {
     // the option is disabled
     if (hostdb_serve_stale_but_revalidate <= 0)
       return false;
@@ -202,8 +216,8 @@ struct HostDBInfo
     // hostdb_serve_stale_but_revalidate == number of seconds
     // ip_interval() is the number of seconds between now() and when the entry 
was inserted
     if ((ip_timeout_interval + hostdb_serve_stale_but_revalidate) > 
ip_interval()) {
-      Debug("hostdb", "serving stale entry %d | %d | %d as requested by 
config",
-            ip_timeout_interval, hostdb_serve_stale_but_revalidate, 
ip_interval());
+      Debug("hostdb", "serving stale entry %d | %d | %d as requested by 
config", ip_timeout_interval,
+            hostdb_serve_stale_but_revalidate, ip_interval());
       return true;
     }
     // otherwise, the entry is too old
@@ -216,7 +230,7 @@ struct HostDBInfo
   //
 
   union {
-    IpEndpoint ip; ///< IP address / port data.
+    IpEndpoint ip;       ///< IP address / port data.
     int hostname_offset; ///< Some hostname thing.
     SRVInfo srv;
   } data;
@@ -226,24 +240,28 @@ struct HostDBInfo
   // if this is 0 then no timeout.
   unsigned int ip_timeout_interval;
 
-  unsigned int full:1;
-  unsigned int backed:1;        // duplicated in lower level
-  unsigned int deleted:1;
-  unsigned int hits:3;
+  unsigned int full : 1;
+  unsigned int backed : 1; // duplicated in lower level
+  unsigned int deleted : 1;
+  unsigned int hits : 3;
 
-  unsigned int is_srv:1; // steal a bit from ip_timeout_interval
-  unsigned int round_robin:1;
-  unsigned int reverse_dns:1;
+  unsigned int is_srv : 1; // steal a bit from ip_timeout_interval
+  unsigned int round_robin : 1;
+  unsigned int reverse_dns : 1;
 
-  unsigned int md5_low_low:24;
+  unsigned int md5_low_low : 24;
   unsigned int md5_low;
 
   uint64_t md5_high;
 
-  bool failed() {
+  bool
+  failed()
+  {
     return !((is_srv && data.srv.srv_offset) || (reverse_dns && 
data.hostname_offset) || ats_is_ip(ip()));
   }
-  void set_failed() {
+  void
+  set_failed()
+  {
     if (is_srv)
       data.srv.srv_offset = 0;
     else if (reverse_dns)
@@ -252,12 +270,25 @@ struct HostDBInfo
       ats_ip_invalidate(ip());
   }
 
-  void set_deleted() { deleted = 1; }
-  bool is_deleted() const { return deleted; }
+  void
+  set_deleted()
+  {
+    deleted = 1;
+  }
+  bool
+  is_deleted() const
+  {
+    return deleted;
+  }
 
-  bool is_empty() const { return !full; }
+  bool
+  is_empty() const
+  {
+    return !full;
+  }
 
-  void set_empty()
+  void
+  set_empty()
   {
     full = 0;
     md5_high = 0;
@@ -265,18 +296,20 @@ struct HostDBInfo
     md5_low_low = 0;
   }
 
-  void set_full(uint64_t folded_md5, int buckets)
+  void
+  set_full(uint64_t folded_md5, int buckets)
   {
     uint64_t ttag = folded_md5 / buckets;
 
     if (!ttag)
       ttag = 1;
-    md5_low_low = (unsigned int) ttag;
-    md5_low = (unsigned int) (ttag >> 24);
+    md5_low_low = (unsigned int)ttag;
+    md5_low = (unsigned int)(ttag >> 24);
     full = 1;
   }
 
-  void reset()
+  void
+  reset()
   {
     ats_ip_invalidate(ip());
     app.allotment.application1 = 0;
@@ -289,7 +322,9 @@ struct HostDBInfo
     is_srv = 0;
   }
 
-  uint64_t tag() {
+  uint64_t
+  tag()
+  {
     uint64_t f = md5_low;
     return (f << 24) + md5_low_low;
   }
@@ -300,8 +335,7 @@ struct HostDBInfo
 };
 
 
-struct HostDBRoundRobin
-{
+struct HostDBRoundRobin {
   /** Total number (to compute space used). */
   short rrcount;
 
@@ -316,7 +350,8 @@ struct HostDBRoundRobin
 
   // Return the allocation size of a HostDBRoundRobin struct suitable for 
storing
   // "count" HostDBInfo records.
-  static unsigned size(unsigned count, unsigned srv_len = 0)
+  static unsigned
+  size(unsigned count, unsigned srv_len = 0)
   {
     ink_assert(count > 0);
     return INK_ALIGN((sizeof(HostDBRoundRobin) + (count * sizeof(HostDBInfo)) 
+ srv_len), 8);
@@ -325,34 +360,30 @@ struct HostDBRoundRobin
   /** Find the index of @a addr in member @a info.
       @return The index if found, -1 if not found.
   */
-  int index_of(sockaddr const* addr);
-  HostDBInfo *find_ip(sockaddr const* addr);
+  int index_of(sockaddr const *addr);
+  HostDBInfo *find_ip(sockaddr const *addr);
   // Find the srv target
   HostDBInfo *find_target(const char *target);
   /** Select the next entry after @a addr.
       @note If @a addr isn't an address in the round robin nothing is updated.
       @return The selected entry or @c NULL if @a addr wasn't present.
    */
-  HostDBInfo* select_next(sockaddr const* addr);
-  HostDBInfo *select_best_http(sockaddr const* client_ip, ink_time_t now, 
int32_t fail_window);
+  HostDBInfo *select_next(sockaddr const *addr);
+  HostDBInfo *select_best_http(sockaddr const *client_ip, ink_time_t now, 
int32_t fail_window);
   HostDBInfo *select_best_srv(char *target, InkRand *rand, ink_time_t now, 
int32_t fail_window);
-  HostDBRoundRobin()
-    : rrcount(0), good(0), current(0), length(0), timed_rr_ctime(0)
-  { }
-
+  HostDBRoundRobin() : rrcount(0), good(0), current(0), length(0), 
timed_rr_ctime(0) {}
 };
 
 struct HostDBCache;
 
 // Prototype for inline completion functionf or
 //  getbyname_imm()
-typedef void (Continuation::*process_hostdb_info_pfn) (HostDBInfo * r);
-typedef void (Continuation::*process_srv_info_pfn) (HostDBInfo * r);
+typedef void (Continuation::*process_hostdb_info_pfn)(HostDBInfo *r);
+typedef void (Continuation::*process_srv_info_pfn)(HostDBInfo *r);
 
 
 /** The Host Databse access interface. */
-struct HostDBProcessor: public Processor
-{
+struct HostDBProcessor : public Processor {
   friend struct HostDBSyncer;
   // Public Interface
 
@@ -364,8 +395,8 @@ struct HostDBProcessor: public Processor
   //       cache.  The HostDBInfo * becomes invalid when the callback returns.
   //       The HostDBInfo may be changed during the callback.
 
-  enum
-  { HOSTDB_DO_NOT_FORCE_DNS = 0,
+  enum {
+    HOSTDB_DO_NOT_FORCE_DNS = 0,
     HOSTDB_ROUND_ROBIN = 0,
     HOSTDB_FORCE_DNS_RELOAD = 1,
     HOSTDB_FORCE_DNS_ALWAYS = 2,
@@ -374,40 +405,40 @@ struct HostDBProcessor: public Processor
 
   /// Optional parameters for getby...
   struct Options {
-    typedef Options self; ///< Self reference type.
-    int port; ///< Target service port (default 0 -> don't care)
-    int flags; ///< Processing flags (default HOSTDB_DO_NOT_FORCE_DNS)
-    int timeout; ///< Timeout value (default 0 -> default timeout)
+    typedef Options self;        ///< Self reference type.
+    int port;                    ///< Target service port (default 0 -> don't 
care)
+    int flags;                   ///< Processing flags (default 
HOSTDB_DO_NOT_FORCE_DNS)
+    int timeout;                 ///< Timeout value (default 0 -> default 
timeout)
     HostResStyle host_res_style; ///< How to query host (default HOST_RES_IPV4)
 
-    Options() : port(0), flags(HOSTDB_DO_NOT_FORCE_DNS), timeout(0), 
host_res_style(HOST_RES_IPV4)
-    { }
+    Options() : port(0), flags(HOSTDB_DO_NOT_FORCE_DNS), timeout(0), 
host_res_style(HOST_RES_IPV4) {}
 
     /// Set the flags.
-    self& setFlags(int f) { flags = f; return *this; }
+    self &
+    setFlags(int f)
+    {
+      flags = f;
+      return *this;
+    }
   };
 
   /// Default options.
   static Options const DEFAULT_OPTIONS;
 
-  HostDBProcessor()
-  { }
+  HostDBProcessor() {}
 
-  inkcoreapi Action *getbyname_re(Continuation * cont, const char *hostname, 
int len, Options const& opt = DEFAULT_OPTIONS);
+  inkcoreapi Action *getbyname_re(Continuation *cont, const char *hostname, 
int len, Options const &opt = DEFAULT_OPTIONS);
 
-  Action *getSRVbyname_imm(Continuation * cont, process_srv_info_pfn 
process_srv_info, const char *hostname, int len, Options const& opt = 
DEFAULT_OPTIONS);
+  Action *getSRVbyname_imm(Continuation *cont, process_srv_info_pfn 
process_srv_info, const char *hostname, int len,
+                           Options const &opt = DEFAULT_OPTIONS);
 
-  Action *getbyname_imm(
-    Continuation * cont,
-    process_hostdb_info_pfn process_hostdb_info,
-    const char *hostname,
-    int len,
-    Options const& opt = DEFAULT_OPTIONS
-  );
+  Action *getbyname_imm(Continuation *cont, process_hostdb_info_pfn 
process_hostdb_info, const char *hostname, int len,
+                        Options const &opt = DEFAULT_OPTIONS);
 
 
   /** Lookup Hostinfo by addr */
-  Action *getbyaddr_re(Continuation * cont, sockaddr const* aip)
+  Action *
+  getbyaddr_re(Continuation *cont, sockaddr const *aip)
   {
     return getby(cont, NULL, 0, aip, false, HOST_RES_NONE, 0);
   }
@@ -428,18 +459,22 @@ struct HostDBProcessor: public Processor
 #endif
 
   /** Set the application information (fire-and-forget). */
-  void setbyname_appinfo(char *hostname, int len, int port, 
HostDBApplicationInfo * app)
+  void
+  setbyname_appinfo(char *hostname, int len, int port, HostDBApplicationInfo 
*app)
   {
     sockaddr_in addr;
     ats_ip4_set(&addr, INADDR_ANY, port);
     setby(hostname, len, ats_ip_sa_cast(&addr), app);
   }
 
-  void setbyaddr_appinfo(sockaddr const* addr, HostDBApplicationInfo * app) {
+  void
+  setbyaddr_appinfo(sockaddr const *addr, HostDBApplicationInfo *app)
+  {
     this->setby(0, 0, addr, app);
   }
 
-  void setbyaddr_appinfo(in_addr_t ip, HostDBApplicationInfo * app)
+  void
+  setbyaddr_appinfo(in_addr_t ip, HostDBApplicationInfo *app)
   {
     sockaddr_in addr;
     ats_ip4_set(&addr, ip);
@@ -458,29 +493,24 @@ struct HostDBProcessor: public Processor
 
   // Private
   HostDBCache *cache();
+
 private:
-  Action *getby(
-    Continuation * cont,
-    const char *hostname, int len,
-    sockaddr const* ip,
-    bool aforce_dns, HostResStyle host_res_style, int timeout
-  );
+  Action *getby(Continuation *cont, const char *hostname, int len, sockaddr 
const *ip, bool aforce_dns, HostResStyle host_res_style,
+                int timeout);
+
 public:
   /** Set something.
       @a aip can carry address and / or port information. If setting just
       by a port value, the address should be set to INADDR_ANY which is of
       type IPv4.
    */
-  void setby(
-    const char *hostname, ///< Hostname.
-    int len, ///< Length of hostname.
-    sockaddr const* aip, ///< Address and/or port.
-    HostDBApplicationInfo * app ///< I don't know.
-  );
-
-  void setby_srv(const char *hostname, int len, const char *target,
-      HostDBApplicationInfo * app);
+  void setby(const char *hostname,      ///< Hostname.
+             int len,                   ///< Length of hostname.
+             sockaddr const *aip,       ///< Address and/or port.
+             HostDBApplicationInfo *app ///< I don't know.
+             );
 
+  void setby_srv(const char *hostname, int len, const char *target, 
HostDBApplicationInfo *app);
 };
 
 void run_HostDBTest();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/Inline.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/Inline.cc b/iocore/hostdb/Inline.cc
index e93e860..dd8fb46 100644
--- a/iocore/hostdb/Inline.cc
+++ b/iocore/hostdb/Inline.cc
@@ -28,5 +28,3 @@
 
 #define TS_INLINE
 #include "P_HostDB.h"
-
-

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/MultiCache.cc
----------------------------------------------------------------------
diff --git a/iocore/hostdb/MultiCache.cc b/iocore/hostdb/MultiCache.cc
index bac792d..b219631 100644
--- a/iocore/hostdb/MultiCache.cc
+++ b/iocore/hostdb/MultiCache.cc
@@ -32,7 +32,7 @@
 #include "I_Layout.h"
 #include "P_HostDB.h"
 #include "P_MultiCache.h"
-#include "P_EventSystem.h"      // FIXME: need to have this in I_* header 
files.
+#include "P_EventSystem.h" // FIXME: need to have this in I_* header files.
 #include "ink_file.h"
 
 static const int MC_SYNC_MIN_PAUSE_TIME = HRTIME_MSECONDS(200); // Pause for 
at least 200ms
@@ -53,7 +53,7 @@ store_verify(Store *store)
   if (!store)
     return 0;
   for (unsigned i = 0; i < store->n_disks; i++) {
-    for (Span * sd = store->disk[i]; sd; sd = sd->link.next) {
+    for (Span *sd = store->disk[i]; sd; sd = sd->link.next) {
       if (!sd->file_pathname && sd->offset)
         return 0;
     }
@@ -62,9 +62,8 @@ store_verify(Store *store)
 }
 
 MultiCacheHeader::MultiCacheHeader()
-  : magic(MULTI_CACHE_MAGIC_NUMBER), levels(0),
-    tag_bits(0), max_hits(0), elementsize(0),
-    buckets(0), totalelements(0), totalsize(0), nominal_elements(0), 
heap_size(0), heap_halfspace(0)
+  : magic(MULTI_CACHE_MAGIC_NUMBER), levels(0), tag_bits(0), max_hits(0), 
elementsize(0), buckets(0), totalelements(0),
+    totalsize(0), nominal_elements(0), heap_size(0), heap_halfspace(0)
 {
   memset(level_offset, 0, sizeof(level_offset));
   memset(bucketsize, 0, sizeof(bucketsize));
@@ -78,7 +77,7 @@ MultiCacheHeader::MultiCacheHeader()
 static inline int
 bytes_to_blocks(int64_t b)
 {
-  return (int) ((b + (STORE_BLOCK_SIZE - 1)) / STORE_BLOCK_SIZE);
+  return (int)((b + (STORE_BLOCK_SIZE - 1)) / STORE_BLOCK_SIZE);
 }
 
 inline int
@@ -88,7 +87,7 @@ MultiCacheBase::blocks_in_level(unsigned int level)
   int prevblocks = 0;
   int b = 0;
   for (unsigned int i = 0; i <= level; i++) {
-    sumbytes += buckets * ((int64_t) bucketsize[i]);
+    sumbytes += buckets * ((int64_t)bucketsize[i]);
     int sumblocks = bytes_to_blocks(sumbytes);
     b = sumblocks - prevblocks;
     prevblocks = sumblocks;
@@ -102,10 +101,8 @@ MultiCacheBase::blocks_in_level(unsigned int level)
 // The higher levels (lower in number) contain fewer.
 //
 int
-MultiCacheBase::initialize(Store *astore, char *afilename,
-                           int aelements, int abuckets, unsigned int alevels,
-                           int level0_elements_per_bucket,
-                           int level1_elements_per_bucket, int 
level2_elements_per_bucket)
+MultiCacheBase::initialize(Store *astore, char *afilename, int aelements, int 
abuckets, unsigned int alevels,
+                           int level0_elements_per_bucket, int 
level1_elements_per_bucket, int level2_elements_per_bucket)
 {
   int64_t size = 0;
 
@@ -136,7 +133,7 @@ MultiCacheBase::initialize(Store *astore, char *afilename,
     elements[2] = level2_elements_per_bucket;
     totalelements += buckets * level2_elements_per_bucket;
     bucketsize[2] = elementsize * level2_elements_per_bucket;
-    size += (int64_t) bucketsize[2] * (int64_t) buckets;
+    size += (int64_t)bucketsize[2] * (int64_t)buckets;
 
     if (!(level2_elements_per_bucket / level1_elements_per_bucket)) {
       Warning("Size change too large, unable to reconfigure");
@@ -159,7 +156,7 @@ MultiCacheBase::initialize(Store *astore, char *afilename,
     elements[1] = level1_elements_per_bucket;
     totalelements += buckets * level1_elements_per_bucket;
     bucketsize[1] = elementsize * level1_elements_per_bucket;
-    size += (int64_t) bucketsize[1] * (int64_t) buckets;
+    size += (int64_t)bucketsize[1] * (int64_t)buckets;
     if (!(level1_elements_per_bucket / level0_elements_per_bucket)) {
       Warning("Size change too large, unable to reconfigure");
       return -2;
@@ -179,18 +176,18 @@ MultiCacheBase::initialize(Store *astore, char *afilename,
   elements[0] = level0_elements_per_bucket;
   totalelements += buckets * level0_elements_per_bucket;
   bucketsize[0] = elementsize * level0_elements_per_bucket;
-  size += (int64_t) bucketsize[0] * (int64_t) buckets;
+  size += (int64_t)bucketsize[0] * (int64_t)buckets;
 
   buckets_per_partitionF8 = (buckets << 8) / MULTI_CACHE_PARTITIONS;
   ink_release_assert(buckets_per_partitionF8);
 
   unsigned int blocks = (size + (STORE_BLOCK_SIZE - 1)) / STORE_BLOCK_SIZE;
 
-  heap_size = int ((float)totalelements * estimated_heap_bytes_per_entry());
+  heap_size = int((float)totalelements * estimated_heap_bytes_per_entry());
   blocks += bytes_to_blocks(heap_size);
 
-  blocks += 1;                  // header
-  totalsize = (int64_t) blocks *(int64_t) STORE_BLOCK_SIZE;
+  blocks += 1; // header
+  totalsize = (int64_t)blocks * (int64_t)STORE_BLOCK_SIZE;
 
   Debug("multicache", "heap_size = %d, totalelements = %d, totalsize = %d", 
heap_size, totalelements, totalsize);
 
@@ -209,13 +206,13 @@ MultiCacheBase::initialize(Store *astore, char *afilename,
     Warning("Configured store too small, unable to reconfigure");
     return -3;
   }
-  totalsize = (STORE_BLOCK_SIZE) * blocks;
+  totalsize = (STORE_BLOCK_SIZE)*blocks;
 
   level_offset[1] = buckets * bucketsize[0];
   level_offset[2] = buckets * bucketsize[1] + level_offset[1];
 
   if (lowest_level_data)
-    delete[]lowest_level_data;
+    delete[] lowest_level_data;
   lowest_level_data = new char[lowest_level_data_size()];
   ink_assert(lowest_level_data);
   memset(lowest_level_data, 0xFF, lowest_level_data_size());
@@ -224,7 +221,7 @@ MultiCacheBase::initialize(Store *astore, char *afilename,
 }
 
 char *
-MultiCacheBase::mmap_region(int blocks, int *fds, char *cur, size_t& 
total_length, bool private_flag, int zero_fill)
+MultiCacheBase::mmap_region(int blocks, int *fds, char *cur, size_t 
&total_length, bool private_flag, int zero_fill)
 {
   if (!blocks)
     return cur;
@@ -252,13 +249,13 @@ MultiCacheBase::mmap_region(int blocks, int *fds, char 
*cur, size_t& total_lengt
         int flags = private_flag ? MAP_PRIVATE : MAP_SHARED_MAP_NORESERVE;
 
         if (cur)
-          res = (char *) mmap(cur, nbytes, PROT_READ | PROT_WRITE, MAP_FIXED | 
flags, fd, d->offset * STORE_BLOCK_SIZE);
+          res = (char *)mmap(cur, nbytes, PROT_READ | PROT_WRITE, MAP_FIXED | 
flags, fd, d->offset * STORE_BLOCK_SIZE);
         else
-          res = (char *) mmap(cur, nbytes, PROT_READ | PROT_WRITE, flags, fd, 
d->offset * STORE_BLOCK_SIZE);
+          res = (char *)mmap(cur, nbytes, PROT_READ | PROT_WRITE, flags, fd, 
d->offset * STORE_BLOCK_SIZE);
 
         d->offset += b;
 
-        if (res == NULL || res == (caddr_t) MAP_FAILED)
+        if (res == NULL || res == (caddr_t)MAP_FAILED)
           return NULL;
         ink_assert(!cur || res == cur);
         cur = res + nbytes;
@@ -278,7 +275,7 @@ MultiCacheBase::reset()
     delete store;
   store = 0;
   if (lowest_level_data)
-    delete[]lowest_level_data;
+    delete[] lowest_level_data;
   lowest_level_data = 0;
   if (data)
     unmap_data();
@@ -301,7 +298,7 @@ int
 MultiCacheBase::mmap_data(bool private_flag, bool zero_fill)
 {
   ats_scoped_fd fd;
-  int fds[MULTI_CACHE_MAX_FILES] = { 0 };
+  int fds[MULTI_CACHE_MAX_FILES] = {0};
   int n_fds = 0;
   size_t total_mapped = 0; // total mapped memory from storage.
 
@@ -374,13 +371,13 @@ MultiCacheBase::mmap_data(bool private_flag, bool 
zero_fill)
     }
 #endif
 
-    // lots of useless stuff
+// lots of useless stuff
 #if defined(darwin)
-    cur = (char *) mmap(0, totalsize, PROT_READ, MAP_SHARED_MAP_NORESERVE | 
MAP_ANON, -1, 0);
+    cur = (char *)mmap(0, totalsize, PROT_READ, MAP_SHARED_MAP_NORESERVE | 
MAP_ANON, -1, 0);
 #else
-    cur = (char *) mmap(0, totalsize, PROT_READ, MAP_SHARED_MAP_NORESERVE, fd, 
0);
+    cur = (char *)mmap(0, totalsize, PROT_READ, MAP_SHARED_MAP_NORESERVE, fd, 
0);
 #endif
-    if (cur == NULL || cur == (caddr_t) MAP_FAILED) {
+    if (cur == NULL || cur == (caddr_t)MAP_FAILED) {
       store = saved;
 #if defined(darwin)
       Warning("unable to mmap anonymous region for %u bytes: %d, %s", 
totalsize, errno, strerror(errno));
@@ -432,7 +429,7 @@ MultiCacheBase::mmap_data(bool private_flag, bool zero_fill)
         goto Labort;
       }
     }
-    mapped_header = (MultiCacheHeader *) cur;
+    mapped_header = (MultiCacheHeader *)cur;
     if (!mmap_region(1, fds, cur, total_mapped, private_flag, fd)) {
       store = saved;
       goto Labort;
@@ -450,30 +447,29 @@ MultiCacheBase::mmap_data(bool private_flag, bool 
zero_fill)
   }
 
   return 0;
-Lalloc:
-  {
-    free(data);
-    char *cur = 0;
-
-    data = (char *)ats_memalign(ats_pagesize(), totalsize);
-    cur = data + STORE_BLOCK_SIZE * blocks_in_level(0);
-    if (levels > 1)
-      cur = data + STORE_BLOCK_SIZE * blocks_in_level(1);
-    if (levels > 2)
-      cur = data + STORE_BLOCK_SIZE * blocks_in_level(2);
-    if (heap_size) {
-      heap = cur;
-      cur += bytes_to_blocks(heap_size) * STORE_BLOCK_SIZE;
-    }
-    mapped_header = (MultiCacheHeader *) cur;
-    for (int i = 0; i < n_fds; i++) {
-      if (fds[i] >= 0)
-        socketManager.close(fds[i]);
-    }
-
-    return 0;
+Lalloc : {
+  free(data);
+  char *cur = 0;
+
+  data = (char *)ats_memalign(ats_pagesize(), totalsize);
+  cur = data + STORE_BLOCK_SIZE * blocks_in_level(0);
+  if (levels > 1)
+    cur = data + STORE_BLOCK_SIZE * blocks_in_level(1);
+  if (levels > 2)
+    cur = data + STORE_BLOCK_SIZE * blocks_in_level(2);
+  if (heap_size) {
+    heap = cur;
+    cur += bytes_to_blocks(heap_size) * STORE_BLOCK_SIZE;
+  }
+  mapped_header = (MultiCacheHeader *)cur;
+  for (int i = 0; i < n_fds; i++) {
+    if (fds[i] >= 0)
+      socketManager.close(fds[i]);
   }
 
+  return 0;
+}
+
 Labort:
   for (int i = 0; i < n_fds; i++) {
     if (fds[i] >= 0)
@@ -492,18 +488,18 @@ MultiCacheBase::clear()
   heap_used[0] = 8;
   heap_used[1] = 8;
   heap_halfspace = 0;
-  *mapped_header = *(MultiCacheHeader *) this;
+  *mapped_header = *(MultiCacheHeader *)this;
 }
 
 void
 MultiCacheBase::clear_but_heap()
 {
   memset(data, 0, totalelements * elementsize);
-  *mapped_header = *(MultiCacheHeader *) this;
+  *mapped_header = *(MultiCacheHeader *)this;
 }
 
 int
-MultiCacheBase::read_config(const char *config_filename, Store & s, char *fn, 
int *pi, int *pbuck)
+MultiCacheBase::read_config(const char *config_filename, Store &s, char *fn, 
int *pi, int *pbuck)
 {
   int scratch;
   ats_scoped_str rundir(RecConfigReadRuntimeDir());
@@ -548,7 +544,7 @@ MultiCacheBase::write_config(const char *config_filename, 
int nominal_size, int
 
   Layout::relative_to(p, sizeof(p), rundir, config_filename);
 
-  if ((fd =::open(p, O_CREAT | O_WRONLY | O_TRUNC, 0644)) >= 0) {
+  if ((fd = ::open(p, O_CREAT | O_WRONLY | O_TRUNC, 0644)) >= 0) {
     snprintf(buf, sizeof(buf) - 1, "%d\n%d\n%d\n", nominal_size, abuckets, 
heap_size);
     buf[sizeof(buf) - 1] = 0;
     if (ink_file_fd_writestring(fd, buf) != -1 && store->write(fd, filename) 
>= 0)
@@ -561,8 +557,7 @@ MultiCacheBase::write_config(const char *config_filename, 
int nominal_size, int
 }
 
 int
-MultiCacheBase::open(Store *s, const char *config_filename, char *db_filename, 
int db_size,
-                     bool reconfigure, bool fix, bool silent)
+MultiCacheBase::open(Store *s, const char *config_filename, char *db_filename, 
int db_size, bool reconfigure, bool fix, bool silent)
 {
   int ret = 0;
   const char *err = NULL;
@@ -628,7 +623,7 @@ MultiCacheBase::open(Store *s, const char *config_filename, 
char *db_filename, i
             stealStore(freeStore, delta);
             Store more;
             freeStore.spread_alloc(more, delta);
-            if (delta > (int) more.total_blocks())
+            if (delta > (int)more.total_blocks())
               goto LfailReconfig;
             Store more_diff;
             s->try_realloc(more, more_diff);
@@ -676,7 +671,7 @@ MultiCacheBase::open(Store *s, const char *config_filename, 
char *db_filename, i
           goto LfailMap;
         if (!verify_header())
           goto LheaderCorrupt;
-        *(MultiCacheHeader *) this = *mapped_header;
+        *(MultiCacheHeader *)this = *mapped_header;
         ink_assert(store_verify(store));
 
         if (fix)
@@ -730,20 +725,19 @@ LfailMap:
   serr = strerror(errno);
   goto Lfail;
 
-Lfail:
-  {
-    unmap_data();
-    if (!silent) {
-      if (reconfigure) {
-        RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "%s: [%s] %s: disabling 
database\n"
-                     "You may need to 'reconfigure' your cache manually.  
Please refer to\n"
-                     "the 'Configuration' chapter in the manual.", err, 
config_filename, serr ? serr : "");
-      } else {
-        RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "%s: [%s] %s: reinitializing 
database", err, config_filename,
-                     serr ? serr : "");
-      }
+Lfail : {
+  unmap_data();
+  if (!silent) {
+    if (reconfigure) {
+      RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "%s: [%s] %s: disabling 
database\n"
+                                                "You may need to 'reconfigure' 
your cache manually.  Please refer to\n"
+                                                "the 'Configuration' chapter 
in the manual.",
+                       err, config_filename, serr ? serr : "");
+    } else {
+      RecSignalWarning(REC_SIGNAL_CONFIG_ERROR, "%s: [%s] %s: reinitializing 
database", err, config_filename, serr ? serr : "");
     }
   }
+}
   ret = -1;
   goto Lcontinue;
 }
@@ -751,31 +745,21 @@ Lfail:
 bool
 MultiCacheBase::verify_header()
 {
-  return
-    mapped_header->magic == magic &&
-    mapped_header->version.ink_major == version.ink_major &&
-    mapped_header->version.ink_minor == version.ink_minor &&
-    mapped_header->levels == levels &&
-    mapped_header->tag_bits == tag_bits &&
-    mapped_header->max_hits == max_hits &&
-    mapped_header->elementsize == elementsize &&
-    mapped_header->buckets == buckets &&
-    mapped_header->level_offset[0] == level_offset[0] &&
-    mapped_header->level_offset[1] == level_offset[1] &&
-    mapped_header->level_offset[2] == level_offset[2] &&
-    mapped_header->elements[0] == elements[0] &&
-    mapped_header->elements[1] == elements[1] &&
-    mapped_header->elements[2] == elements[2] &&
-    mapped_header->bucketsize[0] == bucketsize[0] &&
-    mapped_header->bucketsize[1] == bucketsize[1] &&
-    mapped_header->bucketsize[2] == bucketsize[2] &&
-    mapped_header->totalelements == totalelements &&
-    mapped_header->totalsize == totalsize && mapped_header->nominal_elements 
== nominal_elements;
+  return mapped_header->magic == magic && mapped_header->version.ink_major == 
version.ink_major &&
+         mapped_header->version.ink_minor == version.ink_minor && 
mapped_header->levels == levels &&
+         mapped_header->tag_bits == tag_bits && mapped_header->max_hits == 
max_hits && mapped_header->elementsize == elementsize &&
+         mapped_header->buckets == buckets && mapped_header->level_offset[0] 
== level_offset[0] &&
+         mapped_header->level_offset[1] == level_offset[1] && 
mapped_header->level_offset[2] == level_offset[2] &&
+         mapped_header->elements[0] == elements[0] && 
mapped_header->elements[1] == elements[1] &&
+         mapped_header->elements[2] == elements[2] && 
mapped_header->bucketsize[0] == bucketsize[0] &&
+         mapped_header->bucketsize[1] == bucketsize[1] && 
mapped_header->bucketsize[2] == bucketsize[2] &&
+         mapped_header->totalelements == totalelements && 
mapped_header->totalsize == totalsize &&
+         mapped_header->nominal_elements == nominal_elements;
 }
 
 void
 MultiCacheBase::print_info(FILE *fp)
-{                               // STDIO OK
+{ // STDIO OK
   fprintf(fp, "    Elements:       %-10d\n", totalelements);
   fprintf(fp, "    Size (bytes):   %-10u\n", totalsize);
 }
@@ -788,7 +772,7 @@ MultiCacheBase::print_info(FILE *fp)
 // if data == NULL we are rebuilding (as opposed to check or fix)
 //
 int
-MultiCacheBase::rebuild(MultiCacheBase & old, int kind)
+MultiCacheBase::rebuild(MultiCacheBase &old, int kind)
 {
   char *new_data = 0;
 
@@ -803,11 +787,11 @@ MultiCacheBase::rebuild(MultiCacheBase & old, int kind)
     return -1;
   }
 
-  new_data = (char *) mmap(0, old.totalsize, PROT_READ | PROT_WRITE, 
MAP_PRIVATE, fd, 0);
+  new_data = (char *)mmap(0, old.totalsize, PROT_READ | PROT_WRITE, 
MAP_PRIVATE, fd, 0);
 
   ink_assert(data != new_data);
-  if (new_data == NULL || new_data == (caddr_t) MAP_FAILED) {
-    Warning("unable to mmap /dev/zero for %u bytes: %d, %s", totalsize,errno, 
strerror(errno));
+  if (new_data == NULL || new_data == (caddr_t)MAP_FAILED) {
+    Warning("unable to mmap /dev/zero for %u bytes: %d, %s", totalsize, errno, 
strerror(errno));
     return -1;
   }
   // if we are rebuilding get the original data
@@ -890,18 +874,15 @@ MultiCacheBase::rebuild(MultiCacheBase & old, int kind)
   if (r.good)
     fprintf(diag_output_fp, "\tGood:       %.2f%% (%d)\n", r.total ? ((r.good 
* 100.0) / r.total) : 0, r.good);
   if (r.deleted)
-    fprintf(diag_output_fp, "\tDeleted:    %5.2f%% (%d)\n",
-            r.deleted ? ((r.deleted * 100.0) / r.total) : 0.0, r.deleted);
+    fprintf(diag_output_fp, "\tDeleted:    %5.2f%% (%d)\n", r.deleted ? 
((r.deleted * 100.0) / r.total) : 0.0, r.deleted);
   if (r.backed)
     fprintf(diag_output_fp, "\tBacked:     %5.2f%% (%d)\n", r.backed ? 
((r.backed * 100.0) / r.total) : 0.0, r.backed);
   if (r.duplicates)
-    fprintf(diag_output_fp, "\tDuplicates: %5.2f%% (%d)\n",
-            r.duplicates ? ((r.duplicates * 100.0) / r.total) : 0.0, 
r.duplicates);
+    fprintf(diag_output_fp, "\tDuplicates: %5.2f%% (%d)\n", r.duplicates ? 
((r.duplicates * 100.0) / r.total) : 0.0, r.duplicates);
   if (r.stale)
     fprintf(diag_output_fp, "\tStale:      %5.2f%% (%d)\n", r.stale ? 
((r.stale * 100.0) / r.total) : 0.0, r.stale);
   if (r.corrupt)
-    fprintf(diag_output_fp, "\tCorrupt:    %5.2f%% (%d)\n",
-            r.corrupt ? ((r.corrupt * 100.0) / r.total) : 0.0, r.corrupt);
+    fprintf(diag_output_fp, "\tCorrupt:    %5.2f%% (%d)\n", r.corrupt ? 
((r.corrupt * 100.0) / r.total) : 0.0, r.corrupt);
 
   old.reset();
 
@@ -936,8 +917,7 @@ MultiCacheBase::sync_heap(int part)
 {
   if (heap_size) {
     int b_per_part = heap_size / MULTI_CACHE_PARTITIONS;
-    if (ats_msync(data + level_offset[2] + buckets * bucketsize[2] +
-                   b_per_part * part, b_per_part, data + totalsize, MS_SYNC) < 
0)
+    if (ats_msync(data + level_offset[2] + buckets * bucketsize[2] + 
b_per_part * part, b_per_part, data + totalsize, MS_SYNC) < 0)
       return -1;
   }
   return 0;
@@ -975,8 +955,8 @@ MultiCacheBase::sync_partition(int partition)
 int
 MultiCacheBase::sync_header()
 {
-  *mapped_header = *(MultiCacheHeader *) this;
-  return ats_msync((char *) mapped_header, STORE_BLOCK_SIZE, (char *) 
mapped_header + STORE_BLOCK_SIZE, MS_SYNC);
+  *mapped_header = *(MultiCacheHeader *)this;
+  return ats_msync((char *)mapped_header, STORE_BLOCK_SIZE, (char 
*)mapped_header + STORE_BLOCK_SIZE, MS_SYNC);
 }
 
 int
@@ -998,38 +978,37 @@ MultiCacheBase::sync_all()
 // Syncs MulitCache
 //
 struct MultiCacheSync;
-typedef int (MultiCacheSync::*MCacheSyncHandler) (int, void *);
+typedef int (MultiCacheSync::*MCacheSyncHandler)(int, void *);
 
-struct MultiCacheSync: public Continuation
-{
+struct MultiCacheSync : public Continuation {
   int partition;
   MultiCacheBase *mc;
   Continuation *cont;
   int before_used;
 
-  int heapEvent(int event, Event *e)
+  int
+  heapEvent(int event, Event *e)
   {
     if (!partition) {
       before_used = mc->heap_used[mc->heap_halfspace];
-      mc->header_snap = *(MultiCacheHeader *) mc;
+      mc->header_snap = *(MultiCacheHeader *)mc;
     }
-    if (partition < MULTI_CACHE_PARTITIONS)
-    {
+    if (partition < MULTI_CACHE_PARTITIONS) {
       mc->sync_heap(partition++);
       e->schedule_imm();
       return EVENT_CONT;
     }
     *mc->mapped_header = mc->header_snap;
-    ink_assert(!ats_msync((char *) mc->mapped_header, STORE_BLOCK_SIZE,
-                           (char *) mc->mapped_header + STORE_BLOCK_SIZE, 
MS_SYNC));
+    ink_assert(!ats_msync((char *)mc->mapped_header, STORE_BLOCK_SIZE, (char 
*)mc->mapped_header + STORE_BLOCK_SIZE, MS_SYNC));
     partition = 0;
-    SET_HANDLER((MCacheSyncHandler) & MultiCacheSync::mcEvent);
+    SET_HANDLER((MCacheSyncHandler)&MultiCacheSync::mcEvent);
     return mcEvent(event, e);
   }
 
-  int mcEvent(int event, Event *e)
+  int
+  mcEvent(int event, Event *e)
   {
-    (void) event;
+    (void)event;
     if (partition >= MULTI_CACHE_PARTITIONS) {
       cont->handleEvent(MULTI_CACHE_EVENT_SYNC, 0);
       Debug("multicache", "MultiCacheSync done (%d, %d)", mc->heap_used[0], 
mc->heap_used[1]);
@@ -1040,28 +1019,30 @@ struct MultiCacheSync: public Continuation
     mc->sync_partition(partition);
     partition++;
     mutex = e->ethread->mutex;
-    SET_HANDLER((MCacheSyncHandler) & MultiCacheSync::pauseEvent);
+    SET_HANDLER((MCacheSyncHandler)&MultiCacheSync::pauseEvent);
     e->schedule_in(MAX(MC_SYNC_MIN_PAUSE_TIME, 
HRTIME_SECONDS(hostdb_sync_frequency - 5) / MULTI_CACHE_PARTITIONS));
     return EVENT_CONT;
   }
 
-  int pauseEvent(int event, Event *e)
+  int
+  pauseEvent(int event, Event *e)
   {
-    (void) event;
-    (void) e;
+    (void)event;
+    (void)e;
     if (partition < MULTI_CACHE_PARTITIONS)
       mutex = mc->locks[partition];
     else
       mutex = cont->mutex;
-    SET_HANDLER((MCacheSyncHandler) & MultiCacheSync::mcEvent);
+    SET_HANDLER((MCacheSyncHandler)&MultiCacheSync::mcEvent);
     e->schedule_imm();
     return EVENT_CONT;
   }
 
-MultiCacheSync(Continuation *acont, MultiCacheBase *amc):
-  Continuation(amc->locks[0]), partition(0), mc(amc), cont(acont), 
before_used(0) {
+  MultiCacheSync(Continuation *acont, MultiCacheBase *amc)
+    : Continuation(amc->locks[0]), partition(0), mc(amc), cont(acont), 
before_used(0)
+  {
     mutex = mc->locks[partition];
-    SET_HANDLER((MCacheSyncHandler) & MultiCacheSync::heapEvent);
+    SET_HANDLER((MCacheSyncHandler)&MultiCacheSync::heapEvent);
   }
 };
 
@@ -1076,10 +1057,10 @@ MultiCacheBase::fixup_heap_offsets(int partition, int 
before_used, UnsunkPtrRegi
     r = &unsunk[partition];
   bool found = 0;
   for (int i = 0; i < r->n; i++) {
-    UnsunkPtr & p = r->ptrs[i];
+    UnsunkPtr &p = r->ptrs[i];
     if (p.offset) {
-      Debug("multicache", "fixup p.offset %d offset %d %" PRId64 " part %d",
-            p.offset, *p.poffset, (int64_t)((char *) p.poffset - data), 
partition);
+      Debug("multicache", "fixup p.offset %d offset %d %" PRId64 " part %d", 
p.offset, *p.poffset,
+            (int64_t)((char *)p.poffset - data), partition);
       if (*p.poffset == -(i + base) - 1) {
         if (halfspace_of(p.offset) != heap_halfspace) {
           ink_assert(0);
@@ -1092,12 +1073,11 @@ MultiCacheBase::fixup_heap_offsets(int partition, int 
before_used, UnsunkPtrRegi
             continue;
         }
       } else {
-        Debug("multicache",
-              "not found %" PRId64 " i %d base %d *p.poffset = %d",
-              (int64_t)((char *) p.poffset - data), i, base, *p.poffset);
+        Debug("multicache", "not found %" PRId64 " i %d base %d *p.poffset = 
%d", (int64_t)((char *)p.poffset - data), i, base,
+              *p.poffset);
       }
       p.offset = 0;
-      p.poffset = (int *) r->next_free;
+      p.poffset = (int *)r->next_free;
       r->next_free = &p;
       found = true;
     }
@@ -1113,41 +1093,36 @@ MultiCacheBase::fixup_heap_offsets(int partition, int 
before_used, UnsunkPtrRegi
   return r;
 }
 
-struct OffsetTable
-{
+struct OffsetTable {
   int new_offset;
   int *poffset;
 };
 
 struct MultiCacheHeapGC;
-typedef int (MultiCacheHeapGC::*MCacheHeapGCHandler) (int, void *);
-struct MultiCacheHeapGC: public Continuation
-{
+typedef int (MultiCacheHeapGC::*MCacheHeapGCHandler)(int, void *);
+struct MultiCacheHeapGC : public Continuation {
   Continuation *cont;
   MultiCacheBase *mc;
   int partition;
   int n_offsets;
   OffsetTable *offset_table;
 
-  int startEvent(int event, Event *e)
+  int
+  startEvent(int event, Event *e)
   {
-    (void) event;
-    if (partition < MULTI_CACHE_PARTITIONS)
-    {
-
+    (void)event;
+    if (partition < MULTI_CACHE_PARTITIONS) {
       // copy heap data
 
       char *before = mc->heap + mc->heap_used[mc->heap_halfspace];
-        mc->copy_heap(partition, this);
+      mc->copy_heap(partition, this);
       char *after = mc->heap + mc->heap_used[mc->heap_halfspace];
 
       // sync new heap data and header (used)
 
-      if (after - before > 0)
-      {
+      if (after - before > 0) {
         ink_assert(!ats_msync(before, after - before, mc->heap + 
mc->totalsize, MS_SYNC));
-        ink_assert(!ats_msync((char *) mc->mapped_header, STORE_BLOCK_SIZE,
-                               (char *) mc->mapped_header + STORE_BLOCK_SIZE, 
MS_SYNC));
+        ink_assert(!ats_msync((char *)mc->mapped_header, STORE_BLOCK_SIZE, 
(char *)mc->mapped_header + STORE_BLOCK_SIZE, MS_SYNC));
       }
       // update table to point to new entries
 
@@ -1169,26 +1144,24 @@ struct MultiCacheHeapGC: public Continuation
       e->schedule_in(MAX(MC_SYNC_MIN_PAUSE_TIME, 
HRTIME_SECONDS(hostdb_sync_frequency - 5) / MULTI_CACHE_PARTITIONS));
       return EVENT_CONT;
     }
-    mc->heap_used[mc->heap_halfspace ? 0 : 1] = 8;      // skip 0
+    mc->heap_used[mc->heap_halfspace ? 0 : 1] = 8; // skip 0
     cont->handleEvent(MULTI_CACHE_EVENT_SYNC, 0);
     Debug("multicache", "MultiCacheHeapGC done");
     delete this;
     return EVENT_DONE;
   }
 
-MultiCacheHeapGC(Continuation *acont, MultiCacheBase *amc):
-  Continuation(amc->locks[0]), cont(acont), mc(amc), partition(0), 
n_offsets(0) {
-
-    SET_HANDLER((MCacheHeapGCHandler) & MultiCacheHeapGC::startEvent);
+  MultiCacheHeapGC(Continuation *acont, MultiCacheBase *amc)
+    : Continuation(amc->locks[0]), cont(acont), mc(amc), partition(0), 
n_offsets(0)
+  {
+    SET_HANDLER((MCacheHeapGCHandler)&MultiCacheHeapGC::startEvent);
     offset_table = (OffsetTable *)ats_malloc(sizeof(OffsetTable) *
-        ((mc->totalelements / MULTI_CACHE_PARTITIONS) + 
mc->elements[mc->levels - 1] * 3 + 1));
+                                             ((mc->totalelements / 
MULTI_CACHE_PARTITIONS) + mc->elements[mc->levels - 1] * 3 + 1));
     // flip halfspaces
     mutex = mc->locks[partition];
     mc->heap_halfspace = mc->heap_halfspace ? 0 : 1;
   }
-  ~MultiCacheHeapGC() {
-    ats_free(offset_table);
-  }
+  ~MultiCacheHeapGC() { ats_free(offset_table); }
 };
 
 void
@@ -1206,11 +1179,11 @@ MultiCacheBase::sync_partitions(Continuation *cont)
 void
 MultiCacheBase::copy_heap_data(char *src, int s, int *pi, int partition, 
MultiCacheHeapGC *gc)
 {
-  char *dest = (char *) alloc(NULL, s);
+  char *dest = (char *)alloc(NULL, s);
   Debug("multicache", "copy %p to %p", src, dest);
   if (dest) {
     memcpy(dest, src, s);
-    if (*pi < 0) {              // already in the unsunk ptr registry, ok to 
change there
+    if (*pi < 0) { // already in the unsunk ptr registry, ok to change there
       UnsunkPtr *ptr = unsunk[partition].ptr(-*pi - 1);
       if (ptr->poffset == pi)
         ptr->offset = dest - heap;
@@ -1229,8 +1202,7 @@ MultiCacheBase::copy_heap_data(char *src, int s, int *pi, 
int partition, MultiCa
   }
 }
 
-UnsunkPtrRegistry::UnsunkPtrRegistry()
-:mc(NULL), n(0), ptrs(NULL), next_free(NULL), next(NULL)
+UnsunkPtrRegistry::UnsunkPtrRegistry() : mc(NULL), n(0), ptrs(NULL), 
next_free(NULL), next(NULL)
 {
 }
 
@@ -1247,7 +1219,7 @@ UnsunkPtrRegistry::alloc_data()
   ptrs = (UnsunkPtr *)ats_malloc(s);
   for (int i = 0; i < bs; i++) {
     ptrs[i].offset = 0;
-    ptrs[i].poffset = (int *) &ptrs[i + 1];
+    ptrs[i].poffset = (int *)&ptrs[i + 1];
   }
   ptrs[bs - 1].poffset = NULL;
   next_free = ptrs;
@@ -1259,7 +1231,7 @@ UnsunkPtrRegistry::alloc(int *poffset, int base)
 {
   if (next_free) {
     UnsunkPtr *res = next_free;
-    next_free = (UnsunkPtr *) next_free->poffset;
+    next_free = (UnsunkPtr *)next_free->poffset;
     *poffset = -(base + (res - ptrs)) - 1;
     ink_assert(*poffset);
     return res;
@@ -1282,10 +1254,10 @@ MultiCacheBase::alloc(int *poffset, int asize)
 {
   int h = heap_halfspace;
   int size = (asize + MULTI_CACHE_HEAP_ALIGNMENT - 1) & 
~(MULTI_CACHE_HEAP_ALIGNMENT - 1);
-  int o = ink_atomic_increment((int *) &heap_used[h], size);
+  int o = ink_atomic_increment((int *)&heap_used[h], size);
 
   if (o + size > halfspace_size()) {
-    ink_atomic_increment((int *) &heap_used[h], -size);
+    ink_atomic_increment((int *)&heap_used[h], -size);
     ink_assert(!"out of space");
     if (poffset)
       *poffset = 0;
@@ -1294,16 +1266,16 @@ MultiCacheBase::alloc(int *poffset, int asize)
   int offset = (h ? halfspace_size() : 0) + o;
   char *p = heap + offset;
   if (poffset) {
-    int part = ptr_to_partition((char *) poffset);
+    int part = ptr_to_partition((char *)poffset);
     if (part < 0)
       return NULL;
     UnsunkPtr *up = unsunk[part].alloc(poffset);
     up->offset = offset;
     up->poffset = poffset;
-    Debug("multicache", "alloc unsunk %d at %" PRId64 " part %d offset %d",
-          *poffset, (int64_t)((char *) poffset - data), part, offset);
+    Debug("multicache", "alloc unsunk %d at %" PRId64 " part %d offset %d", 
*poffset, (int64_t)((char *)poffset - data), part,
+          offset);
   }
-  return (void *) p;
+  return (void *)p;
 }
 
 UnsunkPtr *
@@ -1325,14 +1297,14 @@ void *
 MultiCacheBase::ptr(int *poffset, int partition)
 {
   int o = *poffset;
-  Debug("multicache", "ptr %" PRId64 " part %d %d", (int64_t)((char *) poffset 
- data), partition, o);
+  Debug("multicache", "ptr %" PRId64 " part %d %d", (int64_t)((char *)poffset 
- data), partition, o);
   if (o > 0) {
     if (!valid_offset(o)) {
       ink_assert(!"bad offset");
       *poffset = 0;
       return NULL;
     }
-    return (void *) (heap + o - 1);
+    return (void *)(heap + o - 1);
   }
   if (!o)
     return NULL;
@@ -1341,14 +1313,14 @@ MultiCacheBase::ptr(int *poffset, int partition)
     return NULL;
   if (p->poffset != poffset)
     return NULL;
-  return (void *) (heap + p->offset);
+  return (void *)(heap + p->offset);
 }
 
 void
 MultiCacheBase::update(int *poffset, int *old_poffset)
 {
   int o = *poffset;
-  Debug("multicache", "updating %" PRId64 " %d", (int64_t)((char *) poffset - 
data), o);
+  Debug("multicache", "updating %" PRId64 " %d", (int64_t)((char *)poffset - 
data), o);
   if (o > 0) {
     if (!valid_offset(o)) {
       ink_assert(!"bad poffset");
@@ -1359,7 +1331,7 @@ MultiCacheBase::update(int *poffset, int *old_poffset)
   if (!o)
     return;
 
-  int part = ptr_to_partition((char *) poffset);
+  int part = ptr_to_partition((char *)poffset);
 
   if (part < 0)
     return;
@@ -1392,7 +1364,7 @@ MultiCacheBase::ptr_to_partition(char *ptr)
 
 
 void
-stealStore(Store & s, int blocks)
+stealStore(Store &s, int blocks)
 {
   if (s.read_config())
     return;
@@ -1414,14 +1386,14 @@ stealStore(Store & s, int blocks)
   }
   // grab some end portion of some block... so as not to damage the
   // pool header
-  for (unsigned d = 0; d < s.n_disks; ) {
+  for (unsigned d = 0; d < s.n_disks;) {
     Span *ds = s.disk[d];
     while (ds) {
       if (!blocks)
         ds->blocks = 0;
       else {
         int b = blocks;
-        if ((int) ds->blocks < blocks)
+        if ((int)ds->blocks < blocks)
           b = ds->blocks;
         if (ds->file_pathname)
           ds->offset += (ds->blocks - b);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/P_HostDB.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/P_HostDB.h b/iocore/hostdb/P_HostDB.h
index 1973597..c78e051 100644
--- a/iocore/hostdb/P_HostDB.h
+++ b/iocore/hostdb/P_HostDB.h
@@ -48,12 +48,9 @@
 #include "P_HostDBProcessor.h"
 
 
-#undef  HOSTDB_MODULE_VERSION
-#define HOSTDB_MODULE_VERSION makeModuleVersion(                 \
-                                    HOSTDB_MODULE_MAJOR_VERSION, \
-                                    HOSTDB_MODULE_MINOR_VERSION, \
-                                    PRIVATE_MODULE_HEADER)
-HostDBInfo *probe(ProxyMutex * mutex, HostDBMD5 const& md5, bool 
ignore_timeout);
-
-void make_md5(INK_MD5 & md5, const char *hostname, int len, int port, char 
const*pDNSServers, HostDBMark mark);
+#undef HOSTDB_MODULE_VERSION
+#define HOSTDB_MODULE_VERSION makeModuleVersion(HOSTDB_MODULE_MAJOR_VERSION, 
HOSTDB_MODULE_MINOR_VERSION, PRIVATE_MODULE_HEADER)
+HostDBInfo *probe(ProxyMutex *mutex, HostDBMD5 const &md5, bool 
ignore_timeout);
+
+void make_md5(INK_MD5 &md5, const char *hostname, int len, int port, char 
const *pDNSServers, HostDBMark mark);
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/P_HostDBProcessor.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/P_HostDBProcessor.h 
b/iocore/hostdb/P_HostDBProcessor.h
index e67b0f8..5f2b908 100644
--- a/iocore/hostdb/P_HostDBProcessor.h
+++ b/iocore/hostdb/P_HostDBProcessor.h
@@ -43,8 +43,12 @@ extern int hostdb_insert_timeout;
 extern int hostdb_re_dns_on_reload;
 
 // 0 = obey, 1 = ignore, 2 = min(X,ttl), 3 = max(X,ttl)
-enum
-  { TTL_OBEY, TTL_IGNORE, TTL_MIN, TTL_MAX };
+enum {
+  TTL_OBEY,
+  TTL_IGNORE,
+  TTL_MIN,
+  TTL_MAX,
+};
 extern int hostdb_ttl_mode;
 
 extern unsigned int hostdb_current_interval;
@@ -55,7 +59,7 @@ extern int hostdb_size;
 extern int hostdb_srv_enabled;
 extern char hostdb_filename[PATH_NAME_MAX + 1];
 
-//extern int hostdb_timestamp;
+// extern int hostdb_timestamp;
 extern int hostdb_sync_frequency;
 extern int hostdb_disable_reverse_lookup;
 
@@ -70,29 +74,28 @@ extern HostDBCache hostDB;
  */
 enum HostDBMark {
   HOSTDB_MARK_GENERIC, ///< Anything that's not one of the other types.
-  HOSTDB_MARK_IPV4, ///< IPv4 / T_A
-  HOSTDB_MARK_IPV6, ///< IPv6 / T_AAAA
-  HOSTDB_MARK_SRV, ///< Service / T_SRV
+  HOSTDB_MARK_IPV4,    ///< IPv4 / T_A
+  HOSTDB_MARK_IPV6,    ///< IPv6 / T_AAAA
+  HOSTDB_MARK_SRV,     ///< Service / T_SRV
 };
 /** Convert a HostDB @a mark to a string.
     @return A static string.
  */
-extern char const* string_for(HostDBMark mark);
+extern char const *string_for(HostDBMark mark);
 
-inline unsigned int HOSTDB_CLIENT_IP_HASH(
-  sockaddr const* lhs,
-  sockaddr const* rhs
-) {
+inline unsigned int
+HOSTDB_CLIENT_IP_HASH(sockaddr const *lhs, sockaddr const *rhs)
+{
   unsigned int zret = ~static_cast<unsigned int>(0);
-  if (ats_ip_are_compatible(lhs,rhs)) {
+  if (ats_ip_are_compatible(lhs, rhs)) {
     if (ats_is_ip4(lhs)) {
       in_addr_t ip1 = ats_ip4_addr_cast(lhs);
       in_addr_t ip2 = ats_ip4_addr_cast(rhs);
       zret = (ip1 >> 16) ^ ip1 ^ ip2 ^ (ip2 >> 16);
     } else if (ats_is_ip6(lhs)) {
-      uint32_t const* ip1 = ats_ip_addr32_cast(lhs);
-      uint32_t const* ip2 = ats_ip_addr32_cast(rhs);
-      for ( int i = 0 ; i < 4 ; ++i, ++ip1, ++ip2 ) {
+      uint32_t const *ip1 = ats_ip_addr32_cast(lhs);
+      uint32_t const *ip2 = ats_ip_addr32_cast(rhs);
+      for (int i = 0; i < 4; ++i, ++ip1, ++ip2) {
         zret ^= (*ip1 >> 16) ^ *ip1 ^ *ip2 ^ (*ip2 >> 16);
       }
     }
@@ -104,44 +107,44 @@ inline unsigned int HOSTDB_CLIENT_IP_HASH(
 // Constants
 //
 
-#define HOST_DB_HITS_BITS           3
-#define HOST_DB_TAG_BITS            56
+#define HOST_DB_HITS_BITS 3
+#define HOST_DB_TAG_BITS 56
 
-#define CONFIGURATION_HISTORY_PROBE_DEPTH   1
+#define CONFIGURATION_HISTORY_PROBE_DEPTH 1
 
 // Bump this any time hostdb format is changed
-#define HOST_DB_CACHE_MAJOR_VERSION         3
-#define HOST_DB_CACHE_MINOR_VERSION         0
+#define HOST_DB_CACHE_MAJOR_VERSION 3
+#define HOST_DB_CACHE_MINOR_VERSION 0
 // 2.2: IP family split 2.1 : IPv6
 
-#define DEFAULT_HOST_DB_FILENAME             "host.db"
-#define DEFAULT_HOST_DB_SIZE                 (1<<14)
+#define DEFAULT_HOST_DB_FILENAME "host.db"
+#define DEFAULT_HOST_DB_SIZE (1 << 14)
 // Resolution of timeouts
-#define HOST_DB_TIMEOUT_INTERVAL             HRTIME_SECOND
+#define HOST_DB_TIMEOUT_INTERVAL HRTIME_SECOND
 // Timeout DNS every 24 hours by default if ttl_mode is enabled
-#define HOST_DB_IP_TIMEOUT                   (24*60*60)
+#define HOST_DB_IP_TIMEOUT (24 * 60 * 60)
 // DNS entries should be revalidated every 12 hours
-#define HOST_DB_IP_STALE                     (12*60*60)
+#define HOST_DB_IP_STALE (12 * 60 * 60)
 // DNS entries which failed lookup, should be revalidated every hour
-#define HOST_DB_IP_FAIL_TIMEOUT              (60*60)
+#define HOST_DB_IP_FAIL_TIMEOUT (60 * 60)
 
 //#define HOST_DB_MAX_INTERVAL                 (0x7FFFFFFF)
-#define HOST_DB_MAX_TTL                      (0x1FFFFF) //24 days
+#define HOST_DB_MAX_TTL (0x1FFFFF) // 24 days
 
 //
 // Constants
 //
 
 // period to wait for a remote probe...
-#define HOST_DB_CLUSTER_TIMEOUT  HRTIME_MSECONDS(5000)
-#define HOST_DB_RETRY_PERIOD     HRTIME_MSECONDS(20)
+#define HOST_DB_CLUSTER_TIMEOUT HRTIME_MSECONDS(5000)
+#define HOST_DB_RETRY_PERIOD HRTIME_MSECONDS(20)
 
 //#define TEST(_x) _x
 #define TEST(_x)
 
 
 #ifdef _HOSTDB_CC_
-template struct MultiCache <HostDBInfo >;
+template struct MultiCache<HostDBInfo>;
 #endif /* _HOSTDB_CC_ */
 
 struct ClusterMachine;
@@ -149,13 +152,12 @@ struct HostEnt;
 struct ClusterConfiguration;
 
 // Stats
-enum HostDB_Stats
-{
+enum HostDB_Stats {
   hostdb_total_entries_stat,
   hostdb_total_lookups_stat,
-  hostdb_total_hits_stat,       // D == total hits
-  hostdb_ttl_stat,              // D average TTL
-  hostdb_ttl_expires_stat,      // D == TTL Expires
+  hostdb_total_hits_stat,  // D == total hits
+  hostdb_ttl_stat,         // D average TTL
+  hostdb_ttl_expires_stat, // D == TTL Expires
   hostdb_re_dns_on_reload_stat,
   hostdb_bytes_stat,
   HostDB_Stat_Count
@@ -167,56 +169,55 @@ extern RecRawStatBlock *hostdb_rsb;
 
 // Stat Macros
 
-#define HOSTDB_DEBUG_COUNT_DYN_STAT(_x, _y) \
-RecIncrRawStatCount(hostdb_rsb, mutex->thread_holding, (int)_x, _y)
+#define HOSTDB_DEBUG_COUNT_DYN_STAT(_x, _y) RecIncrRawStatCount(hostdb_rsb, 
mutex->thread_holding, (int)_x, _y)
 
-#define HOSTDB_INCREMENT_DYN_STAT(_x)  \
-RecIncrRawStatSum(hostdb_rsb, mutex->thread_holding, (int)_x, 1)
+#define HOSTDB_INCREMENT_DYN_STAT(_x) RecIncrRawStatSum(hostdb_rsb, 
mutex->thread_holding, (int)_x, 1)
 
-#define HOSTDB_DECREMENT_DYN_STAT(_x) \
-RecIncrRawStatSum(hostdb_rsb, mutex->thread_holding, (int)_x, -1)
+#define HOSTDB_DECREMENT_DYN_STAT(_x) RecIncrRawStatSum(hostdb_rsb, 
mutex->thread_holding, (int)_x, -1)
 
-#define HOSTDB_SUM_DYN_STAT(_x, _r) \
-RecIncrRawStatSum(hostdb_rsb, mutex->thread_holding, (int)_x, _r)
+#define HOSTDB_SUM_DYN_STAT(_x, _r) RecIncrRawStatSum(hostdb_rsb, 
mutex->thread_holding, (int)_x, _r)
 
-#define HOSTDB_READ_DYN_STAT(_x, _count, _sum) do {\
-RecGetRawStatSum(hostdb_rsb, (int)_x, &_sum);          \
-RecGetRawStatCount(hostdb_rsb, (int)_x, &_count);         \
-} while (0)
+#define HOSTDB_READ_DYN_STAT(_x, _count, _sum)        \
+  do {                                                \
+    RecGetRawStatSum(hostdb_rsb, (int)_x, &_sum);     \
+    RecGetRawStatCount(hostdb_rsb, (int)_x, &_count); \
+  } while (0)
 
-#define HOSTDB_SET_DYN_COUNT(_x, _count) \
-RecSetRawStatCount(hostdb_rsb, _x, _count);
+#define HOSTDB_SET_DYN_COUNT(_x, _count) RecSetRawStatCount(hostdb_rsb, _x, 
_count);
 
-#define HOSTDB_INCREMENT_THREAD_DYN_STAT(_s, _t) \
-  RecIncrRawStatSum(hostdb_rsb, _t, (int) _s, 1);
+#define HOSTDB_INCREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStatSum(hostdb_rsb, 
_t, (int)_s, 1);
 
-#define HOSTDB_DECREMENT_THREAD_DYN_STAT(_s, _t) \
-  RecIncrRawStatSum(hostdb_rsb, _t, (int) _s, -1);
+#define HOSTDB_DECREMENT_THREAD_DYN_STAT(_s, _t) RecIncrRawStatSum(hostdb_rsb, 
_t, (int)_s, -1);
 
 
 //
 // HostDBCache (Private)
 //
-struct HostDBCache: public MultiCache<HostDBInfo>
-{
-  int rebuild_callout(HostDBInfo * e, RebuildMC & r);
+struct HostDBCache : public MultiCache<HostDBInfo> {
+  int rebuild_callout(HostDBInfo *e, RebuildMC &r);
   int start(int flags = 0);
-  MultiCacheBase *dup()
+  MultiCacheBase *
+  dup()
   {
     return new HostDBCache;
   }
 
   // This accounts for an average of 2 HostDBInfo per DNS cache (for 
round-robin etc.)
   // In addition, we can do a padding for additional SRV records storage.
-  virtual size_t estimated_heap_bytes_per_entry() const { return 
sizeof(HostDBInfo) * 2 + 512 * hostdb_srv_enabled; }
+  virtual size_t
+  estimated_heap_bytes_per_entry() const
+  {
+    return sizeof(HostDBInfo) * 2 + 512 * hostdb_srv_enabled;
+  }
 
   Queue<HostDBContinuation, Continuation::Link_link> 
pending_dns[MULTI_CACHE_PARTITIONS];
-  Queue<HostDBContinuation, Continuation::Link_link> 
&pending_dns_for_hash(INK_MD5 & md5);
+  Queue<HostDBContinuation, Continuation::Link_link> 
&pending_dns_for_hash(INK_MD5 &md5);
   HostDBCache();
 };
 
 inline int
-HostDBRoundRobin::index_of(sockaddr const* ip) {
+HostDBRoundRobin::index_of(sockaddr const *ip)
+{
   bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good 
<= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
   if (bad) {
     ink_assert(!"bad round robin size");
@@ -232,19 +233,21 @@ HostDBRoundRobin::index_of(sockaddr const* ip) {
   return -1;
 }
 
-inline HostDBInfo*
-HostDBRoundRobin::find_ip(sockaddr const* ip) {
+inline HostDBInfo *
+HostDBRoundRobin::find_ip(sockaddr const *ip)
+{
   int idx = this->index_of(ip);
   return idx < 0 ? NULL : &info[idx];
 }
 
-inline HostDBInfo*
-HostDBRoundRobin::select_next(sockaddr const* ip) {
-  HostDBInfo* zret = 0;
+inline HostDBInfo *
+HostDBRoundRobin::select_next(sockaddr const *ip)
+{
+  HostDBInfo *zret = 0;
   if (good > 1) {
     int idx = this->index_of(ip);
     if (idx >= 0) {
-      idx = (idx+1)%good;
+      idx = (idx + 1) % good;
       zret = &info[idx];
     }
   }
@@ -252,7 +255,8 @@ HostDBRoundRobin::select_next(sockaddr const* ip) {
 }
 
 inline HostDBInfo *
-HostDBRoundRobin::find_target(const char *target) {
+HostDBRoundRobin::find_target(const char *target)
+{
   bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good 
<= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
   if (bad) {
     ink_assert(!"bad round robin size");
@@ -268,7 +272,7 @@ HostDBRoundRobin::find_target(const char *target) {
 }
 
 inline HostDBInfo *
-HostDBRoundRobin::select_best_http(sockaddr const* client_ip, ink_time_t now, 
int32_t fail_window)
+HostDBRoundRobin::select_best_http(sockaddr const *client_ip, ink_time_t now, 
int32_t fail_window)
 {
   bool bad = (rrcount <= 0 || rrcount > HOST_DB_MAX_ROUND_ROBIN_INFO || good 
<= 0 || good > HOST_DB_MAX_ROUND_ROBIN_INFO);
 
@@ -296,7 +300,7 @@ HostDBRoundRobin::select_best_http(sockaddr const* 
client_ip, ink_time_t now, in
     Debug("hostdb", "Using default round robin");
     unsigned int best_hash_any = 0;
     unsigned int best_hash_up = 0;
-    sockaddr const* ip;
+    sockaddr const *ip;
     for (int i = 0; i < good; i++) {
       ip = info[i].ip();
       unsigned int h = HOSTDB_CLIENT_IP_HASH(client_ip, ip);
@@ -304,8 +308,7 @@ HostDBRoundRobin::select_best_http(sockaddr const* 
client_ip, ink_time_t now, in
         best_any = i;
         best_hash_any = h;
       }
-      if (info[i].app.http_data.last_failure == 0 ||
-          (unsigned int) (now - fail_window) > 
info[i].app.http_data.last_failure) {
+      if (info[i].app.http_data.last_failure == 0 || (unsigned int)(now - 
fail_window) > info[i].app.http_data.last_failure) {
         // Entry is marked up
         if (best_hash_up <= h) {
           best_up = i;
@@ -317,7 +320,7 @@ HostDBRoundRobin::select_best_http(sockaddr const* 
client_ip, ink_time_t now, in
         //  as to how far in the future we should tolerate bogus last
         //  failure times.  This sets the upper bound that we would ever
         //  consider a server down to 2*down_server_timeout
-        if (now + fail_window < (int32_t) 
(info[i].app.http_data.last_failure)) {
+        if (now + fail_window < (int32_t)(info[i].app.http_data.last_failure)) 
{
 #ifdef DEBUG
           // because this region is mmaped, I cann't get anything
           //   useful from the structure in core files,  therefore
@@ -356,7 +359,7 @@ HostDBRoundRobin::select_best_srv(char *target, InkRand 
*rand, ink_time_t now, i
 
 #ifdef DEBUG
   for (int i = 1; i < good; ++i) {
-    ink_assert(info[i].data.srv.srv_priority >= 
info[i-1].data.srv.srv_priority);
+    ink_assert(info[i].data.srv.srv_priority >= info[i - 
1].data.srv.srv_priority);
   }
 #endif
 
@@ -366,8 +369,7 @@ HostDBRoundRobin::select_best_srv(char *target, InkRand 
*rand, ink_time_t now, i
   HostDBInfo *infos[HOST_DB_MAX_ROUND_ROBIN_INFO];
 
   do {
-    if (info[i].app.http_data.last_failure != 0 &&
-        (uint32_t) (now - fail_window) < info[i].app.http_data.last_failure) {
+    if (info[i].app.http_data.last_failure != 0 && (uint32_t)(now - 
fail_window) < info[i].app.http_data.last_failure) {
       continue;
     }
 
@@ -413,15 +415,15 @@ struct HostDBMD5 {
 
   INK_MD5 hash; ///< The hash value.
 
-  char const* host_name; ///< Host name.
-  int host_len; ///< Length of @a _host_name
-  IpAddr ip; ///< IP address.
-  in_port_t port; ///< IP port (host order).
+  char const *host_name; ///< Host name.
+  int host_len;          ///< Length of @a _host_name
+  IpAddr ip;             ///< IP address.
+  in_port_t port;        ///< IP port (host order).
   /// DNS server. Not strictly part of the MD5 data but
   /// it's both used by @c HostDBContinuation and provides access to
   /// MD5 data. It's just handier to store it here for both uses.
-  DNSServer* dns_server;
-  SplitDNS* pSD; ///< Hold the container for @a dns_server.
+  DNSServer *dns_server;
+  SplitDNS *pSD;      ///< Hold the container for @a dns_server.
   HostDBMark db_mark; ///< Mark / type of record.
 
   /// Default constructor.
@@ -433,17 +435,16 @@ struct HostDBMD5 {
   /** Assign a hostname.
       This updates the split DNS data as well.
   */
-  self& set_host(char const* name, int len);
+  self &set_host(char const *name, int len);
 };
 
 //
 // Handles a HostDB lookup request
 //
 struct HostDBContinuation;
-typedef int (HostDBContinuation::*HostDBContHandler) (int, void *);
+typedef int (HostDBContinuation::*HostDBContHandler)(int, void *);
 
-struct HostDBContinuation: public Continuation
-{
+struct HostDBContinuation : public Continuation {
   Action action;
   HostDBMD5 md5;
   //  IpEndpoint ip;
@@ -463,45 +464,47 @@ struct HostDBContinuation: public Continuation
   ClusterMachine *past_probes[CONFIGURATION_HISTORY_PROBE_DEPTH];
   //  char name[MAXDNAME];
   //  int namelen;
-  char md5_host_name_store[MAXDNAME+1]; // used as backing store for @a md5
+  char md5_host_name_store[MAXDNAME + 1]; // used as backing store for @a md5
   char srv_target_name[MAXDNAME];
   //  void *m_pDS;
   Action *pending_action;
 
-  unsigned int missing:1;
-  unsigned int force_dns:1;
-  unsigned int round_robin:1;
+  unsigned int missing : 1;
+  unsigned int force_dns : 1;
+  unsigned int round_robin : 1;
 
-  int probeEvent(int event, Event * e);
-  int clusterEvent(int event, Event * e);
-  int clusterResponseEvent(int event, Event * e);
-  int dnsEvent(int event, HostEnt * e);
-  int dnsPendingEvent(int event, Event * e);
-  int backgroundEvent(int event, Event * e);
-  int retryEvent(int event, Event * e);
-  int removeEvent(int event, Event * e);
-  int setbyEvent(int event, Event * e);
+  int probeEvent(int event, Event *e);
+  int clusterEvent(int event, Event *e);
+  int clusterResponseEvent(int event, Event *e);
+  int dnsEvent(int event, HostEnt *e);
+  int dnsPendingEvent(int event, Event *e);
+  int backgroundEvent(int event, Event *e);
+  int retryEvent(int event, Event *e);
+  int removeEvent(int event, Event *e);
+  int setbyEvent(int event, Event *e);
 
   /// Recompute the MD5 and update ancillary values.
   void refresh_MD5();
   void do_dns();
-  bool is_byname()
+  bool
+  is_byname()
   {
     return md5.db_mark == HOSTDB_MARK_IPV4 || md5.db_mark == HOSTDB_MARK_IPV6;
   }
-  bool is_srv()
+  bool
+  is_srv()
   {
     return md5.db_mark == HOSTDB_MARK_SRV;
   }
-  HostDBInfo *lookup_done(IpAddr const& ip, char const* aname, bool 
round_robin, unsigned int attl, SRVHosts * s = NULL);
-  bool do_get_response(Event * e);
-  void do_put_response(ClusterMachine * m, HostDBInfo * r, Continuation * 
cont);
-  int failed_cluster_request(Event * e);
+  HostDBInfo *lookup_done(IpAddr const &ip, char const *aname, bool 
round_robin, unsigned int attl, SRVHosts *s = NULL);
+  bool do_get_response(Event *e);
+  void do_put_response(ClusterMachine *m, HostDBInfo *r, Continuation *cont);
+  int failed_cluster_request(Event *e);
   int key_partition();
   void remove_trigger_pending_dns();
   int set_check_pending_dns();
 
-  ClusterMachine *master_machine(ClusterConfiguration * cc);
+  ClusterMachine *master_machine(ClusterConfiguration *cc);
 
   HostDBInfo *insert(unsigned int attl);
 
@@ -510,38 +513,32 @@ struct HostDBContinuation: public Continuation
   struct Options {
     typedef Options self; ///< Self reference type.
 
-    int timeout; ///< Timeout value. Default 0
+    int timeout;                 ///< Timeout value. Default 0
     HostResStyle host_res_style; ///< IP address family fallback. Default @c 
HOST_RES_NONE
-    bool force_dns; ///< Force DNS lookup. Default @c false
-    Continuation* cont; ///< Continuation / action. Default @c NULL (none)
+    bool force_dns;              ///< Force DNS lookup. Default @c false
+    Continuation *cont;          ///< Continuation / action. Default @c NULL 
(none)
 
-    Options()
-      : timeout(0), host_res_style(HOST_RES_NONE), force_dns(false), cont(0)
-    { }
+    Options() : timeout(0), host_res_style(HOST_RES_NONE), force_dns(false), 
cont(0) {}
   };
   static const Options DEFAULT_OPTIONS; ///< Default defaults.
-  void init(HostDBMD5 const& md5,
-            Options const& opt = DEFAULT_OPTIONS);
+  void init(HostDBMD5 const &md5, Options const &opt = DEFAULT_OPTIONS);
   int make_get_message(char *buf, int len);
-  int make_put_message(HostDBInfo * r, Continuation * c, char *buf, int len);
-
-HostDBContinuation():
-  Continuation(NULL), ttl(0),
-    host_res_style(DEFAULT_OPTIONS.host_res_style),
-    dns_lookup_timeout(DEFAULT_OPTIONS.timeout),
-    timeout(0), from(0),
-    from_cont(0), probe_depth(0), missing(false),
-    force_dns(DEFAULT_OPTIONS.force_dns), round_robin(false) {
+  int make_put_message(HostDBInfo *r, Continuation *c, char *buf, int len);
+
+  HostDBContinuation()
+    : Continuation(NULL), ttl(0), 
host_res_style(DEFAULT_OPTIONS.host_res_style), 
dns_lookup_timeout(DEFAULT_OPTIONS.timeout),
+      timeout(0), from(0), from_cont(0), probe_depth(0), missing(false), 
force_dns(DEFAULT_OPTIONS.force_dns), round_robin(false)
+  {
     ink_zero(md5_host_name_store);
     ink_zero(md5.hash);
-    SET_HANDLER((HostDBContHandler) & HostDBContinuation::probeEvent);
+    SET_HANDLER((HostDBContHandler)&HostDBContinuation::probeEvent);
   }
 };
 
-//extern Queue<HostDBContinuation>  remoteHostDBQueue[MULTI_CACHE_PARTITIONS];
+// extern Queue<HostDBContinuation>  remoteHostDBQueue[MULTI_CACHE_PARTITIONS];
 
 inline unsigned int
-master_hash(INK_MD5 const& md5)
+master_hash(INK_MD5 const &md5)
 {
   return static_cast<int>(md5[1] >> 32);
 }
@@ -549,13 +546,13 @@ master_hash(INK_MD5 const& md5)
 inline bool
 is_dotted_form_hostname(const char *c)
 {
-  return -1 != (int) ink_inet_addr(c);
+  return -1 != (int)ink_inet_addr(c);
 }
 
 inline Queue<HostDBContinuation> &
-HostDBCache::pending_dns_for_hash(INK_MD5 & md5)
+HostDBCache::pending_dns_for_hash(INK_MD5 &md5)
 {
-  return pending_dns[partition_of_bucket((int) (fold_md5(md5) % 
hostDB.buckets))];
+  return pending_dns[partition_of_bucket((int)(fold_md5(md5) % 
hostDB.buckets))];
 }
 
 inline int

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/P_MultiCache.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/P_MultiCache.h b/iocore/hostdb/P_MultiCache.h
index b5f81ac..8f9478c 100644
--- a/iocore/hostdb/P_MultiCache.h
+++ b/iocore/hostdb/P_MultiCache.h
@@ -39,34 +39,34 @@
 // Constants
 //
 
-#define MULTI_CACHE_MAX_LEVELS       3
-#define MULTI_CACHE_MAX_BUCKET_SIZE  256
-#define MULTI_CACHE_MAX_FILES        256
-#define MULTI_CACHE_PARTITIONS       64
+#define MULTI_CACHE_MAX_LEVELS 3
+#define MULTI_CACHE_MAX_BUCKET_SIZE 256
+#define MULTI_CACHE_MAX_FILES 256
+#define MULTI_CACHE_PARTITIONS 64
 
-#define MULTI_CACHE_EVENT_SYNC       MULTI_CACHE_EVENT_EVENTS_START
+#define MULTI_CACHE_EVENT_SYNC MULTI_CACHE_EVENT_EVENTS_START
 
 
 // for heap_offset() and heap_size(), indicates no data
-#define MULTI_CACHE_HEAP_NONE       -1
+#define MULTI_CACHE_HEAP_NONE -1
 
-#define MULTI_CACHE_MAGIC_NUMBER     0x0BAD2D8
+#define MULTI_CACHE_MAGIC_NUMBER 0x0BAD2D8
 
 // Update these if there is a change to MultiCacheBase
 // There is a separate HOST_DB_CACHE_[MAJOR|MINOR]_VERSION
-#define MULTI_CACHE_MAJOR_VERSION    2
-#define MULTI_CACHE_MINOR_VERSION    1
+#define MULTI_CACHE_MAJOR_VERSION 2
+#define MULTI_CACHE_MINOR_VERSION 1
 // 2.1 - IPv6 compatible
 
-#define MULTI_CACHE_HEAP_HIGH_WATER  0.8
+#define MULTI_CACHE_HEAP_HIGH_WATER 0.8
 
-#define MULTI_CACHE_HEAP_INITIAL     sizeof(uint32_t)
-#define MULTI_CACHE_HEAP_ALIGNMENT   8
+#define MULTI_CACHE_HEAP_INITIAL sizeof(uint32_t)
+#define MULTI_CACHE_HEAP_ALIGNMENT 8
 
 // unused.. possible optimization
-#define MULTI_CACHE_OFFSET_PARITION(_x)  ((_x)%MULTI_CACHE_PARTITIONS)
-#define MULTI_CACHE_OFFSET_INDEX(_x)     ((_x)/MULTI_CACHE_PARTITIONS)
-#define MULTI_CACHE_OFFSET(_p,_o)        ((_p) + (_o) * MULTI_CACHE_PARTITIONS)
+#define MULTI_CACHE_OFFSET_PARITION(_x) ((_x) % MULTI_CACHE_PARTITIONS)
+#define MULTI_CACHE_OFFSET_INDEX(_x) ((_x) / MULTI_CACHE_PARTITIONS)
+#define MULTI_CACHE_OFFSET(_p, _o) ((_p) + (_o)*MULTI_CACHE_PARTITIONS)
 
 class ProxyMutex;
 class Continuation;
@@ -80,8 +80,7 @@ class Continuation;
 // required by the templated cache operations.
 
 
-struct MultiCacheBlock
-{
+struct MultiCacheBlock {
   uint64_t tag();
   bool is_deleted();
   void set_deleted();
@@ -89,18 +88,19 @@ struct MultiCacheBlock
   void set_empty();
   void reset();
   void set_full(uint64_t folded_md5, int buckets);
-  int heap_size()
+  int
+  heap_size()
   {
     return 0;
   }
-  int *heap_offset_ptr()
+  int *
+  heap_offset_ptr()
   {
     return NULL;
   }
 };
 
-struct RebuildMC
-{
+struct RebuildMC {
   bool rebuild;
   bool check;
   bool fix;
@@ -116,8 +116,7 @@ struct RebuildMC
   int total;
 };
 
-struct MultiCacheHeader
-{
+struct MultiCacheHeader {
   unsigned int magic;
   VersionNumber version;
 
@@ -142,24 +141,21 @@ struct MultiCacheHeader
   volatile int heap_halfspace;
   volatile int heap_used[2];
 
-    MultiCacheHeader();
+  MultiCacheHeader();
 };
 
 // size of block of unsunk pointers with respect to the number of
 // elements
-#define MULTI_CACHE_UNSUNK_PTR_BLOCK_SIZE(_e)   \
-  ((_e / 8) / MULTI_CACHE_PARTITIONS)
+#define MULTI_CACHE_UNSUNK_PTR_BLOCK_SIZE(_e) ((_e / 8) / 
MULTI_CACHE_PARTITIONS)
 
-struct UnsunkPtr
-{
+struct UnsunkPtr {
   int offset;
-  int *poffset;                 // doubles as freelist pointer
+  int *poffset; // doubles as freelist pointer
 };
 
 struct MultiCacheBase;
 
-struct UnsunkPtrRegistry
-{
+struct UnsunkPtrRegistry {
   MultiCacheBase *mc;
   int n;
   UnsunkPtr *ptrs;
@@ -170,8 +166,8 @@ struct UnsunkPtrRegistry
   UnsunkPtr *alloc(int *p, int base = 0);
   void alloc_data();
 
-    UnsunkPtrRegistry();
-   ~UnsunkPtrRegistry();
+  UnsunkPtrRegistry();
+  ~UnsunkPtrRegistry();
 };
 
 //
@@ -183,8 +179,7 @@ struct UnsunkPtrRegistry
 // used by windows only - to keep track
 // of mapping handles
 //
-struct Unmaper
-{
+struct Unmaper {
   void *hMap;
   char *pAddr;
 };
@@ -194,8 +189,7 @@ typedef int two_ints[2];
 
 struct MultiCacheHeapGC;
 
-struct MultiCacheBase: public MultiCacheHeader
-{
+struct MultiCacheBase : public MultiCacheHeader {
   Store *store;
   char filename[PATH_NAME_MAX + 1];
   MultiCacheHeader *mapped_header;
@@ -212,7 +206,8 @@ struct MultiCacheBase: public MultiCacheHeader
 
   // interface functions
   //
-  int halfspace_size()
+  int
+  halfspace_size()
   {
     return heap_size / 2;
   }
@@ -222,89 +217,100 @@ struct MultiCacheBase: public MultiCacheHeader
   int hit_stat[MULTI_CACHE_MAX_LEVELS];
   int miss_stat;
 
-  unsigned int lowest_level_data_size()
+  unsigned int
+  lowest_level_data_size()
   {
     return (buckets + 3) / 4;
   }
-  unsigned int lowest_level(unsigned int bucket)
+  unsigned int
+  lowest_level(unsigned int bucket)
   {
-    unsigned int i = (unsigned char) lowest_level_data[bucket / 4];
+    unsigned int i = (unsigned char)lowest_level_data[bucket / 4];
     return 3 & (i >> (buckets % 4));
   }
-  void set_lowest_level(unsigned int bucket, unsigned int lowest)
+  void
+  set_lowest_level(unsigned int bucket, unsigned int lowest)
   {
-    unsigned char p = (unsigned char) lowest_level_data[bucket / 4];
+    unsigned char p = (unsigned char)lowest_level_data[bucket / 4];
     p &= ~(3 << (buckets % 4));
     p |= (lowest & 3) << (buckets % 4);
-    lowest_level_data[bucket / 4] = (char) p;
+    lowest_level_data[bucket / 4] = (char)p;
   }
 
   // Fixed point, 8 bits shifted left
   int buckets_per_partitionF8;
 
-  int partition_of_bucket(int b)
+  int
+  partition_of_bucket(int b)
   {
     return ((b << 8) + 0xFF) / buckets_per_partitionF8;
   }
-  int first_bucket_of_partition(int p)
+  int
+  first_bucket_of_partition(int p)
   {
     return ((buckets_per_partitionF8 * p) >> 8);
   }
-  int last_bucket_of_partition(int p)
+  int
+  last_bucket_of_partition(int p)
   {
     return first_bucket_of_partition(p + 1) - 1;
   }
-  int buckets_of_partition(int p)
+  int
+  buckets_of_partition(int p)
   {
     return last_bucket_of_partition(p) - first_bucket_of_partition(p) + 1;
   }
 
-  int open(Store * store, const char *config_filename,
-           char *db_filename = NULL, int db_size = -1, bool reconfigure = 
false, bool fix = false, bool silent = false);
+  int open(Store *store, const char *config_filename, char *db_filename = 
NULL, int db_size = -1, bool reconfigure = false,
+           bool fix = false, bool silent = false);
 
   // 1 for success, 0 for no config file, -1 for failure
-  int read_config(const char *config_filename, Store & store, char *fn = NULL, 
int *pi = NULL, int *pbuckets = NULL);
+  int read_config(const char *config_filename, Store &store, char *fn = NULL, 
int *pi = NULL, int *pbuckets = NULL);
   int write_config(const char *config_filename, int nominal_size, int buckets);
-  int initialize(Store * store, char *filename, int elements,
-                 int buckets = 0, unsigned int levels = 2,
-                 int level0_elements_per_bucket = 4,
-                 int level1_elements_per_bucket = 32, int 
level2_elements_per_bucket = 1);
+  int initialize(Store *store, char *filename, int elements, int buckets = 0, 
unsigned int levels = 2,
+                 int level0_elements_per_bucket = 4, int 
level1_elements_per_bucket = 32, int level2_elements_per_bucket = 1);
   int mmap_data(bool private_flag = false, bool zero_fill = false);
-  char *mmap_region(int blocks, int *fds, char *cur, size_t& total_length, 
bool private_flag, int zero_fill = 0);
+  char *mmap_region(int blocks, int *fds, char *cur, size_t &total_length, 
bool private_flag, int zero_fill = 0);
   int blocks_in_level(unsigned int level);
 
   bool verify_header();
 
   int unmap_data();
   void reset();
-  void clear();                 // this zeros the data
+  void clear(); // this zeros the data
   void clear_but_heap();
 
-  virtual MultiCacheBase *dup()
+  virtual MultiCacheBase *
+  dup()
   {
     ink_assert(0);
     return NULL;
   }
 
-  virtual size_t estimated_heap_bytes_per_entry() const { return 0; }
+  virtual size_t
+  estimated_heap_bytes_per_entry() const
+  {
+    return 0;
+  }
 
-  void print_info(FILE * fp);
+  void print_info(FILE *fp);
 
-  //
-  // Rebuild the database, also perform checks, and fixups
-  // ** cannot be called on a running system **
-  // "this" must be initialized.
-  //
-#define MC_REBUILD         0
-#define MC_REBUILD_CHECK   1
-#define MC_REBUILD_FIX     2
-  int rebuild(MultiCacheBase & old, int kind = MC_REBUILD);     // 0 on success
+//
+// Rebuild the database, also perform checks, and fixups
+// ** cannot be called on a running system **
+// "this" must be initialized.
+//
+#define MC_REBUILD 0
+#define MC_REBUILD_CHECK 1
+#define MC_REBUILD_FIX 2
+  int rebuild(MultiCacheBase &old, int kind = MC_REBUILD); // 0 on success
 
-  virtual void rebuild_element(int buck, char *elem, RebuildMC & r)
+  virtual void
+  rebuild_element(int buck, char *elem, RebuildMC &r)
   {
-    (void) buck;
-    (void) elem;
-    (void) r;
+    (void)buck;
+    (void)elem;
+    (void)r;
     ink_assert(0);
   }
 
@@ -315,13 +321,15 @@ struct MultiCacheBase: public MultiCacheHeader
   //
   int check(const char *config_filename, bool fix = false);
 
-  ProxyMutex *lock_for_bucket(int bucket)
+  ProxyMutex *
+  lock_for_bucket(int bucket)
   {
     return locks[partition_of_bucket(bucket)];
   }
-  uint64_t make_tag(uint64_t folded_md5)
+  uint64_t
+  make_tag(uint64_t folded_md5)
   {
-    uint64_t ttag = folded_md5 / (uint64_t) buckets;
+    uint64_t ttag = folded_md5 / (uint64_t)buckets;
     if (!ttag)
       return 1LL;
     // beeping gcc 2.7.2 is broken
@@ -338,17 +346,16 @@ struct MultiCacheBase: public MultiCacheHeader
   }
 
   int sync_all();
-  int sync_heap(int part);      // part varies between 0 and 
MULTI_CACHE_PARTITIONS
+  int sync_heap(int part); // part varies between 0 and MULTI_CACHE_PARTITIONS
   int sync_header();
   int sync_partition(int partition);
-  void sync_partitions(Continuation * cont);
+  void sync_partitions(Continuation *cont);
 
   MultiCacheBase();
-  virtual ~ MultiCacheBase() {
-    reset();
-  }
+  virtual ~MultiCacheBase() { reset(); }
 
-  virtual int get_elementsize()
+  virtual int
+  get_elementsize()
   {
     ink_assert(0);
     return 0;
@@ -366,7 +373,8 @@ struct MultiCacheBase: public MultiCacheHeader
   void *alloc(int *poffset, int size);
   void update(int *poffset, int *old_poffset);
   void *ptr(int *poffset, int partition);
-  int valid_offset(int offset)
+  int
+  valid_offset(int offset)
   {
     int max;
     if (offset < halfspace_size())
@@ -375,108 +383,121 @@ struct MultiCacheBase: public MultiCacheHeader
       max = halfspace_size() + heap_used[1];
     return offset < max;
   }
-  int valid_heap_pointer(char *p)
+  int
+  valid_heap_pointer(char *p)
   {
     if (p < heap + halfspace_size())
       return p < heap + heap_used[0];
     else
       return p < heap + halfspace_size() + heap_used[1];
   }
-  void copy_heap_data(char *src, int s, int *pi, int partition, 
MultiCacheHeapGC * gc);
-  int halfspace_of(int o)
+  void copy_heap_data(char *src, int s, int *pi, int partition, 
MultiCacheHeapGC *gc);
+  int
+  halfspace_of(int o)
   {
-    return o < halfspace_size()? 0 : 1;
+    return o < halfspace_size() ? 0 : 1;
   }
-  UnsunkPtrRegistry *fixup_heap_offsets(int partition, int before_used, 
UnsunkPtrRegistry * r = NULL, int base = 0);
+  UnsunkPtrRegistry *fixup_heap_offsets(int partition, int before_used, 
UnsunkPtrRegistry *r = NULL, int base = 0);
 
-  virtual void copy_heap(int partition, MultiCacheHeapGC * gc)
+  virtual void
+  copy_heap(int partition, MultiCacheHeapGC *gc)
   {
-    (void) partition;
-    (void) gc;
+    (void)partition;
+    (void)gc;
   }
 
   //
   // Private
   //
-  void alloc_mutexes()
+  void
+  alloc_mutexes()
   {
     for (int i = 0; i < MULTI_CACHE_PARTITIONS; i++)
       locks[i] = new_ProxyMutex();
   }
-  PtrMutex locks[MULTI_CACHE_PARTITIONS];       // 1 lock per 
(buckets/partitions)
+  PtrMutex locks[MULTI_CACHE_PARTITIONS]; // 1 lock per (buckets/partitions)
 };
 
-template<class C> struct MultiCache: public MultiCacheBase
-{
-  int get_elementsize()
+template <class C> struct MultiCache : public MultiCacheBase {
+  int
+  get_elementsize()
   {
     return sizeof(C);
   }
 
-  MultiCacheBase *dup()
+  MultiCacheBase *
+  dup()
   {
     return new MultiCache<C>;
   }
 
-  void rebuild_element(int buck, char *elem, RebuildMC & r);
+  void rebuild_element(int buck, char *elem, RebuildMC &r);
   // -1 is corrupt, 0 == void (do not insert), 1 is OK
-  virtual int rebuild_callout(C * c, RebuildMC & r)
+  virtual int
+  rebuild_callout(C *c, RebuildMC &r)
   {
-    (void) c;
-    (void) r;
+    (void)c;
+    (void)r;
     return 1;
   }
 
-  virtual void rebuild_insert_callout(C * c, RebuildMC & r)
+  virtual void
+  rebuild_insert_callout(C *c, RebuildMC &r)
   {
-    (void) c;
-    (void) r;
+    (void)c;
+    (void)r;
   }
 
   //
   // template operations
   //
-  int level_of_block(C * b);
-  bool match(uint64_t folded_md5, C * block);
+  int level_of_block(C *b);
+  bool match(uint64_t folded_md5, C *block);
   C *cache_bucket(uint64_t folded_md5, unsigned int level);
-  C *insert_block(uint64_t folded_md5, C * new_block, unsigned int level);
-  void flush(C * b, int bucket, unsigned int level);
-  void delete_block(C * block);
+  C *insert_block(uint64_t folded_md5, C *new_block, unsigned int level);
+  void flush(C *b, int bucket, unsigned int level);
+  void delete_block(C *block);
   C *lookup_block(uint64_t folded_md5, unsigned int level);
   void copy_heap(int paritition, MultiCacheHeapGC *);
 };
 
 inline uint64_t
-fold_md5(INK_MD5 const& md5)
+fold_md5(INK_MD5 const &md5)
 {
   return md5.fold();
 }
 
-template<class C> inline int MultiCache<C>::level_of_block(C * b)
+template <class C>
+inline int
+MultiCache<C>::level_of_block(C *b)
 {
-  if ((char *) b - data >= level_offset[1]) {
-    if ((char *) b - data >= level_offset[2])
+  if ((char *)b - data >= level_offset[1]) {
+    if ((char *)b - data >= level_offset[2])
       return 2;
     return 1;
   }
   return 0;
 }
 
-template<class C> inline C * MultiCache<C>::cache_bucket(uint64_t folded_md5, 
unsigned int level)
+template <class C>
+inline C *
+MultiCache<C>::cache_bucket(uint64_t folded_md5, unsigned int level)
 {
-  int bucket = (int) (folded_md5 % buckets);
+  int bucket = (int)(folded_md5 % buckets);
   char *offset = data + level_offset[level] + bucketsize[level] * bucket;
-  return (C *) offset;
+  return (C *)offset;
 }
 
 //
 // Insert an entry
 //
-template<class C> inline C * MultiCache<C>::insert_block(uint64_t folded_md5, 
C * new_block, unsigned int level)
+template <class C>
+inline C *
+MultiCache<C>::insert_block(uint64_t folded_md5, C *new_block, unsigned int 
level)
 {
   C *b = cache_bucket(folded_md5, level);
   C *block = NULL, *empty = NULL;
-  int bucket = (int) (folded_md5 % buckets);
+  int bucket = (int)(folded_md5 % buckets);
   int hits = 0;
 
   // Find the entry
@@ -537,13 +558,14 @@ Lfound:
   return block;
 }
 
-#define REBUILD_FOLDED_MD5(_cl) \
-((_cl->tag() * (uint64_t)buckets + (uint64_t)bucket))
+#define REBUILD_FOLDED_MD5(_cl) ((_cl->tag() * (uint64_t)buckets + 
(uint64_t)bucket))
 
 //
 // This function ejects some number of entries.
 //
-template<class C> inline void MultiCache<C>::flush(C * b, int bucket, unsigned 
int level)
+template <class C>
+inline void
+MultiCache<C>::flush(C *b, int bucket, unsigned int level)
 {
   C *block = NULL;
   // The comparison against the constant is redundant, but it
@@ -566,7 +588,9 @@ template<class C> inline void MultiCache<C>::flush(C * b, 
int bucket, unsigned i
 //
 // Match a cache line and a folded md5 key
 //
-template<class C> inline bool MultiCache<C>::match(uint64_t folded_md5, C * 
block)
+template <class C>
+inline bool
+MultiCache<C>::match(uint64_t folded_md5, C *block)
 {
   return block->tag() == make_tag(folded_md5);
 }
@@ -574,14 +598,16 @@ template<class C> inline bool 
MultiCache<C>::match(uint64_t folded_md5, C * bloc
 //
 // This code is a bit of a mess and should probably be rewritten
 //
-template<class C> inline void MultiCache<C>::delete_block(C * b)
+template <class C>
+inline void
+MultiCache<C>::delete_block(C *b)
 {
   if (b->backed) {
     unsigned int l = level_of_block(b);
     if (l < levels - 1) {
-      int bucket = (((char *) b - data) - level_offset[l]) / bucketsize[l];
-      C *x = (C *) (data + level_offset[l + 1] + bucket * bucketsize[l + 1]);
-      for (C * y = x; y < x + elements[l + 1]; y++)
+      int bucket = (((char *)b - data) - level_offset[l]) / bucketsize[l];
+      C *x = (C *)(data + level_offset[l + 1] + bucket * bucketsize[l + 1]);
+      for (C *y = x; y < x + elements[l + 1]; y++)
         if (b->tag() == y->tag())
           delete_block(y);
     }
@@ -592,7 +618,9 @@ template<class C> inline void MultiCache<C>::delete_block(C 
* b)
 //
 // Lookup an entry up to some level in the cache
 //
-template<class C> inline C * MultiCache<C>::lookup_block(uint64_t folded_md5, 
unsigned int level)
+template <class C>
+inline C *
+MultiCache<C>::lookup_block(uint64_t folded_md5, unsigned int level)
 {
   C *b = cache_bucket(folded_md5, 0);
   uint64_t tag = make_tag(folded_md5);
@@ -618,9 +646,11 @@ template<class C> inline C * 
MultiCache<C>::lookup_block(uint64_t folded_md5, un
   return NULL;
 }
 
-template<class C> inline void MultiCache<C>::rebuild_element(int bucket, char 
*elem, RebuildMC & r)
+template <class C>
+inline void
+MultiCache<C>::rebuild_element(int bucket, char *elem, RebuildMC &r)
 {
-  C *e = (C *) elem;
+  C *e = (C *)elem;
   if (!e->is_empty()) {
     r.total++;
     if (e->is_deleted())
@@ -643,20 +673,22 @@ template<class C> inline void 
MultiCache<C>::rebuild_element(int bucket, char *e
   }
 }
 
-template<class C> inline void MultiCache<C>::copy_heap(int partition, 
MultiCacheHeapGC * gc)
+template <class C>
+inline void
+MultiCache<C>::copy_heap(int partition, MultiCacheHeapGC *gc)
 {
   int b = first_bucket_of_partition(partition);
   int n = buckets_of_partition(partition);
   for (unsigned int level = 0; level < levels; level++) {
     int e = n * elements[level];
     char *d = data + level_offset[level] + b * bucketsize[level];
-    C *x = (C *) d;
+    C *x = (C *)d;
     for (int i = 0; i < e; i++) {
       int s = x[i].heap_size();
       if (s) {
         int *pi = x[i].heap_offset_ptr();
         if (pi) {
-          char *src = (char *) ptr(pi, partition);
+          char *src = (char *)ptr(pi, partition);
           if (src) {
             if (heap_halfspace) {
               if (src >= heap + halfspace_size())
@@ -672,5 +704,5 @@ template<class C> inline void MultiCache<C>::copy_heap(int 
partition, MultiCache
 }
 
 // store either free or in the cache, can be stolen for reconfiguration
-void stealStore(Store & s, int blocks);
+void stealStore(Store &s, int blocks);
 #endif /* _MultiCache_h_ */

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/iocore/hostdb/include/Machine.h
----------------------------------------------------------------------
diff --git a/iocore/hostdb/include/Machine.h b/iocore/hostdb/include/Machine.h
index a933b39..50b24fa 100644
--- a/iocore/hostdb/include/Machine.h
+++ b/iocore/hostdb/include/Machine.h
@@ -41,7 +41,7 @@
 // Timeout the Machine * this amount of time after they
 // fall out of the current configuration that are deleted.
 //
-#define MACHINE_TIMEOUT            (HRTIME_DAY*2)
+#define MACHINE_TIMEOUT (HRTIME_DAY * 2)
 
 
 //
@@ -53,14 +53,13 @@
 //
 //  Long running operations should use more sophisticated synchronization.
 //
-#define NO_RACE_DELAY                  HRTIME_HOUR      // a long long time
+#define NO_RACE_DELAY HRTIME_HOUR // a long long time
 
 //#include "Connection.h"
 
-class ClusterHandler;           // Leave this a class - VC++ gets very anal  
~SR
+class ClusterHandler; // Leave this a class - VC++ gets very anal  ~SR
 
-struct Machine: Server
-{
+struct Machine : Server {
   bool dead;
   char *hostname;
   int hostname_len;
@@ -71,11 +70,11 @@ struct Machine: Server
   unsigned int ip;
   int cluster_port;
 
-    Link<Machine> link;
+  Link<Machine> link;
 
   // default for localhost
-    Machine(char *hostname = NULL, unsigned int ip = 0, int acluster_port = 0);
-   ~Machine();
+  Machine(char *hostname = NULL, unsigned int ip = 0, int acluster_port = 0);
+  ~Machine();
 
   // Cluster message protocol version
   uint16_t msg_proto_major;
@@ -86,17 +85,17 @@ struct Machine: Server
   ClusterHandler *clusterHandler;
 };
 
-struct MachineListElement
-{
+struct MachineListElement {
   unsigned int ip;
   int port;
 };
 
-struct MachineList
-{
+struct MachineList {
   int n;
   MachineListElement machine[1];
-  MachineListElement *find(unsigned int ip, int port = 0) {
+  MachineListElement *
+  find(unsigned int ip, int port = 0)
+  {
     for (int i = 0; i < n; i++)
       if (machine[i].ip == ip && (!port || machine[i].port == port))
         return &machine[i];
@@ -104,7 +103,7 @@ struct MachineList
   }
 };
 
-void free_Machine(Machine * m);
+void free_Machine(Machine *m);
 
 MachineList *the_cluster_config();
 extern ProxyMutex *the_cluster_config_mutex;

Reply via email to