http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/I_RecHttp.h ---------------------------------------------------------------------- diff --git a/lib/records/I_RecHttp.h b/lib/records/I_RecHttp.h index 32a9f2d..9dbd8c0 100644 --- a/lib/records/I_RecHttp.h +++ b/lib/records/I_RecHttp.h @@ -31,19 +31,20 @@ #include <ts/apidefs.h> /// Load default inbound IP addresses from the configuration file. -void RecHttpLoadIp( - char const* name, ///< Name of value in configuration file. - IpAddr& ip4, ///< [out] IPv4 address. - IpAddr& ip6 ///< [out] Ipv6 address. -); +void RecHttpLoadIp(char const *name, ///< Name of value in configuration file. + IpAddr &ip4, ///< [out] IPv4 address. + IpAddr &ip6 ///< [out] Ipv6 address. + ); /** A set of session protocols. This depends on using @c SessionProtocolNameRegistry to get the indices. */ -class SessionProtocolSet { +class SessionProtocolSet +{ typedef SessionProtocolSet self; ///< Self reference type. /// Storage for the set - a bit vector. uint32_t m_bits; + public: // The right way. // static int const MAX = sizeof(m_bits) * CHAR_BIT; @@ -51,40 +52,79 @@ public: static int const MAX = sizeof(uint32_t) * 8; /// Default constructor. /// Constructs and empty set. - SessionProtocolSet() : m_bits(0) { } + SessionProtocolSet() : m_bits(0) {} - uint32_t indexToMask(int idx) const { - return 0 <= idx && idx < static_cast<int>(MAX) - ? static_cast<uint32_t>(1) << idx - : 0 - ; + uint32_t + indexToMask(int idx) const + { + return 0 <= idx && idx < static_cast<int>(MAX) ? static_cast<uint32_t>(1) << idx : 0; } /// Mark the protocol at @a idx as present. - void markIn(int idx) { m_bits |= this->indexToMask(idx); } + void + markIn(int idx) + { + m_bits |= this->indexToMask(idx); + } /// Mark all the protocols in @a that as present in @a this. - void markIn(self const& that) { m_bits |= that.m_bits; } + void + markIn(self const &that) + { + m_bits |= that.m_bits; + } /// Mark the protocol at a idx as not present. - void markOut(int idx) { m_bits &= ~this->indexToMask(idx); } + void + markOut(int idx) + { + m_bits &= ~this->indexToMask(idx); + } /// Mark the protocols in @a that as not in @a this. - void markOut(self const& that) { m_bits &= ~(that.m_bits); } + void + markOut(self const &that) + { + m_bits &= ~(that.m_bits); + } /// Test if a protocol is in the set. - bool contains(int idx) const { return 0 != (m_bits & this->indexToMask(idx)); } + bool + contains(int idx) const + { + return 0 != (m_bits & this->indexToMask(idx)); + } /// Test if all the protocols in @a that are in @a this protocol set. - bool contains(self const& that) const { return that.m_bits == (that.m_bits & m_bits); } + bool + contains(self const &that) const + { + return that.m_bits == (that.m_bits & m_bits); + } /// Mark all possible protocols. - void markAllIn() { m_bits = ~static_cast<uint32_t>(0); } + void + markAllIn() + { + m_bits = ~static_cast<uint32_t>(0); + } /// Clear all protocols. - void markAllOut() { m_bits = 0; } + void + markAllOut() + { + m_bits = 0; + } /// Check for intersection. - bool intersects(self const& that) { return 0 != (m_bits & that.m_bits); } + bool + intersects(self const &that) + { + return 0 != (m_bits & that.m_bits); + } /// Check for empty set. - bool isEmpty() const { return m_bits == 0; } + bool + isEmpty() const + { + return m_bits == 0; + } /// Equality (identical sets). - bool operator == (self const& that) const { return m_bits == that.m_bits; } + bool operator==(self const &that) const { return m_bits == that.m_bits; } }; // Predefined sets of protocols, useful for configuration. @@ -107,10 +147,11 @@ extern SessionProtocolSet DEFAULT_TLS_SESSION_PROTOCOL_SET; If the size gets much larger we should consider doing something more clever. */ -class SessionProtocolNameRegistry { - public: - static int const MAX = SessionProtocolSet::MAX; ///< Maximum # of registered names. - static int const INVALID = -1; ///< Normalized invalid index value. +class SessionProtocolNameRegistry +{ +public: + static int const MAX = SessionProtocolSet::MAX; ///< Maximum # of registered names. + static int const INVALID = -1; ///< Normalized invalid index value. /// Default constructor. /// Creates empty registry with no names. @@ -124,34 +165,34 @@ class SessionProtocolNameRegistry { The name is copied internally. @return The index for the registered @a name. */ - int toIndex(char const* name); + int toIndex(char const *name); /** Get the index for @a name, registering it if needed. The caller @b guarantees @a name is persistent and immutable. @return The index for the registered @a name. */ - int toIndexConst(char const* name); + int toIndexConst(char const *name); /** Convert a @a name to an index. @return The index for @a name or @c INVALID if it is not registered. */ - int indexFor(char const* name) const; + int indexFor(char const *name) const; /** Convert an @a index to the corresponding name. @return A pointer to the name or @c NULL if the index isn't registered. */ - char const* nameFor(int index) const; + char const *nameFor(int index) const; /// Mark protocols as present in @a sp_set based on the names in @a value. /// The names can be separated by ;/|,: and space. /// @internal This is separated out to make it easy to access from the plugin API /// implementation. - void markIn(char const* value, SessionProtocolSet& sp_set); + void markIn(char const *value, SessionProtocolSet &sp_set); - protected: - unsigned int m_n; ///< Index of first unused slot. - char const* m_names[MAX]; ///< Pointers to registered names. - uint8_t m_flags[MAX]; ///< Flags for each name. +protected: + unsigned int m_n; ///< Index of first unused slot. + char const *m_names[MAX]; ///< Pointers to registered names. + uint8_t m_flags[MAX]; ///< Flags for each name. static uint8_t const F_ALLOCATED = 0x1; ///< Flag for allocated by this instance. }; @@ -189,10 +230,10 @@ public: TRANSPORT_PLUGIN /// < Protocol plugin connection }; - int m_fd; ///< Pre-opened file descriptor if present. + int m_fd; ///< Pre-opened file descriptor if present. TransportType m_type; ///< Type of connection. - in_port_t m_port; ///< Port on which to listen. - uint8_t m_family; ///< IP address family. + in_port_t m_port; ///< Port on which to listen. + uint8_t m_family; ///< IP address family. /// True if inbound connects (from client) are transparent. bool m_inbound_transparent_p; /// True if outbound connections (to origin servers) are transparent. @@ -221,9 +262,8 @@ public: @return The IP address for @a family */ - IpAddr& outboundIp( - uint16_t family ///< IP address family. - ); + IpAddr &outboundIp(uint16_t family ///< IP address family. + ); /// Check for SSL port. bool isSSL() const; @@ -235,22 +275,20 @@ public: /// @a opts should not contain any whitespace, only the option string. /// This object's internal state is updated as specified by @a opts. /// @return @c true if a port option was successfully processed, @c false otherwise. - bool processOptions( - char const* opts ///< String containing the options. - ); + bool processOptions(char const *opts ///< String containing the options. + ); /** Global instance. This is provided because most of the work with this data is used as a singleton and it's handy to encapsulate it here. */ - static Vec<self>& global(); + static Vec<self> &global(); /// Check for SSL ports. /// @return @c true if any port in @a ports is an SSL port. - static bool hasSSL( - Group const& ports ///< Ports to check. - ); + static bool hasSSL(Group const &ports ///< Ports to check. + ); /// Check for SSL ports. /// @return @c true if any global port is an SSL port. @@ -265,9 +303,8 @@ public: @return @c true if at least one valid port description was found, @c false if none. */ - static bool loadConfig( - Vec<self>& ports ///< Destination for found port data. - ); + static bool loadConfig(Vec<self> &ports ///< Destination for found port data. + ); /** Load all relevant configuration data into the global ports. @@ -284,10 +321,9 @@ public: @note This is used primarily internally but is available if needed. @return @c true if a valid port was found, @c false if none. */ - static bool loadValue( - Vec<self>& ports, ///< Destination for found port data. - char const* value ///< Source port data. - ); + static bool loadValue(Vec<self> &ports, ///< Destination for found port data. + char const *value ///< Source port data. + ); /** Load ports from a value string into the global ports. @@ -296,15 +332,13 @@ public: @return @c true if a valid port was found, @c false if none. */ - static bool loadValue( - char const* value ///< Source port data. - ); + static bool loadValue(char const *value ///< Source port data. + ); /// Load default value if @a ports is empty. /// @return @c true if the default was needed / loaded. - static bool loadDefaultIfEmpty( - Vec<self>& ports ///< Load target. - ); + static bool loadDefaultIfEmpty(Vec<self> &ports ///< Load target. + ); /// Load default value into the global set if it is empty. /// @return @c true if the default was needed / loaded. @@ -315,101 +349,119 @@ public: are checked. @return The port if found, @c NULL if not. */ - static self* findHttp( - Group const& ports, ///< Group to search. - uint16_t family = AF_UNSPEC ///< Desired address family. - ); + static self *findHttp(Group const &ports, ///< Group to search. + uint16_t family = AF_UNSPEC ///< Desired address family. + ); /** Find an HTTP port in the global ports. If @a family is specified then only ports for that family are checked. @return The port if found, @c NULL if not. */ - static self* findHttp(uint16_t family = AF_UNSPEC); + static self *findHttp(uint16_t family = AF_UNSPEC); /** Create text description to be used for inter-process access. Prints the file descriptor and then any options. @return The number of characters used for the description. */ - int print( - char* out, ///< Output string. - size_t n ///< Maximum output length. - ); + int print(char *out, ///< Output string. + size_t n ///< Maximum output length. + ); - static char const* const PORTS_CONFIG_NAME; ///< New unified port descriptor. + static char const *const PORTS_CONFIG_NAME; ///< New unified port descriptor. /// Default value if no other values can be found. - static char const* const DEFAULT_VALUE; + static char const *const DEFAULT_VALUE; // Keywords (lower case versions, but compares should be case insensitive) - static char const* const OPT_FD_PREFIX; ///< Prefix for file descriptor value. - static char const* const OPT_OUTBOUND_IP_PREFIX; ///< Prefix for inbound IP address. - static char const* const OPT_INBOUND_IP_PREFIX; ///< Prefix for outbound IP address. - static char const* const OPT_IPV6; ///< IPv6. - static char const* const OPT_IPV4; ///< IPv4 - static char const* const OPT_TRANSPARENT_INBOUND; ///< Inbound transparent. - static char const* const OPT_TRANSPARENT_OUTBOUND; ///< Outbound transparent. - static char const* const OPT_TRANSPARENT_FULL; ///< Full transparency. - static char const* const OPT_TRANSPARENT_PASSTHROUGH; ///< Pass-through non-HTTP. - static char const* const OPT_SSL; ///< SSL (experimental) - static char const* const OPT_PLUGIN; ///< Protocol Plugin handle (experimental) - static char const* const OPT_BLIND_TUNNEL; ///< Blind tunnel. - static char const* const OPT_COMPRESSED; ///< Compressed. - static char const* const OPT_HOST_RES_PREFIX; ///< Set DNS family preference. - static char const* const OPT_PROTO_PREFIX; ///< Transport layer protocols. - - static Vec<self>& m_global; ///< Global ("default") data. + static char const *const OPT_FD_PREFIX; ///< Prefix for file descriptor value. + static char const *const OPT_OUTBOUND_IP_PREFIX; ///< Prefix for inbound IP address. + static char const *const OPT_INBOUND_IP_PREFIX; ///< Prefix for outbound IP address. + static char const *const OPT_IPV6; ///< IPv6. + static char const *const OPT_IPV4; ///< IPv4 + static char const *const OPT_TRANSPARENT_INBOUND; ///< Inbound transparent. + static char const *const OPT_TRANSPARENT_OUTBOUND; ///< Outbound transparent. + static char const *const OPT_TRANSPARENT_FULL; ///< Full transparency. + static char const *const OPT_TRANSPARENT_PASSTHROUGH; ///< Pass-through non-HTTP. + static char const *const OPT_SSL; ///< SSL (experimental) + static char const *const OPT_PLUGIN; ///< Protocol Plugin handle (experimental) + static char const *const OPT_BLIND_TUNNEL; ///< Blind tunnel. + static char const *const OPT_COMPRESSED; ///< Compressed. + static char const *const OPT_HOST_RES_PREFIX; ///< Set DNS family preference. + static char const *const OPT_PROTO_PREFIX; ///< Transport layer protocols. + + static Vec<self> &m_global; ///< Global ("default") data. protected: /// Process @a value for DNS resolution family preferences. - void processFamilyPreference(char const* value); + void processFamilyPreference(char const *value); /// Process @a value for session protocol preferences. - void processSessionProtocolPreference(char const* value); + void processSessionProtocolPreference(char const *value); /** Check a prefix option and find the value. @return The address of the start of the value, or @c NULL if the prefix doesn't match. */ - char const* checkPrefix( char const* src ///< Input text - , char const* prefix ///< Keyword prefix - , size_t prefix_len ///< Length of keyword prefix. - ); + char const *checkPrefix(char const *src ///< Input text + , + char const *prefix ///< Keyword prefix + , + size_t prefix_len ///< Length of keyword prefix. + ); }; -inline bool HttpProxyPort::isSSL() const { return TRANSPORT_SSL == m_type; } -inline bool HttpProxyPort::isPlugin() const { return TRANSPORT_PLUGIN == m_type; } +inline bool +HttpProxyPort::isSSL() const +{ + return TRANSPORT_SSL == m_type; +} +inline bool +HttpProxyPort::isPlugin() const +{ + return TRANSPORT_PLUGIN == m_type; +} -inline IpAddr& -HttpProxyPort::outboundIp(uint16_t family) { +inline IpAddr & +HttpProxyPort::outboundIp(uint16_t family) +{ static IpAddr invalid; // dummy to make compiler happy about return. - if (AF_INET == family) return m_outbound_ip4; - else if (AF_INET6 == family) return m_outbound_ip6; + if (AF_INET == family) + return m_outbound_ip4; + else if (AF_INET6 == family) + return m_outbound_ip6; ink_release_assert(!"Invalid family for outbound address on proxy port."); return invalid; // never happens but compiler insists. } inline bool -HttpProxyPort::loadValue(char const* value) { +HttpProxyPort::loadValue(char const *value) +{ return self::loadValue(m_global, value); } inline bool -HttpProxyPort::loadConfig() { +HttpProxyPort::loadConfig() +{ return self::loadConfig(m_global); } inline bool -HttpProxyPort::loadDefaultIfEmpty() { +HttpProxyPort::loadDefaultIfEmpty() +{ return self::loadDefaultIfEmpty(m_global); } -inline Vec<HttpProxyPort>& -HttpProxyPort::global() { +inline Vec<HttpProxyPort> & +HttpProxyPort::global() +{ return m_global; } inline bool -HttpProxyPort::hasSSL() { +HttpProxyPort::hasSSL() +{ return self::hasSSL(m_global); } -inline HttpProxyPort* HttpProxyPort::findHttp(uint16_t family) { +inline HttpProxyPort * +HttpProxyPort::findHttp(uint16_t family) +{ return self::findHttp(m_global, family); }
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/I_RecLocal.h ---------------------------------------------------------------------- diff --git a/lib/records/I_RecLocal.h b/lib/records/I_RecLocal.h index 8af8c33..fdec68c 100644 --- a/lib/records/I_RecLocal.h +++ b/lib/records/I_RecLocal.h @@ -32,7 +32,7 @@ class FileManager; // Initialization //------------------------------------------------------------------------- -int RecLocalInit(Diags * diags = NULL); +int RecLocalInit(Diags *diags = NULL); int RecLocalInitMessage(); int RecLocalStart(FileManager *); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/I_RecMutex.h ---------------------------------------------------------------------- diff --git a/lib/records/I_RecMutex.h b/lib/records/I_RecMutex.h index ace1d26..1d6d498 100644 --- a/lib/records/I_RecMutex.h +++ b/lib/records/I_RecMutex.h @@ -32,16 +32,15 @@ by the SAME thread. This is a trimmed down version of ProxyMutex. */ -struct RecMutex -{ +struct RecMutex { size_t nthread_holding; ink_thread thread_holding; ink_mutex the_mutex; }; -int rec_mutex_init(RecMutex * m, const char *name = NULL); -int rec_mutex_destroy(RecMutex * m); -int rec_mutex_acquire(RecMutex * m); -int rec_mutex_release(RecMutex * m); +int rec_mutex_init(RecMutex *m, const char *name = NULL); +int rec_mutex_destroy(RecMutex *m); +int rec_mutex_acquire(RecMutex *m); +int rec_mutex_release(RecMutex *m); #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/I_RecProcess.h ---------------------------------------------------------------------- diff --git a/lib/records/I_RecProcess.h b/lib/records/I_RecProcess.h index 123041e..dd1e08d 100644 --- a/lib/records/I_RecProcess.h +++ b/lib/records/I_RecProcess.h @@ -31,7 +31,7 @@ //------------------------------------------------------------------------- // Initialization/Starting //------------------------------------------------------------------------- -int RecProcessInit(RecModeT mode_type, Diags * diags = NULL); +int RecProcessInit(RecModeT mode_type, Diags *diags = NULL); int RecProcessInitMessage(RecModeT mode_type); int RecProcessStart(void); @@ -47,7 +47,8 @@ void RecProcess_set_remote_sync_interval_ms(int ms); //------------------------------------------------------------------------- RecRawStatBlock *RecAllocateRawStatBlock(int num_stats); -int _RecRegisterRawStat(RecRawStatBlock * rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id, RecRawStatSyncCb sync_cb); +int _RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id, + RecRawStatSyncCb sync_cb); #define RecRegisterRawStat(rsb, rec_type, name, data_type, persist_type, id, sync_cb) \ _RecRegisterRawStat((rsb), (rec_type), (name), (data_type), REC_PERSISTENCE_TYPE(persist_type), (id), (sync_cb)) @@ -65,13 +66,12 @@ int _RecRegisterRawStat(RecRawStatBlock * rsb, RecT rec_type, const char *name, //------------------------------------------------------------------------- // Predefined RawStat Callbacks //------------------------------------------------------------------------- -int RecRawStatSyncSum(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id); -int RecRawStatSyncCount(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id); -int RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id); -int RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id); -int RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, - RecData * data, RecRawStatBlock * rsb, int id); -int RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData * data, RecRawStatBlock * rsb, int id); +int RecRawStatSyncSum(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id); +int RecRawStatSyncCount(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id); +int RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id); +int RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id); +int RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id); +int RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, RecRawStatBlock *rsb, int id); //------------------------------------------------------------------------- @@ -81,35 +81,35 @@ int RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData * dat // Note: The following RecIncrRawStatXXX calls are fast and don't // require any ink_atomic_xxx64()'s to be executed. Use these RawStat // functions over other RawStat functions whenever possible. -inline int RecIncrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr = 1); -inline int RecIncrRawStatSum(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr = 1); -inline int RecIncrRawStatCount(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr = 1); -int RecIncrRawStatBlock(RecRawStatBlock * rsb, EThread * ethread, RecRawStat * stat_array); +inline int RecIncrRawStat(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr = 1); +inline int RecIncrRawStatSum(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr = 1); +inline int RecIncrRawStatCount(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr = 1); +int RecIncrRawStatBlock(RecRawStatBlock *rsb, EThread *ethread, RecRawStat *stat_array); -int RecSetRawStatSum(RecRawStatBlock * rsb, int id, int64_t data); -int RecSetRawStatCount(RecRawStatBlock * rsb, int id, int64_t data); -int RecSetRawStatBlock(RecRawStatBlock * rsb, RecRawStat * stat_array); +int RecSetRawStatSum(RecRawStatBlock *rsb, int id, int64_t data); +int RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64_t data); +int RecSetRawStatBlock(RecRawStatBlock *rsb, RecRawStat *stat_array); -int RecGetRawStatSum(RecRawStatBlock * rsb, int id, int64_t * data); -int RecGetRawStatCount(RecRawStatBlock * rsb, int id, int64_t * data); +int RecGetRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data); +int RecGetRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data); //------------------------------------------------------------------------- // Global RawStat Items (e.g. same as above, but no thread-local behavior) //------------------------------------------------------------------------- -int RecIncrGlobalRawStat(RecRawStatBlock * rsb, int id, int64_t incr = 1); -int RecIncrGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64_t incr = 1); -int RecIncrGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64_t incr = 1); +int RecIncrGlobalRawStat(RecRawStatBlock *rsb, int id, int64_t incr = 1); +int RecIncrGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t incr = 1); +int RecIncrGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t incr = 1); -int RecSetGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64_t data); -int RecSetGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64_t data); +int RecSetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t data); +int RecSetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t data); -int RecGetGlobalRawStatSum(RecRawStatBlock * rsb, int id, int64_t * data); -int RecGetGlobalRawStatCount(RecRawStatBlock * rsb, int id, int64_t * data); +int RecGetGlobalRawStatSum(RecRawStatBlock *rsb, int id, int64_t *data); +int RecGetGlobalRawStatCount(RecRawStatBlock *rsb, int id, int64_t *data); -RecRawStat *RecGetGlobalRawStatPtr(RecRawStatBlock * rsb, int id); -int64_t *RecGetGlobalRawStatSumPtr(RecRawStatBlock * rsb, int id); -int64_t *RecGetGlobalRawStatCountPtr(RecRawStatBlock * rsb, int id); +RecRawStat *RecGetGlobalRawStatPtr(RecRawStatBlock *rsb, int id); +int64_t *RecGetGlobalRawStatSumPtr(RecRawStatBlock *rsb, int id); +int64_t *RecGetGlobalRawStatCountPtr(RecRawStatBlock *rsb, int id); //------------------------------------------------------------------------- @@ -118,17 +118,17 @@ int64_t *RecGetGlobalRawStatCountPtr(RecRawStatBlock * rsb, int id); // inlined functions that are used very frequently. // FIXME: move it to Inline.cc inline RecRawStat * -raw_stat_get_tlp(RecRawStatBlock * rsb, int id, EThread * ethread) +raw_stat_get_tlp(RecRawStatBlock *rsb, int id, EThread *ethread) { ink_assert((id >= 0) && (id < rsb->max_stats)); if (ethread == NULL) { ethread = this_ethread(); } - return (((RecRawStat *) ((char *) (ethread) + rsb->ethr_stat_offset)) + id); + return (((RecRawStat *)((char *)(ethread) + rsb->ethr_stat_offset)) + id); } inline int -RecIncrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr) +RecIncrRawStat(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr) { RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread); tlp->sum += incr; @@ -137,7 +137,7 @@ RecIncrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr) } inline int -RecDecrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t decr) +RecDecrRawStat(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t decr) { RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread); tlp->sum -= decr; @@ -146,7 +146,7 @@ RecDecrRawStat(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t decr) } inline int -RecIncrRawStatSum(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr) +RecIncrRawStatSum(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr) { RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread); tlp->sum += incr; @@ -154,7 +154,7 @@ RecIncrRawStatSum(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr } inline int -RecIncrRawStatCount(RecRawStatBlock * rsb, EThread * ethread, int id, int64_t incr) +RecIncrRawStatCount(RecRawStatBlock *rsb, EThread *ethread, int id, int64_t incr) { RecRawStat *tlp = raw_stat_get_tlp(rsb, id, ethread); tlp->count += incr; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/I_RecSignals.h ---------------------------------------------------------------------- diff --git a/lib/records/I_RecSignals.h b/lib/records/I_RecSignals.h index 1461c45..28f2ed8 100644 --- a/lib/records/I_RecSignals.h +++ b/lib/records/I_RecSignals.h @@ -25,24 +25,24 @@ #define _I_REC_SIGNALS_H_ // copy from mgmt/BaseManager.h -#define REC_SIGNAL_PID 0 -#define REC_SIGNAL_MACHINE_UP 1 -#define REC_SIGNAL_MACHINE_DOWN 2 -#define REC_SIGNAL_CONFIG_ERROR 3 -#define REC_SIGNAL_SYSTEM_ERROR 4 -#define REC_SIGNAL_LOG_SPACE_CRISIS 5 -#define REC_SIGNAL_CONFIG_FILE_READ 6 -#define REC_SIGNAL_CACHE_ERROR 7 -#define REC_SIGNAL_CACHE_WARNING 8 -#define REC_SIGNAL_LOGGING_ERROR 9 -#define REC_SIGNAL_LOGGING_WARNING 10 +#define REC_SIGNAL_PID 0 +#define REC_SIGNAL_MACHINE_UP 1 +#define REC_SIGNAL_MACHINE_DOWN 2 +#define REC_SIGNAL_CONFIG_ERROR 3 +#define REC_SIGNAL_SYSTEM_ERROR 4 +#define REC_SIGNAL_LOG_SPACE_CRISIS 5 +#define REC_SIGNAL_CONFIG_FILE_READ 6 +#define REC_SIGNAL_CACHE_ERROR 7 +#define REC_SIGNAL_CACHE_WARNING 8 +#define REC_SIGNAL_LOGGING_ERROR 9 +#define REC_SIGNAL_LOGGING_WARNING 10 // Currently unused: 11 -#define REC_SIGNAL_PLUGIN_CONFIG_REG 12 -#define REC_SIGNAL_PLUGIN_ADD_REC 13 -#define REC_SIGNAL_PLUGIN_SET_CONFIG 14 -#define REC_SIGNAL_LOG_FILES_ROLLED 15 -#define REC_SIGNAL_LIBRECORDS 16 -#define REC_SIGNAL_HTTP_CONGESTED_SERVER 20 -#define REC_SIGNAL_HTTP_ALLEVIATED_SERVER 21 +#define REC_SIGNAL_PLUGIN_CONFIG_REG 12 +#define REC_SIGNAL_PLUGIN_ADD_REC 13 +#define REC_SIGNAL_PLUGIN_SET_CONFIG 14 +#define REC_SIGNAL_LOG_FILES_ROLLED 15 +#define REC_SIGNAL_LIBRECORDS 16 +#define REC_SIGNAL_HTTP_CONGESTED_SERVER 20 +#define REC_SIGNAL_HTTP_ALLEVIATED_SERVER 21 #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/P_RecCore.cc ---------------------------------------------------------------------- diff --git a/lib/records/P_RecCore.cc b/lib/records/P_RecCore.cc index abe222d..7a896f9 100644 --- a/lib/records/P_RecCore.cc +++ b/lib/records/P_RecCore.cc @@ -40,7 +40,7 @@ RecModeT g_mode_type = RECM_NULL; // send_reset_message //------------------------------------------------------------------------- static int -send_reset_message(RecRecord * record) +send_reset_message(RecRecord *record) { RecMessage *m; @@ -60,7 +60,7 @@ send_reset_message(RecRecord * record) // send_set_message //------------------------------------------------------------------------- static int -send_set_message(RecRecord * record) +send_set_message(RecRecord *record) { RecMessage *m; @@ -80,7 +80,7 @@ send_set_message(RecRecord * record) // send_register_message //------------------------------------------------------------------------- int -send_register_message(RecRecord * record) +send_register_message(RecRecord *record) { RecMessage *m; @@ -143,7 +143,6 @@ send_pull_message(RecMessageT msg_type) m = RecMessageAlloc(msg_type); switch (msg_type) { - case RECG_PULL_REQ: // We're requesting all of the records from our peer. No payload // here, just send the message. @@ -157,8 +156,7 @@ send_pull_message(RecMessageT msg_type) num_records = g_num_records; for (i = 0; i < num_records; i++) { r = &(g_records[i]); - if (i_am_the_record_owner(r->rec_type) || - (REC_TYPE_IS_STAT(r->rec_type) && !(r->registered)) || + if (i_am_the_record_owner(r->rec_type) || (REC_TYPE_IS_STAT(r->rec_type) && !(r->registered)) || (REC_TYPE_IS_STAT(r->rec_type) && (r->stat_meta.persist_type == RECP_NON_PERSISTENT))) { rec_mutex_acquire(&(r->lock)); m = RecMessageMarshal_Realloc(m, r); @@ -172,7 +170,6 @@ send_pull_message(RecMessageT msg_type) default: RecMessageFree(m); return REC_ERR_FAIL; - } RecMessageSend(m); @@ -186,13 +183,12 @@ send_pull_message(RecMessageT msg_type) // recv_message_cb //------------------------------------------------------------------------- int -recv_message_cb(RecMessage * msg, RecMessageT msg_type, void */* cookie */) +recv_message_cb(RecMessage *msg, RecMessageT msg_type, void * /* cookie */) { RecRecord *r; RecMessageItr itr; switch (msg_type) { - case RECG_SET: RecDebug(DL_Note, "[recv] RECG_SET [%d bytes]", sizeof(RecMessageHdr) + msg->o_end - msg->o_start); @@ -228,8 +224,7 @@ recv_message_cb(RecMessage * msg, RecMessageT msg_type, void */* cookie */) if (REC_TYPE_IS_STAT(r->rec_type)) { RecRegisterStat(r->rec_type, r->name, r->data_type, r->data_default, r->stat_meta.persist_type); } else if (REC_TYPE_IS_CONFIG(r->rec_type)) { - RecRegisterConfig(r->rec_type, r->name, r->data_type, - r->data_default, r->config_meta.update_type, + RecRegisterConfig(r->rec_type, r->name, r->data_type, r->data_default, r->config_meta.update_type, r->config_meta.check_type, r->config_meta.check_expr, r->config_meta.access_type); } } while (RecMessageUnmarshalNext(msg, &itr, &r) != REC_ERR_FAIL); @@ -262,7 +257,6 @@ recv_message_cb(RecMessage * msg, RecMessageT msg_type, void */* cookie */) default: ink_assert(!"Unexpected RecG type"); return REC_ERR_FAIL; - } return REC_ERR_OKAY; @@ -272,25 +266,21 @@ recv_message_cb(RecMessage * msg, RecMessageT msg_type, void */* cookie */) //------------------------------------------------------------------------- // RecRegisterStatXXX //------------------------------------------------------------------------- -#define REC_REGISTER_STAT_XXX(A, B) \ - ink_assert((rec_type == RECT_NODE) || \ - (rec_type == RECT_CLUSTER) || \ - (rec_type == RECT_PROCESS) || \ - (rec_type == RECT_LOCAL) || \ - (rec_type == RECT_PLUGIN)); \ - RecRecord *r; \ - RecData my_data_default; \ - my_data_default.A = data_default; \ - if ((r = RecRegisterStat(rec_type, name, B, my_data_default, \ - persist_type)) != NULL) { \ - if (i_am_the_record_owner(r->rec_type)) { \ - r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED; \ - } else { \ - send_register_message(r); \ - } \ - return REC_ERR_OKAY; \ - } else { \ - return REC_ERR_FAIL; \ +#define REC_REGISTER_STAT_XXX(A, B) \ + ink_assert((rec_type == RECT_NODE) || (rec_type == RECT_CLUSTER) || (rec_type == RECT_PROCESS) || (rec_type == RECT_LOCAL) || \ + (rec_type == RECT_PLUGIN)); \ + RecRecord *r; \ + RecData my_data_default; \ + my_data_default.A = data_default; \ + if ((r = RecRegisterStat(rec_type, name, B, my_data_default, persist_type)) != NULL) { \ + if (i_am_the_record_owner(r->rec_type)) { \ + r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED; \ + } else { \ + send_register_message(r); \ + } \ + return REC_ERR_OKAY; \ + } else { \ + return REC_ERR_FAIL; \ } int @@ -321,36 +311,32 @@ _RecRegisterStatCounter(RecT rec_type, const char *name, RecCounter data_default //------------------------------------------------------------------------- // RecRegisterConfigXXX //------------------------------------------------------------------------- -#define REC_REGISTER_CONFIG_XXX(A, B) \ - RecRecord *r; \ - RecData my_data_default; \ - my_data_default.A = data_default; \ - if ((r = RecRegisterConfig(rec_type, name, B, my_data_default, \ - update_type, check_type, \ - check_regex, access_type)) != NULL) { \ - if (i_am_the_record_owner(r->rec_type)) { \ - r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED; \ - } else { \ - send_register_message(r); \ - } \ - return REC_ERR_OKAY; \ - } else { \ - return REC_ERR_FAIL; \ +#define REC_REGISTER_CONFIG_XXX(A, B) \ + RecRecord *r; \ + RecData my_data_default; \ + my_data_default.A = data_default; \ + if ((r = RecRegisterConfig(rec_type, name, B, my_data_default, update_type, check_type, check_regex, access_type)) != NULL) { \ + if (i_am_the_record_owner(r->rec_type)) { \ + r->sync_required = r->sync_required | REC_PEER_SYNC_REQUIRED; \ + } else { \ + send_register_message(r); \ + } \ + return REC_ERR_OKAY; \ + } else { \ + return REC_ERR_FAIL; \ } int -RecRegisterConfigInt(RecT rec_type, const char *name, - RecInt data_default, RecUpdateT update_type, - RecCheckT check_type, const char *check_regex, RecAccessT access_type) +RecRegisterConfigInt(RecT rec_type, const char *name, RecInt data_default, RecUpdateT update_type, RecCheckT check_type, + const char *check_regex, RecAccessT access_type) { ink_assert((rec_type == RECT_CONFIG) || (rec_type == RECT_LOCAL)); REC_REGISTER_CONFIG_XXX(rec_int, RECD_INT); } int -RecRegisterConfigFloat(RecT rec_type, const char *name, - RecFloat data_default, RecUpdateT update_type, - RecCheckT check_type, const char *check_regex, RecAccessT access_type) +RecRegisterConfigFloat(RecT rec_type, const char *name, RecFloat data_default, RecUpdateT update_type, RecCheckT check_type, + const char *check_regex, RecAccessT access_type) { ink_assert((rec_type == RECT_CONFIG) || (rec_type == RECT_LOCAL)); REC_REGISTER_CONFIG_XXX(rec_float, RECD_FLOAT); @@ -358,9 +344,8 @@ RecRegisterConfigFloat(RecT rec_type, const char *name, int -RecRegisterConfigString(RecT rec_type, const char *name, - const char *data_default_tmp, RecUpdateT update_type, - RecCheckT check_type, const char *check_regex, RecAccessT access_type) +RecRegisterConfigString(RecT rec_type, const char *name, const char *data_default_tmp, RecUpdateT update_type, RecCheckT check_type, + const char *check_regex, RecAccessT access_type) { RecString data_default = (RecString)data_default_tmp; ink_assert((rec_type == RECT_CONFIG) || (rec_type == RECT_LOCAL)); @@ -368,9 +353,8 @@ RecRegisterConfigString(RecT rec_type, const char *name, } int -RecRegisterConfigCounter(RecT rec_type, const char *name, - RecCounter data_default, RecUpdateT update_type, - RecCheckT check_type, const char *check_regex, RecAccessT access_type) +RecRegisterConfigCounter(RecT rec_type, const char *name, RecCounter data_default, RecUpdateT update_type, RecCheckT check_type, + const char *check_regex, RecAccessT access_type) { ink_assert((rec_type == RECT_CONFIG) || (rec_type == RECT_LOCAL)); REC_REGISTER_CONFIG_XXX(rec_counter, RECD_COUNTER); @@ -392,7 +376,7 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, ink_rwlock_wrlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r1)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r1)) { if (i_am_the_record_owner(r1->rec_type)) { rec_mutex_acquire(&(r1->lock)); if ((data_type != RECD_NULL) && (r1->data_type != data_type)) { @@ -473,8 +457,7 @@ RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, } else { err = send_set_message(r1); } - ink_hash_table_insert(g_records_ht, name, (void *) r1); - + ink_hash_table_insert(g_records_ht, name, (void *)r1); } Ldone: @@ -628,14 +611,14 @@ RecSyncStatsFile() // Consume a parsed record, pushing it into the records hash table. static void -RecConsumeConfigEntry(RecT rec_type, RecDataT data_type, const char * name, const char * value, bool inc_version) +RecConsumeConfigEntry(RecT rec_type, RecDataT data_type, const char *name, const char *value, bool inc_version) { - RecData data; + RecData data; - memset(&data, 0, sizeof(RecData)); - RecDataSetFromString(data_type, &data, value); - RecSetRecord(rec_type, name, data_type, &data, NULL, false, inc_version); - RecDataClear(data_type, &data); + memset(&data, 0, sizeof(RecData)); + RecDataSetFromString(data_type, &data, value); + RecSetRecord(rec_type, name, data_type, &data, NULL, false, inc_version); + RecDataClear(data_type, &data); } //------------------------------------------------------------------------- @@ -663,7 +646,7 @@ RecReadConfigFile(bool inc_version) // RecSyncConfigFile //------------------------------------------------------------------------- int -RecSyncConfigToTB(textBuffer * tb, bool *inc_version) +RecSyncConfigToTB(textBuffer *tb, bool *inc_version) { int err = REC_ERR_FAIL; @@ -695,7 +678,7 @@ RecSyncConfigToTB(textBuffer * tb, bool *inc_version) cfe = (RecConfigFileEntry *)ats_malloc(sizeof(RecConfigFileEntry)); cfe->entry_type = RECE_RECORD; cfe->entry = ats_strdup(r->name); - enqueue(g_rec_config_contents_llq, (void *) cfe); + enqueue(g_rec_config_contents_llq, (void *)cfe); ink_hash_table_insert(g_rec_config_contents_ht, r->name, NULL); } r->sync_required = r->sync_required & ~REC_DISK_SYNC_REQUIRED; @@ -722,12 +705,12 @@ RecSyncConfigToTB(textBuffer * tb, bool *inc_version) LLQrec *llq_rec = g_rec_config_contents_llq->head; while (llq_rec != NULL) { - cfe = (RecConfigFileEntry *) llq_rec->data; + cfe = (RecConfigFileEntry *)llq_rec->data; if (cfe->entry_type == RECE_COMMENT) { tb->copyFrom(cfe->entry, strlen(cfe->entry)); tb->copyFrom("\n", 1); } else { - if (ink_hash_table_lookup(g_records_ht, cfe->entry, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, cfe->entry, (void **)&r)) { rec_mutex_acquire(&(r->lock)); // rec_type switch (r->rec_type) { @@ -831,7 +814,7 @@ RecExecConfigUpdateCbs(unsigned int update_required_type) if ((r->config_meta.update_required & update_required_type) && (r->config_meta.update_cb_list)) { RecConfigUpdateCbList *cur_callback = NULL; for (cur_callback = r->config_meta.update_cb_list; cur_callback; cur_callback = cur_callback->next) { - (*(cur_callback->update_cb)) (r->name, r->data_type, r->data, cur_callback->update_cookie); + (*(cur_callback->update_cb))(r->name, r->data_type, r->data, cur_callback->update_cookie); } r->config_meta.update_required = r->config_meta.update_required & ~update_required_type; } @@ -852,7 +835,7 @@ RecResetStatRecord(const char *name) RecRecord *r1 = NULL; int err = REC_ERR_OKAY; - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r1)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r1)) { if (i_am_the_record_owner(r1->rec_type)) { rec_mutex_acquire(&(r1->lock)); ++(r1->version); @@ -895,8 +878,7 @@ RecResetStatRecord(RecT type, bool all) RecRecord *r1 = &(g_records[i]); if (REC_TYPE_IS_STAT(r1->rec_type) && ((type == RECT_NULL) || (r1->rec_type == type)) && - (all || (r1->stat_meta.persist_type != RECP_NON_PERSISTENT)) && - (r1->data_type != RECD_STRING)) { + (all || (r1->stat_meta.persist_type != RECP_NON_PERSISTENT)) && (r1->data_type != RECD_STRING)) { if (i_am_the_record_owner(r1->rec_type)) { rec_mutex_acquire(&(r1->lock)); ++(r1->version); @@ -934,7 +916,7 @@ RecSetSyncRequired(char *name, bool lock) ink_rwlock_wrlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r1)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r1)) { if (i_am_the_record_owner(r1->rec_type)) { rec_mutex_acquire(&(r1->lock)); r1->sync_required = REC_SYNC_REQUIRED; @@ -971,7 +953,8 @@ RecSetSyncRequired(char *name, bool lock) return err; } -int RecWriteConfigFile(textBuffer *tb) +int +RecWriteConfigFile(textBuffer *tb) { #define TMP_FILENAME_EXT_STR ".tmp" #define TMP_FILENAME_EXT_LEN (sizeof(TMP_FILENAME_EXT_STR) - 1) @@ -997,15 +980,13 @@ int RecWriteConfigFile(textBuffer *tb) RecHandle h_file = RecFileOpenW(tmp_filename); do { if (h_file == REC_HANDLE_INVALID) { - RecLog(DL_Warning, "open file: %s to write fail, errno: %d, error info: %s", - tmp_filename, errno, strerror(errno)); + RecLog(DL_Warning, "open file: %s to write fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno)); result = REC_ERR_FAIL; break; } if (RecFileWrite(h_file, tb->bufPtr(), tb->spaceUsed(), &nbytes) != REC_ERR_OKAY) { - RecLog(DL_Warning, "write to file: %s fail, errno: %d, error info: %s", - tmp_filename, errno, strerror(errno)); + RecLog(DL_Warning, "write to file: %s fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno)); result = REC_ERR_FAIL; break; } @@ -1017,22 +998,20 @@ int RecWriteConfigFile(textBuffer *tb) } if (RecFileSync(h_file) != REC_ERR_OKAY) { - RecLog(DL_Warning, "fsync file: %s fail, errno: %d, error info: %s", - tmp_filename, errno, strerror(errno)); + RecLog(DL_Warning, "fsync file: %s fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno)); result = REC_ERR_FAIL; break; } if (RecFileClose(h_file) != REC_ERR_OKAY) { - RecLog(DL_Warning, "close file: %s fail, errno: %d, error info: %s", - tmp_filename, errno, strerror(errno)); + RecLog(DL_Warning, "close file: %s fail, errno: %d, error info: %s", tmp_filename, errno, strerror(errno)); result = REC_ERR_FAIL; break; } h_file = REC_HANDLE_INVALID; if (rename(tmp_filename, g_rec_config_fpath) != 0) { - RecLog(DL_Warning, "rename file %s to %s fail, errno: %d, error info: %s", - tmp_filename, g_rec_config_fpath, errno, strerror(errno)); + RecLog(DL_Warning, "rename file %s to %s fail, errno: %d, error info: %s", tmp_filename, g_rec_config_fpath, errno, + strerror(errno)); result = REC_ERR_FAIL; break; } @@ -1048,4 +1027,3 @@ int RecWriteConfigFile(textBuffer *tb) } return result; } - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/P_RecCore.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecCore.h b/lib/records/P_RecCore.h index 92d0c2e..6f9b6e2 100644 --- a/lib/records/P_RecCore.h +++ b/lib/records/P_RecCore.h @@ -51,29 +51,27 @@ extern ink_mutex g_rec_config_lock; // Initialization //------------------------------------------------------------------------- -int RecCoreInit(RecModeT mode_type, Diags * diags); +int RecCoreInit(RecModeT mode_type, Diags *diags); //------------------------------------------------------------------------- // Registration/Insertion //------------------------------------------------------------------------- -RecRecord *RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, - RecData data_default, RecPersistT persist_type); +RecRecord *RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, RecPersistT persist_type); -RecRecord *RecRegisterConfig(RecT rec_type, const char *name, RecDataT data_type, - RecData data_default, RecUpdateT update_type, +RecRecord *RecRegisterConfig(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, RecUpdateT update_type, RecCheckT check_type, const char *check_regex, RecAccessT access_type = RECA_NULL); -RecRecord *RecForceInsert(RecRecord * record); +RecRecord *RecForceInsert(RecRecord *record); //------------------------------------------------------------------------- // Setting/Getting //------------------------------------------------------------------------- -int RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, - RecData *data, RecRawStat *raw_stat, bool lock = true, bool inc_version = true); +int RecSetRecord(RecT rec_type, const char *name, RecDataT data_type, RecData *data, RecRawStat *raw_stat, bool lock = true, + bool inc_version = true); -int RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData * data, bool lock = true); +int RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data, bool lock = true); //------------------------------------------------------------------------- // Read/Sync to Disk @@ -83,7 +81,7 @@ int RecReadStatsFile(); int RecSyncStatsFile(); int RecReadConfigFile(bool inc_version); int RecWriteConfigFile(textBuffer *tb); -int RecSyncConfigToTB(textBuffer * tb, bool *inc_version = NULL); +int RecSyncConfigToTB(textBuffer *tb, bool *inc_version = NULL); //------------------------------------------------------------------------- // Misc @@ -92,15 +90,14 @@ int RecSyncConfigToTB(textBuffer * tb, bool *inc_version = NULL); bool i_am_the_record_owner(RecT rec_type); int send_push_message(); int send_pull_message(RecMessageT msg_type); -int send_register_message(RecRecord * record); -int recv_message_cb(RecMessage * msg, RecMessageT msg_type, void *cookie); +int send_register_message(RecRecord *record); +int recv_message_cb(RecMessage *msg, RecMessageT msg_type, void *cookie); RecUpdateT RecExecConfigUpdateCbs(unsigned int update_required_type); int RecExecStatUpdateFuncs(); int RecExecRawStatUpdateFuncs(); void RecDumpRecordsHt(RecT rec_type = RECT_NULL); -void -RecDumpRecords(RecT rec_type, RecDumpEntryCb callback, void *edata); +void RecDumpRecords(RecT rec_type, RecDumpEntryCb callback, void *edata); #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/P_RecDefs.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecDefs.h b/lib/records/P_RecDefs.h index 17cfbb2..4e63d88 100644 --- a/lib/records/P_RecDefs.h +++ b/lib/records/P_RecDefs.h @@ -26,59 +26,55 @@ #include "I_RecDefs.h" -#define REC_CONFIG_FILE "records.config" -#define REC_SHADOW_EXT ".shadow" -#define REC_RAW_STATS_FILE "records.snap" -#define REC_PIPE_NAME "librecords_pipe" +#define REC_CONFIG_FILE "records.config" +#define REC_SHADOW_EXT ".shadow" +#define REC_RAW_STATS_FILE "records.snap" +#define REC_PIPE_NAME "librecords_pipe" -#define REC_MESSAGE_ELE_MAGIC 0xF00DF00D +#define REC_MESSAGE_ELE_MAGIC 0xF00DF00D // This is for the internal stats and configs, as well as API stats. We currently use // about 1600 stats + configs for the core, but we're allocating 2000 for some growth. // TODO: if/when we switch to a new config system, we should make this run-time dynamic. -#define REC_MAX_RECORDS (2000 + TS_MAX_API_STATS) +#define REC_MAX_RECORDS (2000 + TS_MAX_API_STATS) -#define REC_CONFIG_UPDATE_INTERVAL_MS 3000 -#define REC_REMOTE_SYNC_INTERVAL_MS 5000 +#define REC_CONFIG_UPDATE_INTERVAL_MS 3000 +#define REC_REMOTE_SYNC_INTERVAL_MS 5000 -#define REC_RAW_STAT_SYNC_INTERVAL_MS 5000 -#define REC_STAT_UPDATE_INTERVAL_MS 10000 +#define REC_RAW_STAT_SYNC_INTERVAL_MS 5000 +#define REC_STAT_UPDATE_INTERVAL_MS 10000 //------------------------------------------------------------------------- // Record Items //------------------------------------------------------------------------- -#define REC_LOCAL_UPDATE_REQUIRED 1 -#define REC_PROCESS_UPDATE_REQUIRED (REC_LOCAL_UPDATE_REQUIRED << 1) -#define REC_UPDATE_REQUIRED (REC_LOCAL_UPDATE_REQUIRED | REC_PROCESS_UPDATE_REQUIRED) +#define REC_LOCAL_UPDATE_REQUIRED 1 +#define REC_PROCESS_UPDATE_REQUIRED (REC_LOCAL_UPDATE_REQUIRED << 1) +#define REC_UPDATE_REQUIRED (REC_LOCAL_UPDATE_REQUIRED | REC_PROCESS_UPDATE_REQUIRED) -#define REC_DISK_SYNC_REQUIRED 1 -#define REC_PEER_SYNC_REQUIRED (REC_DISK_SYNC_REQUIRED << 1) -#define REC_INC_CONFIG_VERSION (REC_PEER_SYNC_REQUIRED << 1) -#define REC_SYNC_REQUIRED (REC_DISK_SYNC_REQUIRED | REC_PEER_SYNC_REQUIRED) +#define REC_DISK_SYNC_REQUIRED 1 +#define REC_PEER_SYNC_REQUIRED (REC_DISK_SYNC_REQUIRED << 1) +#define REC_INC_CONFIG_VERSION (REC_PEER_SYNC_REQUIRED << 1) +#define REC_SYNC_REQUIRED (REC_DISK_SYNC_REQUIRED | REC_PEER_SYNC_REQUIRED) -enum RecEntryT -{ +enum RecEntryT { RECE_NULL, RECE_COMMENT, - RECE_RECORD + RECE_RECORD, }; -struct RecConfigFileEntry -{ +struct RecConfigFileEntry { RecEntryT entry_type; char *entry; }; -typedef struct RecConfigCbList_t -{ +typedef struct RecConfigCbList_t { RecConfigUpdateCb update_cb; void *update_cookie; struct RecConfigCbList_t *next; } RecConfigUpdateCbList; -typedef struct RecStatUpdateFuncList_t -{ +typedef struct RecStatUpdateFuncList_t { RecRawStatBlock *rsb; int id; RecStatUpdateFunc update_func; @@ -86,8 +82,7 @@ typedef struct RecStatUpdateFuncList_t struct RecStatUpdateFuncList_t *next; } RecStatUpdateFuncList; -struct RecStatMeta -{ +struct RecStatMeta { RecRawStat data_raw; RecRawStatSyncCb sync_cb; RecRawStatBlock *sync_rsb; @@ -95,8 +90,7 @@ struct RecStatMeta RecPersistT persist_type; }; -struct RecConfigMeta -{ +struct RecConfigMeta { unsigned char update_required; RecConfigUpdateCbList *update_cb_list; void *update_cookie; @@ -106,8 +100,7 @@ struct RecConfigMeta RecAccessT access_type; }; -struct RecRecord -{ +struct RecRecord { RecT rec_type; const char *name; RecDataT data_type; @@ -117,8 +110,7 @@ struct RecRecord unsigned char sync_required; uint32_t version; bool registered; - union - { + union { RecStatMeta stat_meta; RecConfigMeta config_meta; }; @@ -127,8 +119,7 @@ struct RecRecord }; // Used for cluster. TODO: Do we still need this? -struct RecRecords -{ +struct RecRecords { int num_recs; RecRecord *recs; }; @@ -137,43 +128,39 @@ struct RecRecords // Message Items //------------------------------------------------------------------------- -enum RecMessageT -{ +enum RecMessageT { RECG_NULL, RECG_SET, RECG_REGISTER, RECG_PUSH, RECG_PULL_REQ, RECG_PULL_ACK, - RECG_RESET + RECG_RESET, }; -struct RecMessageHdr -{ +struct RecMessageHdr { RecMessageT msg_type; int o_start; int o_write; int o_end; int entries; - int alignment; //needs to be 8 byte aligned + int alignment; // needs to be 8 byte aligned }; -struct RecMessageEleHdr -{ +struct RecMessageEleHdr { unsigned int magic; int o_next; }; -struct RecMessageItr -{ +struct RecMessageItr { RecMessageEleHdr *ele_hdr; int next; }; typedef RecMessageHdr RecMessage; -typedef void (*RecDumpEntryCb) (RecT rec_type, void *edata, int registered, const char *name, int data_type, RecData *datum); +typedef void (*RecDumpEntryCb)(RecT rec_type, void *edata, int registered, const char *name, int data_type, RecData *datum); -typedef int (*RecMessageRecvCb) (RecMessage * msg, RecMessageT msg_type, void *cookie); +typedef int (*RecMessageRecvCb)(RecMessage *msg, RecMessageT msg_type, void *cookie); #endif http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/P_RecMessage.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecMessage.h b/lib/records/P_RecMessage.h index 468ff03..2538c02 100644 --- a/lib/records/P_RecMessage.h +++ b/lib/records/P_RecMessage.h @@ -30,7 +30,7 @@ // Initialization //------------------------------------------------------------------------- -//int RecMessageInit(); +// int RecMessageInit(); void RecMessageRegister(); //------------------------------------------------------------------------- @@ -38,13 +38,13 @@ void RecMessageRegister(); //------------------------------------------------------------------------- RecMessage *RecMessageAlloc(RecMessageT msg_type, int initial_size = 256); -int RecMessageFree(RecMessage * msg); +int RecMessageFree(RecMessage *msg); -RecMessage *RecMessageMarshal_Realloc(RecMessage * msg, const RecRecord * record); -int RecMessageUnmarshalFirst(RecMessage * msg, RecMessageItr * itr, RecRecord ** record); -int RecMessageUnmarshalNext(RecMessage * msg, RecMessageItr * itr, RecRecord ** record); +RecMessage *RecMessageMarshal_Realloc(RecMessage *msg, const RecRecord *record); +int RecMessageUnmarshalFirst(RecMessage *msg, RecMessageItr *itr, RecRecord **record); +int RecMessageUnmarshalNext(RecMessage *msg, RecMessageItr *itr, RecRecord **record); -int RecMessageSend(RecMessage * msg); +int RecMessageSend(RecMessage *msg); int RecMessageRegisterRecvCb(RecMessageRecvCb recv_cb, void *cookie); void *RecMessageRecvThis(void *cookie, char *data_raw, int data_len); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/P_RecProcess.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecProcess.h b/lib/records/P_RecProcess.h index 4ebf774..b271188 100644 --- a/lib/records/P_RecProcess.h +++ b/lib/records/P_RecProcess.h @@ -37,7 +37,7 @@ // Protected Interface //------------------------------------------------------------------------- -int RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock * rsb, int id); +int RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatBlock *rsb, int id); int RecExecRawStatSyncCbs(); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/P_RecUtils.h ---------------------------------------------------------------------- diff --git a/lib/records/P_RecUtils.h b/lib/records/P_RecUtils.h index de8f018..c7e7eaa 100644 --- a/lib/records/P_RecUtils.h +++ b/lib/records/P_RecUtils.h @@ -34,14 +34,9 @@ //------------------------------------------------------------------------- #define REC_TYPE_IS_STAT(rec_type) \ - (((rec_type) == RECT_PROCESS) || \ - ((rec_type) == RECT_PLUGIN) || \ - ((rec_type) == RECT_NODE) || \ - ((rec_type) == RECT_CLUSTER)) + (((rec_type) == RECT_PROCESS) || ((rec_type) == RECT_PLUGIN) || ((rec_type) == RECT_NODE) || ((rec_type) == RECT_CLUSTER)) -#define REC_TYPE_IS_CONFIG(rec_type) \ - (((rec_type) == RECT_CONFIG) || \ - ((rec_type) == RECT_LOCAL)) +#define REC_TYPE_IS_CONFIG(rec_type) (((rec_type) == RECT_CONFIG) || ((rec_type) == RECT_LOCAL)) //------------------------------------------------------------------------- @@ -56,13 +51,13 @@ RecRecord *RecAlloc(RecT rec_type, const char *name, RecDataT data_type); // RecData Utils //------------------------------------------------------------------------- -void RecDataClear(RecDataT type, RecData * data); -void RecDataSetMax(RecDataT type, RecData * data); -void RecDataSetMin(RecDataT type, RecData * data); -bool RecDataSet(RecDataT data_type, RecData * data_dst, RecData * data_src); -bool RecDataSetFromInk64(RecDataT data_type, RecData * data_dst, int64_t data_int64); -bool RecDataSetFromFloat(RecDataT data_type, RecData * data_dst, float data_float); -bool RecDataSetFromString(RecDataT data_type, RecData * data_dst, const char *data_string); +void RecDataClear(RecDataT type, RecData *data); +void RecDataSetMax(RecDataT type, RecData *data); +void RecDataSetMin(RecDataT type, RecData *data); +bool RecDataSet(RecDataT data_type, RecData *data_dst, RecData *data_src); +bool RecDataSetFromInk64(RecDataT data_type, RecData *data_dst, int64_t data_int64); +bool RecDataSetFromFloat(RecDataT data_type, RecData *data_dst, float data_float); +bool RecDataSetFromString(RecDataT data_type, RecData *data_dst, const char *data_string); int RecDataCmp(RecDataT type, RecData left, RecData right); RecData RecDataAdd(RecDataT type, RecData left, RecData right); RecData RecDataSub(RecDataT type, RecData left, RecData right); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecConfigParse.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecConfigParse.cc b/lib/records/RecConfigParse.cc index 43b033d..ce418e4 100644 --- a/lib/records/RecConfigParse.cc +++ b/lib/records/RecConfigParse.cc @@ -34,10 +34,10 @@ #include "P_RecCore.h" #include "I_Layout.h" -const char *g_rec_config_fpath = NULL; -LLQ *g_rec_config_contents_llq = NULL; -InkHashTable *g_rec_config_contents_ht = NULL; -ink_mutex g_rec_config_lock; +const char *g_rec_config_fpath = NULL; +LLQ *g_rec_config_contents_llq = NULL; +InkHashTable *g_rec_config_contents_ht = NULL; +ink_mutex g_rec_config_lock; //------------------------------------------------------------------------- // RecConfigFileInit @@ -45,9 +45,9 @@ ink_mutex g_rec_config_lock; void RecConfigFileInit(void) { - ink_mutex_init(&g_rec_config_lock, NULL); - g_rec_config_contents_llq = create_queue(); - g_rec_config_contents_ht = ink_hash_table_create(InkHashTableKeyType_String); + ink_mutex_init(&g_rec_config_lock, NULL); + g_rec_config_contents_llq = create_queue(); + g_rec_config_contents_ht = ink_hash_table_create(InkHashTableKeyType_String); } //------------------------------------------------------------------------- @@ -85,16 +85,20 @@ RecFileImport_Xmalloc(const char *file, char **file_buf, int *file_size) // RecConfigOverrideFromEnvironment //------------------------------------------------------------------------- const char * -RecConfigOverrideFromEnvironment(const char * name, const char * value) +RecConfigOverrideFromEnvironment(const char *name, const char *value) { ats_scoped_str envname(ats_strdup(name)); - const char * envval = NULL; + const char *envval = NULL; // Munge foo.bar.config into FOO_BAR_CONFIG. - for (char * c = envname; *c != '\0'; ++c) { + for (char *c = envname; *c != '\0'; ++c) { switch (*c) { - case '.': *c = '_'; break; - default: *c = ParseRules::ink_toupper(*c); break; + case '.': + *c = '_'; + break; + default: + *c = ParseRules::ink_toupper(*c); + break; } } @@ -110,7 +114,7 @@ RecConfigOverrideFromEnvironment(const char * name, const char * value) // RecParseConfigFile //------------------------------------------------------------------------- int -RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_version) +RecConfigFileParse(const char *path, RecConfigEntryCallback handler, bool inc_version) { char *fbuf; int fsize; @@ -139,7 +143,7 @@ RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_v } // clear our g_rec_config_contents_xxx structures while (!queue_is_empty(g_rec_config_contents_llq)) { - cfe = (RecConfigFileEntry *) dequeue(g_rec_config_contents_llq); + cfe = (RecConfigFileEntry *)dequeue(g_rec_config_contents_llq); ats_free(cfe->entry); ats_free(cfe); } @@ -235,7 +239,7 @@ RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_v cfe = (RecConfigFileEntry *)ats_malloc(sizeof(RecConfigFileEntry)); cfe->entry_type = RECE_RECORD; cfe->entry = ats_strdup(name_str); - enqueue(g_rec_config_contents_llq, (void *) cfe); + enqueue(g_rec_config_contents_llq, (void *)cfe); ink_hash_table_insert(g_rec_config_contents_ht, name_str, NULL); goto L_done; @@ -245,7 +249,7 @@ RecConfigFileParse(const char * path, RecConfigEntryCallback handler, bool inc_v cfe = (RecConfigFileEntry *)ats_malloc(sizeof(RecConfigFileEntry)); cfe->entry_type = RECE_COMMENT; cfe->entry = ats_strdup(line); - enqueue(g_rec_config_contents_llq, (void *) cfe); + enqueue(g_rec_config_contents_llq, (void *)cfe); L_done: line = line_tok.iterNext(&line_tok_state); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecCore.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecCore.cc b/lib/records/RecCore.cc index f24cd84..b326e14 100644 --- a/lib/records/RecCore.cc +++ b/lib/records/RecCore.cc @@ -43,7 +43,7 @@ register_record(RecT rec_type, const char *name, RecDataT data_type, RecData dat { RecRecord *r = NULL; - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { ink_release_assert(r->rec_type == rec_type); ink_release_assert(r->data_type == data_type); // Note: do not set r->data as we want to keep the previous value @@ -55,7 +55,7 @@ register_record(RecT rec_type, const char *name, RecDataT data_type, RecData dat // Set the r->data to its default value as this is a new record RecDataSet(r->data_type, &(r->data), &(data_default)); RecDataSet(r->data_type, &(r->data_default), &(data_default)); - ink_hash_table_insert(g_records_ht, name, (void *) r); + ink_hash_table_insert(g_records_ht, name, (void *)r); if (REC_TYPE_IS_STAT(r->rec_type)) { r->stat_meta.persist_type = persist_type; @@ -76,7 +76,7 @@ register_record(RecT rec_type, const char *name, RecDataT data_type, RecData dat static int link_int(const char * /* name */, RecDataT /* data_type */, RecData data, void *cookie) { - RecInt *rec_int = (RecInt *) cookie; + RecInt *rec_int = (RecInt *)cookie; ink_atomic_swap(rec_int, data.rec_int); return REC_ERR_OKAY; } @@ -84,28 +84,28 @@ link_int(const char * /* name */, RecDataT /* data_type */, RecData data, void * static int link_int32(const char * /* name */, RecDataT /* data_type */, RecData data, void *cookie) { - *((int32_t *) cookie) = (int32_t) data.rec_int; + *((int32_t *)cookie) = (int32_t)data.rec_int; return REC_ERR_OKAY; } static int link_uint32(const char * /* name */, RecDataT /* data_type */, RecData data, void *cookie) { - *((uint32_t *) cookie) = (uint32_t) data.rec_int; + *((uint32_t *)cookie) = (uint32_t)data.rec_int; return REC_ERR_OKAY; } static int link_float(const char * /* name */, RecDataT /* data_type */, RecData data, void *cookie) { - *((RecFloat *) cookie) = data.rec_float; + *((RecFloat *)cookie) = data.rec_float; return REC_ERR_OKAY; } static int link_counter(const char * /* name */, RecDataT /* data_type */, RecData data, void *cookie) { - RecCounter *rec_counter = (RecCounter *) cookie; + RecCounter *rec_counter = (RecCounter *)cookie; ink_atomic_swap(rec_counter, data.rec_counter); return REC_ERR_OKAY; } @@ -115,7 +115,7 @@ link_counter(const char * /* name */, RecDataT /* data_type */, RecData data, vo static int link_byte(const char * /* name */, RecDataT /* data_type */, RecData data, void *cookie) { - RecByte *rec_byte = (RecByte *) cookie; + RecByte *rec_byte = (RecByte *)cookie; RecByte byte = static_cast<RecByte>(data.rec_int); ink_atomic_swap(rec_byte, byte); @@ -207,69 +207,69 @@ RecCoreInit(RecModeT mode_type, Diags *_diags) // RecLinkCnfigXXX //------------------------------------------------------------------------- int -RecLinkConfigInt(const char *name, RecInt * rec_int) +RecLinkConfigInt(const char *name, RecInt *rec_int) { if (RecGetRecordInt(name, rec_int) == REC_ERR_FAIL) { return REC_ERR_FAIL; } - return RecRegisterConfigUpdateCb(name, link_int, (void *) rec_int); + return RecRegisterConfigUpdateCb(name, link_int, (void *)rec_int); } int -RecLinkConfigInt32(const char *name, int32_t * p_int32) +RecLinkConfigInt32(const char *name, int32_t *p_int32) { - return RecRegisterConfigUpdateCb(name, link_int32, (void *) p_int32); + return RecRegisterConfigUpdateCb(name, link_int32, (void *)p_int32); } int -RecLinkConfigUInt32(const char *name, uint32_t * p_uint32) +RecLinkConfigUInt32(const char *name, uint32_t *p_uint32) { - return RecRegisterConfigUpdateCb(name, link_uint32, (void *) p_uint32); + return RecRegisterConfigUpdateCb(name, link_uint32, (void *)p_uint32); } int -RecLinkConfigFloat(const char *name, RecFloat * rec_float) +RecLinkConfigFloat(const char *name, RecFloat *rec_float) { if (RecGetRecordFloat(name, rec_float) == REC_ERR_FAIL) { return REC_ERR_FAIL; } - return RecRegisterConfigUpdateCb(name, link_float, (void *) rec_float); + return RecRegisterConfigUpdateCb(name, link_float, (void *)rec_float); } int -RecLinkConfigCounter(const char *name, RecCounter * rec_counter) +RecLinkConfigCounter(const char *name, RecCounter *rec_counter) { if (RecGetRecordCounter(name, rec_counter) == REC_ERR_FAIL) { return REC_ERR_FAIL; } - return RecRegisterConfigUpdateCb(name, link_counter, (void *) rec_counter); + return RecRegisterConfigUpdateCb(name, link_counter, (void *)rec_counter); } int -RecLinkConfigString(const char *name, RecString * rec_string) +RecLinkConfigString(const char *name, RecString *rec_string) { if (RecGetRecordString_Xmalloc(name, rec_string) == REC_ERR_FAIL) { return REC_ERR_FAIL; } - return RecRegisterConfigUpdateCb(name, link_string_alloc, (void *) rec_string); + return RecRegisterConfigUpdateCb(name, link_string_alloc, (void *)rec_string); } int -RecLinkConfigByte(const char *name, RecByte * rec_byte) +RecLinkConfigByte(const char *name, RecByte *rec_byte) { if (RecGetRecordByte(name, rec_byte) == REC_ERR_FAIL) { return REC_ERR_FAIL; } - return RecRegisterConfigUpdateCb(name, link_byte, (void *) rec_byte); + return RecRegisterConfigUpdateCb(name, link_byte, (void *)rec_byte); } int -RecLinkConfigBool(const char *name, RecBool * rec_bool) +RecLinkConfigBool(const char *name, RecBool *rec_bool) { if (RecGetRecordBool(name, rec_bool) == REC_ERR_FAIL) { return REC_ERR_FAIL; } - return RecRegisterConfigUpdateCb(name, link_byte, (void *) rec_bool); + return RecRegisterConfigUpdateCb(name, link_byte, (void *)rec_bool); } @@ -284,7 +284,7 @@ RecRegisterConfigUpdateCb(const char *name, RecConfigUpdateCb update_cb, void *c ink_rwlock_rdlock(&g_records_rwlock); - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (REC_TYPE_IS_CONFIG(r->rec_type)) { /* -- upgrade to support a list of callback functions @@ -341,7 +341,7 @@ RecGetRecordInt(const char *name, RecInt *rec_int, bool lock) } int -RecGetRecordFloat(const char *name, RecFloat * rec_float, bool lock) +RecGetRecordFloat(const char *name, RecFloat *rec_float, bool lock) { int err; RecData data; @@ -358,7 +358,7 @@ RecGetRecordString(const char *name, char *buf, int buf_len, bool lock) if (lock) { ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (!r->registered || (r->data_type != RECD_STRING)) { err = REC_ERR_FAIL; @@ -380,7 +380,7 @@ RecGetRecordString(const char *name, char *buf, int buf_len, bool lock) } int -RecGetRecordString_Xmalloc(const char *name, RecString * rec_string, bool lock) +RecGetRecordString_Xmalloc(const char *name, RecString *rec_string, bool lock) { int err; RecData data; @@ -390,7 +390,7 @@ RecGetRecordString_Xmalloc(const char *name, RecString * rec_string, bool lock) } int -RecGetRecordCounter(const char *name, RecCounter * rec_counter, bool lock) +RecGetRecordCounter(const char *name, RecCounter *rec_counter, bool lock) { int err; RecData data; @@ -424,7 +424,7 @@ RecGetRecordBool(const char *name, RecBool *rec_bool, bool lock) //------------------------------------------------------------------------- int -RecLookupRecord(const char *name, void (*callback)(const RecRecord *, void *), void * data, bool lock) +RecLookupRecord(const char *name, void (*callback)(const RecRecord *, void *), void *data, bool lock) { int err = REC_ERR_FAIL; RecRecord *r; @@ -433,7 +433,7 @@ RecLookupRecord(const char *name, void (*callback)(const RecRecord *, void *), v ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); callback(r, data); err = REC_ERR_OKAY; @@ -448,7 +448,7 @@ RecLookupRecord(const char *name, void (*callback)(const RecRecord *, void *), v } int -RecGetRecordType(const char *name, RecT * rec_type, bool lock) +RecGetRecordType(const char *name, RecT *rec_type, bool lock) { int err = REC_ERR_FAIL; RecRecord *r; @@ -457,7 +457,7 @@ RecGetRecordType(const char *name, RecT * rec_type, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); *rec_type = r->rec_type; err = REC_ERR_OKAY; @@ -473,7 +473,7 @@ RecGetRecordType(const char *name, RecT * rec_type, bool lock) int -RecGetRecordDataType(const char *name, RecDataT * data_type, bool lock) +RecGetRecordDataType(const char *name, RecDataT *data_type, bool lock) { int err = REC_ERR_FAIL; RecRecord *r = NULL; @@ -482,7 +482,7 @@ RecGetRecordDataType(const char *name, RecDataT * data_type, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (!r->registered) { err = REC_ERR_FAIL; @@ -501,7 +501,7 @@ RecGetRecordDataType(const char *name, RecDataT * data_type, bool lock) } int -RecGetRecordPersistenceType(const char *name, RecPersistT * persist_type, bool lock) +RecGetRecordPersistenceType(const char *name, RecPersistT *persist_type, bool lock) { int err = REC_ERR_FAIL; RecRecord *r = NULL; @@ -512,7 +512,7 @@ RecGetRecordPersistenceType(const char *name, RecPersistT * persist_type, bool l *persist_type = RECP_NULL; - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (REC_TYPE_IS_STAT(r->rec_type)) { *persist_type = r->stat_meta.persist_type; @@ -529,7 +529,7 @@ RecGetRecordPersistenceType(const char *name, RecPersistT * persist_type, bool l } int -RecGetRecordOrderAndId(const char *name, int* order, int* id, bool lock) +RecGetRecordOrderAndId(const char *name, int *order, int *id, bool lock) { int err = REC_ERR_FAIL; RecRecord *r = NULL; @@ -538,7 +538,7 @@ RecGetRecordOrderAndId(const char *name, int* order, int* id, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { if (r->registered) { rec_mutex_acquire(&(r->lock)); if (order) @@ -567,7 +567,7 @@ RecGetRecordUpdateType(const char *name, RecUpdateT *update_type, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (REC_TYPE_IS_CONFIG(r->rec_type)) { *update_type = r->config_meta.update_type; @@ -596,7 +596,7 @@ RecGetRecordCheckType(const char *name, RecCheckT *check_type, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (REC_TYPE_IS_CONFIG(r->rec_type)) { *check_type = r->config_meta.check_type; @@ -625,7 +625,7 @@ RecGetRecordCheckExpr(const char *name, char **check_expr, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (REC_TYPE_IS_CONFIG(r->rec_type)) { *check_expr = r->config_meta.check_expr; @@ -653,7 +653,7 @@ RecGetRecordDefaultDataString_Xmalloc(char *name, char **buf, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { *buf = (char *)ats_malloc(sizeof(char) * 1024); memset(*buf, 0, 1024); err = REC_ERR_OKAY; @@ -704,7 +704,7 @@ RecGetRecordAccessType(const char *name, RecAccessT *access, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); *access = r->config_meta.access_type; err = REC_ERR_OKAY; @@ -729,7 +729,7 @@ RecSetRecordAccessType(const char *name, RecAccessT access, bool lock) ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); r->config_meta.access_type = access; err = REC_ERR_OKAY; @@ -758,7 +758,7 @@ RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, RecData dat // type we are registering, then that means that it changed between the previous software // version and the current version. If the metric changed to non-persistent, reset to the // new default value. - if ((r->stat_meta.persist_type == RECP_NULL ||r->stat_meta.persist_type == RECP_PERSISTENT) && + if ((r->stat_meta.persist_type == RECP_NULL || r->stat_meta.persist_type == RECP_PERSISTENT) && persist_type == RECP_NON_PERSISTENT) { RecDebug(DL_Debug, "resetting default value for formerly persisted stat '%s'", r->name); RecDataSet(r->data_type, &(r->data), &(data_default)); @@ -779,8 +779,7 @@ RecRegisterStat(RecT rec_type, const char *name, RecDataT data_type, RecData dat // RecRegisterConfig //------------------------------------------------------------------------- RecRecord * -RecRegisterConfig(RecT rec_type, const char *name, RecDataT data_type, - RecData data_default, RecUpdateT update_type, +RecRegisterConfig(RecT rec_type, const char *name, RecDataT data_type, RecData data_default, RecUpdateT update_type, RecCheckT check_type, const char *check_expr, RecAccessT access_type) { RecRecord *r; @@ -815,7 +814,7 @@ RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data, bool l ink_rwlock_rdlock(&g_records_rwlock); } - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (!r->registered || (r->data_type != data_type)) { err = REC_ERR_FAIL; @@ -842,14 +841,14 @@ RecGetRecord_Xmalloc(const char *name, RecDataT data_type, RecData *data, bool l // RecForceInsert //------------------------------------------------------------------------- RecRecord * -RecForceInsert(RecRecord * record) +RecForceInsert(RecRecord *record) { RecRecord *r = NULL; bool r_is_a_new_record; ink_rwlock_wrlock(&g_records_rwlock); - if (ink_hash_table_lookup(g_records_ht, record->name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, record->name, (void **)&r)) { r_is_a_new_record = false; rec_mutex_acquire(&(r->lock)); r->rec_type = record->rec_type; @@ -882,7 +881,7 @@ RecForceInsert(RecRecord * record) } if (r_is_a_new_record) { - ink_hash_table_insert(g_records_ht, r->name, (void *) r); + ink_hash_table_insert(g_records_ht, r->name, (void *)r); } else { rec_mutex_release(&(r->lock)); } @@ -900,7 +899,7 @@ RecForceInsert(RecRecord * record) static void debug_record_callback(RecT /* rec_type */, void * /* edata */, int registered, const char *name, int data_type, RecData *datum) { - switch(data_type) { + switch (data_type) { case RECD_INT: RecDebug(DL_Note, " ([%d] '%s', '%" PRId64 "')", registered, name, datum->rec_int); break; @@ -908,8 +907,7 @@ debug_record_callback(RecT /* rec_type */, void * /* edata */, int registered, c RecDebug(DL_Note, " ([%d] '%s', '%f')", registered, name, datum->rec_float); break; case RECD_STRING: - RecDebug(DL_Note, " ([%d] '%s', '%s')", - registered, name, datum->rec_string ? datum->rec_string : "NULL"); + RecDebug(DL_Note, " ([%d] '%s', '%s')", registered, name, datum->rec_string ? datum->rec_string : "NULL"); break; case RECD_COUNTER: RecDebug(DL_Note, " ([%d] '%s', '%" PRId64 "')", registered, name, datum->rec_counter); @@ -936,7 +934,8 @@ RecDumpRecords(RecT rec_type, RecDumpEntryCb callback, void *edata) } void -RecDumpRecordsHt(RecT rec_type) { +RecDumpRecordsHt(RecT rec_type) +{ RecDebug(DL_Note, "Dumping Records:"); RecDumpRecords(rec_type, debug_record_callback, NULL); } @@ -951,7 +950,7 @@ int RecGetRecordPrefix_Xmalloc(char *prefix, char **buf, int *buf_len) { int num_records = g_num_records; - int result_size = num_records * 256; /* estimate buffer size */ + int result_size = num_records * 256; /* estimate buffer size */ int num_matched = 0; char *result = NULL; @@ -978,7 +977,8 @@ RecGetRecordPrefix_Xmalloc(char *prefix, char **buf, int *buf_len) break; case RECD_STRING: num_matched++; - bytes_written = snprintf(result + total_bytes_written, bytes_avail, "%s=%s\r\n", r->name, r->data.rec_string ? r->data.rec_string : "NULL"); + bytes_written = snprintf(result + total_bytes_written, bytes_avail, "%s=%s\r\n", r->name, + r->data.rec_string ? r->data.rec_string : "NULL"); break; case RECD_COUNTER: num_matched++; @@ -988,7 +988,7 @@ RecGetRecordPrefix_Xmalloc(char *prefix, char **buf, int *buf_len) break; } - if(bytes_written <= 0 || bytes_written > bytes_avail) { + if (bytes_written <= 0 || bytes_written > bytes_avail) { error = 1; } else total_bytes_written += bytes_written; @@ -997,7 +997,7 @@ RecGetRecordPrefix_Xmalloc(char *prefix, char **buf, int *buf_len) } } - if(error || total_bytes_written == result_size) { + if (error || total_bytes_written == result_size) { RecLog(DL_Error, "Stat system was unable to fully generate stat list, size exceeded limit of %d", result_size); } @@ -1023,7 +1023,7 @@ char * REC_ConfigReadString(const char *name) { char *t = 0; - RecGetRecordString_Xmalloc(name, (RecString *) & t); + RecGetRecordString_Xmalloc(name, (RecString *)&t); return t; } @@ -1031,7 +1031,7 @@ RecFloat REC_ConfigReadFloat(const char *name) { RecFloat t = 0; - RecGetRecordFloat(name, (RecFloat *) & t); + RecGetRecordFloat(name, (RecFloat *)&t); return t; } @@ -1039,7 +1039,7 @@ RecCounter REC_ConfigReadCounter(const char *name) { RecCounter t = 0; - RecGetRecordCounter(name, (RecCounter *) & t); + RecGetRecordCounter(name, (RecCounter *)&t); return t; } @@ -1048,7 +1048,7 @@ REC_ConfigReadCounter(const char *name) // Backwards compatibility. TODO: Should remove these. //------------------------------------------------------------------------- RecInt -REC_readInteger(const char *name, bool * found, bool lock) +REC_readInteger(const char *name, bool *found, bool lock) { ink_assert(name); RecInt _tmp = 0; @@ -1060,7 +1060,7 @@ REC_readInteger(const char *name, bool * found, bool lock) } RecFloat -REC_readFloat(char *name, bool * found, bool lock) +REC_readFloat(char *name, bool *found, bool lock) { ink_assert(name); RecFloat _tmp = 0.0; @@ -1072,7 +1072,7 @@ REC_readFloat(char *name, bool * found, bool lock) } RecCounter -REC_readCounter(char *name, bool * found, bool lock) +REC_readCounter(char *name, bool *found, bool lock) { ink_assert(name); RecCounter _tmp = 0; @@ -1084,7 +1084,7 @@ REC_readCounter(char *name, bool * found, bool lock) } RecString -REC_readString(const char *name, bool * found, bool lock) +REC_readString(const char *name, bool *found, bool lock) { ink_assert(name); RecString _tmp = NULL; @@ -1176,7 +1176,7 @@ RecConfigReadSnapshotDir() // RecConfigReadConfigPath //------------------------------------------------------------------------- char * -RecConfigReadConfigPath(const char * file_variable, const char * default_value) +RecConfigReadConfigPath(const char *file_variable, const char *default_value) { ats_scoped_str sysconfdir(RecConfigReadConfigDir()); @@ -1203,7 +1203,7 @@ RecConfigReadConfigPath(const char * file_variable, const char * default_value) // RecConfigReadPrefixPath //------------------------------------------------------------------------- char * -RecConfigReadPrefixPath(const char * file_variable, const char * default_value) +RecConfigReadPrefixPath(const char *file_variable, const char *default_value) { char buf[PATH_NAME_MAX + 1]; @@ -1235,7 +1235,7 @@ RecConfigReadPersistentStatsPath() } void -RecSignalWarning(int sig, const char * fmt, ...) +RecSignalWarning(int sig, const char *fmt, ...) { char msg[1024]; va_list args; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecDebug.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecDebug.cc b/lib/records/RecDebug.cc index 836ff23..8bae9db 100644 --- a/lib/records/RecDebug.cc +++ b/lib/records/RecDebug.cc @@ -30,7 +30,7 @@ static Diags *g_diags = NULL; // RecSetDiags //------------------------------------------------------------------------- int -RecSetDiags(Diags * _diags) +RecSetDiags(Diags *_diags) { // Warning! It's very dangerous to change diags on the fly! This // function only exists so that we can boot-strap TM on startup.
