You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/03/23 21:32:49 UTC
[16/52] [partial] trafficserver git commit: TS-3419 Fix some enum's
such that clang-format can handle it the way we want. Basically this means
having a trailing ,
on short enum's. TS-3419 Run clang-format over most of the source
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ConsistentHash.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ConsistentHash.cc b/lib/ts/ConsistentHash.cc
index e39edbd..c983ccb 100644
--- a/lib/ts/ConsistentHash.cc
+++ b/lib/ts/ConsistentHash.cc
@@ -27,8 +27,7 @@
#include <climits>
#include <cstdio>
-std::ostream &
-operator << (std::ostream & os, ATSConsistentHashNode & thing)
+std::ostream &operator<<(std::ostream &os, ATSConsistentHashNode &thing)
{
return os << thing.name;
}
@@ -38,7 +37,7 @@ ATSConsistentHash::ATSConsistentHash(int r, ATSHash64 *h) : replicas(r), hash(h)
}
void
-ATSConsistentHash::insert(ATSConsistentHashNode * node, float weight, ATSHash64 *h)
+ATSConsistentHash::insert(ATSConsistentHashNode *node, float weight, ATSHash64 *h)
{
int i;
char numstr[256];
@@ -57,7 +56,7 @@ ATSConsistentHash::insert(ATSConsistentHashNode * node, float weight, ATSHash64
string_stream << *node;
std_string = string_stream.str();
- for (i = 0; i < (int) roundf(replicas * weight); i++) {
+ for (i = 0; i < (int)roundf(replicas * weight); i++) {
snprintf(numstr, 256, "%d-", i);
thash->update(numstr, strlen(numstr));
thash->update(std_string.c_str(), strlen(std_string.c_str()));
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/ConsistentHash.h
----------------------------------------------------------------------
diff --git a/lib/ts/ConsistentHash.h b/lib/ts/ConsistentHash.h
index 7704c7a..6406a6c 100644
--- a/lib/ts/ConsistentHash.h
+++ b/lib/ts/ConsistentHash.h
@@ -31,14 +31,12 @@
Helper class to be extended to make ring nodes.
*/
-struct ATSConsistentHashNode
-{
+struct ATSConsistentHashNode {
bool available;
char *name;
};
-std::ostream &
-operator<< (std::ostream & os, ATSConsistentHashNode & thing);
+std::ostream &operator<<(std::ostream &os, ATSConsistentHashNode &thing);
typedef std::map<uint64_t, ATSConsistentHashNode *>::iterator ATSConsistentHashIter;
@@ -48,12 +46,12 @@ typedef std::map<uint64_t, ATSConsistentHashNode *>::iterator ATSConsistentHashI
Caller is responsible for freeing ring node memory.
*/
-struct ATSConsistentHash
-{
+struct ATSConsistentHash {
ATSConsistentHash(int r = 1024, ATSHash64 *h = NULL);
void insert(ATSConsistentHashNode *node, float weight = 1.0, ATSHash64 *h = NULL);
ATSConsistentHashNode *lookup(const char *url = NULL, ATSConsistentHashIter *i = NULL, bool *w = NULL, ATSHash64 *h = NULL);
- ATSConsistentHashNode *lookup_available(const char *url = NULL, ATSConsistentHashIter *i = NULL, bool *w = NULL, ATSHash64 *h = NULL);
+ ATSConsistentHashNode *lookup_available(const char *url = NULL, ATSConsistentHashIter *i = NULL, bool *w = NULL,
+ ATSHash64 *h = NULL);
~ATSConsistentHash();
private:
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/CryptoHash.h
----------------------------------------------------------------------
diff --git a/lib/ts/CryptoHash.h b/lib/ts/CryptoHash.h
index 9dcec91..28b6296 100644
--- a/lib/ts/CryptoHash.h
+++ b/lib/ts/CryptoHash.h
@@ -1,5 +1,5 @@
-# if ! defined CRYPTO_HASH_HEADER
-# define CRYPTO_HASH_HEADER
+#if !defined CRYPTO_HASH_HEADER
+#define CRYPTO_HASH_HEADER
/** @file
Protocol class for crypto hashes.
@@ -24,95 +24,106 @@
*/
/// Apache Traffic Server commons.
-namespace ats {
- /// Crypto hash output.
- union CryptoHash {
- uint64_t b[2]; // Legacy placeholder
- uint64_t u64[2];
- uint32_t u32[4];
- uint8_t u8[16];
-
- /// Default constructor - init to zero.
- CryptoHash() {
- u64[0] = 0;
- u64[1] = 0;
- }
-
- /// Assignment - bitwise copy.
- CryptoHash& operator = (CryptoHash const& that) {
- u64[0] = that.u64[0];
- u64[1] = that.u64[1];
- return *this;
- }
-
- /// Equality - bitwise identical.
- bool operator == (CryptoHash const& that) const {
- return u64[0] == that.u64[0] && u64[1] == that.u64[1];
- }
-
- /// Equality - bitwise identical.
- bool operator != (CryptoHash const& that) const {
- return !(*this == that);
- }
-
- /// Reduce to 64 bit value.
- uint64_t fold() const {
- return u64[0] ^ u64[1];
- }
-
- /// Access 64 bit slice.
- uint64_t operator [] (int i) const {
- return u64[i];
- }
-
- /// Access 64 bit slice.
- /// @note Identical to @ operator[] but included for symmetry.
- uint64_t slice64(int i) const {
- return u64[i];
- }
-
- /// Access 32 bit slice.
- uint32_t slice32(int i) const {
- return u32[i];
- }
-
- /// Fast conversion to hex in fixed sized string.
- char *toHexStr(char buffer[33]) {
- return ink_code_to_hex_str(buffer, u8);
- }
- };
-
- extern CryptoHash const CRYPTO_HASH_ZERO;
-
- /** Protocol class for a crypto hash context.
-
- A hash of this type is used for strong hashing, such as for URLs.
- */
- class CryptoContext {
- typedef CryptoContext self; ///< Self reference type.
- public:
-
- /// Destructor (force virtual)
- virtual ~CryptoContext() { }
-
- /// Update the hash with @a data of @a length bytes.
- virtual bool update(void const* data, int length) = 0;
- /// Finalize and extract the @a hash.
- virtual bool finalize(CryptoHash& hash) = 0;
-
- /// Convenience overload.
- bool finalize(CryptoHash* hash);
-
- /// Convenience - compute final @a hash for @a data.
- /// @note This is just as fast as the previous style, as a new context must be initialized
- /// everytime this is done.
- virtual bool hash_immediate(CryptoHash& hash, void const* data, int length);
- };
-
- inline bool CryptoContext::hash_immediate(CryptoHash& hash, void const* data, int length) {
- return this->update(data, length) && this->finalize(hash);
+namespace ats
+{
+/// Crypto hash output.
+union CryptoHash {
+ uint64_t b[2]; // Legacy placeholder
+ uint64_t u64[2];
+ uint32_t u32[4];
+ uint8_t u8[16];
+
+ /// Default constructor - init to zero.
+ CryptoHash()
+ {
+ u64[0] = 0;
+ u64[1] = 0;
}
- inline bool CryptoContext::finalize(CryptoHash* hash) { return this->finalize(*hash); }
+
+ /// Assignment - bitwise copy.
+ CryptoHash &operator=(CryptoHash const &that)
+ {
+ u64[0] = that.u64[0];
+ u64[1] = that.u64[1];
+ return *this;
+ }
+
+ /// Equality - bitwise identical.
+ bool operator==(CryptoHash const &that) const { return u64[0] == that.u64[0] && u64[1] == that.u64[1]; }
+
+ /// Equality - bitwise identical.
+ bool operator!=(CryptoHash const &that) const { return !(*this == that); }
+
+ /// Reduce to 64 bit value.
+ uint64_t
+ fold() const
+ {
+ return u64[0] ^ u64[1];
+ }
+
+ /// Access 64 bit slice.
+ uint64_t operator[](int i) const { return u64[i]; }
+
+ /// Access 64 bit slice.
+ /// @note Identical to @ operator[] but included for symmetry.
+ uint64_t
+ slice64(int i) const
+ {
+ return u64[i];
+ }
+
+ /// Access 32 bit slice.
+ uint32_t
+ slice32(int i) const
+ {
+ return u32[i];
+ }
+
+ /// Fast conversion to hex in fixed sized string.
+ char *
+ toHexStr(char buffer[33])
+ {
+ return ink_code_to_hex_str(buffer, u8);
+ }
+};
+
+extern CryptoHash const CRYPTO_HASH_ZERO;
+
+/** Protocol class for a crypto hash context.
+
+ A hash of this type is used for strong hashing, such as for URLs.
+*/
+class CryptoContext
+{
+ typedef CryptoContext self; ///< Self reference type.
+public:
+ /// Destructor (force virtual)
+ virtual ~CryptoContext() {}
+
+ /// Update the hash with @a data of @a length bytes.
+ virtual bool update(void const *data, int length) = 0;
+ /// Finalize and extract the @a hash.
+ virtual bool finalize(CryptoHash &hash) = 0;
+
+ /// Convenience overload.
+ bool finalize(CryptoHash *hash);
+
+ /// Convenience - compute final @a hash for @a data.
+ /// @note This is just as fast as the previous style, as a new context must be initialized
+ /// everytime this is done.
+ virtual bool hash_immediate(CryptoHash &hash, void const *data, int length);
+};
+
+inline bool
+CryptoContext::hash_immediate(CryptoHash &hash, void const *data, int length)
+{
+ return this->update(data, length) && this->finalize(hash);
+}
+inline bool
+CryptoContext::finalize(CryptoHash *hash)
+{
+ return this->finalize(*hash);
+}
} // end namespace
@@ -121,4 +132,4 @@ using ats::CryptoHash;
using ats::CryptoContext;
using ats::CRYPTO_HASH_ZERO;
-# endif // CRYPTO_HASH_HEADER
+#endif // CRYPTO_HASH_HEADER
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Diags.cc
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.cc b/lib/ts/Diags.cc
index a7ce61d..97c4911 100644
--- a/lib/ts/Diags.cc
+++ b/lib/ts/Diags.cc
@@ -44,7 +44,7 @@
#include "Diags.h"
int diags_on_for_plugins = 0;
-bool DiagsConfigState::enabled[2] = { false, false };
+bool DiagsConfigState::enabled[2] = {false, false};
// Global, used for all diagnostics
inkcoreapi Diags *diags = NULL;
@@ -65,7 +65,7 @@ inkcoreapi Diags *diags = NULL;
char *
SrcLoc::str(char *buf, int buflen) const
{
- const char * shortname;
+ const char *shortname;
if (!this->valid() || buflen < 1)
return (NULL);
@@ -83,8 +83,6 @@ SrcLoc::str(char *buf, int buflen) const
}
-
-
//////////////////////////////////////////////////////////////////////////////
//
// Diags::Diags(char *bdt, char *bat)
@@ -103,9 +101,8 @@ SrcLoc::str(char *buf, int buflen) const
//
//////////////////////////////////////////////////////////////////////////////
-Diags::Diags(const char *bdt, const char *bat, FILE * _diags_log_fp)
- : diags_log_fp(_diags_log_fp), magic(DIAGS_MAGIC), show_location(0),
- base_debug_tags(NULL), base_action_tags(NULL)
+Diags::Diags(const char *bdt, const char *bat, FILE *_diags_log_fp)
+ : diags_log_fp(_diags_log_fp), magic(DIAGS_MAGIC), show_location(0), base_debug_tags(NULL), base_action_tags(NULL)
{
int i;
@@ -141,7 +138,6 @@ Diags::Diags(const char *bdt, const char *bat, FILE * _diags_log_fp)
activated_tags[DiagsTagType_Debug] = NULL;
activated_tags[DiagsTagType_Action] = NULL;
prefix_str = "";
-
}
Diags::~Diags()
@@ -184,8 +180,7 @@ Diags::~Diags()
//////////////////////////////////////////////////////////////////////////////
void
-Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc,
- const char *format_string, va_list ap) const
+Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc, const char *format_string, va_list ap) const
{
struct timeval tp;
const char *s;
@@ -213,13 +208,14 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc
// add the thread id
pthread_t id = pthread_self();
- end_of_format += snprintf(end_of_format, sizeof(format_buf), "{0x%" PRIx64 "} ", (uint64_t) id);
+ end_of_format += snprintf(end_of_format, sizeof(format_buf), "{0x%" PRIx64 "} ", (uint64_t)id);
//////////////////////////////////////
// start with the diag level prefix //
//////////////////////////////////////
- for (s = level_name(diags_level); *s; *end_of_format++ = *s++);
+ for (s = level_name(diags_level); *s; *end_of_format++ = *s++)
+ ;
*end_of_format++ = ':';
*end_of_format++ = ' ';
@@ -232,7 +228,8 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc
lp = loc->str(buf, sizeof(buf));
if (lp) {
*end_of_format++ = '<';
- for (s = lp; *s; *end_of_format++ = *s++);
+ for (s = lp; *s; *end_of_format++ = *s++)
+ ;
*end_of_format++ = '>';
*end_of_format++ = ' ';
}
@@ -243,7 +240,8 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc
if (debug_tag) {
*end_of_format++ = '(';
- for (s = debug_tag; *s; *end_of_format++ = *s++);
+ for (s = debug_tag; *s; *end_of_format++ = *s++)
+ ;
*end_of_format++ = ')';
*end_of_format++ = ' ';
}
@@ -251,7 +249,8 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc
// append original format string, and NUL terminate //
//////////////////////////////////////////////////////
- for (s = format_string; *s; *end_of_format++ = *s++);
+ for (s = format_string; *s; *end_of_format++ = *s++)
+ ;
*end_of_format++ = NUL;
@@ -260,9 +259,9 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc
//////////////////////////////////////////////////////////////////
ink_gethrtimeofday(&tp, NULL);
- time_t cur_clock = (time_t) tp.tv_sec;
+ time_t cur_clock = (time_t)tp.tv_sec;
buffer = ink_ctime_r(&cur_clock, timestamp_buf);
- snprintf(&(timestamp_buf[19]), (sizeof(timestamp_buf) - 20), ".%03d", (int) (tp.tv_usec / 1000));
+ snprintf(&(timestamp_buf[19]), (sizeof(timestamp_buf) - 20), ".%03d", (int)(tp.tv_usec / 1000));
d = format_buf_w_ts;
*d++ = '[';
@@ -273,7 +272,8 @@ Diags::print_va(const char *debug_tag, DiagsLevel diags_level, const SrcLoc *loc
for (int k = 0; prefix_str[k]; k++)
*d++ = prefix_str[k];
- for (s = format_buf; *s; *d++ = *s++);
+ for (s = format_buf; *s; *d++ = *s++)
+ ;
*d++ = NUL;
//////////////////////////////////////
@@ -490,7 +490,7 @@ Diags::level_name(DiagsLevel dl) const
//////////////////////////////////////////////////////////////////////////////
void
-Diags::dump(FILE * fp) const
+Diags::dump(FILE *fp) const
{
int i;
@@ -501,19 +501,16 @@ Diags::dump(FILE * fp) const
fprintf(fp, " action default tags: '%s'\n", (base_action_tags ? base_action_tags : "NULL"));
fprintf(fp, " outputs:\n");
for (i = 0; i < DiagsLevel_Count; i++) {
- fprintf(fp, " %10s [stdout=%d, stderr=%d, syslog=%d, diagslog=%d]\n",
- level_name((DiagsLevel) i),
- config.outputs[i].to_stdout,
+ fprintf(fp, " %10s [stdout=%d, stderr=%d, syslog=%d, diagslog=%d]\n", level_name((DiagsLevel)i), config.outputs[i].to_stdout,
config.outputs[i].to_stderr, config.outputs[i].to_syslog, config.outputs[i].to_diagslog);
}
}
void
-Diags::log(const char *tag, DiagsLevel level,
- const char *file, const char *func, const int line,
- const char *format_string ...) const
+Diags::log(const char *tag, DiagsLevel level, const char *file, const char *func, const int line,
+ const char *format_string...) const
{
- if (! on(tag))
+ if (!on(tag))
return;
va_list ap;
@@ -528,9 +525,7 @@ Diags::log(const char *tag, DiagsLevel level,
}
void
-Diags::error_va(DiagsLevel level,
- const char *file, const char *func, const int line,
- const char *format_string, va_list ap) const
+Diags::error_va(DiagsLevel level, const char *file, const char *func, const int line, const char *format_string, va_list ap) const
{
va_list ap2;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Diags.h
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.h b/lib/ts/Diags.h
index 7a228c5..fe3248f 100644
--- a/lib/ts/Diags.h
+++ b/lib/ts/Diags.h
@@ -46,32 +46,29 @@
class Diags;
// extern int diags_on_for_plugins;
-typedef enum
-{
- DiagsTagType_Debug = 0, // do not renumber --- used as array index
+typedef enum {
+ DiagsTagType_Debug = 0, // do not renumber --- used as array index
DiagsTagType_Action = 1
} DiagsTagType;
-struct DiagsModeOutput
-{
+struct DiagsModeOutput {
bool to_stdout;
bool to_stderr;
bool to_syslog;
bool to_diagslog;
};
-typedef enum
-{ // do not renumber --- used as array index
- DL_Diag = 0, // process does not die
- DL_Debug, // process does not die
- DL_Status, // process does not die
- DL_Note, // process does not die
- DL_Warning, // process does not die
- DL_Error, // process does not die
- DL_Fatal, // causes process termination
- DL_Alert, // causes process termination
- DL_Emergency, // causes process termination
- DL_Undefined // must be last, used for size!
+typedef enum { // do not renumber --- used as array index
+ DL_Diag = 0, // process does not die
+ DL_Debug, // process does not die
+ DL_Status, // process does not die
+ DL_Note, // process does not die
+ DL_Warning, // process does not die
+ DL_Error, // process does not die
+ DL_Fatal, // causes process termination
+ DL_Alert, // causes process termination
+ DL_Emergency, // causes process termination
+ DL_Undefined // must be last, used for size!
} DiagsLevel;
#define DiagsLevel_Count DL_Undefined
@@ -80,13 +77,12 @@ typedef enum
// Cleanup Function Prototype - Called before ink_fatal to
// cleanup process state
-typedef void (*DiagsCleanupFunc) ();
+typedef void (*DiagsCleanupFunc)();
-struct DiagsConfigState
-{
+struct DiagsConfigState {
// this is static to eliminate many loads from the critical path
- static bool enabled[2]; // one debug, one action
- DiagsModeOutput outputs[DiagsLevel_Count]; // where each level prints
+ static bool enabled[2]; // one debug, one action
+ DiagsModeOutput outputs[DiagsLevel_Count]; // where each level prints
};
@@ -109,25 +105,25 @@ public:
const char *func;
int line;
- bool valid() const {
+ bool
+ valid() const
+ {
return file && line;
}
- SrcLoc(const SrcLoc& rhs) : file(rhs.file), func(rhs.func), line(rhs.line) {
- }
+ SrcLoc(const SrcLoc &rhs) : file(rhs.file), func(rhs.func), line(rhs.line) {}
- SrcLoc(const char *_file, const char *_func, int _line)
- : file(_file), func(_func), line(_line) {
- }
+ SrcLoc(const char *_file, const char *_func, int _line) : file(_file), func(_func), line(_line) {}
- SrcLoc& operator=(const SrcLoc& rhs) {
+ SrcLoc &operator=(const SrcLoc &rhs)
+ {
this->file = rhs.file;
this->func = rhs.func;
this->line = rhs.line;
return *this;
}
- char * str(char *buf, int buflen) const;
+ char *str(char *buf, int buflen) const;
};
@@ -149,8 +145,8 @@ public:
class Diags
{
public:
- Diags(const char *base_debug_tags, const char *base_action_tags, FILE * _diags_log_fp = NULL);
- ~Diags();
+ Diags(const char *base_debug_tags, const char *base_action_tags, FILE *_diags_log_fp = NULL);
+ ~Diags();
FILE *diags_log_fp;
const unsigned int magic;
@@ -163,11 +159,15 @@ public:
// conditional debugging //
///////////////////////////
- bool on(DiagsTagType mode = DiagsTagType_Debug) const {
+ bool
+ on(DiagsTagType mode = DiagsTagType_Debug) const
+ {
return (config.enabled[mode]);
}
- bool on(const char *tag, DiagsTagType mode = DiagsTagType_Debug) const {
+ bool
+ on(const char *tag, DiagsTagType mode = DiagsTagType_Debug) const
+ {
return (config.enabled[mode] && tag_activated(tag, mode));
}
@@ -183,16 +183,16 @@ public:
const char *level_name(DiagsLevel dl) const;
- inkcoreapi void print_va(const char *tag, DiagsLevel dl,
- const SrcLoc *loc, const char *format_string, va_list ap) const;
+ inkcoreapi void print_va(const char *tag, DiagsLevel dl, const SrcLoc *loc, const char *format_string, va_list ap) const;
//////////////////////////////
// user printing interfaces //
//////////////////////////////
- void print(const char *tag, DiagsLevel dl, const char *file, const char *func,
- const int line, const char *format_string, ...) const TS_PRINTFLIKE(7, 8)
+ void
+ print(const char *tag, DiagsLevel dl, const char *file, const char *func, const int line, const char *format_string, ...) const
+ TS_PRINTFLIKE(7, 8)
{
va_list ap;
va_start(ap, format_string);
@@ -210,25 +210,22 @@ public:
// on the value of the enable flag, and the state of the debug tags. //
///////////////////////////////////////////////////////////////////////
- void log_va(const char *tag, DiagsLevel dl, const SrcLoc * loc, const char *format_string, va_list ap)
+ void
+ log_va(const char *tag, DiagsLevel dl, const SrcLoc *loc, const char *format_string, va_list ap)
{
if (!on(tag))
return;
print_va(tag, dl, loc, format_string, ap);
}
- void log(const char *tag, DiagsLevel dl,
- const char *file, const char *func, const int line,
- const char *format_string, ...) const TS_PRINTFLIKE(7, 8);
+ void log(const char *tag, DiagsLevel dl, const char *file, const char *func, const int line, const char *format_string, ...) const
+ TS_PRINTFLIKE(7, 8);
- void error_va(DiagsLevel dl,
- const char *file, const char *func, const int line,
- const char *format_string, va_list ap) const;
+ void error_va(DiagsLevel dl, const char *file, const char *func, const int line, const char *format_string, va_list ap) const;
void
- error(DiagsLevel level,
- const char *file, const char *func, const int line,
- const char *format_string, ...) const TS_PRINTFLIKE(6, 7)
+ error(DiagsLevel level, const char *file, const char *func, const int line, const char *format_string, ...) const
+ TS_PRINTFLIKE(6, 7)
{
va_list ap;
va_start(ap, format_string);
@@ -236,24 +233,26 @@ public:
va_end(ap);
}
- void dump(FILE * fp = stdout) const;
+ void dump(FILE *fp = stdout) const;
void activate_taglist(const char *taglist, DiagsTagType mode = DiagsTagType_Debug);
void deactivate_all(DiagsTagType mode = DiagsTagType_Debug);
- const char *base_debug_tags; // internal copy of default debug tags
- const char *base_action_tags; // internal copy of default action tags
+ const char *base_debug_tags; // internal copy of default debug tags
+ const char *base_action_tags; // internal copy of default action tags
private:
- mutable ink_mutex tag_table_lock; // prevents reconfig/read races
- DFA *activated_tags[2]; // 1 table for debug, 1 for action
+ mutable ink_mutex tag_table_lock; // prevents reconfig/read races
+ DFA *activated_tags[2]; // 1 table for debug, 1 for action
- void lock() const
+ void
+ lock() const
{
ink_mutex_acquire(&tag_table_lock);
}
- void unlock() const
+ void
+ unlock() const
{
ink_mutex_release(&tag_table_lock);
}
@@ -272,7 +271,7 @@ private:
// //
//////////////////////////////////////////////////////////////////////////
-#if !defined (__GNUC__)
+#if !defined(__GNUC__)
#ifndef __FUNCTION__
#define __FUNCTION__ NULL
#endif
@@ -280,8 +279,8 @@ private:
extern inkcoreapi Diags *diags;
-#define DTA(l) l,__FILE__,__FUNCTION__,__LINE__
-void dummy_debug(const char * tag, const char *fmt, ...) TS_PRINTFLIKE(2, 3);
+#define DTA(l) l, __FILE__, __FUNCTION__, __LINE__
+void dummy_debug(const char *tag, const char *fmt, ...) TS_PRINTFLIKE(2, 3);
inline void
dummy_debug(const char *tag, const char *fmt, ...)
{
@@ -289,49 +288,63 @@ dummy_debug(const char *tag, const char *fmt, ...)
(void)fmt;
}
-#define Status(...) diags->error(DTA(DL_Status), __VA_ARGS__)
-#define Note(...) diags->error(DTA(DL_Note), __VA_ARGS__)
-#define Warning(...) diags->error(DTA(DL_Warning), __VA_ARGS__)
-#define Error(...) diags->error(DTA(DL_Error), __VA_ARGS__)
-#define Fatal(...) diags->error(DTA(DL_Fatal), __VA_ARGS__)
-#define Alert(...) diags->error(DTA(DL_Alert), __VA_ARGS__)
+#define Status(...) diags->error(DTA(DL_Status), __VA_ARGS__)
+#define Note(...) diags->error(DTA(DL_Note), __VA_ARGS__)
+#define Warning(...) diags->error(DTA(DL_Warning), __VA_ARGS__)
+#define Error(...) diags->error(DTA(DL_Error), __VA_ARGS__)
+#define Fatal(...) diags->error(DTA(DL_Fatal), __VA_ARGS__)
+#define Alert(...) diags->error(DTA(DL_Alert), __VA_ARGS__)
#define Emergency(...) diags->error(DTA(DL_Emergency), __VA_ARGS__)
-#define StatusV(fmt, ap) diags->error_va(DTA(DL_Status), fmt, ap)
-#define NoteV(fmt, ap) diags->error_va(DTA(DL_Note), fmt, ap)
-#define WarningV(fmt, ap) diags->error_va(DTA(DL_Warning), fmt, ap)
-#define ErrorV(fmt, ap) diags->error_va(DTA(DL_Error), fmt, ap)
-#define FatalV(fmt, ap) diags->error_va(DTA(DL_Fatal), fmt, ap)
-#define AlertV(fmt, ap) diags->error_va(DTA(DL_Alert), fmt, ap)
+#define StatusV(fmt, ap) diags->error_va(DTA(DL_Status), fmt, ap)
+#define NoteV(fmt, ap) diags->error_va(DTA(DL_Note), fmt, ap)
+#define WarningV(fmt, ap) diags->error_va(DTA(DL_Warning), fmt, ap)
+#define ErrorV(fmt, ap) diags->error_va(DTA(DL_Error), fmt, ap)
+#define FatalV(fmt, ap) diags->error_va(DTA(DL_Fatal), fmt, ap)
+#define AlertV(fmt, ap) diags->error_va(DTA(DL_Alert), fmt, ap)
#define EmergencyV(fmt, ap) diags->error_va(DTA(DL_Emergency), fmt, ap)
#ifdef TS_USE_DIAGS
-#define Diag(tag, ...) if (unlikely(diags->on())) diags->log(tag, DTA(DL_Diag), __VA_ARGS__)
-#define Debug(tag, ...) if (unlikely(diags->on())) diags->log(tag, DTA(DL_Debug), __VA_ARGS__)
-#define DiagSpecific(flag, tag, ...) if (unlikely(diags->on())) flag ? diags->print(tag, DTA(DL_Diag), __VA_ARGS__) : \
- diags->log(tag, DTA(DL_Diag), __VA_ARGS__)
-#define DebugSpecific(flag, tag, ...) if (unlikely(diags->on())) flag ? diags->print(tag, DTA(DL_Debug), __VA_ARGS__) : \
- diags->log(tag, DTA(DL_Debug), __VA_ARGS__)
-
-#define is_debug_tag_set(_t) unlikely(diags->on(_t,DiagsTagType_Debug))
-#define is_action_tag_set(_t) unlikely(diags->on(_t,DiagsTagType_Action))
-#define debug_tag_assert(_t,_a) (is_debug_tag_set(_t) ? (ink_release_assert(_a), 0) : 0)
-#define action_tag_assert(_t,_a) (is_action_tag_set(_t) ? (ink_release_assert(_a), 0) : 0)
-#define is_diags_on(_t) unlikely(diags->on(_t))
+#define Diag(tag, ...) \
+ if (unlikely(diags->on())) \
+ diags->log(tag, DTA(DL_Diag), __VA_ARGS__)
+#define Debug(tag, ...) \
+ if (unlikely(diags->on())) \
+ diags->log(tag, DTA(DL_Debug), __VA_ARGS__)
+#define DiagSpecific(flag, tag, ...) \
+ if (unlikely(diags->on())) \
+ flag ? diags->print(tag, DTA(DL_Diag), __VA_ARGS__) : diags->log(tag, DTA(DL_Diag), __VA_ARGS__)
+#define DebugSpecific(flag, tag, ...) \
+ if (unlikely(diags->on())) \
+ flag ? diags->print(tag, DTA(DL_Debug), __VA_ARGS__) : diags->log(tag, DTA(DL_Debug), __VA_ARGS__)
+
+#define is_debug_tag_set(_t) unlikely(diags->on(_t, DiagsTagType_Debug))
+#define is_action_tag_set(_t) unlikely(diags->on(_t, DiagsTagType_Action))
+#define debug_tag_assert(_t, _a) (is_debug_tag_set(_t) ? (ink_release_assert(_a), 0) : 0)
+#define action_tag_assert(_t, _a) (is_action_tag_set(_t) ? (ink_release_assert(_a), 0) : 0)
+#define is_diags_on(_t) unlikely(diags->on(_t))
#else // TS_USE_DIAGS
-#define Diag(tag, fmt, ...) if (0) dummy_debug(tag, __VA_ARGS__)
-#define Debug(tag, fmt, ...) if (0) dummy_debug(tag, __VA_ARGS__)
-#define DiagSpecific(flag, tag, ...) if (0 && tag) dummy_debug(tag, __VA_ARGS__);
-#define DebugSpecific(flag, tag, ...) if (0 && tag) dummy_debug(tag, __VA_ARGS__);
-
-
-#define is_debug_tag_set(_t) 0
-#define is_action_tag_set(_t) 0
-#define debug_tag_assert(_t,_a) /**/
-#define action_tag_assert(_t,_a) /**/
-#define is_diags_on(_t) 0
+#define Diag(tag, fmt, ...) \
+ if (0) \
+ dummy_debug(tag, __VA_ARGS__)
+#define Debug(tag, fmt, ...) \
+ if (0) \
+ dummy_debug(tag, __VA_ARGS__)
+#define DiagSpecific(flag, tag, ...) \
+ if (0 && tag) \
+ dummy_debug(tag, __VA_ARGS__);
+#define DebugSpecific(flag, tag, ...) \
+ if (0 && tag) \
+ dummy_debug(tag, __VA_ARGS__);
+
+
+#define is_debug_tag_set(_t) 0
+#define is_action_tag_set(_t) 0
+#define debug_tag_assert(_t, _a) /**/
+#define action_tag_assert(_t, _a) /**/
+#define is_diags_on(_t) 0
#endif // TS_USE_DIAGS
-#endif /*_Diags_h_*/
+#endif /*_Diags_h_*/
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/DynArray.h
----------------------------------------------------------------------
diff --git a/lib/ts/DynArray.h b/lib/ts/DynArray.h
index aa7a599..bd18cc5 100644
--- a/lib/ts/DynArray.h
+++ b/lib/ts/DynArray.h
@@ -24,17 +24,18 @@
#ifndef __DYN_ARRAY_H__
#define __DYN_ARRAY_H__
-template<class T> class DynArray {
+template <class T> class DynArray
+{
public:
- DynArray(const T * val = 0, intptr_t initial_size = 0);
+ DynArray(const T *val = 0, intptr_t initial_size = 0);
~DynArray();
#ifndef __GNUC__
- operator const T *() const;
+ operator const T *() const;
#endif
- operator T *();
- T & operator[](intptr_t idx);
- T & operator()(intptr_t idx);
+ operator T *();
+ T &operator[](intptr_t idx);
+ T &operator()(intptr_t idx);
T *detach();
T defvalue() const;
intptr_t length();
@@ -45,19 +46,16 @@ private:
void resize(intptr_t new_size);
private:
- T * data;
+ T *data;
const T *default_val;
int size;
int pos;
};
-template<class T> inline DynArray<T>::DynArray(const T * val, intptr_t initial_size)
- :
-data(NULL),
-default_val(val),
-size(0),
-pos(-1)
+template <class T>
+inline DynArray<T>::DynArray(const T *val, intptr_t initial_size)
+ : data(NULL), default_val(val), size(0), pos(-1)
{
if (initial_size > 0) {
int i = 1;
@@ -67,41 +65,34 @@ pos(-1)
resize(i);
}
-
}
-template<class T> inline DynArray<T>::~DynArray()
+template <class T> inline DynArray<T>::~DynArray()
{
if (data) {
- delete[]data;
+ delete[] data;
}
}
#ifndef __GNUC__
-template<class T> inline DynArray<T>::operator const T *()
-const
+template <class T> inline DynArray<T>::operator const T *() const
{
- return
- data;
+ return data;
}
#endif
-template <
- class
- T >
- inline
- DynArray <
- T >::operator
-T * ()
+template <class T> inline DynArray<T>::operator T *()
{
return data;
}
-template<class T> inline T & DynArray<T>::operator [](intptr_t idx) {
+template <class T> inline T &DynArray<T>::operator[](intptr_t idx)
+{
return data[idx];
}
-template<class T> inline T & DynArray<T>::operator ()(intptr_t idx) {
+template <class T> inline T &DynArray<T>::operator()(intptr_t idx)
+{
if (idx >= size) {
intptr_t new_size;
@@ -125,7 +116,9 @@ template<class T> inline T & DynArray<T>::operator ()(intptr_t idx) {
return data[idx];
}
-template<class T> inline T * DynArray<T>::detach()
+template <class T>
+inline T *
+DynArray<T>::detach()
{
T *d;
@@ -135,20 +128,26 @@ template<class T> inline T * DynArray<T>::detach()
return d;
}
-template<class T> inline T DynArray<T>::defvalue() const
+template <class T>
+inline T
+DynArray<T>::defvalue() const
{
return *default_val;
}
-template<class T> inline intptr_t DynArray<T>::length()
+template <class T>
+inline intptr_t
+DynArray<T>::length()
{
return pos + 1;
}
-template<class T> inline void DynArray<T>::clear()
+template <class T>
+inline void
+DynArray<T>::clear()
{
if (data) {
- delete[]data;
+ delete[] data;
data = NULL;
}
@@ -156,12 +155,16 @@ template<class T> inline void DynArray<T>::clear()
pos = -1;
}
-template<class T> inline void DynArray<T>::set_length(intptr_t i)
+template <class T>
+inline void
+DynArray<T>::set_length(intptr_t i)
{
pos = i - 1;
}
-template<class T> inline void DynArray<T>::resize(intptr_t new_size)
+template <class T>
+inline void
+DynArray<T>::resize(intptr_t new_size)
{
if (new_size > size) {
T *new_data;
@@ -175,11 +178,11 @@ template<class T> inline void DynArray<T>::resize(intptr_t new_size)
for (; i < new_size; i++) {
if (default_val)
- new_data[i] = (T) * default_val;
+ new_data[i] = (T)*default_val;
}
if (data) {
- delete[]data;
+ delete[] data;
}
data = new_data;
size = new_size;
@@ -188,4 +191,3 @@ template<class T> inline void DynArray<T>::resize(intptr_t new_size)
#endif /* __DYN_ARRAY_H__ */
-
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/EventNotify.cc
----------------------------------------------------------------------
diff --git a/lib/ts/EventNotify.cc b/lib/ts/EventNotify.cc
index 296e220..dce9d81 100644
--- a/lib/ts/EventNotify.cc
+++ b/lib/ts/EventNotify.cc
@@ -109,8 +109,7 @@ EventNotify::wait(void)
#endif
}
-int
-EventNotify::timedwait(int timeout) // milliseconds
+int EventNotify::timedwait(int timeout) // milliseconds
{
#ifdef HAVE_EVENTFD
ssize_t nr, nr_fd = 0;
@@ -151,7 +150,7 @@ void
EventNotify::lock(void)
{
#ifdef HAVE_EVENTFD
- // do nothing
+// do nothing
#else
ink_mutex_acquire(&m_mutex);
#endif
@@ -171,7 +170,7 @@ void
EventNotify::unlock(void)
{
#ifdef HAVE_EVENTFD
- // do nothing
+// do nothing
#else
ink_mutex_release(&m_mutex);
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Hash.cc
----------------------------------------------------------------------
diff --git a/lib/ts/Hash.cc b/lib/ts/Hash.cc
index d36c96a..31a74b7 100644
--- a/lib/ts/Hash.cc
+++ b/lib/ts/Hash.cc
@@ -26,11 +26,9 @@ ATSHashBase::~ATSHashBase()
{
}
-bool
-ATSHash::operator==(const ATSHash & other) const
+bool ATSHash::operator==(const ATSHash &other) const
{
- if (this->size() != other.size())
- {
+ if (this->size() != other.size()) {
return false;
}
if (memcmp(this->get(), other.get(), this->size()) == 0) {
@@ -40,14 +38,12 @@ ATSHash::operator==(const ATSHash & other) const
}
}
-bool
-ATSHash32::operator==(const ATSHash32 & other) const
+bool ATSHash32::operator==(const ATSHash32 &other) const
{
return this->get() == other.get();
}
-bool
-ATSHash64::operator==(const ATSHash64 & other) const
+bool ATSHash64::operator==(const ATSHash64 &other) const
{
return this->get() == other.get();
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Hash.h
----------------------------------------------------------------------
diff --git a/lib/ts/Hash.h b/lib/ts/Hash.h
index 2306389..19ed7bb 100644
--- a/lib/ts/Hash.h
+++ b/lib/ts/Hash.h
@@ -26,22 +26,20 @@
#include <stdint.h>
#include <ctype.h>
-struct ATSHashBase
-{
+struct ATSHashBase {
virtual void update(const void *, size_t) = 0;
virtual void final(void) = 0;
virtual void clear(void) = 0;
virtual ~ATSHashBase();
};
-struct ATSHash:ATSHashBase
-{
+struct ATSHash : ATSHashBase {
struct nullxfrm {
- uint8_t operator() (uint8_t byte) const { return byte; }
+ uint8_t operator()(uint8_t byte) const { return byte; }
};
struct nocase {
- uint8_t operator() (uint8_t byte) const { return toupper(byte); }
+ uint8_t operator()(uint8_t byte) const { return toupper(byte); }
};
virtual const void *get(void) const = 0;
@@ -49,14 +47,12 @@ struct ATSHash:ATSHashBase
virtual bool operator==(const ATSHash &) const;
};
-struct ATSHash32:ATSHashBase
-{
+struct ATSHash32 : ATSHashBase {
virtual uint32_t get(void) const = 0;
virtual bool operator==(const ATSHash32 &) const;
};
-struct ATSHash64:ATSHashBase
-{
+struct ATSHash64 : ATSHashBase {
virtual uint64_t get(void) const = 0;
virtual bool operator==(const ATSHash64 &) const;
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HashFNV.h
----------------------------------------------------------------------
diff --git a/lib/ts/HashFNV.h b/lib/ts/HashFNV.h
index 4467b7a..97a2bd5 100644
--- a/lib/ts/HashFNV.h
+++ b/lib/ts/HashFNV.h
@@ -31,57 +31,65 @@
#include "Hash.h"
#include <stdint.h>
-struct ATSHash32FNV1a:ATSHash32
-{
+struct ATSHash32FNV1a : ATSHash32 {
ATSHash32FNV1a(void);
template <typename Transform> void update(const void *data, size_t len, Transform xfrm);
- void update(const void *data, size_t len) { update(data, len, ATSHash::nullxfrm()); }
+ void
+ update(const void *data, size_t len)
+ {
+ update(data, len, ATSHash::nullxfrm());
+ }
void final(void);
uint32_t get(void) const;
void clear(void);
private:
- uint32_t hval;
+ uint32_t hval;
};
-template <typename Transform> void
+template <typename Transform>
+void
ATSHash32FNV1a::update(const void *data, size_t len, Transform xfrm)
{
- uint8_t *bp = (uint8_t *) data;
+ uint8_t *bp = (uint8_t *)data;
uint8_t *be = bp + len;
for (; bp < be; ++bp) {
- hval ^= (uint32_t) xfrm(*bp);
+ hval ^= (uint32_t)xfrm(*bp);
hval += (hval << 1) + (hval << 4) + (hval << 7) + (hval << 8) + (hval << 24);
}
}
-struct ATSHash64FNV1a:ATSHash64
-{
+struct ATSHash64FNV1a : ATSHash64 {
ATSHash64FNV1a(void);
template <typename Transform> void update(const void *data, size_t len, Transform xfrm);
- void update(const void *data, size_t len) { update(data, len, ATSHash::nullxfrm()); }
+ void
+ update(const void *data, size_t len)
+ {
+ update(data, len, ATSHash::nullxfrm());
+ }
void final(void);
uint64_t get(void) const;
void clear(void);
private:
- uint64_t hval;
+ uint64_t hval;
};
-template <typename Transform> void
+template <typename Transform>
+void
ATSHash64FNV1a::update(const void *data, size_t len, Transform xfrm)
{
- uint8_t *bp = (uint8_t *) data;
+ uint8_t *bp = (uint8_t *)data;
uint8_t *be = bp + len;
for (; bp < be; ++bp) {
- hval ^= (uint64_t) xfrm(*bp);
+ hval ^= (uint64_t)xfrm(*bp);
hval += (hval << 1) + (hval << 4) + (hval << 5) + (hval << 7) + (hval << 8) + (hval << 40);
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HashMD5.cc
----------------------------------------------------------------------
diff --git a/lib/ts/HashMD5.cc b/lib/ts/HashMD5.cc
index c2607ad..93fb787 100644
--- a/lib/ts/HashMD5.cc
+++ b/lib/ts/HashMD5.cc
@@ -21,49 +21,56 @@
#include "HashMD5.h"
-ATSHashMD5::ATSHashMD5(void) {
- EVP_DigestInit(&ctx, EVP_md5());
- md_len = 0;
- finalized = false;
+ATSHashMD5::ATSHashMD5(void)
+{
+ EVP_DigestInit(&ctx, EVP_md5());
+ md_len = 0;
+ finalized = false;
}
void
-ATSHashMD5::update(const void *data, size_t len) {
- if (!finalized) {
- EVP_DigestUpdate(&ctx, data, len);
- }
+ATSHashMD5::update(const void *data, size_t len)
+{
+ if (!finalized) {
+ EVP_DigestUpdate(&ctx, data, len);
+ }
}
void
-ATSHashMD5::final(void) {
- if (!finalized) {
- EVP_DigestFinal_ex(&ctx, md_value, &md_len);
- finalized = true;
- }
+ATSHashMD5::final(void)
+{
+ if (!finalized) {
+ EVP_DigestFinal_ex(&ctx, md_value, &md_len);
+ finalized = true;
+ }
}
const void *
-ATSHashMD5::get(void) const {
- if (finalized) {
- return (void *) md_value;
- } else {
- return NULL;
- }
+ATSHashMD5::get(void) const
+{
+ if (finalized) {
+ return (void *)md_value;
+ } else {
+ return NULL;
+ }
}
size_t
-ATSHashMD5::size(void) const {
- return EVP_MD_CTX_size(&ctx);
+ATSHashMD5::size(void) const
+{
+ return EVP_MD_CTX_size(&ctx);
}
void
-ATSHashMD5::clear(void) {
- EVP_MD_CTX_cleanup(&ctx);
- EVP_DigestInit(&ctx, EVP_md5());
- md_len = 0;
- finalized = false;
+ATSHashMD5::clear(void)
+{
+ EVP_MD_CTX_cleanup(&ctx);
+ EVP_DigestInit(&ctx, EVP_md5());
+ md_len = 0;
+ finalized = false;
}
-ATSHashMD5::~ATSHashMD5() {
- EVP_MD_CTX_cleanup(&ctx);
+ATSHashMD5::~ATSHashMD5()
+{
+ EVP_MD_CTX_cleanup(&ctx);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HashMD5.h
----------------------------------------------------------------------
diff --git a/lib/ts/HashMD5.h b/lib/ts/HashMD5.h
index bcf2d0b..0a4b566 100644
--- a/lib/ts/HashMD5.h
+++ b/lib/ts/HashMD5.h
@@ -26,19 +26,19 @@
#include <openssl/evp.h>
struct ATSHashMD5 : ATSHash {
- ATSHashMD5(void);
- void update(const void *data, size_t len);
- void final(void);
- const void *get(void) const;
- size_t size(void) const;
- void clear(void);
- ~ATSHashMD5();
+ ATSHashMD5(void);
+ void update(const void *data, size_t len);
+ void final(void);
+ const void *get(void) const;
+ size_t size(void) const;
+ void clear(void);
+ ~ATSHashMD5();
private:
- EVP_MD_CTX ctx;
- unsigned char md_value[EVP_MAX_MD_SIZE];
- unsigned int md_len;
- bool finalized;
+ EVP_MD_CTX ctx;
+ unsigned char md_value[EVP_MAX_MD_SIZE];
+ unsigned int md_len;
+ bool finalized;
};
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HashSip.cc
----------------------------------------------------------------------
diff --git a/lib/ts/HashSip.cc b/lib/ts/HashSip.cc
index 6ccb6d6..80a2c00 100644
--- a/lib/ts/HashSip.cc
+++ b/lib/ts/HashSip.cc
@@ -13,25 +13,25 @@ https://github.com/floodyberry/siphash
#define SIP_BLOCK_SIZE 8
-#define ROTL64(a,b) (((a)<<(b))|((a)>>(64-b)))
+#define ROTL64(a, b) (((a) << (b)) | ((a) >> (64 - b)))
#define U8TO64_LE(p) *(const uint64_t *)(p)
-#define SIPCOMPRESS(x0,x1,x2,x3) \
- x0 += x1; \
- x2 += x3; \
- x1 = ROTL64(x1,13); \
- x3 = ROTL64(x3,16); \
- x1 ^= x0; \
- x3 ^= x2; \
- x0 = ROTL64(x0,32); \
- x2 += x1; \
- x0 += x3; \
- x1 = ROTL64(x1,17); \
- x3 = ROTL64(x3,21); \
- x1 ^= x2; \
- x3 ^= x0; \
- x2 = ROTL64(x2,32);
+#define SIPCOMPRESS(x0, x1, x2, x3) \
+ x0 += x1; \
+ x2 += x3; \
+ x1 = ROTL64(x1, 13); \
+ x3 = ROTL64(x3, 16); \
+ x1 ^= x0; \
+ x3 ^= x2; \
+ x0 = ROTL64(x0, 32); \
+ x2 += x1; \
+ x0 += x3; \
+ x1 = ROTL64(x1, 17); \
+ x3 = ROTL64(x3, 21); \
+ x1 ^= x2; \
+ x3 ^= x0; \
+ x2 = ROTL64(x2, 32);
ATSHash64Sip24::ATSHash64Sip24(void)
{
@@ -63,7 +63,7 @@ ATSHash64Sip24::update(const void *data, size_t len)
uint8_t block_off = 0;
if (!finalized) {
- m = (unsigned char *) data;
+ m = (unsigned char *)data;
total_len += len;
if (len + block_buffer_len < SIP_BLOCK_SIZE) {
@@ -102,10 +102,10 @@ ATSHash64Sip24::final(void)
int i;
if (!finalized) {
- last7 = (uint64_t) (total_len & 0xff) << 56;
+ last7 = (uint64_t)(total_len & 0xff) << 56;
for (i = block_buffer_len - 1; i >= 0; i--) {
- last7 |= (uint64_t) block_buffer[i] << (i * 8);
+ last7 |= (uint64_t)block_buffer[i] << (i * 8);
}
v3 ^= last7;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HashSip.h
----------------------------------------------------------------------
diff --git a/lib/ts/HashSip.h b/lib/ts/HashSip.h
index 30b99c7..fe8a740 100644
--- a/lib/ts/HashSip.h
+++ b/lib/ts/HashSip.h
@@ -32,11 +32,10 @@
a zero key for you.
*/
-struct ATSHash64Sip24:ATSHash64
-{
+struct ATSHash64Sip24 : ATSHash64 {
ATSHash64Sip24(void);
- ATSHash64Sip24(const unsigned char key[16]);
- ATSHash64Sip24(uint64_t key0, uint64_t key1);
+ ATSHash64Sip24(const unsigned char key[16]);
+ ATSHash64Sip24(uint64_t key0, uint64_t key1);
void update(const void *data, size_t len);
void final(void);
uint64_t get(void) const;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HostLookup.cc
----------------------------------------------------------------------
diff --git a/lib/ts/HostLookup.cc b/lib/ts/HostLookup.cc
index 863d124..c0d88e0 100644
--- a/lib/ts/HostLookup.cc
+++ b/lib/ts/HostLookup.cc
@@ -64,7 +64,6 @@ domaincmp(const char *hostname, const char *domain)
}
// Walk through both strings backward
while (domain_cur >= domain && host_cur >= hostname) {
-
// If we still have characters left on both strings and
// they do not match, matching fails
//
@@ -170,39 +169,27 @@ hostcmp(const char *c1, const char *c2)
// Illegal characters map to 255
//
static const unsigned char asciiToTable[256] = {
- 255, 255, 255, 255, 255, 255, 255, 255, // 0 - 7
- 255, 255, 255, 255, 255, 255, 255, 255, // 8 - 15
- 255, 255, 255, 255, 255, 255, 255, 255, // 16 - 23
- 255, 255, 255, 255, 255, 255, 255, 255, // 24 - 31
- 255, 255, 255, 255, 255, 255, 255, 255, // 32 - 39
- 255, 255, 255, 255, 255, 0, 255, 255, // 40 - 47 ('-')
- 1, 2, 3, 4, 5, 6, 7, 8, // 48 - 55 (0-7)
- 9, 10, 255, 255, 255, 255, 255, 255, // 56 - 63 (8-9)
- 255, 11, 12, 13, 14, 15, 16, 17, // 64 - 71 (A-G)
- 18, 19, 20, 21, 22, 23, 24, 25, // 72 - 79 (H-O)
- 26, 27, 28, 29, 30, 31, 32, 33, // 80 - 87 (P-W)
- 34, 35, 36, 255, 255, 255, 255, 37, // 88 - 95 (X-Z, '_')
- 255, 11, 12, 13, 14, 15, 16, 17, // 96 - 103 (a-g)
- 18, 19, 20, 21, 22, 23, 24, 25, // 104 - 111 (h-0)
- 26, 27, 28, 29, 30, 31, 32, 33, // 112 - 119 (p-w)
- 34, 35, 36, 255, 255, 255, 255, 255, // 120 - 127 (x-z)
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255
-};
+ 255, 255, 255, 255, 255, 255, 255, 255, // 0 - 7
+ 255, 255, 255, 255, 255, 255, 255, 255, // 8 - 15
+ 255, 255, 255, 255, 255, 255, 255, 255, // 16 - 23
+ 255, 255, 255, 255, 255, 255, 255, 255, // 24 - 31
+ 255, 255, 255, 255, 255, 255, 255, 255, // 32 - 39
+ 255, 255, 255, 255, 255, 0, 255, 255, // 40 - 47 ('-')
+ 1, 2, 3, 4, 5, 6, 7, 8, // 48 - 55 (0-7)
+ 9, 10, 255, 255, 255, 255, 255, 255, // 56 - 63 (8-9)
+ 255, 11, 12, 13, 14, 15, 16, 17, // 64 - 71 (A-G)
+ 18, 19, 20, 21, 22, 23, 24, 25, // 72 - 79 (H-O)
+ 26, 27, 28, 29, 30, 31, 32, 33, // 80 - 87 (P-W)
+ 34, 35, 36, 255, 255, 255, 255, 37, // 88 - 95 (X-Z, '_')
+ 255, 11, 12, 13, 14, 15, 16, 17, // 96 - 103 (a-g)
+ 18, 19, 20, 21, 22, 23, 24, 25, // 104 - 111 (h-0)
+ 26, 27, 28, 29, 30, 31, 32, 33, // 112 - 119 (p-w)
+ 34, 35, 36, 255, 255, 255, 255, 255, // 120 - 127 (x-z)
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255};
// Number of legal characters in the acssiToTable array
static const int numLegalChars = 38;
@@ -212,8 +199,7 @@ static const int numLegalChars = 38;
// Used by class charIndex. Forms a single level
// in charIndex tree
//
-struct charIndex_el
-{
+struct charIndex_el {
charIndex_el();
~charIndex_el();
HostBranch *branch_array[numLegalChars];
@@ -245,23 +231,21 @@ charIndex_el::~charIndex_el()
// Stores the location of an element in
// class charIndex
//
-struct charIndexIterInternal
-{
+struct charIndexIterInternal {
charIndex_el *ptr;
int index;
};
// Used as a default return element for DynArray in
// struct charIndexIterState
-static charIndexIterInternal default_iter = { NULL, -1 };
+static charIndexIterInternal default_iter = {NULL, -1};
// struct charIndexIterState
//
// struct for the callee to keep interation state
// for class charIndex
//
-struct charIndexIterState
-{
+struct charIndexIterState {
charIndexIterState();
// Where that level we are in interation
@@ -272,10 +256,10 @@ struct charIndexIterState
charIndex_el *cur_el;
// Queue of the above levels
- DynArray<charIndexIterInternal> q;
+ DynArray<charIndexIterInternal> q;
};
-charIndexIterState::charIndexIterState():cur_level(-1), cur_index(-1), cur_el(NULL), q(&default_iter, 6)
+charIndexIterState::charIndexIterState() : cur_level(-1), cur_index(-1), cur_el(NULL), q(&default_iter, 6)
{
}
@@ -316,29 +300,22 @@ charIndexIterState::charIndexIterState():cur_level(-1), cur_index(-1), cur_el(NU
//
//
//
-class
- charIndex
+class charIndex
{
public:
charIndex();
- ~
- charIndex();
- void
- Insert(const char *match_data, HostBranch * toInsert);
- HostBranch *
- Lookup(const char *match_data);
- HostBranch *
- iter_first(charIndexIterState * s);
- HostBranch *
- iter_next(charIndexIterState * s);
+ ~charIndex();
+ void Insert(const char *match_data, HostBranch *toInsert);
+ HostBranch *Lookup(const char *match_data);
+ HostBranch *iter_first(charIndexIterState *s);
+ HostBranch *iter_next(charIndexIterState *s);
+
private:
- charIndex_el *
- root;
- InkHashTable *
- illegalKey;
+ charIndex_el *root;
+ InkHashTable *illegalKey;
};
-charIndex::charIndex():illegalKey(NULL)
+charIndex::charIndex() : illegalKey(NULL)
{
root = new charIndex_el;
}
@@ -357,7 +334,7 @@ charIndex::~charIndex()
ht_entry = ink_hash_table_iterator_first(illegalKey, &ht_iter);
while (ht_entry != NULL) {
- tmp = (HostBranch *) ink_hash_table_entry_value(illegalKey, ht_entry);
+ tmp = (HostBranch *)ink_hash_table_entry_value(illegalKey, ht_entry);
ink_assert(tmp != NULL);
delete tmp;
ht_entry = ink_hash_table_iterator_next(illegalKey, &ht_iter);
@@ -371,7 +348,7 @@ charIndex::~charIndex()
// Places a binding for match_data to toInsert into the index
//
void
-charIndex::Insert(const char *match_data, HostBranch * toInsert)
+charIndex::Insert(const char *match_data, HostBranch *toInsert)
{
unsigned char index;
const char *match_start = match_data;
@@ -385,7 +362,7 @@ charIndex::Insert(const char *match_data, HostBranch * toInsert)
}
while (1) {
- index = asciiToTable[(unsigned char) (*match_data)];
+ index = asciiToTable[(unsigned char)(*match_data)];
// Check to see if our index into table is for an
// 'illegal' DNS character
@@ -394,7 +371,7 @@ charIndex::Insert(const char *match_data, HostBranch * toInsert)
if (illegalKey == NULL) {
illegalKey = ink_hash_table_create(InkHashTableKeyType_String);
}
- ink_hash_table_insert(illegalKey, (char *) match_start, toInsert);
+ ink_hash_table_insert(illegalKey, (char *)match_start, toInsert);
break;
}
@@ -441,8 +418,7 @@ charIndex::Lookup(const char *match_data)
}
while (1) {
-
- index = asciiToTable[(unsigned char) (*match_data)];
+ index = asciiToTable[(unsigned char)(*match_data)];
// Check to see if our index into table is for an
// 'illegal' DNS character
@@ -450,8 +426,8 @@ charIndex::Lookup(const char *match_data)
if (illegalKey == NULL) {
return NULL;
} else {
- if (ink_hash_table_lookup(illegalKey, (char *) match_start, &hash_lookup)) {
- return (HostBranch *) hash_lookup;
+ if (ink_hash_table_lookup(illegalKey, (char *)match_start, &hash_lookup)) {
+ return (HostBranch *)hash_lookup;
} else {
return NULL;
}
@@ -481,7 +457,7 @@ charIndex::Lookup(const char *match_data)
// is returned
//
HostBranch *
-charIndex::iter_first(charIndexIterState * s)
+charIndex::iter_first(charIndexIterState *s)
{
s->cur_level = 0;
s->cur_index = -1;
@@ -498,7 +474,7 @@ charIndex::iter_first(charIndexIterState * s)
// is returned
//
HostBranch *
-charIndex::iter_next(charIndexIterState * s)
+charIndex::iter_next(charIndexIterState *s)
{
int index;
charIndex_el *current_el = s->cur_el;
@@ -519,7 +495,6 @@ charIndex::iter_next(charIndexIterState * s)
}
while (1) {
-
// Check to see if we need to go back up a level
if (index >= numLegalChars) {
if (level <= 0) {
@@ -582,17 +557,18 @@ class hostArray
public:
hostArray();
~hostArray();
- bool Insert(const char *match_data_in, HostBranch * toInsert);
+ bool Insert(const char *match_data_in, HostBranch *toInsert);
HostBranch *Lookup(const char *match_data_in, bool bNotProcess);
- HostBranch *iter_first(hostArrayIterState * s, char **key = NULL);
- HostBranch *iter_next(hostArrayIterState * s, char **key = NULL);
+ HostBranch *iter_first(hostArrayIterState *s, char **key = NULL);
+ HostBranch *iter_next(hostArrayIterState *s, char **key = NULL);
+
private:
- int num_el; // number of elements currently in the array
+ int num_el; // number of elements currently in the array
HostBranch *branch_array[HOST_ARRAY_MAX];
char *match_data[HOST_ARRAY_MAX];
};
-hostArray::hostArray():num_el(0)
+hostArray::hostArray() : num_el(0)
{
memset(branch_array, 0, sizeof(branch_array));
memset(match_data, 0, sizeof(match_data));
@@ -614,7 +590,7 @@ hostArray::~hostArray()
// If space is inadequate, false is returned and nothing is inserted
//
bool
-hostArray::Insert(const char *match_data_in, HostBranch * toInsert)
+hostArray::Insert(const char *match_data_in, HostBranch *toInsert)
{
if (num_el >= HOST_ARRAY_MAX) {
return false;
@@ -642,7 +618,6 @@ hostArray::Lookup(const char *match_data_in, bool bNotProcess)
pMD = match_data[i];
if (bNotProcess && '!' == *pMD) {
-
char *cp = ++pMD;
if ('\0' == *cp)
continue;
@@ -668,7 +643,7 @@ hostArray::Lookup(const char *match_data_in, bool bNotProcess)
// NULL if no elements exist
//
HostBranch *
-hostArray::iter_first(hostArrayIterState * s, char **key)
+hostArray::iter_first(hostArrayIterState *s, char **key)
{
*s = -1;
return iter_next(s, key);
@@ -680,7 +655,7 @@ hostArray::iter_first(hostArrayIterState * s, char **key)
// NULL if none exist
//
HostBranch *
-hostArray::iter_next(hostArrayIterState * s, char **key)
+hostArray::iter_next(hostArrayIterState *s, char **key)
{
(*s)++;
@@ -695,17 +670,11 @@ hostArray::iter_next(hostArrayIterState * s, char **key)
}
// maps enum LeafType to strings
-const char *LeafTypeStr[] = {
- "Leaf Invalid",
- "Host (Partial)",
- "Host (Full)",
- "Domain (Full)",
- "Domain (Partial)"
-};
+const char *LeafTypeStr[] = {"Leaf Invalid", "Host (Partial)", "Host (Full)", "Domain (Full)", "Domain (Partial)"};
static int negative_one = -1;
-HostBranch::HostBranch():level(0), type(HOST_TERMINAL), next_level(NULL), leaf_indexs(&negative_one, 1)
+HostBranch::HostBranch() : level(0), type(HOST_TERMINAL), next_level(NULL), leaf_indexs(&negative_one, 1)
{
}
@@ -715,7 +684,6 @@ HostBranch::HostBranch():level(0), type(HOST_TERMINAL), next_level(NULL), leaf_i
//
HostBranch::~HostBranch()
{
-
// Hash Iteration
InkHashTable *ht;
InkHashTableIteratorState ht_iter;
@@ -737,11 +705,11 @@ HostBranch::~HostBranch()
break;
case HOST_HASH:
ink_assert(next_level != NULL);
- ht = (InkHashTable *) next_level;
+ ht = (InkHashTable *)next_level;
ht_entry = ink_hash_table_iterator_first(ht, &ht_iter);
while (ht_entry != NULL) {
- lower_branch = (HostBranch *) ink_hash_table_entry_value(ht, ht_entry);
+ lower_branch = (HostBranch *)ink_hash_table_entry_value(ht, ht_entry);
delete lower_branch;
ht_entry = ink_hash_table_iterator_next(ht, &ht_iter);
}
@@ -749,7 +717,7 @@ HostBranch::~HostBranch()
break;
case HOST_INDEX:
ink_assert(next_level != NULL);
- ci = (charIndex *) next_level;
+ ci = (charIndex *)next_level;
lower_branch = ci->iter_first(&ci_iter);
while (lower_branch != NULL) {
delete lower_branch;
@@ -759,7 +727,7 @@ HostBranch::~HostBranch()
break;
case HOST_ARRAY:
ink_assert(next_level != NULL);
- ha = (hostArray *) next_level;
+ ha = (hostArray *)next_level;
lower_branch = ha->iter_first(&ha_iter);
while (lower_branch != NULL) {
delete lower_branch;
@@ -770,13 +738,8 @@ HostBranch::~HostBranch()
}
}
-HostLookup::HostLookup(const char *name):
-leaf_array(NULL),
-array_len(-1),
-num_el(-1),
-matcher_name(name)
+HostLookup::HostLookup(const char *name) : leaf_array(NULL), array_len(-1), num_el(-1), matcher_name(name)
{
-
root = new HostBranch;
root->level = 0;
root->type = HOST_TERMINAL;
@@ -785,20 +748,19 @@ matcher_name(name)
HostLookup::~HostLookup()
{
-
if (leaf_array != NULL) {
// Free up the match strings
for (int i = 0; i < num_el; i++) {
ats_free(leaf_array[i].match);
}
- delete[]leaf_array;
+ delete[] leaf_array;
}
delete root;
}
static void
-empty_print_fn(void */* opaque_data ATS_UNUSED */)
+empty_print_fn(void * /* opaque_data ATS_UNUSED */)
{
}
@@ -821,9 +783,8 @@ HostLookup::Print(HostLookupPrintFunc f)
// and print out each element
//
void
-HostLookup::PrintHostBranch(HostBranch * hb, HostLookupPrintFunc f)
+HostLookup::PrintHostBranch(HostBranch *hb, HostLookupPrintFunc f)
{
-
// Hash iteration
InkHashTable *ht;
InkHashTableIteratorState ht_iter;
@@ -839,7 +800,7 @@ HostLookup::PrintHostBranch(HostBranch * hb, HostLookupPrintFunc f)
HostBranch *lower_branch;
intptr_t curIndex;
- intptr_t i; // Loop var
+ intptr_t i; // Loop var
for (i = 0; i < hb->leaf_indexs.length(); i++) {
curIndex = hb->leaf_indexs[i];
@@ -853,18 +814,18 @@ HostLookup::PrintHostBranch(HostBranch * hb, HostLookupPrintFunc f)
break;
case HOST_HASH:
ink_assert(hb->next_level != NULL);
- ht = (InkHashTable *) hb->next_level;
+ ht = (InkHashTable *)hb->next_level;
ht_entry = ink_hash_table_iterator_first(ht, &ht_iter);
while (ht_entry != NULL) {
- lower_branch = (HostBranch *) ink_hash_table_entry_value(ht, ht_entry);
+ lower_branch = (HostBranch *)ink_hash_table_entry_value(ht, ht_entry);
PrintHostBranch(lower_branch, f);
ht_entry = ink_hash_table_iterator_next(ht, &ht_iter);
}
break;
case HOST_INDEX:
ink_assert(hb->next_level != NULL);
- ci = (charIndex *) hb->next_level;
+ ci = (charIndex *)hb->next_level;
lower_branch = ci->iter_first(&ci_iter);
while (lower_branch != NULL) {
PrintHostBranch(lower_branch, f);
@@ -873,7 +834,7 @@ HostLookup::PrintHostBranch(HostBranch * hb, HostLookupPrintFunc f)
break;
case HOST_ARRAY:
ink_assert(hb->next_level != NULL);
- h_array = (hostArray *) hb->next_level;
+ h_array = (hostArray *)hb->next_level;
lower_branch = h_array->iter_first(&ha_iter);
while (lower_branch != NULL) {
PrintHostBranch(lower_branch, f);
@@ -892,7 +853,7 @@ HostLookup::PrintHostBranch(HostBranch * hb, HostLookupPrintFunc f)
// HostBranch
//
HostBranch *
-HostLookup::TableNewLevel(HostBranch * from, const char *level_data)
+HostLookup::TableNewLevel(HostBranch *from, const char *level_data)
{
hostArray *new_ha_table;
charIndex *new_ci_table;
@@ -924,9 +885,8 @@ HostLookup::TableNewLevel(HostBranch * from, const char *level_data)
// by class HostMatcher
//
HostBranch *
-HostLookup::InsertBranch(HostBranch * insert_in, const char *level_data)
+HostLookup::InsertBranch(HostBranch *insert_in, const char *level_data)
{
-
// Variables for moving an array into a hash table after it
// gets too big
//
@@ -948,18 +908,17 @@ HostLookup::InsertBranch(HostBranch * insert_in, const char *level_data)
ink_release_assert(0);
break;
case HOST_HASH:
- ink_hash_table_insert((InkHashTable *) insert_in->next_level, (char *) level_data, new_branch);
+ ink_hash_table_insert((InkHashTable *)insert_in->next_level, (char *)level_data, new_branch);
break;
case HOST_INDEX:
- ((charIndex *) insert_in->next_level)->Insert(level_data, new_branch);
+ ((charIndex *)insert_in->next_level)->Insert(level_data, new_branch);
break;
case HOST_ARRAY:
- if (((hostArray *) insert_in->next_level)->Insert(level_data, new_branch) == false) {
-
+ if (((hostArray *)insert_in->next_level)->Insert(level_data, new_branch) == false) {
// The array is out of space, time to move to a hash table
- ha = (hostArray *) insert_in->next_level;
+ ha = (hostArray *)insert_in->next_level;
new_ht = ink_hash_table_create(InkHashTableKeyType_String);
- ink_hash_table_insert(new_ht, (char *) level_data, new_branch);
+ ink_hash_table_insert(new_ht, (char *)level_data, new_branch);
// Iterate through the existing elements in the array and
// stuff them into the hash table
@@ -977,7 +936,6 @@ HostLookup::InsertBranch(HostBranch * insert_in, const char *level_data)
insert_in->type = HOST_HASH;
}
break;
-
}
return new_branch;
@@ -992,9 +950,8 @@ HostLookup::InsertBranch(HostBranch * insert_in, const char *level_data)
// otherwise returns NULL
//
HostBranch *
-HostLookup::FindNextLevel(HostBranch * from, const char *level_data, bool bNotProcess)
+HostLookup::FindNextLevel(HostBranch *from, const char *level_data, bool bNotProcess)
{
-
HostBranch *r = NULL;
InkHashTable *hash;
charIndex *ci_table;
@@ -1007,21 +964,21 @@ HostLookup::FindNextLevel(HostBranch * from, const char *level_data, bool bNotPr
ink_assert(0);
return NULL;
case HOST_HASH:
- hash = (InkHashTable *) from->next_level;
+ hash = (InkHashTable *)from->next_level;
ink_assert(hash != NULL);
- if (ink_hash_table_lookup(hash, (char *) level_data, &lookup)) {
- r = (HostBranch *) lookup;
+ if (ink_hash_table_lookup(hash, (char *)level_data, &lookup)) {
+ r = (HostBranch *)lookup;
} else {
r = NULL;
}
break;
case HOST_INDEX:
- ci_table = (charIndex *) from->next_level;
+ ci_table = (charIndex *)from->next_level;
ink_assert(ci_table != NULL);
r = ci_table->Lookup(level_data);
break;
case HOST_ARRAY:
- ha_table = (hostArray *) from->next_level;
+ ha_table = (hostArray *)from->next_level;
ink_assert(ha_table != NULL);
r = ha_table->Lookup(level_data, bNotProcess);
break;
@@ -1054,7 +1011,6 @@ HostLookup::TableInsert(const char *match_data, int index, bool domain_record)
// OR We reach the level where the match stops
//
for (i = 0; i < HOST_TABLE_DEPTH; i++) {
-
// Check to see we need to stop at the current level
if (numTok == cur->level) {
break;
@@ -1122,7 +1078,7 @@ HostLookup::TableInsert(const char *match_data, int index, bool domain_record)
//
bool
-HostLookup::MatchArray(HostLookupState * s, void **opaque_ptr, DynArray<int>&array, bool host_done)
+HostLookup::MatchArray(HostLookupState *s, void **opaque_ptr, DynArray<int> &array, bool host_done)
{
intptr_t index;
intptr_t i;
@@ -1153,7 +1109,7 @@ HostLookup::MatchArray(HostLookupState * s, void **opaque_ptr, DynArray<int>&arr
if (domaincmp(s->hostname, leaf_array[index].match) == false) {
break;
}
- // FALL THROUGH
+ // FALL THROUGH
case DOMAIN_COMPLETE:
*opaque_ptr = leaf_array[index].opaque_data;
s->array_index = i;
@@ -1174,7 +1130,7 @@ HostLookup::MatchArray(HostLookupState * s, void **opaque_ptr, DynArray<int>&arr
//
//
bool
-HostLookup::MatchFirst(const char *host, HostLookupState * s, void **opaque_ptr)
+HostLookup::MatchFirst(const char *host, HostLookupState *s, void **opaque_ptr)
{
char *last_dot = NULL;
@@ -1210,7 +1166,7 @@ HostLookup::MatchFirst(const char *host, HostLookupState * s, void **opaque_ptr)
// arg hostname
//
bool
-HostLookup::MatchNext(HostLookupState * s, void **opaque_ptr)
+HostLookup::MatchNext(HostLookupState *s, void **opaque_ptr)
{
HostBranch *cur = s->cur;
@@ -1220,7 +1176,6 @@ HostLookup::MatchNext(HostLookupState * s, void **opaque_ptr)
}
while (s->table_level <= HOST_TABLE_DEPTH) {
-
if (MatchArray(s, opaque_ptr, cur->leaf_indexs, (s->host_copy_next == NULL))) {
return true;
}
@@ -1247,7 +1202,6 @@ HostLookup::MatchNext(HostLookupState * s, void **opaque_ptr)
// Nothing left
s->host_copy_next = NULL;
} else {
-
// Back up to period ahead of us and axe it
s->host_copy_next--;
ink_assert(*s->host_copy_next == '.');
@@ -1256,7 +1210,6 @@ HostLookup::MatchNext(HostLookupState * s, void **opaque_ptr)
s->host_copy_next--;
while (1) {
-
if (s->host_copy_next <= s->host_copy) {
s->host_copy_next = s->host_copy;
break;
@@ -1302,7 +1255,6 @@ HostLookup::AllocateSpace(int num_entries)
void
HostLookup::NewEntry(const char *match_data, bool domain_record, void *opaque_data_in)
{
-
// Make sure space has been allocated
ink_assert(num_el >= 0);
ink_assert(array_len >= 0);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/HostLookup.h
----------------------------------------------------------------------
diff --git a/lib/ts/HostLookup.h b/lib/ts/HostLookup.h
index d5f091f..5e8bd7b 100644
--- a/lib/ts/HostLookup.h
+++ b/lib/ts/HostLookup.h
@@ -37,11 +37,18 @@ const int HOST_ARRAY_MAX = 8; // Sets the fixed array size
//
// Begin Host Lookup Helper types
//
-enum HostNodeType
-{ HOST_TERMINAL, HOST_HASH, HOST_INDEX, HOST_ARRAY };
-enum LeafType
-{ LEAF_INVALID, HOST_PARTIAL, HOST_COMPLETE,
- DOMAIN_COMPLETE, DOMAIN_PARTIAL
+enum HostNodeType {
+ HOST_TERMINAL,
+ HOST_HASH,
+ HOST_INDEX,
+ HOST_ARRAY,
+};
+enum LeafType {
+ LEAF_INVALID,
+ HOST_PARTIAL,
+ HOST_COMPLETE,
+ DOMAIN_COMPLETE,
+ DOMAIN_PARTIAL,
};
// The data in the HostMatcher tree is pointers to HostBranches.
@@ -53,77 +60,72 @@ enum LeafType
// There is HostLeaf struct for each data item put into the
// table
//
-struct HostLeaf
-{
+struct HostLeaf {
LeafType type;
- char *match; // Contains a copy of the match data
- int len; // length of the data
- bool isNot; // used by any fasssst path ...
- void *opaque_data; // Data associated with this leaf
+ char *match; // Contains a copy of the match data
+ int len; // length of the data
+ bool isNot; // used by any fasssst path ...
+ void *opaque_data; // Data associated with this leaf
};
-struct HostBranch
-{
+struct HostBranch {
HostBranch();
~HostBranch();
- int level; // what level in the tree. the root is level 0
- HostNodeType type; // tells what kind of data structure is next_level is
- void *next_level; // opaque pointer to lookup structure
- DynArray<int>leaf_indexs; // pointers HostLeaf(s)
+ int level; // what level in the tree. the root is level 0
+ HostNodeType type; // tells what kind of data structure is next_level is
+ void *next_level; // opaque pointer to lookup structure
+ DynArray<int> leaf_indexs; // pointers HostLeaf(s)
};
-typedef void (*HostLookupPrintFunc) (void *opaque_data);
+typedef void (*HostLookupPrintFunc)(void *opaque_data);
//
// End Host Lookup Helper types
//
-struct HostLookupState
-{
- HostLookupState()
- : cur(NULL), table_level(0), array_index(0), hostname(NULL), host_copy(NULL), host_copy_next(NULL)
- { }
+struct HostLookupState {
+ HostLookupState() : cur(NULL), table_level(0), array_index(0), hostname(NULL), host_copy(NULL), host_copy_next(NULL) {}
- ~HostLookupState() {
- ats_free(host_copy);
- }
+ ~HostLookupState() { ats_free(host_copy); }
HostBranch *cur;
int table_level;
int array_index;
const char *hostname;
- char *host_copy; // request lower-cased host name copy
- char *host_copy_next; // ptr to part of host_copy for next use
+ char *host_copy; // request lower-cased host name copy
+ char *host_copy_next; // ptr to part of host_copy for next use
};
class HostLookup
{
public:
HostLookup(const char *name);
- ~HostLookup();
+ ~HostLookup();
void NewEntry(const char *match_data, bool domain_record, void *opaque_data_in);
void AllocateSpace(int num_entries);
bool Match(const char *host);
bool Match(const char *host, void **opaque_ptr);
- bool MatchFirst(const char *host, HostLookupState * s, void **opaque_ptr);
- bool MatchNext(HostLookupState * s, void **opaque_ptr);
+ bool MatchFirst(const char *host, HostLookupState *s, void **opaque_ptr);
+ bool MatchNext(HostLookupState *s, void **opaque_ptr);
void Print(HostLookupPrintFunc f);
void Print();
- HostLeaf *getLArray()
+ HostLeaf *
+ getLArray()
{
return leaf_array;
};
+
private:
void TableInsert(const char *match_data, int index, bool domain_record);
- HostBranch *TableNewLevel(HostBranch * from, const char *level_data);
- HostBranch *InsertBranch(HostBranch * insert_in, const char *level_data);
- HostBranch *FindNextLevel(HostBranch * from, const char *level_data, bool bNotProcess = false);
- bool MatchArray(HostLookupState * s, void **opaque_ptr, DynArray<int>&array, bool host_done);
- void PrintHostBranch(HostBranch * hb, HostLookupPrintFunc f);
- HostBranch *root; // The top of the search tree
- HostLeaf *leaf_array; // array of all leaves in tree
- int array_len; // the length of the arrays
- int num_el; // the numbe of itmems in the tree
- const char *matcher_name; // Used for Debug/Warning/Error messages
+ HostBranch *TableNewLevel(HostBranch *from, const char *level_data);
+ HostBranch *InsertBranch(HostBranch *insert_in, const char *level_data);
+ HostBranch *FindNextLevel(HostBranch *from, const char *level_data, bool bNotProcess = false);
+ bool MatchArray(HostLookupState *s, void **opaque_ptr, DynArray<int> &array, bool host_done);
+ void PrintHostBranch(HostBranch *hb, HostLookupPrintFunc f);
+ HostBranch *root; // The top of the search tree
+ HostLeaf *leaf_array; // array of all leaves in tree
+ int array_len; // the length of the arrays
+ int num_el; // the numbe of itmems in the tree
+ const char *matcher_name; // Used for Debug/Warning/Error messages
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/INK_MD5.h
----------------------------------------------------------------------
diff --git a/lib/ts/INK_MD5.h b/lib/ts/INK_MD5.h
index d5d4e91..218ad99 100644
--- a/lib/ts/INK_MD5.h
+++ b/lib/ts/INK_MD5.h
@@ -22,21 +22,23 @@
*/
#ifndef _INK_MD5_h_
-#define _INK_MD5_h_
+#define _INK_MD5_h_
#include "ink_code.h"
#include "ink_defs.h"
#include "CryptoHash.h"
-class MD5Context : public CryptoContext {
+class MD5Context : public CryptoContext
+{
protected:
MD5_CTX _ctx;
+
public:
MD5Context();
/// Update the hash with @a data of @a length bytes.
- virtual bool update(void const* data, int length);
+ virtual bool update(void const *data, int length);
/// Finalize and extract the @a hash.
- virtual bool finalize(CryptoHash& hash);
+ virtual bool finalize(CryptoHash &hash);
};
typedef CryptoHash INK_MD5;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/I_Layout.h
----------------------------------------------------------------------
diff --git a/lib/ts/I_Layout.h b/lib/ts/I_Layout.h
index 432ed91..2be9b19 100644
--- a/lib/ts/I_Layout.h
+++ b/lib/ts/I_Layout.h
@@ -35,8 +35,7 @@
The Layout is a simple place holder for the distribution layout.
*/
-struct Layout
-{
+struct Layout {
char *prefix;
char *exec_prefix;
char *bindir;
@@ -55,7 +54,7 @@ struct Layout
char *cachedir;
Layout(const char *prefix = 0);
- ~Layout();
+ ~Layout();
/**
Return file path relative to Layout->prefix
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/I_Version.h
----------------------------------------------------------------------
diff --git a/lib/ts/I_Version.h b/lib/ts/I_Version.h
index 668c2e7..c51e1bd 100644
--- a/lib/ts/I_Version.h
+++ b/lib/ts/I_Version.h
@@ -31,42 +31,41 @@
#ifndef _Version_h
#define _Version_h
-struct VersionNumber
-{
- short int ink_major; // incompatible change
- short int ink_minor; // minor change, not incompatible
+struct VersionNumber {
+ short int ink_major; // incompatible change
+ short int ink_minor; // minor change, not incompatible
VersionNumber() {}
VersionNumber(short int major, short int minor) : ink_major(major), ink_minor(minor) {}
};
-inline bool operator < (VersionNumber const& lhs, VersionNumber const& rhs) {
- return lhs.ink_major < rhs.ink_major ||
- (lhs.ink_major == rhs.ink_major && lhs.ink_minor < rhs.ink_minor)
- ;
+inline bool operator<(VersionNumber const &lhs, VersionNumber const &rhs)
+{
+ return lhs.ink_major < rhs.ink_major || (lhs.ink_major == rhs.ink_major && lhs.ink_minor < rhs.ink_minor);
}
-struct Version
-{
+struct Version {
VersionNumber cacheDB;
VersionNumber cacheDir;
VersionNumber clustering;
VersionNumber clustering_min;
};
-enum ModuleVersion
-{ MODULE_VERSION_MIN = 0, MODULE_VERSION_MAX = 2147483647 };
-enum ModuleHeaderType
-{ PUBLIC_MODULE_HEADER, PRIVATE_MODULE_HEADER };
+enum ModuleVersion {
+ MODULE_VERSION_MIN = 0,
+ MODULE_VERSION_MAX = 2147483647,
+};
+enum ModuleHeaderType {
+ PUBLIC_MODULE_HEADER,
+ PRIVATE_MODULE_HEADER,
+};
#define makeModuleVersion(_major_version, _minor_version, _module_type) \
-((ModuleVersion)((((int)_module_type) << 24) + \
- (((int)_major_version) << 16) + \
- (((int)_minor_version) << 8)))
+ ((ModuleVersion)((((int)_module_type) << 24) + (((int)_major_version) << 16) + (((int)_minor_version) << 8)))
#define majorModuleVersion(_v) ((((int)_v) >> 16) & 255)
#define minorModuleVersion(_v) ((((int)_v) >> 8) & 255)
-#define moduleVersionType(_v) ((((int)_v) >> 24) & 127)
+#define moduleVersionType(_v) ((((int)_v) >> 24) & 127)
static inline int
checkModuleVersion(ModuleVersion userVersion, ModuleVersion libVersion)
@@ -101,9 +100,8 @@ public:
char FullVersionInfoStr[256];
AppVersionInfo();
- void setup(const char *pkg_name, const char *app_name, const char *app_version,
- const char *build_date, const char *build_time, const char *build_machine,
- const char *build_person, const char *build_cflags);
+ void setup(const char *pkg_name, const char *app_name, const char *app_version, const char *build_date, const char *build_time,
+ const char *build_machine, const char *build_person, const char *build_cflags);
};
#endif /*_Version_h*/
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/InkErrno.h
----------------------------------------------------------------------
diff --git a/lib/ts/InkErrno.h b/lib/ts/InkErrno.h
index 7f8676e..f3f796a 100644
--- a/lib/ts/InkErrno.h
+++ b/lib/ts/InkErrno.h
@@ -27,46 +27,46 @@
*/
-#if !defined (_Errno_h_)
+#if !defined(_Errno_h_)
#define _Errno_h_
#include <errno.h>
#define INK_START_ERRNO 20000
-#define SOCK_ERRNO INK_START_ERRNO
-#define NET_ERRNO INK_START_ERRNO+100
-#define CLUSTER_ERRNO INK_START_ERRNO+200
-#define CACHE_ERRNO INK_START_ERRNO+400
-#define HTTP_ERRNO INK_START_ERRNO+600
+#define SOCK_ERRNO INK_START_ERRNO
+#define NET_ERRNO INK_START_ERRNO + 100
+#define CLUSTER_ERRNO INK_START_ERRNO + 200
+#define CACHE_ERRNO INK_START_ERRNO + 400
+#define HTTP_ERRNO INK_START_ERRNO + 600
-#define ENET_THROTTLING (NET_ERRNO+1)
-#define ENET_CONNECT_TIMEOUT (NET_ERRNO+2)
-#define ENET_CONNECT_FAILED (NET_ERRNO+3)
+#define ENET_THROTTLING (NET_ERRNO + 1)
+#define ENET_CONNECT_TIMEOUT (NET_ERRNO + 2)
+#define ENET_CONNECT_FAILED (NET_ERRNO + 3)
-#define ESOCK_DENIED (SOCK_ERRNO+0)
-#define ESOCK_TIMEOUT (SOCK_ERRNO+1)
-#define ESOCK_NO_SOCK_SERVER_CONN (SOCK_ERRNO+2)
+#define ESOCK_DENIED (SOCK_ERRNO + 0)
+#define ESOCK_TIMEOUT (SOCK_ERRNO + 1)
+#define ESOCK_NO_SOCK_SERVER_CONN (SOCK_ERRNO + 2)
// Error codes for CLUSTER_EVENT_OPEN_FAILED
-#define ECLUSTER_NO_VC (CLUSTER_ERRNO+0)
-#define ECLUSTER_NO_MACHINE (CLUSTER_ERRNO+1)
-#define ECLUSTER_OP_TIMEOUT (CLUSTER_ERRNO+2)
-#define ECLUSTER_ORB_DATA_READ (CLUSTER_ERRNO+3)
-#define ECLUSTER_ORB_EIO (CLUSTER_ERRNO+4)
-#define ECLUSTER_CHANNEL_INUSE (CLUSTER_ERRNO+5)
-#define ECLUSTER_NOMORE_CHANNELS (CLUSTER_ERRNO+6)
-
-#define ECACHE_NO_DOC (CACHE_ERRNO+0)
-#define ECACHE_DOC_BUSY (CACHE_ERRNO+1)
-#define ECACHE_DIR_BAD (CACHE_ERRNO+2)
-#define ECACHE_BAD_META_DATA (CACHE_ERRNO+3)
-#define ECACHE_READ_FAIL (CACHE_ERRNO+4)
-#define ECACHE_WRITE_FAIL (CACHE_ERRNO+5)
-#define ECACHE_MAX_ALT_EXCEEDED (CACHE_ERRNO+6)
-#define ECACHE_NOT_READY (CACHE_ERRNO+7)
-#define ECACHE_ALT_MISS (CACHE_ERRNO+8)
-#define ECACHE_BAD_READ_REQUEST (CACHE_ERRNO+9)
-
-#define EHTTP_ERROR (HTTP_ERRNO+0)
+#define ECLUSTER_NO_VC (CLUSTER_ERRNO + 0)
+#define ECLUSTER_NO_MACHINE (CLUSTER_ERRNO + 1)
+#define ECLUSTER_OP_TIMEOUT (CLUSTER_ERRNO + 2)
+#define ECLUSTER_ORB_DATA_READ (CLUSTER_ERRNO + 3)
+#define ECLUSTER_ORB_EIO (CLUSTER_ERRNO + 4)
+#define ECLUSTER_CHANNEL_INUSE (CLUSTER_ERRNO + 5)
+#define ECLUSTER_NOMORE_CHANNELS (CLUSTER_ERRNO + 6)
+
+#define ECACHE_NO_DOC (CACHE_ERRNO + 0)
+#define ECACHE_DOC_BUSY (CACHE_ERRNO + 1)
+#define ECACHE_DIR_BAD (CACHE_ERRNO + 2)
+#define ECACHE_BAD_META_DATA (CACHE_ERRNO + 3)
+#define ECACHE_READ_FAIL (CACHE_ERRNO + 4)
+#define ECACHE_WRITE_FAIL (CACHE_ERRNO + 5)
+#define ECACHE_MAX_ALT_EXCEEDED (CACHE_ERRNO + 6)
+#define ECACHE_NOT_READY (CACHE_ERRNO + 7)
+#define ECACHE_ALT_MISS (CACHE_ERRNO + 8)
+#define ECACHE_BAD_READ_REQUEST (CACHE_ERRNO + 9)
+
+#define EHTTP_ERROR (HTTP_ERRNO + 0)
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/InkPool.h
----------------------------------------------------------------------
diff --git a/lib/ts/InkPool.h b/lib/ts/InkPool.h
index a26ad51..51a9d5e 100644
--- a/lib/ts/InkPool.h
+++ b/lib/ts/InkPool.h
@@ -28,22 +28,21 @@
// Template of a static size pool of objects.
//
//
-template<class C> class InkStaticPool {
+template <class C> class InkStaticPool
+{
public:
+ InkStaticPool(int size) : sz1(size + 1), head(0), tail(0) { pool = new C *[sz1]; }
- InkStaticPool(int size):sz1(size + 1), head(0), tail(0)
+ virtual ~InkStaticPool()
{
- pool = new C *[sz1];
- }
-
- virtual ~ InkStaticPool() {
cleanUp();
- delete[]pool;
+ delete[] pool;
}
C *get();
- bool put(C * newObj);
- void put_or_delete(C * newObj)
+ bool put(C *newObj);
+ void
+ put_or_delete(C *newObj)
{
if (!put(newObj))
delete newObj;
@@ -59,7 +58,9 @@ private:
C **pool;
};
-template<class C> inline C * InkStaticPool<C>::get()
+template <class C>
+inline C *
+InkStaticPool<C>::get()
{
if (head != tail) {
C *res = pool[head++];
@@ -69,10 +70,12 @@ template<class C> inline C * InkStaticPool<C>::get()
return (NULL);
}
-template<class C> inline bool InkStaticPool<C>::put(C * newObj)
+template <class C>
+inline bool
+InkStaticPool<C>::put(C *newObj)
{
if (newObj == NULL)
- return (false); // cannot put NULL pointer
+ return (false); // cannot put NULL pointer
int newTail = (tail + 1) % sz1;
bool res = (newTail != head);
@@ -83,7 +86,9 @@ template<class C> inline bool InkStaticPool<C>::put(C * newObj)
return (res);
}
-template<class C> inline void InkStaticPool<C>::cleanUp(void)
+template <class C>
+inline void
+InkStaticPool<C>::cleanUp(void)
{
while (true) {
C *tp = get();