trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1058347 - in /trafficserver/traffic/trunk: example/remap/ iocore/aio/ iocore/cache/ lib/ts/ proxy/ proxy/hdrs/ proxy/logging/ proxy/mgmt2/ proxy/mgmt2/cli/ proxy/mgmt2/cli2/ proxy/mgmt2/cluster/ proxy/mgmt2/cop/ proxy/mgmt2/tools/ proxy/mg...
Date Wed, 12 Jan 2011 23:13:42 GMT
Author: zwoop
Date: Wed Jan 12 23:13:41 2011
New Revision: 1058347

URL: http://svn.apache.org/viewvc?rev=1058347&view=rev
Log:
TS-491 ports used by Cluser function opened even no clustering

This will effectively disable the cluster port (8088) if
clustering is not enabled. In addition, traffic_cop is now
also checking the "cli" (unix domain socket) for health. And
of course, it only checks the health of the cluster port if
clustering is enabled.

Modified:
    trafficserver/traffic/trunk/example/remap/remap.cc
    trafficserver/traffic/trunk/iocore/aio/test_AIO.i
    trafficserver/traffic/trunk/iocore/cache/Cache.cc
    trafficserver/traffic/trunk/iocore/cache/CacheHosting.cc
    trafficserver/traffic/trunk/lib/ts/SimpleTokenizer.h
    trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
    trafficserver/traffic/trunk/proxy/hdrs/load_http_hdr.cc
    trafficserver/traffic/trunk/proxy/logging/LogConfig.cc
    trafficserver/traffic/trunk/proxy/logging/LogFieldAliasMap.cc
    trafficserver/traffic/trunk/proxy/mgmt2/WebPluginList.h
    trafficserver/traffic/trunk/proxy/mgmt2/cli/CliMain.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h
    trafficserver/traffic/trunk/proxy/mgmt2/cli2/cliParseArg.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cli2/createArgument.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.cc
    trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.h
    trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc
    trafficserver/traffic/trunk/proxy/mgmt2/tools/SysAPI.cc
    trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc
    trafficserver/traffic/trunk/rc/update_records.cc

Modified: trafficserver/traffic/trunk/example/remap/remap.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/example/remap/remap.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/example/remap/remap.cc (original)
+++ trafficserver/traffic/trunk/example/remap/remap.cc Wed Jan 12 23:13:41 2011
@@ -91,7 +91,7 @@ argv(NULL)
   if (_argc > 0 && _argv && (argv = (char **) malloc(sizeof(char *) * (_argc + 1))) != 0) {
     argc = _argc;
     for (i = 0; i < argc; i++)
-      argv[i] = strdup(_argv[i]);
+      argv[i] = TSstrdup(_argv[i]);
     argv[i] = NULL;
   }
 }

Modified: trafficserver/traffic/trunk/iocore/aio/test_AIO.i
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/aio/test_AIO.i?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/aio/test_AIO.i (original)
+++ trafficserver/traffic/trunk/iocore/aio/test_AIO.i Wed Jan 12 23:13:41 2011
@@ -451,7 +451,7 @@ read_config(const char *config_filename)
       else if (strcmp(field_name, "disk_path") == 0) {
       assert(n_disk_path < MAX_DISK_THREADS);
       fin >> field_value;
-      disk_path[n_disk_path] = strdup(field_value);
+      disk_path[n_disk_path] = xstrdup(field_value);
       cout << "reading disk_path = " << disk_path[n_disk_path] << endl;
       n_disk_path++;
     }

