List:Commits« Previous MessageNext Message »
From:Stewart Smith Date:January 13 2006 12:43am
Subject:bk commit into 4.1 tree (stewart:1.2476) BUG#11331
View as plain text  
Below is the list of changes that have just been committed into a local
4.1 repository of stewart. When stewart does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2476 06/01/13 11:43:50 stewart@stripped +7 -0
  BUG#11331 "Warning: could not add log destination" message does not provide enough info
  
  Implement error reporting to Logger and associated classes.

  ndb/src/mgmsrv/MgmtSrvr.cpp
    1.73 06/01/13 11:43:47 stewart@stripped +12 -2
    Report error when adding log handler

  ndb/src/common/logger/SysLogHandler.cpp
    1.5 06/01/13 11:43:47 stewart@stripped +1 -0
    Report an error on invalid syslog facility

  ndb/src/common/logger/Logger.cpp
    1.11 06/01/13 11:43:47 stewart@stripped +10 -1
    Report back errors when adding a handler via BaseString

  ndb/src/common/logger/LogHandler.cpp
    1.11 06/01/13 11:43:47 stewart@stripped +26 -3
    Implement error reporting.
    
    Trim spaces and tabs out of parameter names. This allows "p=v, param=value"

  ndb/src/common/logger/FileLogHandler.cpp
    1.10 06/01/13 11:43:47 stewart@stripped +13 -4
    Implement error reporting

  ndb/include/logger/Logger.hpp
    1.7 06/01/13 11:43:47 stewart@stripped +4 -1
    Add reporting back of error to addHandler(BaseString).

  ndb/include/logger/LogHandler.hpp
    1.7 06/01/13 11:43:47 stewart@stripped +13 -0
    Add error string to LogHandler along with error code

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	stewart
# Host:	willster.(none)
# Root:	/home/stewart/Documents/MySQL/4.1/bug11331

--- 1.6/ndb/include/logger/LogHandler.hpp	2004-12-23 08:47:51 +11:00
+++ 1.7/ndb/include/logger/LogHandler.hpp	2006-01-13 11:43:47 +11:00
@@ -126,6 +126,18 @@
   void setErrorCode(int code);
 
   /**
+   * Returns the error string.
+   */
+  char* getErrorStr();
+
+  /**
+   * Sets the error string.
+   *
+   * @param str the error string.
+   */
+  void setErrorStr(char* str);
+
+  /**
    * Parse logstring parameters
    *
    * @param params list of parameters, formatted as "param=value", 
@@ -195,6 +207,7 @@
 
   const char* m_pDateTimeFormat;
   int m_errorCode;
+  char* m_errorStr;
 
   // for handling repeated messages
   unsigned m_count_repeated_messages;

--- 1.6/ndb/include/logger/Logger.hpp	2004-12-23 08:47:51 +11:00
+++ 1.7/ndb/include/logger/Logger.hpp	2006-01-13 11:43:47 +11:00
@@ -178,8 +178,11 @@
    * Add a new handler
    *
    * @param logstring string describing the handler to add
+   * @param err OS errno in event of error
+   * @param len max length of errStr buffer
+   * @param errStr logger error string in event of error
    */
-  bool addHandler(const BaseString &logstring);
+  bool addHandler(const BaseString &logstring, int *err, int len, char* errStr);
 
   /**
    * Remove a log handler.

--- 1.9/ndb/src/common/logger/FileLogHandler.cpp	2004-12-17 20:32:21 +11:00
+++ 1.10/ndb/src/common/logger/FileLogHandler.cpp	2006-01-13 11:43:47 +11:00
@@ -187,6 +187,7 @@
     return setMaxSize(value);
   if(param == "maxfiles")
     return setMaxFiles(value);
+  setErrorStr("Invalid parameter");
   return false;
 }
 
@@ -196,16 +197,18 @@
   if(m_pLogFile)
     delete m_pLogFile;
   m_pLogFile = new File_class(filename.c_str(), "a+");
-  open();
-  return true;
+  return open();
 }
 
 bool
 FileLogHandler::setMaxSize(const BaseString &size) {
   char *end;
   long val = strtol(size.c_str(), &end, 0); /* XXX */
-  if(size.c_str() == end)
+  if(size.c_str() == end || val < 0)
+  {
+    setErrorStr("Invalid file size");
     return false;
+  }
   if(end[0] == 'M')
     val *= 1024*1024;
   if(end[0] == 'k')
