trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From z..@apache.org
Subject git commit: TS-2202: remove manager error and fatal useless error message
Date Thu, 31 Oct 2013 15:10:14 GMT
Updated Branches:
  refs/heads/master e75d33a39 -> c2452f5fb


TS-2202: remove manager error and fatal useless error message

we should log errno and strerror(errno) only when errno != 0.
the errno parameter should pass by the caller.
functions mgmt_elog and mgmt_fatal changed


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

Branch: refs/heads/master
Commit: c2452f5fbfafab8291537ef8abd4ac2e75253c45
Parents: e75d33a
Author: Yu Qing <zhuangyuan@taobao.com>
Authored: Thu Oct 31 22:41:38 2013 +0800
Committer: Zhao Yongming <ming.zym@gmail.com>
Committed: Thu Oct 31 22:44:28 2013 +0800

----------------------------------------------------------------------
 mgmt/Alarms.cc                |   2 +-
 mgmt/FileManager.cc           |  12 ++--
 mgmt/LocalManager.cc          |  82 ++++++++++++------------
 mgmt/Main.cc                  |  70 ++++++++++-----------
 mgmt/ProcessManager.cc        |  24 +++----
 mgmt/Rollback.cc              |   8 +--
 mgmt/api/NetworkUtilsLocal.cc |  14 ++---
 mgmt/cluster/ClusterCom.cc    | 126 ++++++++++++++++++-------------------
 mgmt/cluster/VMap.cc          |  18 +++---
 mgmt/utils/MgmtUtils.cc       |  75 ++++++++++++----------
 mgmt/utils/MgmtUtils.h        |   8 +--
 mgmt/utils/WebMgmtUtils.cc    |   2 +-
 mgmt/web2/WebHttp.cc          |   2 +-
 mgmt/web2/WebIntrMain.cc      |  26 ++++----
 14 files changed, 240 insertions(+), 229 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/Alarms.cc
