trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r950713 - in /trafficserver/traffic/trunk/proxy/logging: LogAccess.cc LogAccess.h LogAccessHttp.cc LogAccessICP.cc LogBuffer.cc LogBuffer.h LogConfig.cc LogField.h LogFilter.cc LogFilter.h
Date Wed, 02 Jun 2010 18:44:49 GMT
Author: zwoop
Date: Wed Jun  2 18:44:48 2010
New Revision: 950713

URL: http://svn.apache.org/viewvc?rev=950713&view=rev
Log:
TS-34: Fix the broken logging, and some more cleanup.

Modified:
    trafficserver/traffic/trunk/proxy/logging/LogAccess.cc
    trafficserver/traffic/trunk/proxy/logging/LogAccess.h
    trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc
    trafficserver/traffic/trunk/proxy/logging/LogAccessICP.cc
    trafficserver/traffic/trunk/proxy/logging/LogBuffer.cc
    trafficserver/traffic/trunk/proxy/logging/LogBuffer.h
    trafficserver/traffic/trunk/proxy/logging/LogConfig.cc
    trafficserver/traffic/trunk/proxy/logging/LogField.h
    trafficserver/traffic/trunk/proxy/logging/LogFilter.cc
    trafficserver/traffic/trunk/proxy/logging/LogFilter.h

Modified: trafficserver/traffic/trunk/proxy/logging/LogAccess.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccess.cc?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccess.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccess.cc Wed Jun  2 18:44:48 2010
@@ -57,6 +57,7 @@
 #include "LogBuffer.h"
 #include "Log.h"
 
+
 /*-------------------------------------------------------------------------
   LogAccess::init
   -------------------------------------------------------------------------*/