Modified: trafficserver/traffic/trunk/iocore/cache/Cache.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/Cache.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/Cache.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/Cache.cc Wed Jan 12 23:13:41 2011
@@ -1012,7 +1012,7 @@ int
 Part::init(char *s, off_t blocks, off_t dir_skip, bool clear)
 {
   dir_skip = ROUND_TO_STORE_BLOCK((dir_skip < START_POS ? START_POS : dir_skip));
-  path = strdup(s);
+  path = xstrdup(s);
   const size_t hash_id_size = strlen(s) + 32;
   hash_id = (char *) malloc(hash_id_size);
   ink_strncpy(hash_id, s, hash_id_size);

Modified: trafficserver/traffic/trunk/iocore/cache/CacheHosting.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/iocore/cache/CacheHosting.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/iocore/cache/CacheHosting.cc (original)
+++ trafficserver/traffic/trunk/iocore/cache/CacheHosting.cc Wed Jan 12 23:13:41 2011
@@ -492,6 +492,7 @@ CacheHostRecord::Init(matcher_line * lin
   err[0] = 0;
   int is_part_present = 0;
   char config_file[PATH_NAME_MAX];
+
   IOCORE_ReadConfigString(config_file, "proxy.config.cache.hosting_filename", PATH_NAME_MAX);
   type = typ;
   for (i = 0; i < MATCHER_MAX_TOKENS; i++) {
@@ -502,7 +503,7 @@ CacheHostRecord::Init(matcher_line * lin
 
     if (!strcasecmp(label, "partition")) {
       /* parse the list of partitions */
-      val = strdup(line_info->line[1][i]);
+      val = xstrdup(line_info->line[1][i]);
       char *part_no = val;
       char *s = val;
       int partition_number;

Modified: trafficserver/traffic/trunk/lib/ts/SimpleTokenizer.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/SimpleTokenizer.h?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/SimpleTokenizer.h (original)
+++ trafficserver/traffic/trunk/lib/ts/SimpleTokenizer.h Wed Jan 12 23:13:41 2011
@@ -28,12 +28,11 @@
 #include <string.h>
 #include <ctype.h>
 #include "ink_bool.h"
+#include "ink_resource.h"
 
 /*-----------------------------------------------------------------------------
   SimpleTokenizer
 
-
-
   This class provides easy token parsing from an input string. It supports:
 
   1- ignoring (or not) of null fields
@@ -128,14 +127,15 @@ public:
     OVERWRITE_INPUT_STRING = 8
   };
 
-  SimpleTokenizer(char delimiter = ' ', int mode = 0, char escape = '\\'):
-  _data(0), _delimiter(delimiter), _mode(mode), _escape(escape), _start(0), _length(0) {
-  };
+  SimpleTokenizer(char delimiter = ' ', int mode = 0, char escape = '\\')
+    : _data(0), _delimiter(delimiter), _mode(mode), _escape(escape), _start(0), _length(0)
+  {  }
 
-SimpleTokenizer(char *s, char delimiter = ' ', int mode = 0, char escape = '\\'):
-  _data(0), _delimiter(delimiter), _mode(mode), _escape(escape) {
+SimpleTokenizer(char *s, char delimiter = ' ', int mode = 0, char escape = '\\')
+  : _data(0), _delimiter(delimiter), _mode(mode), _escape(escape)
+  {
     setString(s);
-  };
+  }
 
   ~SimpleTokenizer() {
     _clearData();
@@ -147,7 +147,7 @@ SimpleTokenizer(char *s, char delimiter 
 
     _start = 0;
     _length = strlen(s);
-    _data = (_mode & OVERWRITE_INPUT_STRING ? s : strdup(s));
+    _data = (_mode & OVERWRITE_INPUT_STRING ? s : xstrdup(s));
 
     // to handle the case where there is a null field at the end of the
     // input string, we replace the null character at the end of the

Modified: trafficserver/traffic/trunk/proxy/InkAPITestTool.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPITestTool.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPITestTool.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPITestTool.cc Wed Jan 12 23:13:41 2011
@@ -501,7 +501,7 @@ synclient_txn_send_request(ClientTxn * t
   TSCont cont;
 
   TSAssert(txn->magic == MAGIC_ALIVE);
-  txn->request = strdup(request);
+  txn->request = xstrdup(request);
   SET_TEST_HANDLER(txn->current_handler, synclient_txn_connect_handler);
 
   cont = TSContCreate(synclient_txn_main_handler, TSMutexCreate());
@@ -516,7 +516,7 @@ synclient_txn_send_request_to_vc(ClientT
 {
   TSCont cont;
   TSAssert(txn->magic == MAGIC_ALIVE);
-  txn->request = strdup(request);
+  txn->request = xstrdup(request);
   SET_TEST_HANDLER(txn->current_handler, synclient_txn_connect_handler);
 
   cont = TSContCreate(synclient_txn_main_handler, TSMutexCreate());

Modified: trafficserver/traffic/trunk/proxy/hdrs/load_http_hdr.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/load_http_hdr.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/load_http_hdr.cc (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/load_http_hdr.cc Wed Jan 12 23:13:41 2011
@@ -127,7 +127,7 @@ process_mime_block_impl(MIMEFieldBlockIm
   for (unsigned int i = 0; i < freetop; i++) {
     MIMEField *f = &mblock->m_field_slots[i];
     if (hdrtoken_is_valid_wks_idx(f->m_wks_idx)) {
-      n = strdup(hdrtoken_index_to_wks(f->m_wks_idx));
+      n = xstrdup(hdrtoken_index_to_wks(f->m_wks_idx));
     } else {
       n = load_string(f->m_ptr_name, f->m_len_name, offset);
     }

Modified: trafficserver/traffic/trunk/proxy/logging/LogConfig.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogConfig.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogConfig.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogConfig.cc Wed Jan 12 23:13:41 2011
@@ -476,11 +476,8 @@ LogConfig::read_configuration_variables(
   // rolling_offset_hr, or rolling_size_mb because the LogObject takes care of this
   //
   rolling_enabled = (int) LOG_ConfigReadInteger("proxy.config.log.rolling_enabled");
-
   rolling_interval_sec = (int) LOG_ConfigReadInteger("proxy.config.log.rolling_interval_sec");
-
   rolling_offset_hr = (int) LOG_ConfigReadInteger("proxy.config.log.rolling_offset_hr");
-
   rolling_size_mb = (int) LOG_ConfigReadInteger("proxy.config.log.rolling_size_mb");
 
   val = (int) LOG_ConfigReadInteger("proxy.config.log." "auto_delete_rolled_files");
@@ -2374,7 +2371,7 @@ LogConfig::read_log_hosts_file(size_t * 
             continue;
           }
           LogUtils::strip_trailing_newline(line);
-          hosts[i] = strdup(line);
+          hosts[i] = xstrdup(line);
           ++i;
         }
         ink_assert(i == nhosts);

Modified: trafficserver/traffic/trunk/proxy/logging/LogFieldAliasMap.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/logging/LogFieldAliasMap.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/logging/LogFieldAliasMap.cc (original)
+++ trafficserver/traffic/trunk/proxy/logging/LogFieldAliasMap.cc Wed Jan 12 23:13:41 2011
@@ -70,7 +70,7 @@ LogFieldAliasTable::init(size_t numPairs
     size_t i = val - m_min;
     name = va_arg(ap, char *);
 
-    m_table[i].name = strdup(name);
+    m_table[i].name = xstrdup(name);
     m_table[i].length = strlen(name);
     m_table[i].valid = true;
   }

Modified: trafficserver/traffic/trunk/proxy/mgmt2/WebPluginList.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/WebPluginList.h?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/WebPluginList.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/WebPluginList.h Wed Jan 12 23:13:41 2011
@@ -39,8 +39,8 @@ struct WebPluginConfig
 {
   WebPluginConfig(const char *aName, const char *aConfigPath)
   {
-    name = strdup(aName);
-    config_path = strdup(aConfigPath);
+    name = xstrdup(aName);
+    config_path = xstrdup(aConfigPath);
     next = NULL;
   }
    ~WebPluginConfig(void)

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli/CliMain.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli/CliMain.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli/CliMain.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli/CliMain.cc Wed Jan 12 23:13:41 2011
@@ -84,7 +84,7 @@ static int ClearNode;
 static int timeout_arg;
 
 static void
-handleArgInvocation(clientCLI * cli)
+handleArgInvocation(ClientCLI * cli)
 {
   char bufToLm[1024];           // buffer to send request to Local Manager
   textBuffer response(512);     // textBuffer object to hold response
@@ -214,7 +214,7 @@ handleArgInvocation(clientCLI * cli)
 }                               // end handleArgInvocation
 
 static void
-runInteractive(clientCLI * cli)
+runInteractive(ClientCLI * cli)
 {
   char buf[512];                // holds request from interactive prompt
   char sendbuf[512];            // holds request to send LM
@@ -318,7 +318,7 @@ main(int argc, char **argv)
 
   // Before accessing file system initialize Layout engine
   Layout::create();
-  clientCLI *cli = new clientCLI();
+  ClientCLI *cli = new ClientCLI();
 
 /* Argument description table used to describe how to parse command line args, */
 /* see 'ink_args.h' for meanings of the various fields */
@@ -373,19 +373,18 @@ main(int argc, char **argv)
 
   // Connect to Local Manager
 #ifndef _WIN32
-  if (cli->connectToLM() != clientCLI::err_none) {
+  if (cli->connectToLM() != ClientCLI::err_none) {
     char sock_path[PATH_NAME_MAX + 1];
 
-    Layout::relative_to(sock_path, sizeof(sock_path),
-                        Layout::get()->runtimedir, clientCLI::defaultSockPath);
+    Layout::relative_to(sock_path, sizeof(sock_path), Layout::get()->runtimedir, ClientCLI::defaultSockPath);
     cli->setSockPath(sock_path);
-    if (cli->connectToLM() != clientCLI::err_none) {
+    if (cli->connectToLM() != ClientCLI::err_none) {
       fprintf(stderr, "%s: unable to connect to traffic_manager via %s\n", programName, cli->sockPath);
       exit(1);
     }
   }
 #else
-  if (cli->connectToLM() != clientCLI::err_none) {
+  if (cli->connectToLM() != ClientCLI::err_none) {
     fprintf(stderr, "%s: unable to connect to traffic_manager via %s\n", programName, cli->sockPath);
     exit(1);
   }

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.cc Wed Jan 12 23:13:41 2011
@@ -24,7 +24,7 @@
 /***************************************/
 /****************************************************************************
  *
- *  clientCLI.cc - A simple client to communicate to local manager
+ *  ClientCLI.cc - A simple client to communicate to local manager
  *
  *
  ****************************************************************************/
@@ -36,7 +36,7 @@
 #include "CliUtils.h"           /* cli_read_timeout(), cli_write_timeout(),GetTSDirectory() */
 #include "clientCLI.h"
 
-const char *clientCLI::CliResultStr[] = {
+const char *ClientCLI::CliResultStr[] = {
   "no error",
   "traffic_manager refusing onnection",
   "unable to connect to traffic_manager",
@@ -45,38 +45,38 @@ const char *clientCLI::CliResultStr[] = 
 };
 
 #ifndef _WIN32
-const char *clientCLI::defaultSockPath = "cli";
+const char *ClientCLI::defaultSockPath = "cli";
 #else
-const int clientCLI::defaultCliPort = 9000;
+const int ClientCLI::defaultCliPort = 9000;
 #endif
 
-clientCLI::clientCLI(void)
+ClientCLI::ClientCLI(void)
   : socketFD(0)
 {
 #ifndef _WIN32
-  ink_strncpy(sockPath, clientCLI::defaultSockPath, sizeof(sockPath));
+  ink_strncpy(sockPath, ClientCLI::defaultSockPath, sizeof(sockPath));
 #else
-  cliPort = clientCLI::defaultCliPort;
+  cliPort = ClientCLI::defaultCliPort;
 #endif
   //coverity[uninit_member]
 }
 
 #ifndef _WIN32
 void
-clientCLI::setSockPath(const char *path)
+ClientCLI::setSockPath(const char *path)
 {
   ink_strncpy(sockPath, path, sizeof(sockPath));
 }
 #else
 void
-clientCLI::setCliPort(int port)
+ClientCLI::setCliPort(int port)
 {
   cliPort = port;
 }
 #endif
 
-clientCLI::CliResult
-clientCLI::disconnectFromLM(void)
+ClientCLI::CliResult
+ClientCLI::disconnectFromLM(void)
 {
   close_socket(socketFD);
   socketFD = 0;
@@ -90,8 +90,8 @@ clientCLI::disconnectFromLM(void)
 //    process via the UNIX domain socket
 //    referenced by sockPath
 //
-clientCLI::CliResult
-clientCLI::connectToLM(void)
+ClientCLI::CliResult
+ClientCLI::connectToLM(void)
 {
   struct sockaddr_un clientS;
   int sockaddrLen;
@@ -132,8 +132,8 @@ clientCLI::connectToLM(void)
 
 #else /* WIN32 */
 
-clientCLI::CliResult
-clientCLI::connectToLM(void)
+ClientCLI::CliResult
+ClientCLI::connectToLM(void)
 {
   struct sockaddr_in clientS;
   int sockaddrLen;
@@ -166,7 +166,7 @@ clientCLI::connectToLM(void)
 //    Timeout is in milliseconds
 //
 int
-clientCLI::readResponse(textBuffer * output, ink_hrtime timeout)
+ClientCLI::readResponse(textBuffer * output, ink_hrtime timeout)
 {
   int readBytes = 0;            // number of bytes read
   int readResult = 0;           // status of read
@@ -200,7 +200,7 @@ clientCLI::readResponse(textBuffer * out
 }                               // end readResponse()
 
 int
-clientCLI::sendCommand(const char *cmd, textBuffer * response, ink_hrtime timeout)
+ClientCLI::sendCommand(const char *cmd, textBuffer * response, ink_hrtime timeout)
 {
   // Timeout vars
   ink_hrtime timeLeft, endTime = 0;
@@ -224,8 +224,8 @@ clientCLI::sendCommand(const char *cmd, 
   return readResponse(response, timeLeft);
 }
 
-clientCLI::CliResult
-clientCLI::startupLocal(void)
+ClientCLI::CliResult
+ClientCLI::startupLocal(void)
 {
   textBuffer response(512);                // textBuffer object to hold response
   //char*       responseStr;   // actual response string
@@ -252,8 +252,8 @@ clientCLI::startupLocal(void)
   return err_tm_invalid_resp;
 }
 
-clientCLI::CliResult
-clientCLI::shutdownLocal(void)
+ClientCLI::CliResult
+ClientCLI::shutdownLocal(void)
 {
   textBuffer response(512);                // textBuffer object to hold response
   //char*       responseStr;   // actual response string
@@ -280,8 +280,8 @@ clientCLI::shutdownLocal(void)
   return err_tm_invalid_resp;
 }
 
-clientCLI::CliResult
-clientCLI::probeLocal(bool * running)
+ClientCLI::CliResult
+ClientCLI::probeLocal(bool * running)
 {
   textBuffer response(512);                // textBuffer object to hold response
   //char*       responseStr;   // actual response string
@@ -316,8 +316,8 @@ clientCLI::probeLocal(bool * running)
   return result;
 }
 
-clientCLI::CliResult
-clientCLI::getVariable(const char *name, char **value)
+ClientCLI::CliResult
+ClientCLI::getVariable(const char *name, char **value)
 {
   textBuffer response(512);                // textBuffer object to hold response
   //char*       responseStr;   // actual response string
@@ -330,7 +330,6 @@ clientCLI::getVariable(const char *name,
 
   snprintf(requestStr, sizeof(requestStr), "b get %s", name);
   sendCommand(requestStr, &response);
-  //responseStr = response.bufPtr();
 
   // parse response request from server into 3 tokens:
   // status, prompt and response
@@ -343,7 +342,7 @@ clientCLI::getVariable(const char *name,
   if (status && *status == '1') {       // OK
     if (resp != NULL) {
       result = err_none;
-      *value = strdup(resp);
+      *value = xstrdup(resp);
     } else {
       *value = NULL;
     }

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli/clientCLI.h Wed Jan 12 23:13:41 2011
@@ -21,7 +21,6 @@
   limitations under the License.
  */
 
-/***************************************/
 /****************************************************************************
  *
  *  clientCLI.h - A simple client to communicate to local manager
@@ -38,7 +37,7 @@
 class textBuffer;
 
 /* Client side part of CLI */
-class clientCLI
+class ClientCLI
 {
 public:
 
@@ -53,8 +52,8 @@ public:
 
   static const char *CliResultStr[];
 
-  clientCLI(void);
-  ~clientCLI(void) {}
+  ClientCLI(void);
+  ~ClientCLI(void) {}
 
 #ifndef _WIN32
    void setSockPath(const char *path);
@@ -98,8 +97,8 @@ private:
   int socketFD;
 
   /* copy constructor and assignment operator are private */
-  clientCLI(const clientCLI &);
-  clientCLI & operator =(const clientCLI &);
+  ClientCLI(const ClientCLI &);
+  ClientCLI & operator =(const ClientCLI &);
 };
 
 #endif /* _CLIENT_CLI_H_ */

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli2/cliParseArg.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli2/cliParseArg.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli2/cliParseArg.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli2/cliParseArg.cc Wed Jan 12 23:13:41 2011
@@ -253,14 +253,14 @@ cliParseArgument(int argc, const char **
             Tcl_AppendResult(interp, "\"", curArg, "\" option requires an additional argument", (char *) NULL);
             return TCL_ERROR;
           }
-          parsedInfoPtr->arg_string = strdup(argv[srcIndex]);
+          parsedInfoPtr->arg_string = xstrdup(argv[srcIndex]);
           parsedInfoPtr->parsed_args = infoPtr->arg_ref;
           srcIndex++;
           argc--;
           break;
         case CLI_ARGV_OPTION_NAME_VALUE:
           if (argc > 0) {
-            parsedInfoPtr->arg_string = strdup(argv[srcIndex]);
+            parsedInfoPtr->arg_string = xstrdup(argv[srcIndex]);
           }
           parsedInfoPtr->parsed_args = infoPtr->arg_ref;
           break;
@@ -361,13 +361,13 @@ cliParseArgument(int argc, const char **
 
 
         if (prevMatchPtr->type != CLI_ARGV_OPTION_NAME_VALUE) {
-          parsedInfoPtr->data = strdup(curArg);
+          parsedInfoPtr->data = xstrdup(curArg);
           parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_DATA;
         } else
           parsedInfoPtr--;
 
       } else {
-        parsedInfoPtr->data = strdup(curArg);
+        parsedInfoPtr->data = xstrdup(curArg);
         parsedInfoPtr->parsed_args = CLI_PARSED_ARGV_DATA;
       }
     }

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cli2/createArgument.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cli2/createArgument.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cli2/createArgument.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cli2/createArgument.cc Wed Jan 12 23:13:41 2011
@@ -153,7 +153,7 @@ findRequired(cli_ArgvInfo * argtable)
   for (infoPtr = argtable; (infoPtr->key != NULL); infoPtr++) {
     if (infoPtr->option == CLI_ARGV_REQUIRED) {
 
-      args[i] = strdup(infoPtr->key);
+      args[i] = xstrdup(infoPtr->key);
       i++;
     }
   }
@@ -260,7 +260,7 @@ getIntRange(char *range, int *r1, int *r
   char *endPtr;
 
   buf = (char *) ckalloc(sizeof(char) * 256);
-  range_str = strdup(range);
+  range_str = xstrdup(range);
   len = strlen(range_str);
   range_str[len] = 0;
   str = range_str;
@@ -334,7 +334,7 @@ getFloatRange(char *range, float *r1, fl
   char *endPtr;
 
   buf = (char *) ckalloc(sizeof(char) * 256);
-  range_str = strdup(range);
+  range_str = xstrdup(range);
   len = strlen(range_str);
   range_str[len] = 0;
   str = range_str;

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.cc Wed Jan 12 23:13:41 2011
@@ -165,163 +165,136 @@ drainIncomingChannel(void *arg)
       }
 #endif
 
-      if (lmgmt->ccom->cluster_type == NO_CLUSTER) {
-        // In no cluster mode, all we want is for the cop
-        //   to be able to heartbeat us
-
-
-        // Only allow localhosts requests since all we
-        //   should get is stuff from the cop
-        if (strcmp(inet_ntoa(cli_addr.sin_addr), "127.0.0.1") == 0) {
-
-          /* Handle Request */
-          if (mgmt_readline(req_fd, message, 61440) > 0) {
-
-            if (!checkBackDoor(req_fd, message)) {      /* Heh... */
-              mgmt_log("[ClusterCom::drainIncomingChannel] Unexpected message on cluster"
-                       " port.  Possibly an attack\n");
-              Debug("ccom", "Unknown message to rsport received: %s", message);
-            }
-          }
-        } else {
-          mgmt_log("[ClusterCom::drainIncomingChannel] Unexpected message on cluster" " port.  Possibly an attack\n");
-        }
-
-      } else {
-
-        /* Handle Request */
-        if (mgmt_readline(req_fd, message, 61440) > 0) {
+      // In no cluster mode, the rsport should not be listening.
+      ink_release_assert(lmgmt->ccom->cluster_type != NO_CLUSTER);
 
-          if (strstr(message, "aresolv: ")) {
+      /* Handle Request */
+      if (mgmt_readline(req_fd, message, 61440) > 0) {
+        if (strstr(message, "aresolv: ")) {
+          /* Peer is Resolving our alarm */
+          alarm_t a;
 
-            /* Peer is Resolving our alarm */
-            alarm_t a;
-
-            // coverity[secure_coding]
-            if (sscanf(message, "aresolv: %d", &a) != 1) {
-              close_socket(req_fd);
-              continue;
-            }
-            lmgmt->alarm_keeper->resolveAlarm(a);
-          } else if (strstr(message, "unmap: ")) {
-
-            /*
-             * Explicit virtual ip unmap request. Note order unmap then
-             * map for strstr.
-             */
-            char msg_ip[80];
-            const char *msg;
-            if (sscanf(message, "unmap: %79s", msg_ip) != 1) {
-              close_socket(req_fd);
-              continue;
-            }
-
-            mgmt_log("[drainIncomingChannel] Got unmap request: '%s'\n", message);
+          // coverity[secure_coding]
+          if (sscanf(message, "aresolv: %d", &a) != 1) {
+            close_socket(req_fd);
+            continue;
+          }
+          lmgmt->alarm_keeper->resolveAlarm(a);
+        } else if (strstr(message, "unmap: ")) {
+          /*
+           * Explicit virtual ip unmap request. Note order unmap then
+           * map for strstr.
+           */
+          char msg_ip[80];
+          const char *msg;
+          if (sscanf(message, "unmap: %79s", msg_ip) != 1) {
+            close_socket(req_fd);
+            continue;
+          }
 
-            ink_mutex_acquire(&(lmgmt->ccom->mutex));   /* Grab the lock */
-            if (lmgmt->virt_map->rl_unmap(msg_ip)) {    /* Requires lock */
-              msg = "unmap: done";
-            } else {
-              msg = "unmap: failed";
-            }
-            ink_mutex_release(&(lmgmt->ccom->mutex));   /* Release the lock */
+          mgmt_log("[drainIncomingChannel] Got unmap request: '%s'\n", message);
 
-            mgmt_writeline(req_fd, msg, strlen(msg));
+          ink_mutex_acquire(&(lmgmt->ccom->mutex));   /* Grab the lock */
+          if (lmgmt->virt_map->rl_unmap(msg_ip)) {    /* Requires lock */
+            msg = "unmap: done";
+          } else {
+            msg = "unmap: failed";
+          }
+          ink_mutex_release(&(lmgmt->ccom->mutex));   /* Release the lock */
 
-            /* Wait for peer to read status */
-            if (mgmt_readline(req_fd, message, 61440) != 0) {
-              mgmt_elog("[drainIncomingChannel] Connection not closed\n");
-            }
-          } else if (strstr(message, "map: ")) {
+          mgmt_writeline(req_fd, msg, strlen(msg));
 
-            /* Explicit virtual ip map request */
-            char msg_ip[80];
-            const char *msg;
-            if (sscanf(message, "map: %79s", msg_ip) != 1) {
-              close_socket(req_fd);
-              continue;
-            }
+          /* Wait for peer to read status */
+          if (mgmt_readline(req_fd, message, 61440) != 0) {
+            mgmt_elog("[drainIncomingChannel] Connection not closed\n");
+          }
+        } else if (strstr(message, "map: ")) {
+          /* Explicit virtual ip map request */
+          char msg_ip[80];
+          const char *msg;
+          if (sscanf(message, "map: %79s", msg_ip) != 1) {
+            close_socket(req_fd);
+            continue;
+          }
 
-            mgmt_log("[drainIncomingChannel] Got map request: '%s'\n", message);
+          mgmt_log("[drainIncomingChannel] Got map request: '%s'\n", message);
 
-            if (lmgmt->run_proxy) {
+          if (lmgmt->run_proxy) {
 
-              ink_mutex_acquire(&(lmgmt->ccom->mutex)); /* Grab the lock */
-              if (lmgmt->virt_map->rl_map(msg_ip)) {    /* Requires the lock */
-                msg = "map: done";
-              } else {
-                msg = "map: failed";
-              }
-              ink_mutex_release(&(lmgmt->ccom->mutex)); /* Release the lock */
+            ink_mutex_acquire(&(lmgmt->ccom->mutex)); /* Grab the lock */
+            if (lmgmt->virt_map->rl_map(msg_ip)) {    /* Requires the lock */
+              msg = "map: done";
             } else {
               msg = "map: failed";
             }
+            ink_mutex_release(&(lmgmt->ccom->mutex)); /* Release the lock */
+          } else {
+            msg = "map: failed";
+          }
 
-            mgmt_writeline(req_fd, msg, strlen(msg));
+          mgmt_writeline(req_fd, msg, strlen(msg));
 
-            /* Wait for peer to read status */
-            if (mgmt_readline(req_fd, message, 61440) != 0) {
-              mgmt_elog("[drainIncomingChannel] Connection not closedx\n");
-            }
+          /* Wait for peer to read status */
+          if (mgmt_readline(req_fd, message, 61440) != 0) {
+            mgmt_elog("[drainIncomingChannel] Connection not closedx\n");
+          }
 
-          } else if (strstr(message, "file: ")) {
+        } else if (strstr(message, "file: ")) {
+          /* Requesting a config file from us */
+          bool stat = false;
+          char fname[1024];
+          version_t ver;
+          textBuffer *buff = NULL;
+          Rollback *rb;
 
-            /* Requesting a config file from us */
-            bool stat = false;
-            char fname[1024];
-            version_t ver;
-            textBuffer *buff = NULL;
-            Rollback *rb;
-
-            /* Get the file and blast it back */
-            if (sscanf(message, "file: %1023s %d", fname, &ver) != 2) {
-              close_socket(req_fd);
-              continue;
-            }
+          /* Get the file and blast it back */
+          if (sscanf(message, "file: %1023s %d", fname, &ver) != 2) {
+            close_socket(req_fd);
+            continue;
+          }
 
-            if (configFiles->getRollbackObj(fname, &rb) &&
-                (rb->getCurrentVersion() == ver) && (rb->getVersion(ver, &buff) == OK_ROLLBACK)) {
-              size_t bytes_written = 0;
-              stat = true;
-              bytes_written = write_socket(req_fd, buff->bufPtr(), strlen(buff->bufPtr()));
-              if (bytes_written != strlen(buff->bufPtr())) {
-                stat = false;
-                mgmt_log(stderr, "[drainIncomingChannel] Failed file req: %s v: %d\n", fname, ver);
-              } else {
-                mgmt_log(stderr,
-                         "[drainIncomingChannel] file req: %s v: %d bytes: %d\n", fname, ver, strlen(buff->bufPtr()));
-              }
+          if (configFiles->getRollbackObj(fname, &rb) &&
+              (rb->getCurrentVersion() == ver) && (rb->getVersion(ver, &buff) == OK_ROLLBACK)) {
+            size_t bytes_written = 0;
+            stat = true;
+            bytes_written = write_socket(req_fd, buff->bufPtr(), strlen(buff->bufPtr()));
+            if (bytes_written != strlen(buff->bufPtr())) {
+              stat = false;
+              mgmt_log(stderr, "[drainIncomingChannel] Failed file req: %s v: %d\n", fname, ver);
             } else {
-              mgmt_elog("[drainIncomingChannel] Error file req: %s ver: %d\n", fname, ver);
+              mgmt_log(stderr,
+                       "[drainIncomingChannel] file req: %s v: %d bytes: %d\n", fname, ver, strlen(buff->bufPtr()));
             }
+          } else {
+            mgmt_elog("[drainIncomingChannel] Error file req: %s ver: %d\n", fname, ver);
+          }
 
-            if (!stat) {
-              const char *msg = "file: failed";
-              mgmt_writeline(req_fd, msg, strlen(msg));
-            }
-            if (buff)
-              delete buff;
-          } else if (strstr(message, "cmd: shutdown_manager")) {
-            mgmt_log("[ClusterCom::drainIncomingChannel] Received manager shutdown request\n");
-            lmgmt->mgmtShutdown(0);
-          } else if (strstr(message, "cmd: shutdown_process")) {
-            mgmt_log("[ClusterCom::drainIncomingChannel] Received process shutdown request\n");
-            lmgmt->processShutdown();
-          } else if (strstr(message, "cmd: restart_process")) {
-            mgmt_log("[ClusterCom::drainIncomingChannel] Received restart process request\n");
-            lmgmt->processRestart();
-          } else if (strstr(message, "cmd: bounce_process")) {
-            mgmt_log("[ClusterCom::drainIncomingChannel] Received bounce process request\n");
-            lmgmt->processBounce();
-          } else if (strstr(message, "cmd: clear_stats")) {
-            mgmt_log("[ClusterCom::drainIncomingChannel] Received clear stats request\n");
-            lmgmt->clearStats();
-          } else if (!checkBackDoor(req_fd, message)) { /* Heh... */
-            mgmt_log("[ClusterCom::drainIncomingChannel] Unexpected message on cluster" " port.  Possibly an attack\n");
-            Debug("ccom", "Unknown message to rsport received: %s", message);
-            close_socket(req_fd);
-            continue;
+          if (!stat) {
+            const char *msg = "file: failed";
+            mgmt_writeline(req_fd, msg, strlen(msg));
           }
+          if (buff)
+            delete buff;
+        } else if (strstr(message, "cmd: shutdown_manager")) {
+          mgmt_log("[ClusterCom::drainIncomingChannel] Received manager shutdown request\n");
+          lmgmt->mgmtShutdown(0);
+        } else if (strstr(message, "cmd: shutdown_process")) {
+          mgmt_log("[ClusterCom::drainIncomingChannel] Received process shutdown request\n");
+          lmgmt->processShutdown();
+        } else if (strstr(message, "cmd: restart_process")) {
+          mgmt_log("[ClusterCom::drainIncomingChannel] Received restart process request\n");
+          lmgmt->processRestart();
+        } else if (strstr(message, "cmd: bounce_process")) {
+          mgmt_log("[ClusterCom::drainIncomingChannel] Received bounce process request\n");
+          lmgmt->processBounce();
+        } else if (strstr(message, "cmd: clear_stats")) {
+          mgmt_log("[ClusterCom::drainIncomingChannel] Received clear stats request\n");
+          lmgmt->clearStats();
+        } else if (!checkBackDoor(req_fd, message)) { /* Heh... */
+          mgmt_log("[ClusterCom::drainIncomingChannel] Unexpected message on cluster" " port.  Possibly an attack\n");
+          Debug("ccom", "Unknown message to rsport received: %s", message);
+          close_socket(req_fd);
+          continue;
         }
       }
       close_socket(req_fd);
@@ -1597,7 +1570,7 @@ ClusterCom::constructSharedFilePacket(ch
 /*
  * estabilishChannels(...)
  *   Sets up the multi-cast and reliable tcp channels for cluster
- * communication.
+ * communication. But only if clustering is enabled in some shape.
  */
 void
 ClusterCom::establishChannels()
@@ -1605,48 +1578,44 @@ ClusterCom::establishChannels()
   int one = 1;
   struct sockaddr_in serv_addr;
 
-  // We only setup the reliable service port when
-  //   running no clustered.  We need the rs port so
-  //   that the cop can heartbeat us
   if (cluster_type != NO_CLUSTER) {
     establishBroadcastChannel();
     establishReceiveChannel();
-  }
 
-  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");
-    }
+    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");
+      }
 #ifndef _WIN32                  /* no need to set close-on-exec on NT */
-    if (fcntl(reliable_server_fd, F_SETFD, 1) < 0) {
-      mgmt_fatal("[ClusterCom::establishChannels] Unable to set close-on-exec.\n");
-    }
+      if (fcntl(reliable_server_fd, F_SETFD, 1) < 0) {
+        mgmt_fatal("[ClusterCom::establishChannels] Unable to set close-on-exec.\n");
+      }
 #endif
 
-    if (setsockopt(reliable_server_fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(int)) < 0) {
-      mgmt_fatal("[ClusterCom::establishChannels] Unable to set socket options.\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");
+      }
 
-    memset(&serv_addr, 0, sizeof(serv_addr));
-    serv_addr.sin_family = AF_INET;
-    serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
-    serv_addr.sin_port = htons(reliable_server_port);
+      memset(&serv_addr, 0, sizeof(serv_addr));
+      serv_addr.sin_family = AF_INET;
+      serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+      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);
-    }
+      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);
+      }
 
-    if ((listen(reliable_server_fd, 10)) < 0) {
-      mgmt_fatal("[ClusterCom::establishChannels] Unable to listen on socket\n");
+      if ((listen(reliable_server_fd, 10)) < 0) {
+        mgmt_fatal("[ClusterCom::establishChannels] Unable to listen on socket\n");
+      }
     }
   }
 
   Debug("ccom", "[ClusterCom::establishChannels] Channels setup\n");
   init = true;
-
   return;
-}                               /* End ClusterCom::establishChannels */
+}
 
 
 /*

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.h?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.h (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cluster/ClusterCom.h Wed Jan 12 23:13:41 2011
@@ -59,8 +59,11 @@
 #define CLUSTER_CONFIG_FILE_BLURB "# Cluster Configuration file\n#\n# This file is machine generated and machine parsed.\n# Please do not change this file by hand.\n#\n# This file designates the machines which make up the cluster\n# proper.  Data and load are distributed among these machines.\n#\n############################################################################\n# Number\n# IP:Port \n# ...\n############################################################################\n# Number = { 0, 1 ... } where 0 is a stand-alone proxy\n# IP:Port = IP address: cluster accept port number\n#\n# Example 1: stand-alone proxy\n# 0\n#\n# Example 2: 3 machines\n# 3\n# 127.1.2.3:83\n# 127.1.2.4:83\n# 127.1.2.5:83\n#\n"
 
 enum MgmtClusterType
-{ CLUSTER_INVALID = 0, FULL_CLUSTER,
-  MGMT_CLUSTER, NO_CLUSTER
+{
+  CLUSTER_INVALID = 0,
+  FULL_CLUSTER,
+  MGMT_CLUSTER,
+  NO_CLUSTER
 };
 
 enum ClusterMismatch

Modified: trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/cop/TrafficCop.cc Wed Jan 12 23:13:41 2011
@@ -33,6 +33,15 @@
 #include <sys/ipc.h>
 #include <sys/sem.h>
 
+// From ClusterCom.h
+enum MgmtClusterType
+{
+  CLUSTER_INVALID = 0,
+  FULL_CLUSTER,
+  MGMT_CLUSTER,
+  NO_CLUSTER
+};
+
 union semun
 {
   int val;                      /* value for SETVAL */
@@ -88,6 +97,7 @@ static char bin_path[PATH_MAX];
 
 static int autoconf_port = 8083;
 static int rs_port = 8088;
+static int cluster_type = NO_CLUSTER;
 static int http_backdoor_port = 8084;
 static char http_backdoor_ip[PATH_MAX];
 
@@ -519,7 +529,7 @@ build_config_table(FILE * fp)
     }
     varname[i] = '\0';
 
-    ink_hash_table_insert(configTable, varname, strdup(buffer));
+    ink_hash_table_insert(configTable, varname, xstrdup(buffer));
   }
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Leaving build_config_table(%d)\n", fp);
@@ -669,6 +679,7 @@ read_config()
   read_config_int("proxy.config.process_manager.mgmt_port", &http_backdoor_port);
   read_config_int("proxy.config.admin.autoconf_port", &autoconf_port);
   read_config_int("proxy.config.cluster.rsport", &rs_port);
+  read_config_int("proxy.local.cluster.type", &cluster_type);
   read_config_int("proxy.config.lm.sem_id", &sem_id);
 
   // If TS is going to bind to incoming_ip_to_bind, we need to make
@@ -1139,6 +1150,28 @@ read_manager_int(const char *variable, i
 }
 
 static int
+read_cli_int(ClientCLI *cli, const char *variable, int *value)
+{
+  char *resp = NULL;
+  int ret = 0;
+
+  if (cli->connectToLM() != ClientCLI::err_none)
+    return -1;
+
+  if ((cli->getVariable(variable, &resp) == ClientCLI::err_none) && resp) {
+    *value = ink_atoi(resp);
+    xfree(resp);
+  } else {
+    ret = -1;
+    cop_log(COP_WARNING, "(cli test) could not communicate with cli\n");
+  }
+
+  cli->disconnectFromLM();
+  return ret;
+}
+
+
+static int
 test_rs_port()
 {
   char buffer[4096];
@@ -1159,6 +1192,30 @@ test_rs_port()
 
 
 static int
+test_cli_port(ClientCLI *cli)
+{
+  char *resp = NULL;
+  int ret = 0;
+
+  if (cli->connectToLM() != ClientCLI::err_none)
+    return -1;
+
+  if ((cli->getVariable("proxy.config.manager_binary", &resp) == ClientCLI::err_none) && resp) {
+    if (strcmp(resp, manager_binary) != 0) {
+      cop_log(COP_WARNING, "(cli test) bad response value, got %s, expected %s\n", resp, manager_binary);
+      ret = -1;
+    }
+    xfree(resp);
+  } else {
+    ret = -1;
+  }
+
+  cli->disconnectFromLM();
+  return ret;
+}
+
+
+static int
 test_http_port(int port, char *request, int timeout, char *ip = NULL, char *ip_to_bind = NULL)
 {
   char buffer[4096];
@@ -1247,28 +1304,35 @@ test_manager_http_port()
 
 
 static int
-heartbeat_manager()
+heartbeat_manager(ClientCLI *cli)
 {
   int err;
 
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Entering heartbeat_manager()\n");
 #endif
-  err = test_rs_port();
+  // the CLI, and the rsport if cluster is enabled.
+  err = test_cli_port(cli);
+  if ((0 == err) && (cluster_type != NO_CLUSTER))
+    err = test_rs_port();
+
   if (err < 0) {
-    manager_failures += 1;
-    cop_log(COP_WARNING, "manager heartbeat [variable] failed [%d]\n", manager_failures);
+    if (err < 0) {
+      manager_failures += 1;
+      cop_log(COP_WARNING, "manager heartbeat [variable] failed [%d]\n", manager_failures);
 
-    if (manager_failures > 1) {
-      manager_failures = 0;
-      cop_log(COP_WARNING, "killing manager\n");
-      safe_kill(manager_lockfile, manager_binary, true);
-    }
+      if (manager_failures > 1) {
+        manager_failures = 0;
+        cop_log(COP_WARNING, "killing manager\n");
+        safe_kill(manager_lockfile, manager_binary, true);
+      }
 #ifdef TRACE_LOG_COP
-    cop_log(COP_DEBUG, "Leaving heartbeat_manager() --> %d\n", err);
+      cop_log(COP_DEBUG, "Leaving heartbeat_manager() --> %d\n", err);
 #endif
-    return err;
+      return err;
+    }
   }
+
 #if TS_HAS_WEBUI
   err = test_manager_http_port();
 
@@ -1290,7 +1354,6 @@ heartbeat_manager()
       cop_log(COP_WARNING, "manager heartbeat [http] succeeded\n");
     manager_failures = 0;
   }
-
 #endif // TS_HAS_WEBUI
 
 #ifdef TRACE_LOG_COP
@@ -1348,22 +1411,34 @@ heartbeat_server()
 }
 
 static int
-server_up()
+server_up(ClientCLI *cli)
 {
   static int old_val = 0;
-  int val;
+  int val = -1;
   int err;
 
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Entering server_up()\n");
 #endif
-  err = read_manager_int("proxy.node.proxy_running", &val);
-  if (err < 0) {
-    cop_log(COP_WARNING, "could not contact manager, " "assuming server is down\n");
+  if (cluster_type != NO_CLUSTER) {
+    err = read_manager_int("proxy.node.proxy_running", &val);
+    if (err < 0) {
+      cop_log(COP_WARNING, "could not contact manager, " "assuming server is down\n");
 #ifdef TRACE_LOG_COP
-    cop_log(COP_DEBUG, "Leaving server_up() --> 0\n");
+      cop_log(COP_DEBUG, "Leaving server_up() --> 0\n");
 #endif
-    return 0;
+      return 0;
+    }
+  } else {
+    err = read_cli_int(cli, "proxy.node.proxy_running", &val);
+    printf("GOT %d\n", val);
+    if (err < 0) {
+      cop_log(COP_WARNING, "could not contact manager, " "assuming server is down\n");
+#ifdef TRACE_LOG_COP
+      cop_log(COP_DEBUG, "Leaving server_up() --> 0\n");
+#endif
+      return 0;
+    }
   }
 
   if (val != old_val) {
@@ -1402,7 +1477,7 @@ server_up()
 
 
 static void
-check_programs()
+check_programs(ClientCLI *cli)
 {
   int err;
   pid_t holding_pid;
@@ -1495,14 +1570,14 @@ check_programs()
     // running. If there is we test it.
 
     alarm(2 * manager_timeout);
-    err = heartbeat_manager();
+    err = heartbeat_manager(cli);
     alarm(0);
 
     if (err < 0) {
       return;
     }
 
-    if (server_up() <= 0) {
+    if (server_up(cli) <= 0) {
       return;
     }
 
@@ -1632,6 +1707,13 @@ check(void *arg)
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Entering check()\n");
 #endif
+  // Get a CLI
+  char sock_path[PATH_NAME_MAX + 1];
+  ClientCLI *cli = new ClientCLI();
+
+  Layout::relative_to(sock_path, sizeof(sock_path), Layout::get()->runtimedir, ClientCLI::defaultSockPath);
+  cli->setSockPath(sock_path);
+
   for (;;) {
     // problems with the ownership of this file as root Make sure it is
     // owned by the admin user
@@ -1660,27 +1742,24 @@ check(void *arg)
 
       child_pid = child_status = 0;
     }
-    // Get a new CLI
-    clientCLI *cli = new clientCLI();
-
     // Re-read the config file information
     read_config();
 
     // Check to make sure the programs are running
-    check_programs();
+    check_programs(cli);
 
     // Check to see if we're running out of free memory
     check_memory();
 
-    // Get rid of the CLI
-    delete cli;
-
     // Pause to catch our breath. (10 seconds).
     // Use 'millisleep()' because normal 'sleep()' interferes with
     // the SIGALRM signal which we use to heartbeat the cop.
     millisleep(sleep_time * 1000);
   }
 
+  // Get rid of the CLI
+  delete cli;
+
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Leaving check()\n");
 #endif
@@ -1815,12 +1894,9 @@ init_lockfiles()
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Entering init_lockfiles()\n");
 #endif
-  Layout::relative_to(cop_lockfile, sizeof(cop_lockfile),
-                      Layout::get()->runtimedir, COP_LOCK);
-  Layout::relative_to(manager_lockfile, sizeof(manager_lockfile),
-                      Layout::get()->runtimedir, MANAGER_LOCK);
-  Layout::relative_to(server_lockfile, sizeof(server_lockfile),
-                      Layout::get()->runtimedir, SERVER_LOCK);
+  Layout::relative_to(cop_lockfile, sizeof(cop_lockfile), Layout::get()->runtimedir, COP_LOCK);
+  Layout::relative_to(manager_lockfile, sizeof(manager_lockfile), Layout::get()->runtimedir, MANAGER_LOCK);
+  Layout::relative_to(server_lockfile, sizeof(server_lockfile), Layout::get()->runtimedir, SERVER_LOCK);
 
 #ifdef TRACE_LOG_COP
   cop_log(COP_DEBUG, "Leaving init_lockfiles()\n");
@@ -1889,12 +1965,12 @@ init()
 }
 
 int version_flag = 0;
+
 int
 main(int argc, char *argv[])
 {
   int fd;
-  appVersionInfo.setup(PACKAGE_NAME,"traffic_cop", PACKAGE_VERSION, __DATE__,
-                       __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
+  appVersionInfo.setup(PACKAGE_NAME,"traffic_cop", PACKAGE_VERSION, __DATE__, __TIME__, BUILD_MACHINE, BUILD_PERSON, "");
 
   // Before accessing file system initialize Layout engine
   Layout::create();

Modified: trafficserver/traffic/trunk/proxy/mgmt2/tools/SysAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/tools/SysAPI.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/tools/SysAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/tools/SysAPI.cc Wed Jan 12 23:13:41 2011
@@ -1108,7 +1108,7 @@ Net_GetEncryptedRootPassword(char **pass
   if (find == 0)
     *password = NULL;
   else
-    *password = strtok(strdup(shadowPasswd), ":");
+    *password = strtok(xstrdup(shadowPasswd), ":");
   setreuid(old_euid, old_euid);
   return 0;
 }
@@ -1327,7 +1327,7 @@ Net_SetEncryptedRootPassword(char *passw
         fputs(buffer, tmp);
       } else {
         char *buf;
-        if ((buf = strdup(buffer)) != NULL) {
+        if ((buf = xstrdup(buffer)) != NULL) {
           strtok_r(buf, ":", &remainingTokens);
           strtok_r(NULL, ":", &remainingTokens);
           fprintf(tmp, "root:%s:%s", password, remainingTokens);
@@ -2599,7 +2599,7 @@ Net_GetEncryptedRootPassword(char **pass
   if (find == 0)
     *password = NULL;
   else
-    *password = strtok(strdup(shadowPasswd), ":");
+    *password = strtok(xstrdup(shadowPasswd), ":");
   setreuid(old_euid, old_euid);
   return 0;
 }
@@ -2803,7 +2803,7 @@ Net_SetEncryptedRootPassword(char *passw
       if (strncmp(buffer, "root", 4) != 0) {
         fputs(buffer, tmp);
       } else {
-        char *toks = strtok_r(strdup(buffer), ":", &remainingTokens);
+        char *toks = strtok_r(xstrdup(buffer), ":", &remainingTokens);
         toks = strtok_r(NULL, ":", &remainingTokens);
         fprintf(tmp, "root:%s:%s", password, remainingTokens);
       }

Modified: trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc (original)
+++ trafficserver/traffic/trunk/proxy/mgmt2/web2/WebHttp.cc Wed Jan 12 23:13:41 2011
@@ -1146,7 +1146,7 @@ handle_submit_snapshot_to_filesystem(Web
         RecSetRecordString("proxy.config.snapshot_dir", snapDirFromRecordsConf);
         // Create a directory for the snap shot
         if (snap_directory[0] != '/') {
-          char *snap_dir_cpy = strdup(snap_directory);
+          char *snap_dir_cpy = xstrdup(snap_directory);
           int newLen;
 
           newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
@@ -1307,7 +1307,7 @@ handle_submit_snapshot_to_filesystem(Web
       ink_release_assert(found);
 
       if (snap_directory[0] != '/') {
-        char *snap_dir_cpy = strdup(snap_directory);
+        char *snap_dir_cpy = xstrdup(snap_directory);
         int newLen;
 
         newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
@@ -1337,7 +1337,7 @@ handle_submit_snapshot_to_filesystem(Web
         RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
         ink_release_assert(found);
         if (snapDirFromRecordsConf[0] != '/') {
-          char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
+          char *snap_dir_cpy = xstrdup(snapDirFromRecordsConf);
           ink_assert(snap_dir_cpy);
           int newLen;
           newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;
@@ -1362,7 +1362,7 @@ Ldelete:
         RecGetRecordString_Xmalloc("proxy.config.snapshot_dir", &snapDirFromRecordsConf);
         ink_release_assert(found);
         if (snapDirFromRecordsConf[0] != '/') {
-          char *snap_dir_cpy = strdup(snapDirFromRecordsConf);
+          char *snap_dir_cpy = xstrdup(snapDirFromRecordsConf);
           ink_assert(snap_dir_cpy);
           int newLen;
           newLen = strlen(snap_dir_cpy) + strlen(config_dir) + 2;

Modified: trafficserver/traffic/trunk/rc/update_records.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/rc/update_records.cc?rev=1058347&r1=1058346&r2=1058347&view=diff
==============================================================================
--- trafficserver/traffic/trunk/rc/update_records.cc (original)
+++ trafficserver/traffic/trunk/rc/update_records.cc Wed Jan 12 23:13:41 2011
@@ -235,7 +235,7 @@ generate_b_ht_from_b_ht_buf()
       printf("[Error] Could not allocate memory\n");
       return -1;
     }
-    if ((p_copy = strdup(p)) == 0) {
+    if ((p_copy = xstrdup(p)) == 0) {
       printf("[Error] Could not allocate memory\n");
       if (ce)
         free(ce);
@@ -387,7 +387,7 @@ find_config_updates()
       clear_trailing_whitespace(p);
     }
     // 'p' points to start of this line, 'q' points to start of next
-    if ((p_copy = strdup(p)) == 0) {
+    if ((p_copy = xstrdup(p)) == 0) {
       printf("[Error] Could not allocate memory\n");
       return -1;
     }
@@ -523,7 +523,7 @@ generate_new_config(char *fname)
       clear_trailing_whitespace(p);
     }
     // 'p' points to start of this line, 'q' points to start of next
-    if ((p_copy = strdup(p)) == 0) {
+    if ((p_copy = xstrdup(p)) == 0) {
       printf("[Error] Could not allocate memory\n");
       // coverity[leaked_storage]
       return -1;
@@ -586,7 +586,7 @@ main(int argc, char *argv[])
     goto lerror;
   if ((b_buf = import_file(argv[2])) == 0)
     goto lerror;
-  if ((b_ht_buf = strdup(b_buf)) == 0) {
+  if ((b_ht_buf = xstrdup(b_buf)) == 0) {
     printf("[Error] Could not allocate memory\n");
     goto lerror;
   }



Mime
View raw message