----------------------------------------------------------------------
diff --git a/mgmt/Alarms.cc b/mgmt/Alarms.cc
index cbf2dc0..16c4149 100644
--- a/mgmt/Alarms.cc
+++ b/mgmt/Alarms.cc
@@ -523,7 +523,7 @@ Alarms::execAlarmBin(const char *desc)
   if ((pid = fork1()) < 0)
 #endif
   {
-    mgmt_elog(stderr, "[Alarms::execAlarmBin] Unable to fork1 process\n");
+    mgmt_elog(stderr, errno, "[Alarms::execAlarmBin] Unable to fork1 process\n");
   } else if (pid > 0) {         /* Parent */
     // INKqa11769
     bool script_done = false;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/FileManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/FileManager.cc b/mgmt/FileManager.cc
index 7ae2265..33cafe7 100644
--- a/mgmt/FileManager.cc
+++ b/mgmt/FileManager.cc
@@ -67,7 +67,7 @@ FileManager::FileManager()
   ink_mutex_init(&cbListLock, "File Changed Callback Mutex");
 
   if (varStrFromName("proxy.config.config_dir", configTmp, sizeof(configTmp)) == false) {
-    mgmt_fatal(stderr,
+    mgmt_fatal(stderr, 0,
                "[FileManager::FileManager] Unable to find configuration directory from proxy.config.config_dir\n");
   }
   if (configTmp[0] != '/') {
@@ -77,9 +77,9 @@ FileManager::FileManager()
   if (access(configTmp, R_OK) == -1) {
     ink_strlcpy(configTmp, system_config_directory,sizeof(configTmp));
     if (access(configTmp, R_OK) == -1) {
-        mgmt_elog("[FileManager::FileManager] unable to access() directory '%s': %d, %s\n",
+        mgmt_elog(0, "[FileManager::FileManager] unable to access() directory '%s': %d, %s\n",
                 mgmt_path, errno, strerror(errno));
-        mgmt_elog("[FileManager::FileManager] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
+        mgmt_elog(0, "[FileManager::FileManager] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
         _exit(1);
     }
   }
@@ -98,7 +98,7 @@ FileManager::FileManager()
   if (access(snapshotDir, F_OK) == -1) {
     if (mkdir(snapshotDir, DIR_MODE) < 0) {
       // Failed to create the snapshot directory
-      mgmt_fatal(stderr, "[FileManager::FileManager] Failed to create the snapshot directory %s: %s\n", snapshotDir, strerror(errno));
+      mgmt_fatal(stderr, 0, "[FileManager::FileManager] Failed to create the snapshot directory %s: %s\n", snapshotDir, strerror(errno));
     }
   }
 }
@@ -349,7 +349,7 @@ FileManager::abortRestore(const char *abortTo)
 
     currentVersion = bind->rb->getCurrentVersion();
     if (bind->rb->revertToVersion_ml(currentVersion - 1) != OK_ROLLBACK) {
-      mgmt_fatal(stderr,
+      mgmt_fatal(stderr, 0,
                  "[FileManager::abortRestore] Unable to abort a failed snapshot restore.  Configuration files have been left in a inconsistent state\n");
     }
   }
@@ -708,7 +708,7 @@ FileManager::WalkSnaps(ExpandingArray * snapList)
   //ink_assert(found);
 
   if (varStrFromName("proxy.config.config_dir", config_dir, 256) == false) {
-    mgmt_fatal(stderr,
+    mgmt_fatal(stderr, 0,
                "[FileManager::FileManager] Unable to find configuration directory from proxy.config.config_dir\n");
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index 56f3f9e..12adb34 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -241,9 +241,9 @@ LocalManager::LocalManager(char * /* mpath ATS_UNUSED */, bool proxy_on)
   if (access(absolute_config_path, R_OK) == -1) {
     config_path = ats_strdup(system_config_directory);
     if (access(config_path, R_OK) == -1) {
-        mgmt_elog("[LocalManager::LocalManager] unable to access() directory '%s': %d, %s\n",
+        mgmt_elog(0, "[LocalManager::LocalManager] unable to access() directory '%s': %d, %s\n",
                 config_path, errno, strerror(errno));
-        mgmt_fatal("[LocalManager::LocalManager] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
+        mgmt_fatal(0, "[LocalManager::LocalManager] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
     }
   } else {
     config_path = absolute_config_path;
@@ -294,9 +294,9 @@ LocalManager::LocalManager(char * /* mpath ATS_UNUSED */, bool proxy_on)
     absolute_proxy_binary = Layout::relative_to(Layout::get()->bindir, proxy_binary);
     // coverity[fs_check_call]
     if (access(absolute_proxy_binary, R_OK | X_OK) == -1) {
-        mgmt_elog("[LocalManager::LocalManager] Unable to access() '%s': %d, %s\n",
+        mgmt_elog(0, "[LocalManager::LocalManager] Unable to access() '%s': %d, %s\n",
                 absolute_proxy_binary, errno, strerror(errno));
-        mgmt_fatal("[LocalManager::LocalManager] please set bin path 'proxy.config.bin_path' \n");
+        mgmt_fatal(0, "[LocalManager::LocalManager] please set bin path 'proxy.config.bin_path' \n");
     }
   }
 
@@ -333,7 +333,7 @@ LocalManager::initCCom(int mcport, char *addr, int rsport)
   char *envBuf;
 
   if (gethostname(hostname, 1024) < 0) {
-    mgmt_fatal(stderr, "[LocalManager::initCCom] gethostname failed\n");
+    mgmt_fatal(stderr, errno, "[LocalManager::initCCom] gethostname failed\n");
   }
   // Fetch which interface we are using for clustering
   intrName = REC_readString("proxy.config.cluster.ethernet_interface", &found);
@@ -341,9 +341,9 @@ LocalManager::initCCom(int mcport, char *addr, int rsport)
 
   found = mgmt_getAddrForIntr(intrName, &cluster_ip.sa);
   if (found == false) {
-    mgmt_fatal(stderr, "[LocalManager::initCCom] Unable to find network interface %s.  Exiting...\n", intrName);
+    mgmt_fatal(stderr, 0, "[LocalManager::initCCom] Unable to find network interface %s.  Exiting...\n", intrName);
   } else if (!ats_is_ip4(&cluster_ip)) {
-    mgmt_fatal(stderr, "[LocalManager::initCCom] Unable to find IPv4 network interface %s.  Exiting...\n", intrName);
+    mgmt_fatal(stderr, 0, "[LocalManager::initCCom] Unable to find IPv4 network interface %s.  Exiting...\n", intrName);
   }
 
   ats_ip_ntop(&cluster_ip, clusterAddrStr, sizeof(clusterAddrStr));
@@ -398,11 +398,11 @@ LocalManager::initMgmtProcessServer()
   snprintf(fpath, sizeof(fpath), "%s/%s", pserver_path, LM_CONNECTION_SERVER);
   unlink(fpath);
   if ((process_server_sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
-    mgmt_fatal(stderr, "[LocalManager::initMgmtProcessServer] Unable to open socket exiting\n");
+    mgmt_fatal(stderr, errno, "[LocalManager::initMgmtProcessServer] Unable to open socket exiting\n");
   }
 
   if (fcntl(process_server_sockfd, F_SETFD, 1) < 0) {
-    mgmt_fatal(stderr, "[LocalManager::initMgmtProcessServer] Unable to set close-on-exec\n");
+    mgmt_fatal(stderr, errno, "[LocalManager::initMgmtProcessServer] Unable to set close-on-exec\n");
   }
 
   memset(&serv_addr, 0, sizeof(serv_addr));
@@ -414,15 +414,15 @@ LocalManager::initMgmtProcessServer()
   servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family);
 #endif
   if (setsockopt(process_server_sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
-    mgmt_fatal(stderr, "[LocalManager::initMgmtProcessServer] Unable to set socket options.\n");
+    mgmt_fatal(stderr, errno, "[LocalManager::initMgmtProcessServer] Unable to set socket options.\n");
   }
 
   if ((bind(process_server_sockfd, (struct sockaddr *) &serv_addr, servlen)) < 0) {
-    mgmt_fatal(stderr, "[LocalManager::initMgmtProcessServer] Unable to bind '%s' socket exiting\n", fpath);
+    mgmt_fatal(stderr, errno, "[LocalManager::initMgmtProcessServer] Unable to bind '%s' socket exiting\n", fpath);
   }
 
   if ((listen(process_server_sockfd, 5)) < 0) {
-    mgmt_fatal(stderr, "[LocalManager::initMgmtProcessServer] Unable to listen on socket exiting\n");
+    mgmt_fatal(stderr, errno, "[LocalManager::initMgmtProcessServer] Unable to listen on socket exiting\n");
   }
 
   RecSetRecordInt("proxy.node.restarts.manager.start_time", manager_started_at);
@@ -484,7 +484,7 @@ LocalManager::pollMgmtProcessServer()
         mgmt_log(stderr, "[LocalManager::pollMgmtProcessServer] New process connecting fd '%d'\n", new_sockfd);
 
         if (new_sockfd < 0) {
-          mgmt_elog(stderr, "[LocalManager::pollMgmtProcessServer] ==> ");
+          mgmt_elog(stderr, errno, "[LocalManager::pollMgmtProcessServer] ==> ");
         } else if (!processRunning()) {
           watched_process_fd = new_sockfd;
           data_len = sizeof(mgmt_sync_key);
@@ -493,7 +493,7 @@ LocalManager::pollMgmtProcessServer()
           mh->data_len = data_len;
           memcpy((char *) mh + sizeof(MgmtMessageHdr), &mgmt_sync_key, data_len);
           if (mgmt_write_pipe(new_sockfd, (char *) mh, sizeof(MgmtMessageHdr) + data_len) <= 0) {
-            mgmt_elog("[LocalManager::pollMgmtProcessServer] Error writing sync key message!\n");
+            mgmt_elog(errno, "[LocalManager::pollMgmtProcessServer] Error writing sync key message!\n");
             close_socket(new_sockfd);
             watched_process_fd = watched_process_pid = -1;
           }
@@ -517,10 +517,10 @@ LocalManager::pollMgmtProcessServer()
           if ((res = mgmt_read_pipe(watched_process_fd, data_raw, mh_hdr.data_len)) > 0) {
             handleMgmtMsgFromProcesses(mh_full);
           } else if (res < 0) {
-            mgmt_fatal("[LocalManager::pollMgmtProcessServer] Error in read (errno: %d)\n", -res);
+            mgmt_fatal(0, "[LocalManager::pollMgmtProcessServer] Error in read (errno: %d)\n", -res);
           }
         } else if (res < 0) {
-          mgmt_fatal("[LocalManager::pollMgmtProcessServer] Error in read (errno: %d)\n", -res);
+          mgmt_fatal(0, "[LocalManager::pollMgmtProcessServer] Error in read (errno: %d)\n", -res);
         }
         // handle EOF
         if (res == 0) {
@@ -534,12 +534,12 @@ LocalManager::pollMgmtProcessServer()
           waitpid(watched_process_pid, &estatus, 0);    /* Reap child */
           if (WIFSIGNALED(estatus)) {
             int sig = WTERMSIG(estatus);
-            mgmt_elog(stderr, "[LocalManager::pollMgmtProcessServer] "
+            mgmt_elog(stderr, 0, "[LocalManager::pollMgmtProcessServer] "
                       "Server Process terminated due to Sig %d: %s\n", sig, strsignal(sig));
           }
 
           if (lmgmt->run_proxy) {
-            mgmt_elog("[Alarms::signalAlarm] Server Process was reset\n");
+            mgmt_elog(0, "[Alarms::signalAlarm] Server Process was reset\n");
             lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_PROXY_PROCESS_DIED);
           } else {
             mgmt_log("[TrafficManager] Server process shutdown\n");
@@ -559,7 +559,7 @@ LocalManager::pollMgmtProcessServer()
       ink_assert(num == 0);     /* Invariant */
 
     } else if (num < 0) {       /* Error */
-      mgmt_elog(stderr, "[LocalManager::pollMgmtProcessServer] select failed or was interrupted (%d)\n", errno);
+      mgmt_elog(stderr, 0, "[LocalManager::pollMgmtProcessServer] select failed or was interrupted (%d)\n", errno);
     }
 
   }
@@ -673,7 +673,7 @@ LocalManager::handleMgmtMsgFromProcesses(MgmtMessageHdr * mh)
       case MGMT_STRING:
       case MGMT_INVALID:
       default:
-        mgmt_elog(stderr,
+        mgmt_elog(stderr, 0,
                   "[LocalManager::handleMgmtMsgFromProcesses] " "Invalid plugin set-config msg '%s'\n", data_raw);
         break;
       }
@@ -766,14 +766,14 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr * mh)
     if (RecGetRecordType(data_raw, &rec_type) == REC_ERR_OKAY && rec_type == RECT_CONFIG) {
       RecSetSyncRequired(data_raw);
     } else {
-      mgmt_elog(stderr, "[LocalManager:sendMgmtMsgToProcesses] Unknown file change: '%s'\n", data_raw);
+      mgmt_elog(stderr, 0, "[LocalManager:sendMgmtMsgToProcesses] Unknown file change: '%s'\n", data_raw);
     }
     ink_assert(found);
     if (!(configFiles->getRollbackObj(fname, &rb)) &&
         (strcmp(data_raw, "proxy.config.cluster.cluster_configuration") != 0) &&
         (strcmp(data_raw, "proxy.config.arm.acl_filename_master") != 0) &&
         (strcmp(data_raw, "proxy.config.body_factory.template_sets_dir") != 0)) {
-      mgmt_elog(stderr, "[LocalManager::sendMgmtMsgToProcesses] "
+      mgmt_elog(stderr, 0, "[LocalManager::sendMgmtMsgToProcesses] "
                 "Invalid 'data_raw' for MGMT_EVENT_CONFIG_FILE_UPDATE\n");
       ink_assert(false);
     }
@@ -800,15 +800,15 @@ LocalManager::sendMgmtMsgToProcesses(MgmtMessageHdr * mh)
       if (check_prev_pid == check_current_pid) {
         check_current_pid = -1;
         int lerrno = errno;
-        mgmt_elog(stderr, "[LocalManager::sendMgmtMsgToProcesses] Error writing message\n");
+        mgmt_elog(stderr, errno, "[LocalManager::sendMgmtMsgToProcesses] Error writing message\n");
         if (lerrno == ECONNRESET || lerrno == EPIPE) {  // Connection closed by peer or Broken pipe
           if ((kill(watched_process_pid, 0) < 0) && (errno == ESRCH)) {
             // TS is down
             pid_t tmp_pid = watched_process_pid;
             close_socket(watched_process_fd);
-            mgmt_elog(stderr, "[LocalManager::pollMgmtProcessServer] " "Server Process has been terminated\n");
+            mgmt_elog(stderr, 0, "[LocalManager::pollMgmtProcessServer] " "Server Process has been terminated\n");
             if (lmgmt->run_proxy) {
-              mgmt_elog("[Alarms::signalAlarm] Server Process was reset\n");
+              mgmt_elog(0, "[Alarms::signalAlarm] Server Process was reset\n");
               lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_PROXY_PROCESS_DIED);
             } else {
               mgmt_log("[TrafficManager] Server process shutdown\n");
@@ -899,7 +899,7 @@ LocalManager::processEventQueue()
       if (!(strcmp(data_raw, "records.config"))) {
         bool incVersion = mh->msg_id == MGMT_EVENT_CONFIG_FILE_UPDATE;
         if (RecReadConfigFile(incVersion) != REC_ERR_OKAY) {
-          mgmt_elog(stderr, "[fileUpdated] Config update failed for records.config\n");
+          mgmt_elog(stderr, errno, "[fileUpdated] Config update failed for records.config\n");
         }
         handled_by_mgmt = true;
       }
@@ -939,13 +939,13 @@ LocalManager::startProxy()
   // the traffic server binary along with it's execute permmissions
   if (access(absolute_proxy_binary, F_OK) < 0) {
     // Error can't find traffic_server
-    mgmt_elog(stderr, "[LocalManager::startProxy] Unable to find traffic server at %s\n", absolute_proxy_binary);
+    mgmt_elog(stderr, errno, "[LocalManager::startProxy] Unable to find traffic server at %s\n", absolute_proxy_binary);
     return false;
   }
   // traffic server binary exists, check permissions
   else if (access(absolute_proxy_binary, R_OK | X_OK) < 0) {
     // Error don't have proper permissions
-    mgmt_elog(stderr, "[LocalManager::startProxy] Unable to access %s due to bad permisssions \n",
+    mgmt_elog(stderr, errno, "[LocalManager::startProxy] Unable to access %s due to bad permisssions \n",
               absolute_proxy_binary);
     return false;
   }
@@ -957,7 +957,7 @@ LocalManager::startProxy()
     if ((pid = fork1()) < 0)
 #endif
     {
-      mgmt_elog(stderr, "[LocalManager::startProxy] Unable to fork1 prep process\n");
+      mgmt_elog(stderr, errno, "[LocalManager::startProxy] Unable to fork1 prep process\n");
       return false;
     } else if (pid > 0) {
       int estatus;
@@ -977,7 +977,7 @@ LocalManager::startProxy()
   if ((pid = fork1()) < 0)
 #endif
   {
-    mgmt_elog(stderr, "[LocalManager::startProxy] Unable to fork1 process\n");
+    mgmt_elog(stderr, errno, "[LocalManager::startProxy] Unable to fork1 process\n");
     return false;
   } else if (pid > 0) {         /* Parent */
     proxy_launch_pid = pid;
@@ -1037,11 +1037,11 @@ LocalManager::startProxy()
     }
 
     if (!strstr(proxy_options, "-M")) { // Make sure we're starting the proxy in mgmt mode
-      mgmt_fatal(stderr, "[LocalManager::startProxy] ts options must contain -M");
+      mgmt_fatal(stderr, 0, "[LocalManager::startProxy] ts options must contain -M");
     }
 
     res = execv(absolute_proxy_binary, options);
-    mgmt_elog(stderr, "[LocalManager::startProxy] Exec of %s failed\n", absolute_proxy_binary);
+    mgmt_elog(stderr, errno, "[LocalManager::startProxy] Exec of %s failed\n", absolute_proxy_binary);
     _exit(res);
   }
   return true;
@@ -1085,7 +1085,7 @@ LocalManager::listenForProxy()
     }
 
     if ((listen(p.m_fd, backlog)) < 0) {
-      mgmt_fatal(stderr, "[LocalManager::listenForProxy] Unable to listen on socket: %d\n", p.m_port);
+      mgmt_fatal(stderr, errno, "[LocalManager::listenForProxy] Unable to listen on socket: %d\n", p.m_port);
     }
     mgmt_log(stderr, "[LocalManager::listenForProxy] Listening on port: %d\n", p.m_port);
   }
@@ -1109,7 +1109,7 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
 
   if (port.m_port < 1024 && euid != 0) {
     if (restoreRootPriv(&saved_euid) == false) {
-      mgmt_elog(stderr, "[bindProxyPort] Unable to get root priviledges to bind port %d. euid is %d.  Exiting\n",
+      mgmt_elog(stderr, 0, "[bindProxyPort] Unable to get root priviledges to bind port %d. euid is %d.  Exiting\n",
                 port.m_port, euid);
       _exit(0);
     } else {
@@ -1120,7 +1120,7 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
 
   /* Setup reliable connection, for large config changes */
   if ((port.m_fd = socket(port.m_family, SOCK_STREAM, 0)) < 0) {
-    mgmt_elog(stderr, "[bindProxyPort] Unable to create socket : %s\n", strerror(errno));
+    mgmt_elog(stderr, 0, "[bindProxyPort] Unable to create socket : %s\n", strerror(errno));
     _exit(1);
   }
 
@@ -1137,11 +1137,11 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
 
   if (port.m_family == AF_INET6) {
     if (setsockopt(port.m_fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int)) < 0) {
-      mgmt_elog(stderr, "[bindProxyPort] Unable to set socket options: %d : %s\n", port.m_port, strerror(errno));
+      mgmt_elog(stderr, 0, "[bindProxyPort] Unable to set socket options: %d : %s\n", port.m_port, strerror(errno));
     }
   }
   if (setsockopt(port.m_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
-    mgmt_elog(stderr, "[bindProxyPort] Unable to set socket options: %d : %s\n", port.m_port, strerror(errno));
+    mgmt_elog(stderr, 0, "[bindProxyPort] Unable to set socket options: %d : %s\n", port.m_port, strerror(errno));
     _exit(1);
   }
 
@@ -1149,7 +1149,7 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
 #if TS_USE_TPROXY
     Debug("http_tproxy", "Listen port %d inbound transparency enabled.\n", port.m_port);
     if (setsockopt(port.m_fd, SOL_IP, TS_IP_TRANSPARENT, &one, sizeof(one)) == -1) {
-      mgmt_elog(stderr, "[bindProxyPort] Unable to set transparent socket option [%d] %s\n", errno, strerror(errno));
+      mgmt_elog(stderr, 0, "[bindProxyPort] Unable to set transparent socket option [%d] %s\n", errno, strerror(errno));
       _exit(1);
     }
 #else
@@ -1167,12 +1167,12 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
     if (m_inbound_ip4.isValid()) ip.assign(m_inbound_ip4);
     else ip.setToAnyAddr(AF_INET);
   } else {
-    mgmt_elog(stderr, "[bindProxyPort] Proxy port with invalid address type %d\n", port.m_family);
+    mgmt_elog(stderr, 0, "[bindProxyPort] Proxy port with invalid address type %d\n", port.m_family);
     _exit(1);
   }
   ip.port() = htons(port.m_port);
   if (bind(port.m_fd, &ip.sa, ats_ip_size(&ip)) < 0) {
-    mgmt_elog(stderr, "[bindProxyPort] Unable to bind socket: %d : %s\n", port.m_port, strerror(errno));
+    mgmt_elog(stderr, 0, "[bindProxyPort] Unable to bind socket: %d : %s\n", port.m_port, strerror(errno));
     _exit(1);
   }
 
@@ -1182,7 +1182,7 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
   if (port.m_port < 1024 && euid != 0) {
     if (privBoost == true) {
       if (removeRootPriv(saved_euid) == false) {
-        mgmt_elog(stderr, "[bindProxyPort] Unable to reset permissions to euid %d.  Exiting...\n", getuid());
+        mgmt_elog(stderr, 0, "[bindProxyPort] Unable to reset permissions to euid %d.  Exiting...\n", getuid());
         _exit(1);
       }
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index f752220..8dde9b6 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -132,10 +132,10 @@ check_lockfile()
 #else
       fprintf(stderr, "FATAL: Lockfile '%s' says server already running as PID %d\n", lockfile, holding_pid);
 #endif
-      mgmt_elog(stderr, "FATAL: Lockfile '%s' says server already running as PID %d\n", lockfile, holding_pid);
+      mgmt_elog(stderr, 0, "FATAL: Lockfile '%s' says server already running as PID %d\n", lockfile, holding_pid);
     } else {
       fprintf(stderr, "FATAL: Can't open server lockfile '%s' (%s)\n", lockfile, (reason ? reason : "Unknown Reason"));
-      mgmt_elog(stderr, "FATAL: Can't open server lockfile '%s' (%s)\n",
+      mgmt_elog(stderr, 0, "FATAL: Can't open server lockfile '%s' (%s)\n",
                 lockfile, (reason ? reason : "Unknown Reason"));
     }
     exit(1);
@@ -150,17 +150,17 @@ check_lockfile()
   if (err != 1) {
     char *reason = strerror(-err);
     fprintf(stderr, "FATAL: Can't acquire manager lockfile '%s'", lockfile);
-    mgmt_elog(stderr, "FATAL: Can't acquire manager lockfile '%s'", lockfile);
+    mgmt_elog(stderr, 0, "FATAL: Can't acquire manager lockfile '%s'", lockfile);
     if (err == 0) {
 #if defined(solaris)
       fprintf(stderr, " (Lock file held by process ID %d)\n", (int)holding_pid);
 #else
       fprintf(stderr, " (Lock file held by process ID %d)\n", holding_pid);
 #endif
-      mgmt_elog(stderr, " (Lock file held by process ID %d)\n", holding_pid);
+      mgmt_elog(stderr, 0, " (Lock file held by process ID %d)\n", holding_pid);
     } else if (reason) {
       fprintf(stderr, " (%s)\n", reason);
-      mgmt_elog(stderr, " (%s)\n", reason);
+      mgmt_elog(stderr, 0, " (%s)\n", reason);
     } else {
       fprintf(stderr, "\n");
     }
@@ -278,8 +278,8 @@ init_dirs()
   REC_ReadConfigString(buf, "proxy.config.config_dir", PATH_NAME_MAX);
   Layout::get()->relative(system_config_directory, PATH_NAME_MAX, buf);
   if (access(system_config_directory, R_OK) == -1) {
-    mgmt_elog("unable to access() config dir '%s': %d, %s\n", system_config_directory, errno, strerror(errno));
-    mgmt_elog("please set config path via 'proxy.config.config_dir' \n");
+    mgmt_elog(0, "unable to access() config dir '%s': %d, %s\n", system_config_directory, errno, strerror(errno));
+    mgmt_elog(0, "please set config path via 'proxy.config.config_dir' \n");
     _exit(1);
   }
 
@@ -288,16 +288,16 @@ init_dirs()
   REC_ReadConfigString(buf, "proxy.config.local_state_dir", PATH_NAME_MAX);
   Layout::get()->relative(system_runtime_dir, PATH_NAME_MAX, buf);
   if (access(system_runtime_dir, R_OK) == -1) {
-    mgmt_elog("unable to access() local state dir '%s': %d, %s\n", system_runtime_dir, errno, strerror(errno));
-    mgmt_elog("please set 'proxy.config.local_state_dir'\n");
+    mgmt_elog(0, "unable to access() local state dir '%s': %d, %s\n", system_runtime_dir, errno, strerror(errno));
+    mgmt_elog(0, "please set 'proxy.config.local_state_dir'\n");
     _exit(1);
   }
 
   REC_ReadConfigString(buf, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
   Layout::get()->relative(system_log_dir, PATH_NAME_MAX, buf);
   if (access(system_log_dir, W_OK) == -1) {
-    mgmt_elog("unable to access() log dir'%s': %d, %s\n", system_log_dir, errno, strerror(errno));
-    mgmt_elog("please set 'proxy.config.log.logfile_dir'\n");
+    mgmt_elog(0, "unable to access() log dir'%s': %d, %s\n", system_log_dir, errno, strerror(errno));
+    mgmt_elog(0, "please set 'proxy.config.log.logfile_dir'\n");
     _exit(1);
   }
 }
@@ -307,8 +307,8 @@ chdir_root()
 {
 
   if (system_root_dir[0] && (chdir(system_root_dir) < 0)) {
-    mgmt_elog("unable to change to root directory \"%s\" [%d '%s']\n", system_root_dir, errno, strerror(errno));
-    mgmt_elog(" please set correct path in env variable TS_ROOT \n");
+    mgmt_elog(0, "unable to change to root directory \"%s\" [%d '%s']\n", system_root_dir, errno, strerror(errno));
+    mgmt_elog(0, " please set correct path in env variable TS_ROOT \n");
     exit(1);
   } else {
     mgmt_log("[TrafficManager] using root directory '%s'\n",system_root_dir);
@@ -357,7 +357,7 @@ Errata_Logger(ts::Errata const& err) {
     while (n && (buff[n-1] == '\n' || buff[n-1] == '\r'))
       buff[--n] = 0;
     // log it.
-    if (code > 1) mgmt_elog("[WCCP]%s", buff);
+    if (code > 1) mgmt_elog(0, "[WCCP]%s", buff);
     else if (code > 0) mgmt_log("[WCCP]%s", buff);
     else Debug("WCCP", "%s", buff);
   }
@@ -627,13 +627,13 @@ main(int argc, char **argv)
     ink_assert(found);
 
     if (!found) {
-      mgmt_elog("Could not read %s.  Defaulting to DAEMON\n", sys_var);
+      mgmt_elog(0, "Could not read %s.  Defaulting to DAEMON\n", sys_var);
       facility_int = LOG_DAEMON;
     } else {
       facility_int = facility_string_to_int(facility_str);
       ats_free(facility_str);
       if (facility_int < 0) {
-        mgmt_elog("Bad syslog facility specified.  Defaulting to DAEMON\n");
+        mgmt_elog(0, "Bad syslog facility specified.  Defaulting to DAEMON\n");
         facility_int = LOG_DAEMON;
       }
     }
@@ -709,7 +709,7 @@ main(int argc, char **argv)
   in_addr_t group_addr_ip = inet_network(group_addr);
 
   if (!(min_ip < group_addr_ip && group_addr_ip < max_ip)) {
-    mgmt_fatal("[TrafficManager] Multi-Cast group addr '%s' is not in the permitted range of %s\n",
+    mgmt_fatal(0, "[TrafficManager] Multi-Cast group addr '%s' is not in the permitted range of %s\n",
                group_addr, "224.0.1.0 - 239.255.255.255");
   }
 
@@ -835,8 +835,8 @@ SignalAlrmHandler(int /* sig ATS_UNUSED */)
 #endif
 {
   /*
-     fprintf(stderr,"[TrafficManager] ==> SIGALRM received\n");
-     mgmt_elog(stderr,"[TrafficManager] ==> SIGALRM received\n");
+     fprintf(stderr, "[TrafficManager] ==> SIGALRM received\n");
+     mgmt_elog(stderr, 0, "[TrafficManager] ==> SIGALRM received\n");
    */
 #if !defined(linux) && !defined(freebsd) && !defined(darwin)
   if (t) {
@@ -846,10 +846,10 @@ SignalAlrmHandler(int /* sig ATS_UNUSED */)
 #else
       fprintf(stderr, "[TrafficManager] ==> User Alarm from pid: %d uid: %d\n", t->si_pid, t->si_uid);
 #endif
-      mgmt_elog(stderr, "[TrafficManager] ==> User Alarm from pid: %d uid: %d\n", t->si_pid, t->si_uid);
+      mgmt_elog(stderr, 0, "[TrafficManager] ==> User Alarm from pid: %d uid: %d\n", t->si_pid, t->si_uid);
     } else {
       fprintf(stderr, "[TrafficManager] ==> Kernel Alarm Reason: %d\n", t->si_code);
-      mgmt_elog(stderr, "[TrafficManager] ==> Kernel Alarm Reason: %d\n", t->si_code);
+      mgmt_elog(stderr, 0, "[TrafficManager] ==> Kernel Alarm Reason: %d\n", t->si_code);
     }
   }
 #endif
@@ -877,10 +877,10 @@ SignalHandler(int sig)
 #else
       fprintf(stderr, "[TrafficManager] ==> User Sig %d from pid: %d uid: %d\n", sig, t->si_pid, t->si_uid);
 #endif
-      mgmt_elog(stderr, "[TrafficManager] ==> User Sig %d from pid: %d uid: %d\n", sig, t->si_pid, t->si_uid);
+      mgmt_elog(stderr, 0, "[TrafficManager] ==> User Sig %d from pid: %d uid: %d\n", sig, t->si_pid, t->si_uid);
     } else {
       fprintf(stderr, "[TrafficManager] ==> Kernel Sig %d; Reason: %d\n", sig, t->si_code);
-      mgmt_elog(stderr, "[TrafficManager] ==> Kernel Sig %d; Reason: %d\n", sig, t->si_code);
+      mgmt_elog(stderr, 0, "[TrafficManager] ==> Kernel Sig %d; Reason: %d\n", sig, t->si_code);
     }
   }
 #endif
@@ -896,7 +896,7 @@ SignalHandler(int sig)
     return;
   }
   fprintf(stderr, "[TrafficManager] ==> Cleaning up and reissuing signal #%d\n", sig);
-  mgmt_elog(stderr, "[TrafficManager] ==> Cleaning up and reissuing signal #%d\n", sig);
+  mgmt_elog(stderr, 0, "[TrafficManager] ==> Cleaning up and reissuing signal #%d\n", sig);
 
   if (lmgmt && !clean) {
     clean = 1;
@@ -926,11 +926,11 @@ SignalHandler(int sig)
     abort();
   default:
     fprintf(stderr, "[TrafficManager] ==> signal #%d\n", sig);
-    mgmt_elog(stderr, "[TrafficManager] ==> signal #%d\n", sig);
+    mgmt_elog(stderr, 0, "[TrafficManager] ==> signal #%d\n", sig);
     _exit(sig);
   }
   fprintf(stderr, "[TrafficManager] ==> signal2 #%d\n", sig);
-  mgmt_elog(stderr, "[TrafficManager] ==> signal2 #%d\n", sig);
+  mgmt_elog(stderr, 0, "[TrafficManager] ==> signal2 #%d\n", sig);
   _exit(sig);
 }                               /* End SignalHandler */
 
@@ -1063,7 +1063,7 @@ fileUpdated(char *fname, bool incVersion)
   } else if (strcmp(fname, "prefetch.config") == 0) {
     lmgmt->signalFileChange("proxy.config.prefetch.config_file");
   } else {
-    mgmt_elog(stderr, "[fileUpdated] Unknown config file updated '%s'\n", fname);
+    mgmt_elog(stderr, 0, "[fileUpdated] Unknown config file updated '%s'\n", fname);
 
   }
   return;
@@ -1133,7 +1133,7 @@ runAsUser(char *userName)
 
 
     if (userName == NULL || userName[0] == '\0') {
-      mgmt_elog(stderr, "[runAsUser] Fatal Error: proxy.config.admin.user_id is not set\n", userName, strerror(errno));
+      mgmt_elog(stderr, 0, "[runAsUser] Fatal Error: proxy.config.admin.user_id is not set\n");
       _exit(1);
     }
 
@@ -1159,12 +1159,12 @@ runAsUser(char *userName)
     }
 
     if (result == NULL) {
-      mgmt_elog(stderr, "[runAsUser] Fatal Error: Unable to get info about user %s : %s\n", userName, strerror(errno));
+      mgmt_elog(stderr, 0, "[runAsUser] Fatal Error: Unable to get info about user %s : %s\n", userName, strerror(errno));
       _exit(1);
     }
 
     if (setegid(result->pw_gid) != 0 || seteuid(result->pw_uid) != 0) {
-      mgmt_elog(stderr, "[runAsUser] Fatal Error: Unable to switch to user %s : %s\n", userName, strerror(errno));
+      mgmt_elog(stderr, 0, "[runAsUser] Fatal Error: Unable to switch to user %s : %s\n", userName, strerror(errno));
       _exit(1);
     }
 
@@ -1175,7 +1175,7 @@ runAsUser(char *userName)
     Debug("lm", "[runAsUser] Running with uid: '%d' euid: '%d'\n", uid, euid);
 
     if (uid != result->pw_uid && euid != result->pw_uid) {
-      mgmt_elog(stderr, "[runAsUser] Fatal Error: Failed to switch to user %s\n", userName);
+      mgmt_elog(stderr, 0, "[runAsUser] Fatal Error: Failed to switch to user %s\n", userName);
       _exit(1);
     }
 
@@ -1186,7 +1186,7 @@ runAsUser(char *userName)
 
 #if TS_USE_POSIX_CAP
     if (0 != restoreCapabilities()) {
-      mgmt_elog(stderr, "[runAsUser] Error: Failed to restore capabilities after switch to user %s.\n", userName);
+      mgmt_elog(stderr, 0, "[runAsUser] Error: Failed to restore capabilities after switch to user %s.\n", userName);
     }
 #endif
 
@@ -1217,7 +1217,7 @@ extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *f
     if (!(fin = fopen(file, "r"))) {
       ink_filepath_make(file, sizeof(file), mgmt_path, recs_conf);
       if (!(fin = fopen(file, "r"))) {
-        mgmt_elog(stderr, "[extractConfigInfo] Unable to open config file(%s)\n", file);
+        mgmt_elog(stderr, errno, "[extractConfigInfo] Unable to open config file(%s)\n", file);
         _exit(1);
       }
     }
@@ -1238,12 +1238,12 @@ extractConfigInfo(char *mgmt_path, const char *recs_conf, char *userName, int *f
     }
     fclose(fin);
   } else {
-    mgmt_elog(stderr, "[extractConfigInfo] Fatal Error: unable to access records file\n");
+    mgmt_elog(stderr, 0, "[extractConfigInfo] Fatal Error: unable to access records file\n");
     _exit(1);
   }
 
   if (useridFound == false) {
-    mgmt_elog(stderr, "[extractConfigInfo] Fatal Error: proxy.config.admin.user_id is not set\n");
+    mgmt_elog(stderr, 0, "[extractConfigInfo] Fatal Error: proxy.config.admin.user_id is not set\n");
     _exit(1);
   }
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/ProcessManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/ProcessManager.cc b/mgmt/ProcessManager.cc
index b582cec..5490a24 100644
--- a/mgmt/ProcessManager.cc
+++ b/mgmt/ProcessManager.cc
@@ -151,7 +151,7 @@ ProcessManager::processSignalQueue()
     Debug("pmgmt", "[ProcessManager] ==> Signalling local manager '%d'\n", mh->msg_id);
 
     if (require_lm && mgmt_write_pipe(local_manager_sockfd, (char *) mh, sizeof(MgmtMessageHdr) + mh->data_len) <= 0) {
-      mgmt_fatal(stderr, "[ProcessManager::processSignalQueue] Error writing message!");
+      mgmt_fatal(stderr, errno, "[ProcessManager::processSignalQueue] Error writing message!");
       //ink_assert(enqueue(mgmt_signal_queue, mh));
     } else {
       ats_free(mh);
@@ -188,15 +188,15 @@ ProcessManager::initLMConnection()
   servlen = strlen(serv_addr.sun_path) + sizeof(serv_addr.sun_family);
 #endif
   if ((local_manager_sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
-    mgmt_fatal(stderr, "[ProcessManager::initLMConnection] Unable to create socket\n");
+    mgmt_fatal(stderr, errno, "[ProcessManager::initLMConnection] Unable to create socket\n");
   }
 
   if (fcntl(local_manager_sockfd, F_SETFD, 1) < 0) {
-    mgmt_fatal(stderr, "[ProcessManager::initLMConnection] Unable to set close-on-exec\n");
+    mgmt_fatal(stderr, errno, "[ProcessManager::initLMConnection] Unable to set close-on-exec\n");
   }
 
   if ((connect(local_manager_sockfd, (struct sockaddr *) &serv_addr, servlen)) < 0) {
-    mgmt_fatal(stderr, "[ProcessManager::initLMConnection] Connect failed\n");
+    mgmt_fatal(stderr, errno, "[ProcessManager::initLMConnection] Connect failed\n");
   }
 
   data_len = sizeof(pid_t);
@@ -205,19 +205,19 @@ ProcessManager::initLMConnection()
   mh_full->data_len = data_len;
   memcpy((char *) mh_full + sizeof(MgmtMessageHdr), &(pid), data_len);
   if (mgmt_write_pipe(local_manager_sockfd, (char *) mh_full, sizeof(MgmtMessageHdr) + data_len) <= 0) {
-    mgmt_fatal(stderr, "[ProcessManager::initLMConnection] Error writing message!\n");
+    mgmt_fatal(stderr, errno, "[ProcessManager::initLMConnection] Error writing message!\n");
   }
 
   /* Read SYNC_KEY from manager */
   if (mgmt_read_pipe(local_manager_sockfd, (char *) &mh_hdr, sizeof(MgmtMessageHdr)) <= 0) {
-    mgmt_fatal(stderr, "[ProcessManager::initLMConnection] Error reading sem message!\n");
+    mgmt_fatal(stderr, errno, "[ProcessManager::initLMConnection] Error reading sem message!\n");
   } else {
     // coverity[uninit_use]
     mh_full = (MgmtMessageHdr *) alloca(sizeof(MgmtMessageHdr) + mh_hdr.data_len);
     memcpy(mh_full, &mh_hdr, sizeof(MgmtMessageHdr));
     sync_key_raw = (char *) mh_full + sizeof(MgmtMessageHdr);
     if (mgmt_read_pipe(local_manager_sockfd, sync_key_raw, mh_hdr.data_len) < 0) {
-      mgmt_fatal(stderr, "[ProcessManager::initLMConnection] Error reading sem message!\n");
+      mgmt_fatal(stderr, errno, "[ProcessManager::initLMConnection] Error reading sem message!\n");
     }
   }
 
@@ -266,19 +266,19 @@ ProcessManager::pollLMConnection()
           Debug("pmgmt", "[ProcessManager::pollLMConnection] Message: '%d'", mh_full->msg_id);
           handleMgmtMsgFromLM(mh_full);
         } else if (res < 0) {
-          mgmt_fatal(stderr, "[ProcessManager::pollLMConnection] Error in read!");
+          mgmt_fatal(stderr, errno, "[ProcessManager::pollLMConnection] Error in read!");
         }
       } else if (res < 0) {
-        mgmt_fatal(stderr, "[ProcessManager::pollLMConnection] Error in read!");
+        mgmt_fatal(stderr, errno, "[ProcessManager::pollLMConnection] Error in read!");
       }
       // handle EOF
       if (res == 0) {
         close_socket(local_manager_sockfd);
-        mgmt_fatal(stderr, "[ProcessManager::pollLMConnection] Lost Manager EOF!");
+        mgmt_fatal(stderr, 0, "[ProcessManager::pollLMConnection] Lost Manager EOF!");
       }
 
     } else if (num < 0) {       /* Error */
-      mgmt_elog(stderr, "[ProcessManager::pollLMConnection] select failed or was interrupted (%d)\n", errno);
+      mgmt_elog(stderr, 0, "[ProcessManager::pollLMConnection] select failed or was interrupted (%d)\n", errno);
     }
 
   }
@@ -332,7 +332,7 @@ ProcessManager::handleMgmtMsgFromLM(MgmtMessageHdr * mh)
     signalMgmtEntity(MGMT_EVENT_LIBRECORDS, data_raw, mh->data_len);
     break;
   default:
-    mgmt_elog(stderr, "[ProcessManager::pollLMConnection] unknown type %d\n", mh->msg_id);
+    mgmt_elog(stderr, 0, "[ProcessManager::pollLMConnection] unknown type %d\n", mh->msg_id);
     break;
   }
 }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/Rollback.cc
----------------------------------------------------------------------
diff --git a/mgmt/Rollback.cc b/mgmt/Rollback.cc
index 76ed82e..0a4c961 100644
--- a/mgmt/Rollback.cc
+++ b/mgmt/Rollback.cc
@@ -81,9 +81,9 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
   }
 
   if ((err = stat(system_config_directory, &s)) < 0) {
-    mgmt_elog("[Rollback::Rollback] unable to stat() directory '%s': %d %d, %s\n",
+    mgmt_elog(0, "[Rollback::Rollback] unable to stat() directory '%s': %d %d, %s\n",
               system_config_directory, err, errno, strerror(errno));
-    mgmt_elog("[Rollback::Rollback] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
+    mgmt_elog(0, "[Rollback::Rollback] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
     _exit(1);
   }
 
@@ -157,7 +157,7 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
           ats_free(alarmMsg);
           closeFile(fd);
         } else {
-          mgmt_fatal(stderr,
+          mgmt_fatal(stderr, 0,
                      "[RollBack::Rollback] Unable to find configuration file %s.\n\tCreation of a placeholder failed : %s\n",
                      fileName, strerror(errno));
         }
@@ -168,7 +168,7 @@ Rollback::Rollback(const char *baseFileName, bool root_access_needed_)
     } else {
       // If is there but we can not stat it, it is unusable to manager
       //   probably due to permissions problems.  Bail!
-      mgmt_fatal(stderr, "[RollBack::Rollback] Unable to find configuration file %s.\n\tStat failed : %s\n",
+      mgmt_fatal(stderr, 0, "[RollBack::Rollback] Unable to find configuration file %s.\n\tStat failed : %s\n",
                  fileName, strerror(errno));
     }
   } else {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/api/NetworkUtilsLocal.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/NetworkUtilsLocal.cc b/mgmt/api/NetworkUtilsLocal.cc
index 595f007..03b4666 100644
--- a/mgmt/api/NetworkUtilsLocal.cc
+++ b/mgmt/api/NetworkUtilsLocal.cc
@@ -67,7 +67,7 @@ socket_flush(struct SocketInfo sock_info)
         continue;
 
       Debug("ts_main", "[socket_read_n] socket read for version byte failed.\n");
-      mgmt_elog("[socket_flush] (TS_ERR_NET_READ) %s\n", strerror(errno));
+      mgmt_elog(0, "[socket_flush] (TS_ERR_NET_READ) %s\n", strerror(errno));
       return TS_ERR_NET_READ;
     }
 
@@ -79,7 +79,7 @@ socket_flush(struct SocketInfo sock_info)
     byte_read += ret;
   }
 
-  mgmt_elog("[socket_flush] uh oh! didn't finish flushing socket!\n");
+  mgmt_elog(0, "[socket_flush] uh oh! didn't finish flushing socket!\n");
   return TS_ERR_FAIL;
 }
 
@@ -110,7 +110,7 @@ socket_read_n(struct SocketInfo sock_info, char *buf, int bytes)
         continue;
 
       Debug("ts_main", "[socket_read_n] socket read for version byte failed.\n");
-      mgmt_elog("[socket_read_n] (TS_ERR_NET_READ) %s\n", strerror(errno));
+      mgmt_elog(0, "[socket_read_n] (TS_ERR_NET_READ) %s\n", strerror(errno));
       return TS_ERR_NET_READ;
     }
 
@@ -148,7 +148,7 @@ socket_write_n(struct SocketInfo sock_info, const char *buf, int bytes)
 
     if (ret < 0) {
       Debug("ts_main", "[socket_write_n] return error %s \n", strerror(errno));
-      mgmt_elog("[socket_write_n] %s\n", strerror(errno));
+      mgmt_elog(0, "[socket_write_n] %s\n", strerror(errno));
       if (errno == EAGAIN)
         continue;
 
@@ -156,7 +156,7 @@ socket_write_n(struct SocketInfo sock_info, const char *buf, int bytes)
     }
 
     if (ret == 0) {
-      mgmt_elog("[socket_write_n] %s\n", strerror(errno));
+      mgmt_elog(0, "[socket_write_n] %s\n", strerror(errno));
       return TS_ERR_NET_EOF;
     }
     // we are all good here
@@ -198,7 +198,7 @@ preprocess_msg(struct SocketInfo sock_info, OpType * op_t, char **req)
 
   // check if invalid op type
   if ((int) op > UNDEFINED_OP) {
-    mgmt_elog("[preprocess_msg] ERROR: %d is invalid op type\n", op);
+    mgmt_elog(0, "[preprocess_msg] ERROR: %d is invalid op type\n", op);
 
     // need to flush the invalid message from the socket
     if ((ret = socket_flush(sock_info)) != TS_ERR_NET_EOF)
@@ -211,7 +211,7 @@ preprocess_msg(struct SocketInfo sock_info, OpType * op_t, char **req)
   // now read the request msg size
   ret = socket_read_n(sock_info, (char *) &req_len, SIZE_LEN);
   if (ret != TS_ERR_OKAY) {
-    mgmt_elog("[preprocess_msg] ERROR %d reading msg size\n", ret);
+    mgmt_elog(0, "[preprocess_msg] ERROR %d reading msg size\n", ret);
     Debug("ts_main", "[preprocess_msg] ERROR %d reading msg size\n", ret);
     goto Lerror;
   }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/cluster/ClusterCom.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/ClusterCom.cc b/mgmt/cluster/ClusterCom.cc
index e0ef793..0fac4ea 100644
--- a/mgmt/cluster/ClusterCom.cc
+++ b/mgmt/cluster/ClusterCom.cc
@@ -189,11 +189,11 @@ drainIncomingChannel(void *arg)
       int clilen = sizeof(cli_addr);
       int req_fd = mgmt_accept(lmgmt->ccom->reliable_server_fd, (struct sockaddr *) &cli_addr, &clilen);
       if (req_fd < 0) {
-        mgmt_elog(stderr, "[drainIncomingChannel] error accepting " "reliable connection\n");
+        mgmt_elog(stderr, errno, "[drainIncomingChannel] error accepting " "reliable connection\n");
         continue;
       }
       if (fcntl(req_fd, F_SETFD, 1) < 0) {
-        mgmt_elog(stderr, "[drainIncomingChannel] Unable to set close " "on exec flag\n");
+        mgmt_elog(stderr, errno, "[drainIncomingChannel] Unable to set close " "on exec flag\n");
         close(req_fd);
         continue;
       }
@@ -239,7 +239,7 @@ drainIncomingChannel(void *arg)
 
           /* Wait for peer to read status */
           if (mgmt_readline(req_fd, message, 61440) != 0) {
-            mgmt_elog("[drainIncomingChannel] Connection not closed\n");
+            mgmt_elog(0, "[drainIncomingChannel] Connection not closed\n");
           }
         } else if (strstr(message, "map: ")) {
           /* Explicit virtual ip map request */
@@ -269,7 +269,7 @@ drainIncomingChannel(void *arg)
 
           /* Wait for peer to read status */
           if (mgmt_readline(req_fd, message, 61440) != 0) {
-            mgmt_elog("[drainIncomingChannel] Connection not closedx\n");
+            mgmt_elog(0, "[drainIncomingChannel] Connection not closed\n");
           }
 
         } else if (strstr(message, "file: ")) {
@@ -298,7 +298,7 @@ drainIncomingChannel(void *arg)
               Debug("ccom", "[drainIncomingChannel] file req: %s v: %d bytes: %d\n", fname, ver, (int)strlen(buff->bufPtr()));
             }
           } else {
-            mgmt_elog("[drainIncomingChannel] Error file req: %s ver: %d\n", fname, ver);
+            mgmt_elog(0, "[drainIncomingChannel] Error file req: %s ver: %d\n", fname, ver);
           }
 
           if (!stat) {
@@ -371,7 +371,7 @@ ClusterCom::ClusterCom(unsigned long oip, char *host, int mcport, char *group, i
 
   init = false;
   if (strlen(host) >= 1024) {
-    mgmt_fatal(stderr, "[ClusterCom::ClusterCom] Hostname too large: %s\n", host);
+    mgmt_fatal(stderr, 0, "[ClusterCom::ClusterCom] Hostname too large: %s\n", host);
   }
   // the constructor does a memset() on broadcast_addr and receive_addr, initializing them
   // coverity[uninit_member]
@@ -408,11 +408,11 @@ ClusterCom::ClusterCom(unsigned long oip, char *host, int mcport, char *group, i
   found = (rec_err == REC_ERR_OKAY);
 
   if (!found) {
-    mgmt_fatal(stderr, "[ClusterCom::ClusterCom] no cluster_configuration filename configured\n");
+    mgmt_fatal(stderr, 0, "[ClusterCom::ClusterCom] no cluster_configuration filename configured\n");
   }
 
   if (strlen(p) + strlen(cluster_file) >= 1024) {
-    mgmt_fatal(stderr, "[ClusterCom::ClusterCom] path + filename too large\n");
+    mgmt_fatal(stderr, 0, "[ClusterCom::ClusterCom] path + filename too large\n");
   }
   // XXX: This allows to have absolute config cluster_configuration directive.
   //      If that file must be inside config directory (p) use
@@ -430,7 +430,7 @@ ClusterCom::ClusterCom(unsigned long oip, char *host, int mcport, char *group, i
     mgmt_log("[ClusterCom::ClusterCom] Node running on OS: '%s' Release: '%s'\n", sys_name, sys_release);
   } else {
     sys_name[0] = sys_release[0] = '\0';
-    mgmt_elog("[ClusterCom::ClusterCom] Unable to determime OS and release info\n");
+    mgmt_elog(errno, "[ClusterCom::ClusterCom] Unable to determime OS and release info\n");
   }
 
   /* Grab the proxy cluster port */
@@ -438,7 +438,7 @@ ClusterCom::ClusterCom(unsigned long oip, char *host, int mcport, char *group, i
   RecRegisterConfigUpdateCb("proxy.config.cluster.cluster_port", cluster_com_port_watcher, NULL);
 
   if (!(strlen(group) < (MAX_MC_GROUP_LEN - 1))) {
-    mgmt_fatal(stderr, "[ClusterCom::ClusterCom] mc group length to large!\n");
+    mgmt_fatal(stderr, 0, "[ClusterCom::ClusterCom] mc group length too large!\n");
   }
 
   ink_strlcpy(mc_group, group, sizeof(mc_group));
@@ -636,7 +636,7 @@ ClusterCom::checkPeers(time_t * ticker)
      */
     if (num_peers != number_of_nodes) {
       if (cluster_file_rb->forceUpdate(buff) != OK_ROLLBACK) {
-        mgmt_elog("[ClusterCom::checkPeers] Failed update: cluster.config\n");
+        mgmt_elog(0, "[ClusterCom::checkPeers] Failed update: cluster.config\n");
         signal_alarm = true;    /* Throw the alarm after releasing the lock */
       } else {
         number_of_nodes = num_peers;    /* Update the static count */
@@ -789,7 +789,7 @@ ClusterCom::handleMultiCastMessage(char *message)
     handleMultiCastVMapPacket(last, ip);
     return;
   } else {
-    mgmt_elog("[ClusterCom::handleMultiCastMessage] Invalid type msg: '%s'\n", line);
+    mgmt_elog(0, "[ClusterCom::handleMultiCastMessage] Invalid type msg: '%s'\n", line);
     return;
   }
 
@@ -821,21 +821,21 @@ ClusterCom::handleMultiCastMessage(char *message)
   if ((line = strtok_r(NULL, "\n", &last)) == NULL)
     goto Lbogus;                /* Hostname of sender */
   if (strlen(line) >= sizeof(hostname) || sscanf(line, "hostname: %s", hostname) != 1) {
-    mgmt_elog("[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
+    mgmt_elog(0, "[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
     return;
   }
 
   if ((line = strtok_r(NULL, "\n", &last)) == NULL)
     goto Lbogus;                /* mc_port of sender */
   if (sscanf(line, "port: %d", &peer_cluster_port) != 1) {
-    mgmt_elog("[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
+    mgmt_elog(0, "[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
     return;
   }
 
   if ((line = strtok_r(NULL, "\n", &last)) == NULL)
     goto Lbogus;                /* rs_port of sender */
   if (sscanf(line, "ccomport: %d", &ccom_port) != 1) {
-    mgmt_elog("[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
+    mgmt_elog(0, "[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
     return;
   }
 
@@ -844,7 +844,7 @@ ClusterCom::handleMultiCastMessage(char *message)
     goto Lbogus;
   int64_t tt;
   if (sscanf(line, "time: %" PRId64 "", &tt) != 1) {
-    mgmt_elog("[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
+    mgmt_elog(0, "[ClusterCom::handleMultiCastMessage] Invalid message-line(%d) '%s'\n", __LINE__, line);
     return;
   }
   peer_wall_clock = (time_t)tt;
@@ -910,7 +910,7 @@ ClusterCom::handleMultiCastMessage(char *message)
 
 Lbogus:
   if (log_bogus_mc_msgs) {
-    mgmt_elog("[ClusterCom::handleMultiCastMessage] Bogus mc message-line\n");
+    mgmt_elog(0, "[ClusterCom::handleMultiCastMessage] Bogus mc message-line\n");
     if (line) {
       Debug("ccom", "[ClusterCom::handleMultiCastMessage] Bogus mc message-line %s\n", line);
     }
@@ -955,7 +955,7 @@ ClusterCom::handleMultiCastStatPacket(char *last, ClusterPeerInfo * peer)
             tmp_msg_val = ink_atoi64(v3 + 1);
         }
         if (!v2 || !v3) {
-          mgmt_elog("[ClusterCom::handleMultiCastStatPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
+          mgmt_elog(0, "[ClusterCom::handleMultiCastStatPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
           return;
         }
         ink_assert(i == tmp_id && rec->data_type == tmp_type);
@@ -976,7 +976,7 @@ ClusterCom::handleMultiCastStatPacket(char *last, ClusterPeerInfo * peer)
         // the types specified are all have a defined constant size
         // coverity[secure_coding]
         if (sscanf(line, "%d:%d: %f", &tmp_id, (int *) &tmp_type, &tmp_msg_val) != 3) {
-          mgmt_elog("[ClusterCom::handleMultiCastStatPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
+          mgmt_elog(0, "[ClusterCom::handleMultiCastStatPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
           return;
         }
         ink_assert(i == tmp_id && rec->data_type == tmp_type);
@@ -995,7 +995,7 @@ ClusterCom::handleMultiCastStatPacket(char *last, ClusterPeerInfo * peer)
         // the types specified are all have a defined constant size
         // coverity[secure_coding]
         if (sscanf(line, "%d:%d: %n", &tmp_id, (int *) &tmp_type, &ccons) != 2) {
-          mgmt_elog("[ClusterCom::handleMultiCastStatPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
+          mgmt_elog(0, "[ClusterCom::handleMultiCastStatPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
           return;
         }
         tmp_msg_val = &line[ccons];
@@ -1161,7 +1161,7 @@ ClusterCom::handleMultiCastFilePacket(char *last, char *ip)
     file_update_failure = false;
     // coverity[secure_coding]
     if (sscanf(line, "%1023s %d %" PRId64 "\n", file, &ver, &tt) != 3) {
-      mgmt_elog("[ClusterCom::handleMultiCastFilePacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
+      mgmt_elog(0, "[ClusterCom::handleMultiCastFilePacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
       return;
     }
 
@@ -1228,7 +1228,7 @@ ClusterCom::handleMultiCastFilePacket(char *last, char *ip)
         }
 
         if (file_update_failure) {
-          mgmt_elog("[ClusterCom::handleMultiCastFilePacket] Update failed\n");
+          mgmt_elog(0, "[ClusterCom::handleMultiCastFilePacket] Update failed\n");
         } else {
           mgmt_log(stderr, "[ClusterCom::handleMultiCastFilePacket] " "Updated '%s' o: %d n: %d\n", file, our_ver, ver);
         }
@@ -1237,7 +1237,7 @@ ClusterCom::handleMultiCastFilePacket(char *last, char *ip)
 
       }
     } else {
-      mgmt_elog("[ClusterCom::handleMultiCastFilePacket] Unknown file seen: '%s'\n", file);
+      mgmt_elog(0, "[ClusterCom::handleMultiCastFilePacket] Unknown file seen: '%s'\n", file);
     }
   }
 
@@ -1277,7 +1277,7 @@ ClusterCom::handleMultiCastAlarmPacket(char *last, char *ip)
     // both types have a finite size
     // coverity[secure_coding]
     if (sscanf(line, "alarm: %d %n", &a, &ccons) != 1) {
-      mgmt_elog("[ClusterCom::handleMultiCastAlarmPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
+      mgmt_elog(0, "[ClusterCom::handleMultiCastAlarmPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
       return;
     }
 
@@ -1316,7 +1316,7 @@ ClusterCom::handleMultiCastVMapPacket(char *last, char *ip)
     }
     // coverity[secure_coding]
     if (sscanf(line, "virt: %79s", vaddr) != 1) {
-      mgmt_elog("[ClusterCom::handleMultiCastVMapPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
+      mgmt_elog(0, "[ClusterCom::handleMultiCastVMapPacket] Invalid message-line(%d) '%s'\n", __LINE__, line);
       return;
     }
 
@@ -1424,7 +1424,7 @@ ClusterCom::constructSharedGenericPacket(char *message, int max, RecT packet_typ
     running_sum += strlen("type: stat\n");
     ink_release_assert(running_sum < max);
   } else {
-    mgmt_elog("[ClusterCom::constructSharedGenericPacket] Illegal type seen '%d'\n", packet_type);
+    mgmt_elog(0, "[ClusterCom::constructSharedGenericPacket] Illegal type seen '%d'\n", packet_type);
     return;
   }
 
@@ -1468,7 +1468,7 @@ ClusterCom::constructSharedGenericPacket(char *message, int max, RecT packet_typ
     ink_strlcpy(&message[running_sum], tmp, (max - running_sum));
     running_sum += strlen(tmp);
   } else {
-    mgmt_elog(stderr, "[ClusterCom::constructSharedPacket] time failed\n");
+    mgmt_elog(stderr, errno, "[ClusterCom::constructSharedPacket] time failed\n");
   }
   ink_release_assert(running_sum < max);
 
@@ -1604,7 +1604,7 @@ ClusterCom::constructSharedFilePacket(char *message, int max)
       running_sum += strlen(tmp);
       ink_release_assert(running_sum < max);
     } else {
-      mgmt_elog("[ClusterCom::constructSharedFilePacket] Invalid base name? '%s'\n", line);
+      mgmt_elog(0, "[ClusterCom::constructSharedFilePacket] Invalid base name? '%s'\n", line);
     }
   } while ((line = strtok_r(NULL, "\n", &last)));
 
@@ -1631,14 +1631,14 @@ ClusterCom::establishChannels()
     if (reliable_server_port > 0) {
       /* Setup reliable connection, for large config changes */
       if ((reliable_server_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-        mgmt_fatal("[ClusterCom::establishChannels] Unable to create socket\n");
+        mgmt_fatal(errno, "[ClusterCom::establishChannels] Unable to create socket\n");
       }
       if (fcntl(reliable_server_fd, F_SETFD, 1) < 0) {
-        mgmt_fatal("[ClusterCom::establishChannels] Unable to set close-on-exec.\n");
+        mgmt_fatal(errno, "[ClusterCom::establishChannels] Unable to set close-on-exec.\n");
       }
 
       if (setsockopt(reliable_server_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
-        mgmt_fatal("[ClusterCom::establishChannels] Unable to set socket options.\n");
+        mgmt_fatal(errno, "[ClusterCom::establishChannels] Unable to set socket options.\n");
       }
 
       memset(&serv_addr, 0, sizeof(serv_addr));
@@ -1647,11 +1647,11 @@ ClusterCom::establishChannels()
       serv_addr.sin_port = htons(reliable_server_port);
 
       if ((bind(reliable_server_fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr))) < 0) {
-        mgmt_fatal("[ClusterCom::establishChannels] Unable to bind socket (port:%d)\n", reliable_server_port);
+        mgmt_fatal(errno, "[ClusterCom::establishChannels] Unable to bind socket (port:%d)\n", reliable_server_port);
       }
 
       if ((listen(reliable_server_fd, 10)) < 0) {
-        mgmt_fatal("[ClusterCom::establishChannels] Unable to listen on socket\n");
+        mgmt_fatal(errno, "[ClusterCom::establishChannels] Unable to listen on socket\n");
       }
     }
   }
@@ -1670,16 +1670,16 @@ void
 ClusterCom::establishBroadcastChannel(void)
 {
   if ((broadcast_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-    mgmt_fatal("[ClusterCom::establishBroadcastChannel] Unable to open socket.\n");
+    mgmt_fatal(errno, "[ClusterCom::establishBroadcastChannel] Unable to open socket.\n");
   }
 
   if (fcntl(broadcast_fd, F_SETFD, 1) < 0) {
-    mgmt_fatal("[ClusterCom::establishBroadcastChannel] Unable to set close-on-exec.\n");
+    mgmt_fatal(errno, "[ClusterCom::establishBroadcastChannel] Unable to set close-on-exec.\n");
   }
 
   int one = 1;
   if (setsockopt(broadcast_fd, SOL_SOCKET, SO_REUSEADDR, (const char *) &one, sizeof(one)) < 0) {
-    mgmt_fatal("[ClusterCom::establishBroadcastChannel] Unable to set socket options.\n");
+    mgmt_fatal(errno, "[ClusterCom::establishBroadcastChannel] Unable to set socket options.\n");
   }
 
   memset(&broadcast_addr, 0, sizeof(broadcast_addr));
@@ -1691,12 +1691,12 @@ ClusterCom::establishBroadcastChannel(void)
 
   /* Set ttl(max forwards), 1 should be default(same subnetwork). */
   if (setsockopt(broadcast_fd, IPPROTO_IP, IP_MULTICAST_TTL, (const char *) &ttl, sizeof(ttl)) < 0) {
-    mgmt_fatal("[ClusterCom::establishBroadcastChannel] Unable to setsocketopt, ttl\n");
+    mgmt_fatal(errno, "[ClusterCom::establishBroadcastChannel] Unable to setsocketopt, ttl\n");
   }
 
   /* Disable broadcast loopback, that is broadcasting to self */
   if (setsockopt(broadcast_fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const char *) &loop, sizeof(loop)) < 0) {
-    mgmt_fatal("[ClusterCom::establishBroadcastChannel] Unable to disable loopback\n");
+    mgmt_fatal(errno, "[ClusterCom::establishBroadcastChannel] Unable to disable loopback\n");
   }
 
   return;
@@ -1717,7 +1717,7 @@ ClusterCom::establishReceiveChannel(int fatal_on_error)
       Debug("ccom", "establishReceiveChannel: Unable to open socket");
       return 1;
     }
-    mgmt_fatal("[ClusterCom::establishReceiveChannel] Unable to open socket\n");
+    mgmt_fatal(errno, "[ClusterCom::establishReceiveChannel] Unable to open socket\n");
   }
 
   if (fcntl(receive_fd, F_SETFD, 1) < 0) {
@@ -1727,7 +1727,7 @@ ClusterCom::establishReceiveChannel(int fatal_on_error)
       Debug("ccom", "establishReceiveChannel: Unable to set close-on-exec");
       return 1;
     }
-    mgmt_fatal("[ClusterCom::establishReceiveChannel] Unable to set close-on-exec.\n");
+    mgmt_fatal(errno, "[ClusterCom::establishReceiveChannel] Unable to set close-on-exec.\n");
   }
 
   int one = 1;
@@ -1738,7 +1738,7 @@ ClusterCom::establishReceiveChannel(int fatal_on_error)
       Debug("ccom", "establishReceiveChannel: Unable to set socket to reuse addr");
       return 1;
     }
-    mgmt_fatal("[ClusterCom::establishReceiveChannel] Unable to set socket to reuse addr.\n");
+    mgmt_fatal(errno, "[ClusterCom::establishReceiveChannel] Unable to set socket to reuse addr.\n");
   }
 
   memset(&receive_addr, 0, sizeof(receive_addr));
@@ -1753,7 +1753,7 @@ ClusterCom::establishReceiveChannel(int fatal_on_error)
       Debug("ccom", "establishReceiveChannel: Unable to bind to socket, port %d", mc_port);
       return 1;
     }
-    mgmt_fatal("[ClusterCom::establishReceiveChannel] Unable to bind to socket, port %d\n", mc_port);
+    mgmt_fatal(errno, "[ClusterCom::establishReceiveChannel] Unable to bind to socket, port %d\n", mc_port);
   }
   /* Add ourselves to the group */
   struct ip_mreq mc_request;
@@ -1767,7 +1767,7 @@ ClusterCom::establishReceiveChannel(int fatal_on_error)
 
       return 1;
     }
-    mgmt_fatal("[ClusterCom::establishReceiveChannel] Can't add ourselves to multicast group %s\n", mc_group);
+    mgmt_fatal(errno, "[ClusterCom::establishReceiveChannel] Can't add ourselves to multicast group %s\n", mc_group);
   }
 
   return 0;
@@ -1784,7 +1784,7 @@ bool
 ClusterCom::sendOutgoingMessage(char *buf, int len)
 {
   if (mgmt_sendto(broadcast_fd, buf, len, 0, (struct sockaddr *) &broadcast_addr, sizeof(broadcast_addr)) < 0) {
-    mgmt_elog("[ClusterCom::sendOutgoingMessage] Message send failed\n");
+    mgmt_elog(errno, "[ClusterCom::sendOutgoingMessage] Message send failed\n");
     return false;
   }
   return true;
@@ -1898,7 +1898,7 @@ ClusterCom::rl_sendReliableMessage(unsigned long addr, const char *buf, int len)
 
 
   if ((fd = mgmt_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-    mgmt_elog("[ClusterCom::rl_sendReliableMessage] Unable to create socket\n");
+    mgmt_elog(errno, "[ClusterCom::rl_sendReliableMessage] Unable to create socket\n");
     return false;
   }
   if (fcntl(fd, F_SETFD, 1) < 0) {
@@ -1908,13 +1908,13 @@ ClusterCom::rl_sendReliableMessage(unsigned long addr, const char *buf, int len)
   }
 
   if (connect(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
-    mgmt_elog("[ClusterCom::rl_sendReliableMessage] Unable to connect to peer\n");
+    mgmt_elog(errno, "[ClusterCom::rl_sendReliableMessage] Unable to connect to peer\n");
     close_socket(fd);
     return false;
   }
 
   if (mgmt_writeline(fd, buf, len) != 0) {
-    mgmt_elog(stderr, "[ClusterCom::rl_sendReliableMessage] Write failed\n");
+    mgmt_elog(stderr, errno, "[ClusterCom::rl_sendReliableMessage] Write failed\n");
     close_socket(fd);
     return false;
   }
@@ -1955,14 +1955,14 @@ ClusterCom::sendReliableMessage(unsigned long addr, char *buf, int len, char *re
   serv_addr.sin_port = htons(cport);
 
   if ((fd = mgmt_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessage] Unable to create socket\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessage] Unable to create socket\n");
     if (take_lock) {
       ink_mutex_release(&mutex);
     }
     return false;
   }
   if (fcntl(fd, F_SETFD, 1) < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessage] Unable to set close-on-exec.\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessage] Unable to set close-on-exec.\n");
     if (take_lock) {
       ink_mutex_release(&mutex);
     }
@@ -1971,7 +1971,7 @@ ClusterCom::sendReliableMessage(unsigned long addr, char *buf, int len, char *re
   }
 
   if (connect(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessage] Unable to connect to peer\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessage] Unable to connect to peer\n");
     if (take_lock) {
       ink_mutex_release(&mutex);
     }
@@ -1980,7 +1980,7 @@ ClusterCom::sendReliableMessage(unsigned long addr, char *buf, int len, char *re
   }
 
   if (mgmt_writeline(fd, buf, len) != 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessage] Write failed\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessage] Write failed\n");
     if (take_lock) {
       ink_mutex_release(&mutex);
     }
@@ -1989,7 +1989,7 @@ ClusterCom::sendReliableMessage(unsigned long addr, char *buf, int len, char *re
   }
 
   if (mgmt_readline(fd, reply, len2) == -1) {
-    mgmt_elog(stderr, "[ClusterCom::sendReliableMessage] Read failed\n");
+    mgmt_elog(stderr, errno, "[ClusterCom::sendReliableMessage] Read failed\n");
     perror("ClusterCom::sendReliableMessage");
     reply[0] = '\0';
     if (take_lock) {
@@ -2035,26 +2035,26 @@ ClusterCom::sendReliableMessageReadTillClose(unsigned long addr, char *buf, int
   serv_addr.sin_port = htons(cport);
 
   if ((fd = mgmt_socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessageReadTillClose] Unable create sock\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessageReadTillClose] Unable create sock\n");
     ink_mutex_release(&mutex);
     return false;
   }
   if (fcntl(fd, F_SETFD, 1) < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessageReadTillClose] Unable to set close-on-exec.\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessageReadTillClose] Unable to set close-on-exec.\n");
     ink_mutex_release(&mutex);
     close(fd);
     return false;
   }
 
   if (connect(fd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessageReadTillClose] Unable to connect\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessageReadTillClose] Unable to connect\n");
     ink_mutex_release(&mutex);
     close_socket(fd);
     return false;
   }
 
   if (mgmt_writeline(fd, buf, len) != 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessageReadTillClose] Write failed\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessageReadTillClose] Write failed\n");
     ink_mutex_release(&mutex);
     close_socket(fd);
     return false;
@@ -2072,7 +2072,7 @@ ClusterCom::sendReliableMessageReadTillClose(unsigned long addr, char *buf, int
   }
 
   if (res < 0) {
-    mgmt_elog("[ClusterCom::sendReliableMessageReadTillClose] Read failed\n");
+    mgmt_elog(errno, "[ClusterCom::sendReliableMessageReadTillClose] Read failed\n");
     perror("ClusterCom::sendReliableMessageReadTillClose");
     ink_mutex_release(&mutex);
     close_socket(fd);
@@ -2096,7 +2096,7 @@ ClusterCom::receiveIncomingMessage(char *buf, int max)
   int nbytes = 0, addr_len = sizeof(receive_addr);
 
   if ((nbytes = recvfrom(receive_fd, buf, max, 0, (struct sockaddr *) &receive_addr, (socklen_t *) & addr_len)) < 0) {
-    mgmt_elog(stderr, "[ClusterCom::receiveIncomingMessage] Receive failed\n");
+    mgmt_elog(stderr, errno, "[ClusterCom::receiveIncomingMessage] Receive failed\n");
   }
   return nbytes;
 }                               /* End ClusterCom::processIncomingMessages */
@@ -2304,7 +2304,7 @@ checkBackDoor(int req_fd, char *message)
 
     // coverity[secure_coding]
     if (sscanf(message, "read %s\n", variable) != 1) {
-      mgmt_elog("[ClusterCom::CBD] Invalid message-line(%d) '%s'\n", __LINE__, message);
+      mgmt_elog(0, "[ClusterCom::CBD] Invalid message-line(%d) '%s'\n", __LINE__, message);
       return false;
     }
 
@@ -2346,17 +2346,17 @@ checkBackDoor(int req_fd, char *message)
       if (found) {
         mgmt_writeline(req_fd, reply, rep_len);
       } else {
-        mgmt_elog("[checkBackDoor] record not found '%s'\n", variable);
+        mgmt_elog(0, "[checkBackDoor] record not found '%s'\n", variable);
       }
     } else {
-      mgmt_elog("[checkBackDoor] Unknown variable requested '%s'\n", variable);
+      mgmt_elog(0, "[checkBackDoor] Unknown variable requested '%s'\n", variable);
     }
     return true;
   } else if (strstr(message, "write ")) {
     char variable[1024], value[1024];
 
     if (sscanf(message, "write %s %s", variable, value) != 2) {
-      mgmt_elog("[ClusterCom::CBD] Invalid message-line(%d) '%s'\n", __LINE__, message);
+      mgmt_elog(0, "[ClusterCom::CBD] Invalid message-line(%d) '%s'\n", __LINE__, message);
       return false;
     }
     // TODO: I think this is correct, it used to do lmgmt->record_data-> ...
@@ -2364,7 +2364,7 @@ checkBackDoor(int req_fd, char *message)
       ink_strlcpy(reply, "\nRecord Updated\n\n", sizeof(reply));
       mgmt_writeline(req_fd, reply, strlen(reply));
     } else {
-      mgmt_elog("[checkBackDoor] Assignment to unknown variable requested '%s'\n", variable);
+      mgmt_elog(0, "[checkBackDoor] Assignment to unknown variable requested '%s'\n", variable);
     }
     return true;
   } else if (strstr(message, "peers")) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/cluster/VMap.cc
----------------------------------------------------------------------
diff --git a/mgmt/cluster/VMap.cc b/mgmt/cluster/VMap.cc
index 51fa525..5539e6f 100644
--- a/mgmt/cluster/VMap.cc
+++ b/mgmt/cluster/VMap.cc
@@ -116,7 +116,7 @@ VMap::VMap(char *interface, unsigned long ip, ink_mutex * m)
     int len;
 
     if ((tmp_socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-      mgmt_fatal(stderr, "[VMap::VMap] Unable to create socket for interface ioctls\n");
+      mgmt_fatal(stderr, errno, "[VMap::VMap] Unable to create socket for interface ioctls\n");
     }
     // INKqa06739
     // Fetch the list of network interfaces
@@ -131,7 +131,7 @@ VMap::VMap(char *interface, unsigned long ip, ink_mutex * m)
       ifc.ifc_buf = ifbuf;
       if (ioctl(tmp_socket, SIOCGIFCONF, &ifc) < 0) {
         if (errno != EINVAL || lastlen != 0) {
-          mgmt_fatal(stderr, "[VMap::VMap] Unable to read network interface configuration\n");
+          mgmt_fatal(stderr, errno, "[VMap::VMap] Unable to read network interface configuration\n");
         }
       } else {
         if (ifc.ifc_len == lastlen) {
@@ -273,7 +273,7 @@ VMap::lt_runGambit()
         ink_strlcpy(raddr, inet_ntoa(real_addr), sizeof(raddr));
         rl_remote_map(vaddr, raddr);
       } else if (!rl_map(vaddr)) {      /* We are the winner, map it to us */
-        mgmt_elog(stderr, "[VMap::lt_runGambit] Map failed for vaddr: %s\n", vaddr);
+        mgmt_elog(stderr, 0, "[VMap::lt_runGambit] Map failed for vaddr: %s\n", vaddr);
       } else {
         mgmt_log(stderr, "[VMap::lt_runGambit] Map succeeded for vaddr: %s\n", vaddr);
       }
@@ -379,7 +379,7 @@ VMap::lt_readAListFile(char *data)
                  " virtual ips\n", tmp_interface);
       }
     } else {
-      mgmt_elog(stderr, "[VMap::lt_readAListFile] VIP in config file but no interface"
+      mgmt_elog(stderr, 0, "[VMap::lt_readAListFile] VIP in config file but no interface"
                 " '%s' present on node.\n", tmp_interface);
     }
   }
@@ -455,7 +455,7 @@ VMap::rl_remote_map(char *virt_ip, char *real_ip)
 
   snprintf((char *) buf, sizeof(buf), "map: %s", virt_ip);
   if (!(lmgmt->ccom->sendReliableMessage(inet_addr(real_ip), buf, strlen(buf), reply, 4096, false))) {
-    mgmt_elog(stderr, "[VMap::rl_remote_map] Reliable send failed\n");
+    mgmt_elog(stderr, errno, "[VMap::rl_remote_map] Reliable send failed\n");
     return false;
   } else if (strcmp(reply, "map: failed") == 0) {
     mgmt_log(stderr, "[VMap::rl_remote_map] Mapping failed\n");
@@ -477,7 +477,7 @@ VMap::rl_remote_unmap(char *virt_ip, char *real_ip)
 
   snprintf((char *) buf, sizeof(buf), "unmap: %s", virt_ip);
   if (!(lmgmt->ccom->sendReliableMessage(inet_addr(real_ip), buf, strlen(buf), reply, 4096, false))) {
-    mgmt_elog(stderr, "[VMap::rl_remote_unmap] Reliable send failed\n");
+    mgmt_elog(stderr, errno, "[VMap::rl_remote_unmap] Reliable send failed\n");
     return false;
   } else if (strcmp((char *) reply, "unmap: failed") == 0) {
     mgmt_log(stderr, "[VMap::rl_remote_unmap] Mapping failed\n");
@@ -518,7 +518,7 @@ VMap::rl_map(char *virt_ip, char *real_ip)
   *entry = true;
 
   if (!real_ip) {
-    mgmt_elog("[VMap::rl_map] no real ip associated with virtual ip %s, mapping to local\n", buf);
+    mgmt_elog(0, "[VMap::rl_map] no real ip associated with virtual ip %s, mapping to local\n", buf);
     last_map_change = time(NULL);
   }
   ink_hash_table_insert(tmp, buf, (void *) entry);
@@ -593,7 +593,7 @@ VMap::rl_checkConflict(char *virt_ip)
       buf++;
       ink_strlcpy(buf2, buf, sizeof(buf2));
     } else {
-      mgmt_fatal(stderr, "[VMap::rl_checkConflict] Corrupt VMap entry('%s'), bailing\n", key);
+      mgmt_fatal(stderr, 0, "[VMap::rl_checkConflict] Corrupt VMap entry('%s'), bailing\n", key);
     }
     return ats_strdup(buf2);
   }
@@ -754,7 +754,7 @@ VMap::rl_boundTo(char *virt_ip)
         buf++;
         ink_strlcpy(buf2, buf, sizeof(buf2));
       } else {
-        mgmt_fatal(stderr, "[VMap::rl_boundTo] Corrupt VMap entry('%s'), bailing\n", key);
+        mgmt_fatal(stderr, 0, "[VMap::rl_boundTo] Corrupt VMap entry('%s'), bailing\n", key);
       }
       return (inet_addr(buf2));
     }

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/utils/MgmtUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtUtils.cc b/mgmt/utils/MgmtUtils.cc
index 05cd022..275ff3e 100644
--- a/mgmt/utils/MgmtUtils.cc
+++ b/mgmt/utils/MgmtUtils.cc
@@ -304,7 +304,7 @@ mgmt_log(const char *message_format, ...)
  *   Same as above, but intended for errors.
  */
 void
-mgmt_elog(FILE * log, const char *message_format, ...)
+mgmt_elog(FILE * log, const int lerrno, const char *message_format, ...)
 {
   va_list ap;
   char extended_format[4096], message[4096];
@@ -313,23 +313,27 @@ mgmt_elog(FILE * log, const char *message_format, ...)
 
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   if (diags_init) {
-    int lerrno = errno;
-
     diags->print_va(NULL, DL_Error, NULL, message_format, ap);
-    diags->print(NULL, DTA(DL_Error), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    if (lerrno != 0) {
+      diags->print(NULL, DTA(DL_Error), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    }
   } else {
 #endif
     if (use_syslog) {
       snprintf(extended_format, sizeof(extended_format), "ERROR ==> %s", message_format);
       vsprintf(message, extended_format, ap);
       syslog(LOG_ERR, "%s", message);
-      syslog(LOG_ERR, " (last system error %d: %s)", errno, strerror(errno));
+      if (lerrno != 0) {
+        syslog(LOG_ERR, " (last system error %d: %s)", lerrno, strerror(lerrno));
+      }
     } else {
       snprintf(extended_format, sizeof(extended_format), "[E. Mgmt] ERROR ==> %s", message_format);
       vsprintf(message, extended_format, ap);
       ink_assert(fwrite(message, strlen(message), 1, log) == 1);
-      snprintf(message, sizeof(message), "(last system error %d: %s)", errno, strerror(errno));
-      ink_assert(fwrite(message, strlen(message), 1, log) == 1);
+      if (lerrno != 0) {
+        snprintf(message, sizeof(message), "(last system error %d: %s)", lerrno, strerror(lerrno));
+        ink_assert(fwrite(message, strlen(message), 1, log) == 1);
+      }
     }
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   }
@@ -341,7 +345,7 @@ mgmt_elog(FILE * log, const char *message_format, ...)
 
 
 void
-mgmt_elog(const char *message_format, ...)
+mgmt_elog(const int lerrno, const char *message_format, ...)
 {
   va_list ap;
   char extended_format[4096], message[4096];
@@ -350,9 +354,10 @@ mgmt_elog(const char *message_format, ...)
 
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   if (diags_init) {
-    int lerrno = errno;
     diags->print_va(NULL, DL_Error, NULL, message_format, ap);
-    diags->print(NULL, DTA(DL_Error), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    if (lerrno != 0) {
+      diags->print(NULL, DTA(DL_Error), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    }
   } else {
 #endif
 
@@ -360,13 +365,17 @@ mgmt_elog(const char *message_format, ...)
       snprintf(extended_format, sizeof(extended_format), "ERROR ==> %s", message_format);
       vsprintf(message, extended_format, ap);
       syslog(LOG_ERR, "%s", message);
-      syslog(LOG_ERR, " (last system error %d: %s)", errno, strerror(errno));
+      if (lerrno != 0) {
+        syslog(LOG_ERR, " (last system error %d: %s)", lerrno, strerror(lerrno));
+      }
     } else {
       snprintf(extended_format, sizeof(extended_format), "Manager ERROR: %s", message_format);
       vsprintf(message, extended_format, ap);
       ink_assert(fwrite(message, strlen(message), 1, stderr) == 1);
-      snprintf(message, sizeof(message), "(last system error %d: %s)", errno, strerror(errno));
-      ink_assert(fwrite(message, strlen(message), 1, stderr) == 1);
+      if (lerrno != 0) {
+        snprintf(message, sizeof(message), "(last system error %d: %s)", lerrno, strerror(lerrno));
+        ink_assert(fwrite(message, strlen(message), 1, stderr) == 1);
+      }
     }
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   }
@@ -382,7 +391,7 @@ mgmt_elog(const char *message_format, ...)
  * asserts false.
  */
 void
-mgmt_fatal(FILE * log, const char *message_format, ...)
+mgmt_fatal(FILE * log, const int lerrno, const char *message_format, ...)
 {
   va_list ap;
   char extended_format[4096], message[4096];
@@ -392,9 +401,10 @@ mgmt_fatal(FILE * log, const char *message_format, ...)
 
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   if (diags_init) {
-    int lerrno = errno;
     diags->print_va(NULL, DL_Fatal, NULL, message_format, ap);
-    diags->print(NULL, DTA(DL_Fatal), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    if (lerrno != 0) {
+      diags->print(NULL, DTA(DL_Fatal), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    }
   } else {
 #endif
 
@@ -407,13 +417,13 @@ mgmt_fatal(FILE * log, const char *message_format, ...)
       syslog(LOG_ERR, "%s", message);
     }
 
-
-
-    perror("[E. Mgmt] ");
-
-    if (use_syslog) {
-      syslog(LOG_ERR, " (last system error %d: %s)", errno, strerror(errno));
+    if (lerrno != 0) {
+      fprintf(stderr, "[E. Mgmt] last system error %d: %s", lerrno, strerror(lerrno));
+      if (use_syslog) {
+        syslog(LOG_ERR, " (last system error %d: %s)", lerrno, strerror(lerrno));
+      }
     }
+
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   }
 #endif
@@ -427,7 +437,7 @@ mgmt_fatal(FILE * log, const char *message_format, ...)
 
 
 void
-mgmt_fatal(const char *message_format, ...)
+mgmt_fatal(const int lerrno, const char *message_format, ...)
 {
   va_list ap;
   char extended_format[4096], message[4096];
@@ -436,9 +446,10 @@ mgmt_fatal(const char *message_format, ...)
 
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   if (diags_init) {
-    int lerrno = errno;
     diags->print_va(NULL, DL_Fatal, NULL, message_format, ap);
-    diags->print(NULL, DTA(DL_Fatal), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    if (lerrno != 0) {
+      diags->print(NULL, DTA(DL_Fatal), " (last system error %d: %s)\n", lerrno, strerror(lerrno));
+    }
   } else {
 #endif
 
@@ -451,12 +462,12 @@ mgmt_fatal(const char *message_format, ...)
       syslog(LOG_ERR, "%s", message);
     }
 
+    if (lerrno != 0) {
+      fprintf(stderr, "[E. Mgmt] last system error %d: %s", lerrno, strerror(lerrno));
 
-
-    perror("[E. Mgmt] ");
-
-    if (use_syslog) {
-      syslog(LOG_ERR, " (last system error %d: %s)", errno, strerror(errno));
+      if (use_syslog) {
+        syslog(LOG_ERR, " (last system error %d: %s)", lerrno, strerror(lerrno));
+      }
     }
 #if defined(LOCAL_MANAGER) || defined(PROCESS_MANAGER)
   }
@@ -512,7 +523,7 @@ mgmt_getAddrForIntr(char *intrName, sockaddr* addr, int *mtu)
   memset(addr, 0, sizeof(struct in_addr));
 
   if ((fakeSocket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-    mgmt_fatal(stderr, "[getAddrForIntr] Unable to create socket\n");
+    mgmt_fatal(stderr, errno, "[getAddrForIntr] Unable to create socket\n");
   }
   // INKqa06739
   // Fetch the list of network interfaces
@@ -527,7 +538,7 @@ mgmt_getAddrForIntr(char *intrName, sockaddr* addr, int *mtu)
     ifc.ifc_buf = ifbuf;
     if (ioctl(fakeSocket, SIOCGIFCONF, &ifc) < 0) {
       if (errno != EINVAL || lastlen != 0) {
-        mgmt_fatal(stderr, "[getAddrForIntr] Unable to read network interface configuration\n");
+        mgmt_fatal(stderr, errno, "[getAddrForIntr] Unable to read network interface configuration\n");
       }
     } else {
       if (ifc.ifc_len == lastlen) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/utils/MgmtUtils.h
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtUtils.h b/mgmt/utils/MgmtUtils.h
index 9acb521..cad15e2 100644
--- a/mgmt/utils/MgmtUtils.h
+++ b/mgmt/utils/MgmtUtils.h
@@ -56,11 +56,11 @@ bool mgmt_getAddrForIntr(char *intrName, sockaddr* addr, int *mtu = 0);
 /* the following functions are all DEPRECATED.  The Diags
    interface should be used exclusively in the future */
 void mgmt_log(FILE * log, const char *message_format, ...);
-void mgmt_elog(FILE * log, const char *message_format, ...);
-void mgmt_fatal(FILE * log, const char *message_format, ...);
+void mgmt_elog(FILE * log, const int lerrno, const char *message_format, ...);
+void mgmt_fatal(FILE * log, const int lerrno, const char *message_format, ...);
 void mgmt_log(const char *message_format, ...);
-void mgmt_elog(const char *message_format, ...);
-void mgmt_fatal(const char *message_format, ...);
+void mgmt_elog(const int lerrno, const char *message_format, ...);
+void mgmt_fatal(const int lerrno, const char *message_format, ...);
 void mgmt_log_output(FILE * stdio_or_null, DiagsLevel type, const char *format, ...);
 void mgmt_log_output_va(FILE * stdio_or_null, DiagsLevel type, const char *format, va_list ap);
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/utils/WebMgmtUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/utils/WebMgmtUtils.cc b/mgmt/utils/WebMgmtUtils.cc
index f3c2353..ed82b09 100644
--- a/mgmt/utils/WebMgmtUtils.cc
+++ b/mgmt/utils/WebMgmtUtils.cc
@@ -1065,7 +1065,7 @@ setHostnameVar()
 
   // Get Our HostName
   if (gethostname(ourHostName, MAXDNAME) < 0) {
-    mgmt_fatal(stderr, "[setHostnameVar] Can not determine our hostname");
+    mgmt_fatal(stderr, errno, "[setHostnameVar] Can not determine our hostname");
   }
 
   res_init();

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/web2/WebHttp.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebHttp.cc b/mgmt/web2/WebHttp.cc
index ecad1c7..9df0da5 100644
--- a/mgmt/web2/WebHttp.cc
+++ b/mgmt/web2/WebHttp.cc
@@ -524,7 +524,7 @@ WebHttpHandleConnection(WebHttpConInfo * whci)
     // on the autoconf port.  can't have users downloading arbitrary
     // files under the config directory!
     if (!ink_hash_table_isbound(g_autoconf_allow_ht, file)) {
-      mgmt_elog(stderr,"[WebHttpHandleConnection] %s not valid autoconf file",file);
+      mgmt_elog(stderr, 0, "[WebHttpHandleConnection] %s not valid autoconf file", file);
       whc->response_hdr->setStatus(STATUS_NOT_FOUND);
       WebHttpSetErrorResponse(whc, STATUS_NOT_FOUND);
       goto Ltransaction_send;

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/c2452f5f/mgmt/web2/WebIntrMain.cc
----------------------------------------------------------------------
diff --git a/mgmt/web2/WebIntrMain.cc b/mgmt/web2/WebIntrMain.cc
index 29fb81f..ff29c97 100644
--- a/mgmt/web2/WebIntrMain.cc
+++ b/mgmt/web2/WebIntrMain.cc
@@ -202,7 +202,7 @@ newUNIXsocket(char *fpath)
   // Set the close on exec flag so our children do not
   //  have this socket open
   if (fcntl(socketFD, F_SETFD, 1) < 0) {
-    mgmt_elog(stderr, "[newUNIXSocket] Unable to set close on exec flag\n");
+    mgmt_elog(stderr, errno, "[newUNIXSocket] Unable to set close on exec flag\n");
   }
 
   return socketFD;
@@ -228,7 +228,7 @@ newTcpSocket(int port)
 
   // Create the new TCP Socket
   if ((socketFD = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
-    mgmt_fatal(stderr, "[newTcpSocket]: %s", "Unable to Create Socket\n");
+    mgmt_fatal(stderr, errno, "[newTcpSocket]: %s", "Unable to Create Socket\n");
     return -1;
   }
   // Specify our port number is network order
@@ -239,24 +239,24 @@ newTcpSocket(int port)
 
   // Allow for immediate re-binding to port
   if (setsockopt(socketFD, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
-    mgmt_fatal(stderr, "[newTcpSocket] Unable to set socket options.\n");
+    mgmt_fatal(stderr, errno, "[newTcpSocket] Unable to set socket options.\n");
   }
   // Bind the port to the socket
   if (bind(socketFD, (sockaddr *) & socketInfo, sizeof(socketInfo)) < 0) {
-    mgmt_elog(stderr, "[newTcpSocket] Unable to bind port %d to socket: %s\n", port, strerror(errno));
+    mgmt_elog(stderr, 0, "[newTcpSocket] Unable to bind port %d to socket: %s\n", port, strerror(errno));
     close_socket(socketFD);
     return -1;
   }
   // Listen on the new socket
   if (listen(socketFD, 5) < 0) {
-    mgmt_elog(stderr, "[newTcpSocket] %s\n", "Unable to listen on the socket");
+    mgmt_elog(stderr, errno, "[newTcpSocket] %s\n", "Unable to listen on the socket");
     close_socket(socketFD);
     return -1;
   }
   // Set the close on exec flag so our children do not
   //  have this socket open
   if (fcntl(socketFD, F_SETFD, 1) < 0) {
-    mgmt_elog(stderr, "[newTcpSocket] Unable to set close on exec flag\n");
+    mgmt_elog(stderr, errno, "[newTcpSocket] Unable to set close on exec flag\n");
   }
 
   return socketFD;
@@ -408,7 +408,7 @@ webIntr_main(void *)
   ink_assert(found);
 
   if (autoconfContext.docRoot == NULL) {
-    mgmt_fatal(stderr, "[WebIntrMain] No Client AutoConf Root\n");
+    mgmt_fatal(stderr, 0, "[WebIntrMain] No Client AutoConf Root\n");
   } else {
     struct stat s;
     int err;
@@ -417,10 +417,10 @@ webIntr_main(void *)
       ats_free(autoconfContext.docRoot);
       autoconfContext.docRoot = ats_strdup(system_config_directory);
       if ((err = stat(autoconfContext.docRoot, &s)) < 0) {
-        mgmt_elog("[WebIntrMain] unable to stat() directory '%s': %d %d, %s\n",
+        mgmt_elog(0, "[WebIntrMain] unable to stat() directory '%s': %d %d, %s\n",
                 autoconfContext.docRoot, err, errno, strerror(errno));
-        mgmt_elog("[WebIntrMain] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
-        mgmt_fatal(stderr, "[WebIntrMain] No Client AutoConf Root\n");
+        mgmt_elog(0, "[WebIntrMain] please set config path via command line '-path <path>' or 'proxy.config.config_dir' \n");
+        mgmt_fatal(stderr, 0, "[WebIntrMain] No Client AutoConf Root\n");
       }
     }
     autoconfContext.docRootLen = strlen(autoconfContext.docRoot);
@@ -467,7 +467,7 @@ webIntr_main(void *)
     lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_WEB_ERROR, pacFailMsg);
   } else {
     if ((autoconfFD = newTcpSocket(publicPort)) < 0) {
-      mgmt_elog(stderr, "[WebIntrMain] Unable to start client autoconf server\n");
+      mgmt_elog(stderr, errno, "[WebIntrMain] Unable to start client autoconf server\n");
       lmgmt->alarm_keeper->signalAlarm(MGMT_ALARM_WEB_ERROR, pacFailMsg);
     }
   }
@@ -553,7 +553,7 @@ webIntr_main(void *)
               wGlobals.serviceThrArray[i].threadId = thrId;
             } else {
               // Failed to create thread
-              mgmt_elog(stderr, "[WebIntrMain] Failed to create service thread\n");
+              mgmt_elog(stderr, errno, "[WebIntrMain] Failed to create service thread\n");
               wGlobals.serviceThrArray[i].threadId = 0;
               wGlobals.serviceThrArray[i].fd = -1;
               close_socket(clientFD);
@@ -567,7 +567,7 @@ webIntr_main(void *)
 
             break;
           } else if (i == MAX_SERVICE_THREADS - 1) {
-            mgmt_fatal(stderr, "[WebIntrMain] Syncronizaion Failure\n");
+            mgmt_fatal(stderr, 0, "[WebIntrMain] Syncronizaion Failure\n");
             _exit(1);
           }
         }


Mime
View raw message