@@ -780,7 +781,7 @@ int
 LogAccess::marshal_config_int_var(char *config_var, char *buf)
 {
   if (buf) {
-    int64 val = (int64)LOG_ConfigReadInteger(config_var);
+    int64 val = (int64) LOG_ConfigReadInteger(config_var);
     marshal_int(buf, val);
   }
   return INK_MIN_ALIGN;
@@ -834,7 +835,7 @@ LogAccess::marshal_record(char *record, 
 #define LOG_COUNTER RECD_COUNTER
 #define LOG_FLOAT   RECD_FLOAT
 #define LOG_STRING  RECD_STRING
-  typedef RecInt LogInt; // TODO/XXX: This needs to match changes made for LogInt
+  typedef RecInt LogInt; // TODO/XXX: This needs to match changes made for uint64
   typedef RecCounter LogCounter;
   typedef RecFloat LogFloat;
   typedef RecString LogString;
@@ -959,37 +960,6 @@ LogAccess::marshal_record(char *record, 
   return max_chars;
 }
 
-/*-------------------------------------------------------------------------
-  The following functions are helper functions for the LogAccess* classes
-  -------------------------------------------------------------------------*/
-
-/*-------------------------------------------------------------------------
-  LogAccess::marshal_int
-
-  Place the given value into the buffer.  Note that the buffer needs to be
-  aligned with the size of INK_MIN_ALIGN for this to succeed.  We also convert
-  to network byte order, just in case we read the data on a different
-  machine; unmarshal_int() will convert back to host byte order.
-
-  ASSUMES dest IS NOT NULL.
-  -------------------------------------------------------------------------*/
-
-#if DO_NOT_INLINE
-void
-LogAccess::marshal_int(char *dest, int64 source)
-{
-  ink_assert(dest != NULL);
-  // TODO: This used to do htonl
-  *((int64 *) dest) = source;
-}
-
-void
-LogAccess::marshal_int_no_byte_order_conversion(char *dest, int64 source)
-{
-  ink_assert(dest != NULL);
-  *((int64 *) dest) = source;
-}
-#endif
 
 /*-------------------------------------------------------------------------
   LogAccess::marshal_str
@@ -1092,14 +1062,15 @@ LogAccess::unmarshal_with_map(int64 code
   pointer past the int.  The int will be converted back to host byte order.
   -------------------------------------------------------------------------*/
 
-int64 LogAccess::unmarshal_int(char **buf)
+int64
+LogAccess::unmarshal_int(char **buf)
 {
   ink_assert(buf != NULL);
   ink_assert(*buf != NULL);
   int64 val;
 
-  // TODO: this used to do nthol
-  val = ntohl(*((int64 *) (*buf)));
+  // TODO: this used to do nthol, do we need to worrry?
+  val = *((int64 *)(*buf));
   *buf += INK_MIN_ALIGN;
   return val;
 }
@@ -1125,7 +1096,7 @@ LogAccess::unmarshal_itoa(int64 val, cha
     while (dest - p < field_width) {
       *p-- = leading_char;
     }
-    return (int64) (dest - p);
+    return (int)(dest - p);
   }
 
   while (val) {
@@ -1135,7 +1106,7 @@ LogAccess::unmarshal_itoa(int64 val, cha
   while (dest - p < field_width) {
     *p-- = leading_char;
   }
-  return (int) (dest - p);
+  return (int)(dest - p);
 }
 
 /*-------------------------------------------------------------------------
@@ -1152,19 +1123,18 @@ LogAccess::unmarshal_itox(int64 val, cha
 {
   ink_assert(dest != NULL);
 
-  char *
-    p = dest;
-  static char
-    table[] = "0123456789abcdef?";
+  char *p = dest;
+  static char table[] = "0123456789abcdef?";
 
-  for (int i = 0; i < (int) (sizeof(int64) * 2); i++) {
+  for (int i = 0; i < (int)(sizeof(int64) * 2); i++) {
     *p-- = table[val & 0xf];
     val >>= 4;
   }
   while (dest - p < field_width) {
     *p-- = leading_char;
   }
-  return (int) (dest - p);
+
+  return (int64)(dest - p);
 }
 
 /*-------------------------------------------------------------------------
@@ -1182,8 +1152,8 @@ LogAccess::unmarshal_int_to_str(char **b
 
   char val_buf[128];
   int64 val = unmarshal_int(buf);
-
   int val_len = unmarshal_itoa(val, val_buf + 127);
+
   if (val_len < len) {
     memcpy(dest, val_buf + 128 - val_len, val_len);
     return val_len;
@@ -1207,6 +1177,7 @@ LogAccess::unmarshal_int_to_str_hex(char
   char val_buf[128];
   int64 val = unmarshal_int(buf);
   int val_len = unmarshal_itox(val, val_buf + 127);
+
   if (val_len < len) {
     memcpy(dest, val_buf + 128 - val_len, val_len);
     return val_len;
@@ -1234,6 +1205,7 @@ LogAccess::unmarshal_str(char **buf, cha
 
   char *val_buf = *buf;
   int val_len = (int)::strlen(val_buf);
+
   *buf += LogAccess::strlen(val_buf);   // this is how it was stored
   if (val_len < len) {
     memcpy(dest, val_buf, val_len);

Modified: trafficserver/traffic/trunk/proxy/logging/LogAccess.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccess.h?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccess.h (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccess.h Wed Jun  2 18:44:48 2010
@@ -25,12 +25,6 @@
  Logging - LogAccess.h
 
 
-// Since we changed to 64-bit only for all int's. Look for htonl etc.
-#ifndef LITTLE_ENDIAN
-#error FIX_ME
-#endif
-
-
  ***************************************************************************/
 #if !defined (INK_NO_LOG)
 #ifndef LOG_ACCESS_H
@@ -103,8 +97,8 @@
 
 #define DEFAULT_INT_FIELD {\
     if (buf) { \
-	int64 i = 0; \
-	marshal_int (buf, i); \
+      int64 i = 0; \
+      marshal_int (buf, i); \
     } \
     return INK_MIN_ALIGN; \
 }
@@ -327,7 +321,6 @@ public:
 
 public:
   inkcoreapi void static marshal_int(char *dest, int64 source);
-  inkcoreapi void static marshal_int_no_byte_order_conversion(char *dest, int64 source);
   inkcoreapi void static marshal_str(char *dest, const char *source, int padded_len);
   inkcoreapi void static marshal_mem(char *dest, const char *source, int actual_len, int
padded_len);
 
@@ -365,14 +358,8 @@ LogAccess::strlen(char *str)
 inline void
 LogAccess::marshal_int(char *dest, int64 source)
 {
-  // TODO: This used to to htonl().
-  *((int64 *) dest) = source;
-}
-
-inline void
-LogAccess::marshal_int_no_byte_order_conversion(char *dest, int64 source)
-{
-  *((int64 *) dest) = source;
+  // TODO: This used to do htonl on the source
+  *((int64 *)dest) = source;
 }
 
 /*-------------------------------------------------------------------------

Modified: trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccessHttp.cc Wed Jun  2 18:44:48 2010
@@ -141,10 +141,8 @@ int
 LogAccessHttp::marshal_client_host_ip(char *buf)
 {
   if (buf) {
-    int64 ip = m_http_sm->t_state.client_info.ip;
-    // the ip is already in network order, no byte order conversion
-    // is needed
-    marshal_int_no_byte_order_conversion(buf, ip);
+    unsigned int ip = m_http_sm->t_state.client_info.ip;
+    marshal_int(buf, (int64)ntohl(ip));
   }
   return INK_MIN_ALIGN;
 }
@@ -643,9 +641,7 @@ LogAccessHttp::marshal_proxy_req_server_
     if (m_http_sm->t_state.current.server != NULL) {
       the_ip = m_http_sm->t_state.current.server->ip;
     }
-    // the ip is already in network order, no byte order conversion
-    // is needed
-    marshal_int_no_byte_order_conversion(buf, (int64) the_ip);
+    marshal_int(buf, (int64)ntohl(the_ip));
   }
   return INK_MIN_ALIGN;
 }
@@ -670,16 +666,14 @@ int
 LogAccessHttp::marshal_server_host_ip(char *buf)
 {
   if (buf) {
-    int64 val = 0;
+    unsigned int val = 0;
     val = m_http_sm->t_state.server_info.ip;
     if (val == 0) {
       if (m_http_sm->t_state.current.server != NULL) {
         val = m_http_sm->t_state.current.server->ip;
       }
     }
-    // the ip is already in network order, no byte order conversion
-    // is needed
-    marshal_int_no_byte_order_conversion(buf, val);
+    marshal_int(buf, (int64)ntohl(val));
   }
   return INK_MIN_ALIGN;
 }

Modified: trafficserver/traffic/trunk/proxy/logging/LogAccessICP.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogAccessICP.cc?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogAccessICP.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogAccessICP.cc Wed Jun  2 18:44:48 2010
@@ -71,7 +71,7 @@ LogAccessICP::marshal_client_host_ip(cha
   if (buf) {
     int64 ip = m_icp_log->GetClientIP()->s_addr;
     // ip is already in network order
-    marshal_int_no_byte_order_conversion(buf, ip);
+    marshal_int(buf, (int64)ntohl(ip));
   }
   return INK_MIN_ALIGN;
 }

Modified: trafficserver/traffic/trunk/proxy/logging/LogBuffer.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogBuffer.cc?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogBuffer.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogBuffer.cc Wed Jun  2 18:44:48 2010
@@ -1014,6 +1014,8 @@ LogBuffer::convert_to_host_order()
   convert_to_host_order(m_header);
 }
 
+
+// TODO: This is probably broken with the migration to 64-bit log ints.
 void
 LogBuffer::convert_to_host_order(LogBufferHeader * header)
 {
@@ -1050,6 +1052,7 @@ LogBuffer::convert_to_host_order(LogBuff
   //
   LogBufferIterator iter(header, true);
   LogEntryHeader *entry_header;
+
   while ((entry_header = iter.next())) {
     entry_header->timestamp = ntohl(entry_header->timestamp);
     entry_header->timestamp_usec = ntohl(entry_header->timestamp_usec);
@@ -1149,7 +1152,6 @@ LogEntryHeader *
 LogBufferIterator::next()
 {
   LogEntryHeader *ret_val = NULL;
-
   LogEntryHeader *entry = (LogEntryHeader *) m_next;
 
   if (entry) {

Modified: trafficserver/traffic/trunk/proxy/logging/LogBuffer.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogBuffer.h?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogBuffer.h (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogBuffer.h Wed Jun  2 18:44:48 2010
@@ -377,7 +377,7 @@ public:
   LogEntryHeader *next();
 
 private:
-    bool m_in_network_order;
+  bool m_in_network_order;
   char *m_next;
   unsigned m_iter_entry_count;
   unsigned m_buffer_entry_count;
@@ -398,14 +398,10 @@ private:
 
 inline
 LogBufferIterator::LogBufferIterator(LogBufferHeader * header, bool in_network_order)
-  :
-m_in_network_order(in_network_order)
-  ,
-m_next(0)
-  ,
-m_iter_entry_count(0)
-  ,
-m_buffer_entry_count(0)
+                  : m_in_network_order(in_network_order),
+                  m_next(0),
+                  m_iter_entry_count(0),
+                  m_buffer_entry_count(0)
 {
   ink_debug_assert(header);
 

Modified: trafficserver/traffic/trunk/proxy/logging/LogConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogConfig.cc?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogConfig.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogConfig.cc Wed Jun  2 18:44:48 2010
@@ -1053,10 +1053,13 @@ LogConfig::split_by_protocol(const PreDe
     return NULL;
   }
   // http MUST be last entry
-  enum
-  { icp=0, mixt, http };
-  unsigned value[] = { LOG_ENTRY_ICP,
-    LOG_ENTRY_MIXT, LOG_ENTRY_HTTP
+  enum { icp=0,
+         mixt,
+         http
+  };
+
+  int64 value[] = { LOG_ENTRY_ICP,
+                    LOG_ENTRY_MIXT, LOG_ENTRY_HTTP
   };
   const char *name[] = { "icp", "mixt", "http" };
   const char *filter_name[] = { "__icp__", "__mixt__", "__http__" };

Modified: trafficserver/traffic/trunk/proxy/logging/LogField.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogField.h?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogField.h (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogField.h Wed Jun  2 18:44:48 2010
@@ -20,15 +20,15 @@
   See the License for the specific language governing permissions and
   limitations under the License.
  */
+
+
+
 #ifndef LOG_FIELD_H
 #define LOG_FIELD_H
 
 #include "inktomi++.h"
 #include "LogFieldAliasMap.h"
 
-// This is setup for 64-bit log integers
-#define MIN_ALIGN	8
-
 class LogAccess;
 
 /*-------------------------------------------------------------------------

Modified: trafficserver/traffic/trunk/proxy/logging/LogFilter.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogFilter.cc?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogFilter.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogFilter.cc Wed Jun  2 18:44:48 2010
@@ -497,8 +497,9 @@ LogFilterInt::_setValues(size_t n, int64
   }
 }
 
+// TODO: ival should be int64
 int
-LogFilterInt::_convertStringToInt(char *value, int64 *ival, LogFieldAliasMap * map)
+LogFilterInt::_convertStringToInt(char *value, unsigned *ival, LogFieldAliasMap * map)
 {
   size_t i, l = strlen(value);
   for (i = 0; i < l && ParseRules::is_digit(value[i]); i++);
@@ -508,8 +509,7 @@ LogFilterInt::_convertStringToInt(char *
     // value is an alias and try to get the actual integer value
     // from the log field alias map if field has one
     //
-    // TODO: should not cast
-    if (map == NULL || map->asInt(value, (unsigned int*)ival) != LogFieldAliasMap::ALL_OK)
{
+    if (map == NULL || map->asInt(value, ival) != LogFieldAliasMap::ALL_OK) {
       return -1;                // error
     };
   } else {
@@ -523,25 +523,23 @@ LogFilterInt::_convertStringToInt(char *
 
 LogFilterInt::LogFilterInt(const char *name, LogField * field,
                            LogFilter::Action action, LogFilter::Operator oper, int64 value)
-:LogFilter(name, field, action, oper)
+ : LogFilter(name, field, action, oper)
 {
-  int64  v[1];
+  int64 v[1];
   v[0] = value;
   _setValues(1, v);
 }
 
 LogFilterInt::LogFilterInt(const char *name, LogField * field,
                            LogFilter::Action action, LogFilter::Operator oper, size_t num_values,
int64 *value)
-  :
-LogFilter(name, field, action, oper)
+  : LogFilter(name, field, action, oper)
 {
   _setValues(num_values, value);
 }
 
 LogFilterInt::LogFilterInt(const char *name, LogField * field,
                            LogFilter::Action action, LogFilter::Operator oper, char *values)
-  :
-LogFilter(name, field, action, oper)
+  : LogFilter(name, field, action, oper)
 {
   // parse the comma-separated list of values and construct array
   //
@@ -549,11 +547,12 @@ LogFilter(name, field, action, oper)
   size_t i = 0;
   SimpleTokenizer tok(values, ',');
   size_t n = tok.getNumTokensRemaining();
+
   if (n) {
     val_array = NEW(new int64[n]);
     char *t;
     while (t = tok.getNext(), t != NULL) {
-      int64 ival;
+      unsigned ival;
       if (!_convertStringToInt(t, &ival, field->map())) {
         // conversion was successful, add entry to array
         //

Modified: trafficserver/traffic/trunk/proxy/logging/LogFilter.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogFilter.h?rev=950713&r1=950712&r2=950713&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogFilter.h (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogFilter.h Wed Jun  2 18:44:48 2010
@@ -198,7 +198,7 @@ private:
   int64 *m_value;            // the array of values
 
   void _setValues(size_t n, int64 *value);
-  int _convertStringToInt(char *val, int64 *ival, LogFieldAliasMap * map);
+  int _convertStringToInt(char *val, unsigned *ival, LogFieldAliasMap * map);
 
   // -- member functions that are not allowed --
     LogFilterInt();



Mime
View raw message