trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [01/12] trafficserver git commit: TS-3230: remove unused ink_error APIs
Date Tue, 09 Dec 2014 22:13:46 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master 2857d531a -> c7554f263


TS-3230: remove unused ink_error APIs


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/948b6af0
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/948b6af0
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/948b6af0

Branch: refs/heads/master
Commit: 948b6af04c1c9448bb6c3a81fad222fc681ebcbe
Parents: 8b52dcd
Author: James Peach <jpeach@apache.org>
Authored: Tue Nov 18 16:24:43 2014 -0800
Committer: James Peach <jpeach@apache.org>
Committed: Tue Dec 9 13:46:39 2014 -0800

----------------------------------------------------------------------
 lib/ts/Diags.cc          |  5 +--
 lib/ts/ink_args.cc       |  6 ++--
 lib/ts/ink_assert.cc     |  2 +-
 lib/ts/ink_error.cc      | 78 ++++++++++---------------------------------
 lib/ts/ink_error.h       | 18 ++--------
 lib/ts/ink_hash_table.cc |  4 +--
 lib/ts/ink_memory.cc     | 14 ++++----
 lib/ts/ink_queue.cc      | 12 +++----
 lib/ts/ink_queue_ext.cc  |  6 ++--
 proxy/Main.cc            |  6 +---
 tools/jtest/jtest.cc     |  2 +-
 11 files changed, 47 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/Diags.cc
----------------------------------------------------------------------
diff --git a/lib/ts/Diags.cc b/lib/ts/Diags.cc
index cb9b3b6..dc06144 100644
--- a/lib/ts/Diags.cc
+++ b/lib/ts/Diags.cc
@@ -546,8 +546,9 @@ Diags::error_va(DiagsLevel level,
   }
 
   if (DiagsLevel_IsTerminal(level)) {
-    if (cleanup_func)
+    if (cleanup_func) {
       cleanup_func();
-    ink_fatal_va(1, format_string, ap2);
+    }
+    ink_fatal_va(format_string, ap2);
   }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_args.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_args.cc b/lib/ts/ink_args.cc
index c6c0e65..57f82c8 100644
--- a/lib/ts/ink_args.cc
+++ b/lib/ts/ink_args.cc
@@ -66,7 +66,7 @@ static void
 append_file_argument(const char * arg)
 {
     if (n_file_arguments >= countof(file_arguments)) {
-      ink_fatal(1, "too many files");
+      ink_fatal("too many files");
     }
     file_arguments[n_file_arguments++] = arg;
     file_arguments[n_file_arguments] = NULL;
@@ -112,7 +112,7 @@ process_arg(const AppVersionInfo * appinfo, const ArgumentDescription
* argument
         }
         break;
       default:
-        ink_fatal(1, (char *) "bad argument description");
+        ink_fatal("bad argument description");
         break;
       }
       **argv += strlen(**argv) - 1;
