trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [trafficserver] 28/33: TS-4425: Switch proxy/logging over to Ptr::get().
Date Wed, 11 May 2016 20:31:52 GMT
This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 8faceca2c67b45977df2e42c257b3b5e41a95746
Author: James Peach <jpeach@apache.org>
AuthorDate: Sat May 7 13:41:18 2016 -0700

    TS-4425: Switch proxy/logging over to Ptr::get().
---
 proxy/logging/Log.cc       | 33 +++++++++++++++++++--------------
 proxy/logging/LogField.cc  |  4 ++--
 proxy/logging/LogFilter.cc |  2 +-
 proxy/logging/LogHost.cc   |  6 ++++--
 proxy/logging/LogHost.h    |  3 ++-
 proxy/logging/LogObject.h  |  2 +-
 6 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index 6e481ca..636610a 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -99,6 +99,13 @@ RecRawStatBlock *log_rsb;
 LogConfig *Log::config = NULL;
 static unsigned log_configid = 0;
 
+// Downcast from a Ptr<LogFieldAliasTable> to a Ptr<LogFieldAliasMap>.
+static Ptr<LogFieldAliasMap>
+make_alias_map(Ptr<LogFieldAliasTable> &table)
+{
+  return make_ptr(static_cast<LogFieldAliasMap *>(table.get()));
+}
+
 void
 Log::change_configuration()
 {
@@ -502,7 +509,7 @@ Log::init_fields()
   finish_status_map->init(N_LOG_FINISH_CODE_TYPES, LOG_FINISH_FIN, "FIN", LOG_FINISH_INTR,
"INTR", LOG_FINISH_TIMEOUT, "TIMEOUT");
 
   field = new LogField("client_finish_status_code", "cfsc", LogField::sINT, &LogAccess::marshal_client_finish_status_code,
-                       &LogAccess::unmarshal_finish_status, (Ptr<LogFieldAliasMap>)finish_status_map);
+                       &LogAccess::unmarshal_finish_status, make_alias_map(finish_status_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cfsc", field);
 
@@ -538,7 +545,7 @@ Log::init_fields()
   ink_hash_table_insert(field_symbol_hash, "pshl", field);
 
   field = new LogField("proxy_finish_status_code", "pfsc", LogField::sINT, &LogAccess::marshal_proxy_finish_status_code,
-                       &LogAccess::unmarshal_finish_status, (Ptr<LogFieldAliasMap>)finish_status_map);
+                       &LogAccess::unmarshal_finish_status, make_alias_map(finish_status_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "pfsc", field);
 
@@ -579,12 +586,12 @@ Log::init_fields()
                            SQUID_MISS_CACHE_BYPASS, "MISS_CACHE_BYPASS", SQUID_HIT_MISS_INVALID_ASSIGNED_CODE,
"INVALID_CODE");
 
   field = new LogField("cache_result_code", "crc", LogField::sINT, &LogAccess::marshal_cache_result_code,
-                       &LogAccess::unmarshal_cache_code, (Ptr<LogFieldAliasMap>)cache_code_map);
+                       &LogAccess::unmarshal_cache_code, make_alias_map(cache_code_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "crc", field);
 
   field = new LogField("cache_hit_miss", "chm", LogField::sINT, &LogAccess::marshal_cache_hit_miss,
-                       &LogAccess::unmarshal_cache_hit_miss, (Ptr<LogFieldAliasMap>)cache_hit_miss_map);
+                       &LogAccess::unmarshal_cache_hit_miss, make_alias_map(cache_hit_miss_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "chm", field);
 
@@ -635,7 +642,7 @@ Log::init_fields()
     "INVALID_ASSIGNED_CODE");
 
   field = new LogField("proxy_hierarchy_route", "phr", LogField::sINT, &LogAccess::marshal_proxy_hierarchy_route,
-                       &LogAccess::unmarshal_hierarchy, (Ptr<LogFieldAliasMap>)hierarchy_map);
+                       &LogAccess::unmarshal_hierarchy, make_alias_map(hierarchy_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "phr", field);
 
@@ -750,12 +757,12 @@ Log::init_fields()
   cache_write_code_map->init(N_LOG_CACHE_WRITE_TYPES, LOG_CACHE_WRITE_NONE, "-", LOG_CACHE_WRITE_LOCK_MISSED,
"WL_MISS",
                              LOG_CACHE_WRITE_LOCK_ABORTED, "INTR", LOG_CACHE_WRITE_ERROR,
"ERR", LOG_CACHE_WRITE_COMPLETE, "FIN");
   field = new LogField("cache_write_result", "cwr", LogField::sINT, &LogAccess::marshal_cache_write_code,
-                       &LogAccess::unmarshal_cache_write_code, (Ptr<LogFieldAliasMap>)cache_write_code_map);
+                       &LogAccess::unmarshal_cache_write_code, make_alias_map(cache_write_code_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cwr", field);
 
   field = new LogField("cache_write_transform_result", "cwtr", LogField::sINT, &LogAccess::marshal_cache_write_transform_code,
-                       &LogAccess::unmarshal_cache_write_code, (Ptr<LogFieldAliasMap>)cache_write_code_map);
+                       &LogAccess::unmarshal_cache_write_code, make_alias_map(cache_write_code_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "cwtr", field);
 
@@ -788,7 +795,7 @@ Log::init_fields()
   Ptr<LogFieldAliasTable> entry_type_map = make_ptr(new LogFieldAliasTable);
   entry_type_map->init(N_LOG_ENTRY_TYPES, LOG_ENTRY_HTTP, "LOG_ENTRY_HTTP", LOG_ENTRY_ICP,
"LOG_ENTRY_ICP");
   field = new LogField("log_entry_type", "etype", LogField::sINT, &LogAccess::marshal_entry_type,
&LogAccess::unmarshal_entry_type,
-                       (Ptr<LogFieldAliasMap>)entry_type_map);
+                       make_alias_map(entry_type_map));
   global_field_list.add(field, false);
   ink_hash_table_insert(field_symbol_hash, "etype", field);
 
