diff options
Diffstat (limited to 'ndb/src/kernel/main.cpp')
-rw-r--r-- | ndb/src/kernel/main.cpp | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index 4d3a0afe6ed..fa44704807d 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -15,9 +15,11 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <ndb_global.h> +#include <my_pthread.h> #include <ndb_version.h> #include "Configuration.hpp" +#include <LocalConfig.hpp> #include <TransporterRegistry.hpp> #include "vm/SimBlockList.hpp" @@ -26,6 +28,7 @@ #include <NdbOut.hpp> #include <NdbMain.h> #include <NdbDaemon.h> +#include <NdbSleep.h> #include <NdbConfig.h> #include <WatchDog.hpp> @@ -39,6 +42,7 @@ #endif extern EventLogger g_eventLogger; +extern NdbMutex * theShutdownMutex; void catchsigs(bool ignore); // for process signal handling @@ -53,6 +57,7 @@ const char programName[] = "NDB Kernel"; NDB_MAIN(ndb_kernel){ + ndb_init(); // Print to stdout/console g_eventLogger.createConsoleHandler(); g_eventLogger.setCategory("NDB"); @@ -63,14 +68,23 @@ NDB_MAIN(ndb_kernel){ // Parse command line options Configuration* theConfig = globalEmulatorData.theConfiguration; if(!theConfig->init(argc, argv)){ - return 0; + return NRT_Default; } + LocalConfig local_config; + if (!local_config.init(theConfig->getConnectString(),0)){ + local_config.printError(); + local_config.printUsage(); + return NRT_Default; + } + { // Do configuration signal(SIGPIPE, SIG_IGN); - theConfig->fetch_configuration(); + theConfig->fetch_configuration(local_config); } + chdir(NdbConfig_get_path(0)); + if (theConfig->getDaemonMode()) { // Become a daemon char *lockfile= NdbConfig_PidFileName(globalData.ownId); @@ -129,7 +143,7 @@ NDB_MAIN(ndb_kernel){ exit(0); } g_eventLogger.info("Ndb has terminated (pid %d) restarting", child); - theConfig->fetch_configuration(); + theConfig->fetch_configuration(local_config); } g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid()); @@ -238,6 +252,9 @@ systemInfo(const Configuration & config, const LogLevel & logLevel){ if(logLevel.getLogLevel(LogLevel::llStartUp) > 0){ g_eventLogger.info("NDB Cluster -- DB node %d", globalData.ownId); g_eventLogger.info("%s --", NDB_VERSION_STRING); + if (config.get_mgmd_host()) + g_eventLogger.info("Configuration fetched at %s port %d", + config.get_mgmd_host(), config.get_mgmd_port()); #ifdef NDB_SOLARIS // ok g_eventLogger.info("NDB is running on a machine with %d processor(s) at %d MHz", processor, speed); @@ -328,16 +345,24 @@ handler_shutdown(int signum){ extern "C" void handler_error(int signum){ + // only let one thread run shutdown + static long thread_id= 0; + + if (thread_id != 0 && thread_id == my_thread_id()) + { + // Shutdown thread received signal + signal(signum, SIG_DFL); + kill(getpid(), signum); + while(true) + NdbSleep_MilliSleep(10); + } + if(theShutdownMutex && NdbMutex_Trylock(theShutdownMutex) != 0) + while(true) + NdbSleep_MilliSleep(10); + thread_id= my_thread_id(); g_eventLogger.info("Received signal %d. Running error handler.", signum); // restart the system char errorData[40]; - snprintf(errorData, 40, "Signal %d received", signum); - ERROR_SET(fatal, 0, errorData, __FILE__); + BaseString::snprintf(errorData, 40, "Signal %d received", signum); + ERROR_SET_SIGNAL(fatal, 0, errorData, __FILE__); } - - - - - - - |