@@ -149,7 +149,7 @@ show_argument_configuration(const ArgumentDescription * argument_descriptions,
u
         printf("%s", (char *) argument_descriptions[i].location);
         break;
       default:
-        ink_fatal(1, (char *) "bad argument description");
+        ink_fatal("bad argument description");
         break;
       }
       printf("\n");

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_assert.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_assert.cc b/lib/ts/ink_assert.cc
index 013905a..b87bae8 100644
--- a/lib/ts/ink_assert.cc
+++ b/lib/ts/ink_assert.cc
@@ -34,5 +34,5 @@ Assertions
 void
 _ink_assert(const char *expression, const char *file, int line)
 {
-  ink_fatal(1, "%s:%d: failed assert `%s`", file, line, expression);
+  ink_fatal("%s:%d: failed assert `%s`", file, line, expression);
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_error.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_error.cc b/lib/ts/ink_error.cc
index a0b0ad2..06b9c7d 100644
--- a/lib/ts/ink_error.cc
+++ b/lib/ts/ink_error.cc
@@ -29,7 +29,7 @@
 #include <syslog.h>
 #include <signal.h>    /* MAGIC_EDITING_TAG */
 
-static int ink_dprintf_level = 0;
+static void ink_die_die_die() TS_NORETURN;
 
 /**
   This routine causes process death. Some signal handler problems got
@@ -37,22 +37,21 @@ static int ink_dprintf_level = 0;
   amusing implementation.
 
 */
-void
-ink_die_die_die(int retval)
+static void
+ink_die_die_die()
 {
   abort();
-  _exit(retval);
-  exit(retval);
+  _exit(70); // 70 corresponds to EX_SOFTWARE in BSD's sysexits. As good a status as any.
+  exit(70);
 }
 
 /**
   This routine prints/logs an error message given the printf format
-  string in message_format, and the optional arguments.  The program is
-  then terminated with return_code.
+  string in message_format, and the optional arguments.
 
 */
 void
-ink_fatal_va(int return_code, const char * fmt, va_list ap)
+ink_fatal_va(const char * fmt, va_list ap)
 {
   char msg[1024];
   const size_t len = sizeof("FATAL: ") - 1;
@@ -63,54 +62,44 @@ ink_fatal_va(int return_code, const char * fmt, va_list ap)
 
   fprintf(stderr, "%s\n", msg);
   syslog(LOG_CRIT, "%s", msg);
-  ink_stack_trace_dump();
-  ink_die_die_die(return_code);
-}
-
-void
-ink_fatal(int return_code, const char *message_format, ...)
-{
-  va_list ap;
-  va_start(ap, message_format);
-  ink_fatal_va(return_code, message_format, ap);
-  va_end(ap);
+  ink_die_die_die();
 }
 
 void
-ink_fatal_die(const char *message_format, ...)
+ink_fatal(const char *message_format, ...)
 {
   va_list ap;
   va_start(ap, message_format);
-  ink_fatal_va(1, message_format, ap);
+  ink_fatal_va(message_format, ap);
   va_end(ap);
 }
 
 /**
   This routine prints/logs an error message given the printf format
   string in message_format, and the optional arguments.  The current
-  errno is also printed.  The program is then terminated with return_code.
+  errno is also printed.
 
 */
 void
-ink_pfatal(int return_code, const char *message_format, ...)
+ink_pfatal(const char *message_format, ...)
 {
   va_list ap;
   char extended_format[4096], message[4096];
 
-  char *errno_string;
+  int errsav = errno;
+  const char * errno_string = strerror(errsav);
 
   va_start(ap, message_format);
-  errno_string = strerror(errno);
   snprintf(extended_format, sizeof(extended_format) - 1, "FATAL: %s <last errno = %d (%s)>",
-           message_format, errno, (errno_string == NULL ? "unknown" : errno_string));
+           message_format, errsav, (errno_string == NULL ? "unknown" : errno_string));
   extended_format[sizeof(extended_format) - 1] = 0;
   vsnprintf(message, sizeof(message) - 1, extended_format, ap);
   message[sizeof(message) - 1] = 0;
   fprintf(stderr, "%s\n", message);
   syslog(LOG_CRIT, "%s", message);
   va_end(ap);
-  ink_stack_trace_dump();
-  ink_die_die_die(return_code);
+
+  ink_die_die_die();
 }
 
 /**
@@ -214,36 +203,3 @@ ink_error(const char *message_format, ...)
   syslog(LOG_ERR, "%s", message);
   va_end(ap);
 }
-
-/**
-  This routine prints/logs a message given the printf format string in
-  message_format, and the optional arguments.
-
-*/
-void
-ink_dprintf(int debug_level, const char *message_format, ...)
-{
-  char message[4096];
-  va_list ap;
-  if (debug_level <= ink_dprintf_level) {
-    va_start(ap, message_format);
-    vsnprintf(message, sizeof(message) - 1, message_format, ap);
-    message[sizeof(message) - 1] = 0;
-    fprintf(stderr, "%s\n", message);
-    va_end(ap);
-  }
-}
-
-/**
-  Set output level for ink_dprintf() function. For debugging purposes
-  only!
-
-*/
-int
-ink_set_dprintf_level(int debug_level)
-{
-  int old_ink_dprintf_level = ink_dprintf_level;
-  if ((ink_dprintf_level = debug_level) < 0)
-    ink_dprintf_level = 0;
-  return old_ink_dprintf_level;
-}

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_error.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_error.h b/lib/ts/ink_error.h
index ce0211a..cd96d41 100644
--- a/lib/ts/ink_error.h
+++ b/lib/ts/ink_error.h
@@ -34,29 +34,17 @@
 
 #include <stdarg.h>
 #include "ink_platform.h"