@@ -1184,12 +1191,10 @@ Log::preproc_thread_main(void *args)
 void *
 Log::flush_thread_main(void * /* args ATS_UNUSED */)
 {
-  char *buf;
-  LogFile *logfile;
   LogBuffer *logbuffer;
   LogFlushData *fdata;
   ink_hrtime now, last_time = 0;
-  int len, bytes_written, total_bytes;
+  int len, total_bytes;
   SLL<LogFlushData, LogFlushData::Link_link> link, invert_link;
   ProxyMutex *mutex = this_thread()->mutex;
 
@@ -1210,9 +1215,9 @@ Log::flush_thread_main(void * /* args ATS_UNUSED */)
     // process each flush data
     //
     while ((fdata = invert_link.pop())) {
-      buf = NULL;
-      bytes_written = 0;
-      logfile = fdata->m_logfile;
+      char *buf = NULL;
+      int bytes_written = 0;
+      LogFile *logfile = fdata->m_logfile.get();
 
       if (logfile->m_file_format == LOG_FILE_BINARY) {
         logbuffer = (LogBuffer *)fdata->m_data;
diff --git a/proxy/logging/LogField.cc b/proxy/logging/LogField.cc
index 3ae1a0b..8413add 100644
--- a/proxy/logging/LogField.cc
+++ b/proxy/logging/LogField.cc
@@ -223,7 +223,7 @@ LogField::LogField(const char *name, const char *symbol, Type type, MarshalFunc
   ink_assert(m_symbol != NULL);
   ink_assert(m_type >= 0 && m_type < N_TYPES);
   ink_assert(m_marshal_func != (MarshalFunc)NULL);
-  ink_assert(m_alias_map != NULL);
+  ink_assert(m_alias_map);
 
   m_time_field = (strcmp(m_symbol, "cqts") == 0 || strcmp(m_symbol, "cqth") == 0 || strcmp(m_symbol,
"cqtq") == 0 ||
                   strcmp(m_symbol, "cqtn") == 0 || strcmp(m_symbol, "cqtd") == 0 || strcmp(m_symbol,
"cqtt") == 0);
@@ -521,7 +521,7 @@ LogField::marshal_agg(char *buf)
 unsigned
 LogField::unmarshal(char **buf, char *dest, int len)
 {
-  if (m_alias_map == NULL) {
+  if (!m_alias_map) {
     if (m_unmarshal_func == (UnmarshalFunc)LogAccess::unmarshal_str ||
         m_unmarshal_func == (UnmarshalFunc)LogAccess::unmarshal_http_text) {
       UnmarshalFuncWithSlice func = (UnmarshalFuncWithSlice)m_unmarshal_func;
diff --git a/proxy/logging/LogFilter.cc b/proxy/logging/LogFilter.cc
index 592df6a..62fb923 100644
--- a/proxy/logging/LogFilter.cc
+++ b/proxy/logging/LogFilter.cc
@@ -435,7 +435,7 @@ LogFilterInt::LogFilterInt(const char *name, LogField *field, LogFilter::Action
     char *t;
     while (t = tok.getNext(), t != NULL) {
       int64_t ival;
-      if (!_convertStringToInt(t, &ival, field->map())) {
+      if (!_convertStringToInt(t, &ival, field->map().get())) {
         // conversion was successful, add entry to array
         //
         val_array[i++] = ival;
diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc
index b4efa96..2cd87ba 100644
--- a/proxy/logging/LogHost.cc
+++ b/proxy/logging/LogHost.cc
@@ -228,7 +228,10 @@ LogHost::disconnect()
 void
 LogHost::create_orphan_LogFile_object()
 {
-  delete m_orphan_file;
+  // We expect that no-one else is holding any refcounts on the
+  // orphan file so that is will be releases when we replace it
+  // below.
+  ink_assert(m_orphan_file->refcount() == 1);
 
   const char *orphan_ext = "orphan";
   unsigned name_len = (unsigned)(strlen(m_object_filename) + strlen(name()) + strlen(orphan_ext)
+ 16);
@@ -241,7 +244,6 @@ LogHost::create_orphan_LogFile_object()
   // should check for conflicts with orphan filename
   //
   m_orphan_file = new LogFile(name_buf, NULL, LOG_FILE_ASCII, m_object_signature);
-  ink_assert(m_orphan_file != NULL);
   ats_free(name_buf);
 }
 
diff --git a/proxy/logging/LogHost.h b/proxy/logging/LogHost.h
index 7425d7c..03a977e 100644
--- a/proxy/logging/LogHost.h
+++ b/proxy/logging/LogHost.h
@@ -87,8 +87,9 @@ public:
   LogFile *
   get_orphan_logfile() const
   {
-    return m_orphan_file;
+    return m_orphan_file.get();
   }
+
   // check if we will be able to write orphan file
   int
   do_filesystem_checks()
diff --git a/proxy/logging/LogObject.h b/proxy/logging/LogObject.h
index abfef3a..3b866b4 100644
--- a/proxy/logging/LogObject.h
+++ b/proxy/logging/LogObject.h
@@ -143,7 +143,7 @@ public:
       idx = m_buffer_manager_idx++ % m_flush_threads;
 
     if (m_logFile) {
-      nfb = m_buffer_manager[idx].preproc_buffers(m_logFile);
+      nfb = m_buffer_manager[idx].preproc_buffers(m_logFile.get());
     } else {
       nfb = m_buffer_manager[idx].preproc_buffers(&m_host_list);
     }

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message