#At file:///home/msvensson/mysql/6.2-bug38502/ based on revid:jonas@strippedb5cjznp4mok0k
3003 Magnus Blåudd 2009-09-24
Bug#38502 NDB_PORT cause ndb_mgmd fail
- Detect the case when "./configure --with-ndb-port" is used without
a portnumber(or something) actually supplied.
- Cleanup the usage of NDB_PORT by putting it in [my_]config.h
- Remove some sprintf by using preprocessor macros for building
the default connect string as well as string variants of the
port number.
- Quite sure that the compiler will now complain if the port is
not a number.
modified:
config/ac-macros/ha_ndbcluster.m4
storage/ndb/include/ndb_global.h.in
storage/ndb/src/mgmapi/LocalConfig.cpp
storage/ndb/src/mgmapi/Makefile.am
storage/ndb/src/mgmsrv/ConfigInfo.cpp
=== modified file 'config/ac-macros/ha_ndbcluster.m4'
--- a/config/ac-macros/ha_ndbcluster.m4 2009-05-08 09:57:18 +0000
+++ b/config/ac-macros/ha_ndbcluster.m4 2009-09-24 16:17:14 +0000
@@ -63,10 +63,21 @@ AC_DEFUN([MYSQL_CHECK_NDB_OPTIONS], [
[ndb_docs="$withval"],
[ndb_docs=no])
AC_ARG_WITH([ndb-port],
- [AC_HELP_STRING([--with-ndb-port],
- [Port for NDB Cluster management server])],
- [ndb_port="$withval"],
- [ndb_port="default"])
+ [AC_HELP_STRING([--with-ndb-port=port-number],
+ [Default port used by NDB Cluster management server])],
+ [ndb_port="$withval"],[ndb_port="no"])
+ case "$ndb_port" in
+ "yes" )
+ AC_MSG_ERROR([--with-ndb-port=<port-number> needs an argument])
+ ;;
+ "no" )
+ ;;
+ * )
+ AC_DEFINE_UNQUOTED([NDB_PORT], [$ndb_port],
+ [Default port used by NDB Cluster management server])
+ ;;
+ esac
+
AC_ARG_WITH([ndb-port-base],
[AC_HELP_STRING([--with-ndb-port-base],
[Base port for NDB Cluster transporters])],
@@ -215,11 +226,6 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
fi
fi
- if test X"$ndb_port" = Xdefault
- then
- ndb_port="1186"
- fi
-
have_ndb_binlog="no"
if test X"$ndb_binlog" = Xdefault ||
test X"$ndb_binlog" = Xyes
@@ -322,7 +328,6 @@ AC_DEFUN([MYSQL_SETUP_NDBCLUSTER], [
AC_SUBST(NDB_SCI_LIBS)
AC_SUBST(ndb_transporter_opt_objs)
- AC_SUBST(ndb_port)
AC_SUBST(ndb_bin_am_ldflags)
AC_SUBST(ndb_opt_subdirs)
=== modified file 'storage/ndb/include/ndb_global.h.in'
--- a/storage/ndb/include/ndb_global.h.in 2009-05-26 18:53:34 +0000
+++ b/storage/ndb/include/ndb_global.h.in 2009-09-24 16:17:14 +0000
@@ -22,7 +22,11 @@
#include <my_config.h>
#include <ndb_types.h>
-#define NDB_PORT "@ndb_port@"
+#ifndef NDB_PORT
+/* Default port used by ndb_mgmd */
+#define NDB_PORT 1186
+#endif
+
#define NDB_TCP_BASE_PORT "@ndb_port_base@"
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
=== modified file 'storage/ndb/src/mgmapi/LocalConfig.cpp'
--- a/storage/ndb/src/mgmapi/LocalConfig.cpp 2009-05-26 18:53:34 +0000
+++ b/storage/ndb/src/mgmapi/LocalConfig.cpp 2009-09-24 16:17:14 +0000
@@ -22,6 +22,9 @@
#include <NdbAutoPtr.hpp>
#include <NdbMem.h>
+#define _STR_VALUE(x) #x
+#define STR_VALUE(x) _STR_VALUE(x)
+
LocalConfig::LocalConfig(){
error_line = 0; error_msg[0] = 0;
_ownNodeId= 0;
@@ -95,11 +98,10 @@ LocalConfig::init(const char *connectStr
DBUG_RETURN(false);
}
- //7. Check
+ //7. Use default connect string
{
- char buf2[256];
- BaseString::snprintf(buf2, sizeof(buf2), "host=localhost:%s", NDB_PORT);
- if(readConnectString(buf2, "default connect string"))
+ if(readConnectString("host=localhost:" STR_VALUE(NDB_PORT),
+ "default connect string"))
DBUG_RETURN(true);
}
@@ -189,7 +191,7 @@ LocalConfig::parseHostName(const char *
if (buf == tempString2)
break;
// try to add default port to see if it works
- snprintf(tempString2, sizeof(tempString2),"%s:%s", buf, NDB_PORT);
+ snprintf(tempString2, sizeof(tempString2),"%s:%d", buf, NDB_PORT);
buf= tempString2;
} while(1);
return false;
=== modified file 'storage/ndb/src/mgmapi/Makefile.am'
--- a/storage/ndb/src/mgmapi/Makefile.am 2009-05-26 18:53:34 +0000
+++ b/storage/ndb/src/mgmapi/Makefile.am 2009-09-24 16:17:14 +0000
@@ -24,7 +24,7 @@ libmgmapi_la_SOURCES = mgmapi.cpp ndb_lo
INCLUDES_LOC = -I$(top_srcdir)/storage/ndb/include/mgmapi
DEFS_LOC = -DNDB_MGMAPI -DMYSQLCLUSTERDIR="\"$(MYSQLCLUSTERdir)\"" \
- -DNO_DEBUG_MESSAGES -DNDB_PORT="\"@ndb_port@\""
+ -DNO_DEBUG_MESSAGES
include $(top_srcdir)/storage/ndb/config/common.mk.am
include $(top_srcdir)/storage/ndb/config/type_util.mk.am
=== modified file 'storage/ndb/src/mgmsrv/ConfigInfo.cpp'
--- a/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2009-09-09 09:01:45 +0000
+++ b/storage/ndb/src/mgmsrv/ConfigInfo.cpp 2009-09-24 16:17:14 +0000
@@ -1798,7 +1798,7 @@ const ConfigInfo::ParamInfo ConfigInfo::
ConfigInfo::CI_USED,
false,
ConfigInfo::CI_INT,
- NDB_PORT,
+ STR_VALUE(NDB_PORT),
"0",
STR_VALUE(MAX_PORT_NO) },
@@ -3412,7 +3412,7 @@ fixShmUniqueId(InitConfigFileParser::Con
ctx.m_userProperties.get(ctx.fname, &nodes);
if (nodes == 1) // first management server
{
- Uint32 portno= atoi(NDB_PORT);
+ Uint32 portno= NDB_PORT;
ctx.m_currentSection->get("PortNumber", &portno);
ctx.m_userProperties.put("ShmUniqueId", portno);
}
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20090924161714-indmm2rrelchej04.bundle
| Thread |
|---|
| • bzr commit into mysql-5.1-telco-6.2 branch (magnus.blaudd:3003)Bug#38502 | Magnus Blåudd | 24 Sep |