@@ -220,8 +223,11 @@
 FileLogHandler::setMaxFiles(const BaseString &files) {
   char *end;
   long val = strtol(files.c_str(), &end, 0);
-  if(files.c_str() == end)
+  if(files.c_str() == end || val < 1)
+  {
+    setErrorStr("Invalid maximum number of files");
     return false;
+  }
   m_maxNoFiles = val;
 
   return true;
@@ -230,6 +236,9 @@
 bool
 FileLogHandler::checkParams() {
   if(m_pLogFile == NULL)
+  {
+    setErrorStr("Log file cannot be null.");
     return false;
+  }
   return true;
 }

--- 1.10/ndb/src/common/logger/LogHandler.cpp	2005-07-29 04:24:02 +10:00
+++ 1.11/ndb/src/common/logger/LogHandler.cpp	2006-01-13 11:43:47 +11:00
@@ -23,7 +23,8 @@
 //
 LogHandler::LogHandler() : 
   m_pDateTimeFormat("%d-%.2d-%.2d %.2d:%.2d:%.2d"),
-  m_errorCode(0)
+  m_errorCode(0),
+  m_errorStr(NULL)
 {
   m_max_repeat_frequency= 3; // repeat messages maximum every 3 seconds
   m_count_repeated_messages= 0;
@@ -155,6 +156,19 @@
   m_errorCode = code;
 }
 
+
+char*
+LogHandler::getErrorStr()
+{
+  return m_errorStr;
+}
+
+void
+LogHandler::setErrorStr(char* str)
+{
+  m_errorStr= str;
+}
+
 bool
 LogHandler::parseParams(const BaseString &_params) {
   Vector<BaseString> v_args;
@@ -165,9 +179,18 @@
   for(size_t i=0; i < v_args.size(); i++) {
     Vector<BaseString> v_param_value;
     if(v_args[i].split(v_param_value, "=", 2) != 2)
+    {
       ret = false;
-    else if (!setParam(v_param_value[0], v_param_value[1]))
-      ret = false;
+      setErrorStr("Can't find key=value pair.");
+    }
+    else
+    {
+      v_param_value[0].trim(" \t");
+      if (!setParam(v_param_value[0], v_param_value[1]))
+      {
+        ret = false;
+      }
+    }
   }
 
   if(!checkParams())

--- 1.10/ndb/src/common/logger/Logger.cpp	2005-06-10 20:31:51 +10:00
+++ 1.11/ndb/src/common/logger/Logger.cpp	2006-01-13 11:43:47 +11:00
@@ -167,7 +167,7 @@
 }
 
 bool
-Logger::addHandler(const BaseString &logstring) {
+Logger::addHandler(const BaseString &logstring, int *err, int len, char* errStr) {
   size_t i;
   Vector<BaseString> logdest;
   Vector<LogHandler *>loghandlers;
@@ -200,9 +200,18 @@
       handler = new ConsoleLogHandler();
     
     if(handler == NULL)
+    {
+      snprintf(errStr,len,"Could not create log destination: %s",
+               logdest[i].c_str());
       DBUG_RETURN(false);
+    }
     if(!handler->parseParams(params))
+    {
+      *err= handler->getErrorCode();
+      if(handler->getErrorStr())
+        strncpy(errStr, handler->getErrorStr(), len);
       DBUG_RETURN(false);
+    }
     loghandlers.push_back(handler);
   }
   

--- 1.4/ndb/src/common/logger/SysLogHandler.cpp	2004-09-16 03:00:11 +10:00
+++ 1.5/ndb/src/common/logger/SysLogHandler.cpp	2006-01-13 11:43:47 +11:00
@@ -154,5 +154,6 @@
       return true;
     }
   }
+  setErrorStr("Invalid syslog facility name");
   return false;
 }

--- 1.72/ndb/src/mgmsrv/MgmtSrvr.cpp	2005-09-22 21:55:08 +10:00
+++ 1.73/ndb/src/mgmsrv/MgmtSrvr.cpp	2006-01-13 11:43:47 +11:00
@@ -179,6 +179,8 @@
   }
   
   const char * tmp;
+  char errStr[100];
+  int err= 0;
   BaseString logdest;
   char *clusterLog= NdbConfig_ClusterLogFileName(_ownNodeId);
   NdbAutoPtr<char> tmp_aptr(clusterLog);
@@ -192,9 +194,17 @@
     logdest.assfmt("FILE:filename=%s,maxsize=1000000,maxfiles=6", 
 		   clusterLog);
   }
-  if(!g_eventLogger.addHandler(logdest)) {
+  errStr[0]='\0';
+  if(!g_eventLogger.addHandler(logdest, &err, sizeof(errStr), errStr)) {
     ndbout << "Warning: could not add log destination \""
-	   << logdest.c_str() << "\"" << endl;
+           << logdest.c_str() << "\". Reason: ";
+    if(err)
+      ndbout << strerror(err);
+    if(err && errStr[0]!='\0')
+      ndbout << ", ";
+    if(errStr[0]!='\0')
+      ndbout << errStr;
+    ndbout << endl;
   }
 }
 
Thread
bk commit into 4.1 tree (stewart:1.2476) BUG#11331Stewart Smith13 Jan