-
 #include "ink_apidefs.h"
 
-#ifdef __cplusplus
-extern "C" {
-#endif                          /* __cplusplus */
-
-inkcoreapi void ink_fatal_va(int return_code, const char *message_format, va_list ap) TS_NORETURN;
-void ink_fatal(int return_code, const char *message_format, ...) TS_PRINTFLIKE(2, 3) TS_NORETURN;
-void ink_pfatal(int return_code, const char *message_format, ...) TS_PRINTFLIKE(2, 3) TS_NORETURN;
+void ink_fatal_va(const char *message_format, va_list ap) TS_NORETURN;
+void ink_fatal(const char *message_format, ...) TS_PRINTFLIKE(1, 2) TS_NORETURN;
+void ink_pfatal(const char *message_format, ...) TS_PRINTFLIKE(1, 2) TS_NORETURN;
 void ink_warning(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
 void ink_pwarning(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
 void ink_notice(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
 void ink_eprintf(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
 void ink_error(const char *message_format, ...) TS_PRINTFLIKE(1, 2);
-void ink_dprintf(int debug_level, const char *message_format, ...) TS_PRINTFLIKE(2, 3);
-void ink_fatal_die(const char *message_format, ...) TS_PRINTFLIKE(1, 2) TS_NORETURN;
 
-void ink_die_die_die(int retval) TS_NORETURN;
 int ink_set_dprintf_level(int debug_level);
 
-#ifdef __cplusplus
-}
-#endif                          /* __cplusplus */
-
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_hash_table.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_hash_table.cc b/lib/ts/ink_hash_table.cc
index 68b0dd9..e76a500 100644
--- a/lib/ts/ink_hash_table.cc
+++ b/lib/ts/ink_hash_table.cc
@@ -65,7 +65,7 @@ ink_hash_table_create(InkHashTableKeyType key_type)
   else if (key_type == InkHashTableKeyType_Word)
     tcl_key_type = TCL_ONE_WORD_KEYS;
   else
-    ink_fatal(1, "ink_hash_table_create: bad key_type %d", key_type);
+    ink_fatal("ink_hash_table_create: bad key_type %d", key_type);
 
   Tcl_InitHashTable(tcl_ht_ptr, tcl_key_type);
 
@@ -270,7 +270,7 @@ ink_hash_table_get_entry(InkHashTable *ht_ptr, const char *key, int *new_value)
   tcl_he_ptr = Tcl_CreateHashEntry(tcl_ht_ptr, key, new_value);
 
   if (tcl_he_ptr == NULL) {
-    ink_fatal(1, "%s: Tcl_CreateHashEntry returned NULL", "ink_hash_table_get_entry");
+    ink_fatal("%s: Tcl_CreateHashEntry returned NULL", "ink_hash_table_get_entry");
   }
 
   return ((InkHashTableEntry *) tcl_he_ptr);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_memory.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_memory.cc b/lib/ts/ink_memory.cc
index 764f71b..a996bad 100644
--- a/lib/ts/ink_memory.cc
+++ b/lib/ts/ink_memory.cc
@@ -49,7 +49,7 @@ ats_malloc(size_t size)
   if (likely(size > 0)) {
     if (unlikely((ptr = malloc(size)) == NULL)) {
       ink_stack_trace_dump();
-      ink_fatal(1, "ats_malloc: couldn't allocate %zu bytes", size);
+      ink_fatal("ats_malloc: couldn't allocate %zu bytes", size);
     }
   }
   return ptr;
@@ -61,7 +61,7 @@ ats_calloc(size_t nelem, size_t elsize)
   void *ptr = calloc(nelem, elsize);
   if (unlikely(ptr == NULL)) {
     ink_stack_trace_dump();
-    ink_fatal(1, "ats_calloc: couldn't allocate %zu %zu byte elements", nelem, elsize);
+    ink_fatal("ats_calloc: couldn't allocate %zu %zu byte elements", nelem, elsize);
   }
   return ptr;
 }                               /* End ats_calloc */
@@ -72,7 +72,7 @@ ats_realloc(void *ptr, size_t size)
   void *newptr = realloc(ptr, size);
   if (unlikely(newptr == NULL)) {
     ink_stack_trace_dump();
-    ink_fatal(1, "ats_realloc: couldn't reallocate %zu bytes", size);
+    ink_fatal("ats_realloc: couldn't reallocate %zu bytes", size);
   }
   return newptr;
 }                               /* End ats_realloc */
@@ -97,20 +97,20 @@ ats_memalign(size_t alignment, size_t size)
 
   if (unlikely(retcode)) {
     if (retcode == EINVAL) {
-      ink_fatal(1, "ats_memalign: couldn't allocate %zu bytes at alignment %zu - invalid
alignment parameter",
+      ink_fatal("ats_memalign: couldn't allocate %zu bytes at alignment %zu - invalid alignment
parameter",
                 size, alignment);
     } else if (retcode == ENOMEM) {
-      ink_fatal(1, "ats_memalign: couldn't allocate %zu bytes at alignment %zu - insufficient
memory",
+      ink_fatal("ats_memalign: couldn't allocate %zu bytes at alignment %zu - insufficient
memory",
                 size, alignment);
     } else {
-      ink_fatal(1, "ats_memalign: couldn't allocate %zu bytes at alignment %zu - unknown
error %d",
+      ink_fatal("ats_memalign: couldn't allocate %zu bytes at alignment %zu - unknown error
%d",
                 size, alignment, retcode);
     }
   }
 #else
   ptr = memalign(alignment, size);
   if (unlikely(ptr == NULL)) {
-    ink_fatal(1, "ats_memalign: couldn't allocate %zu bytes at alignment %zu",  size,  alignment);
+    ink_fatal("ats_memalign: couldn't allocate %zu bytes at alignment %zu",  size,  alignment);
   }
 #endif
   return ptr;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_queue.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue.cc b/lib/ts/ink_queue.cc
index 6203ecd..6741b9b 100644
--- a/lib/ts/ink_queue.cc
+++ b/lib/ts/ink_queue.cc
@@ -210,9 +210,9 @@ ink_freelist_new(InkFreeList * f)
 #ifdef SANITY
       if (result) {
         if (FREELIST_POINTER(item) == TO_PTR(FREELIST_POINTER(next)))
-          ink_fatal(1, "ink_freelist_new: loop detected");
+          ink_fatal("ink_freelist_new: loop detected");
         if (((uintptr_t) (TO_PTR(FREELIST_POINTER(next)))) & 3)
-          ink_fatal(1, "ink_freelist_new: bad list");
+          ink_fatal("ink_freelist_new: bad list");
         if (TO_PTR(FREELIST_POINTER(next)))
           fake_global_for_ink_queue = *(int *) TO_PTR(FREELIST_POINTER(next));
       }
@@ -268,9 +268,9 @@ ink_freelist_free(InkFreeList * f, void *item)
     INK_QUEUE_LD(h, f->head);
 #ifdef SANITY
     if (TO_PTR(FREELIST_POINTER(h)) == item)
-      ink_fatal(1, "ink_freelist_free: trying to free item twice");
+      ink_fatal("ink_freelist_free: trying to free item twice");
     if (((uintptr_t) (TO_PTR(FREELIST_POINTER(h)))) & 3)
-      ink_fatal(1, "ink_freelist_free: bad list");
+      ink_fatal("ink_freelist_free: bad list");
     if (TO_PTR(FREELIST_POINTER(h)))
       fake_global_for_ink_queue = *(int *) TO_PTR(FREELIST_POINTER(h));
 #endif /* SANITY */
@@ -325,9 +325,9 @@ ink_freelist_free_bulk(InkFreeList *f, void *head, void *tail, size_t
num_item)
     INK_QUEUE_LD(h, f->head);
 #ifdef SANITY
     if (TO_PTR(FREELIST_POINTER(h)) == head)
-      ink_fatal(1, "ink_freelist_free: trying to free item twice");
+      ink_fatal("ink_freelist_free: trying to free item twice");
     if (((uintptr_t) (TO_PTR(FREELIST_POINTER(h)))) & 3)
-      ink_fatal(1, "ink_freelist_free: bad list");
+      ink_fatal("ink_freelist_free: bad list");
     if (TO_PTR(FREELIST_POINTER(h)))
       fake_global_for_ink_queue = *(int *) TO_PTR(FREELIST_POINTER(h));
 #endif

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/lib/ts/ink_queue_ext.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_queue_ext.cc b/lib/ts/ink_queue_ext.cc
index 76ef902..ac99667 100644
--- a/lib/ts/ink_queue_ext.cc
+++ b/lib/ts/ink_queue_ext.cc
@@ -189,7 +189,7 @@ mmap_align(size_t size, size_t alignment) {
     const char *err_str = "Out of memory, or the process's maximum number of "
                           "mappings would have been exceeded(if so, you can "
                           "enlarge 'vm.max_map_count' by sysctl in linux).";
-    ink_fatal(1, "Failed to mmap %zu bytes, %s", size,
+    ink_fatal("Failed to mmap %zu bytes, %s", size,
               (errno == ENOMEM) ? err_str : strerror(errno));
   }
 
@@ -234,7 +234,7 @@ get_chunk_item_magic_idx(InkFreeList *f, void *item, InkChunkInfo **ppChunk,
   if (do_check && (idx >= f->chunk_size
                    || ((uintptr_t)item - chunk_addr) % f->type_size)) {
     ink_stack_trace_dump();
-    ink_fatal(1, "Invalid address:%p, chunk_addr:%p, type_size:%d, chunk_size:%u, idx:%u",
+    ink_fatal("Invalid address:%p, chunk_addr:%p, type_size:%d, chunk_size:%u, idx:%u",
               item, (void *)chunk_addr, f->type_size, f->chunk_size, idx);
   }
 
@@ -345,7 +345,7 @@ ink_chunk_delete(InkFreeList *f, InkThreadCache *pCache, InkChunkInfo
*pChunk)
 
   if (unlikely(munmap(chunk_addr, f->chunk_byte_size))) {
     ink_stack_trace_dump();
-    ink_fatal(1, "Failed to munmap %u bytes, %s", f->chunk_byte_size, strerror(errno));
+    ink_fatal("Failed to munmap %u bytes, %s", f->chunk_byte_size, strerror(errno));
   }
 
   ink_atomic_increment((int *)&f->allocated, -f->chunk_size);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 8af548e..fe3f3c6 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -1318,7 +1318,7 @@ change_uid_gid(const char * user)
 
 #if !defined(BIG_SECURITY_HOLE) || (BIG_SECURITY_HOLE != 0)
   if (getuid() == 0 || geteuid() == 0) {
-    ink_fatal_die(
+    ink_fatal(
       "Trafficserver has not been designed to serve pages while\n"
       "\trunning as root. There are known race conditions that\n"
       "\twill allow any local user to read any file on the system.\n"
@@ -1369,10 +1369,6 @@ main(int /* argc ATS_UNUSED */, char **argv)
   setbuf(stdout, NULL);
   setbuf(stdin, NULL);
 
-  // Set new debug output level (from command line arg)
-  // Only for debug purposes. We should do it as early as possible.
-  ink_set_dprintf_level(cmd_line_dprintf_level);
-
   // Bootstrap syslog.  Since we haven't read records.config
   //   yet we do not know where
   openlog("traffic_server", LOG_PID | LOG_NDELAY | LOG_NOWAIT, LOG_DAEMON);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/948b6af0/tools/jtest/jtest.cc
----------------------------------------------------------------------
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index 03ff69c..b3e083e 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -2582,7 +2582,7 @@ struct UrlHashTable {
       }
     } END_HASH_LOOP;
 
-    ink_fatal(1, "overview entries overflow");
+    ink_fatal("overview entries overflow");
   }
 
   void clear(uint64_t i) {


Mime
View raw message