diff options
-rw-r--r-- | ndb/include/logger/SysLogHandler.hpp | 4 | ||||
-rw-r--r-- | ndb/include/ndb_global.h | 45 | ||||
-rw-r--r-- | ndb/include/portlib/PortDefs.h | 43 | ||||
-rw-r--r-- | ndb/src/common/mgmcommon/NdbConfig.c | 23 | ||||
-rw-r--r-- | ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp | 2 | ||||
-rw-r--r-- | ndb/src/kernel/blocks/dbdih/DbdihMain.cpp | 4 | ||||
-rw-r--r-- | ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp | 2 | ||||
-rw-r--r-- | ndb/src/kernel/main.cpp | 20 | ||||
-rw-r--r-- | ndb/src/kernel/vm/Configuration.cpp | 8 | ||||
-rw-r--r-- | ndb/src/kernel/vm/Emulator.cpp | 4 | ||||
-rw-r--r-- | ndb/src/mgmsrv/CommandInterpreter.cpp | 9 | ||||
-rw-r--r-- | ndb/src/mgmsrv/main.cpp | 4 | ||||
-rw-r--r-- | scripts/make_win_src_distribution.sh | 2 |
13 files changed, 71 insertions, 99 deletions
diff --git a/ndb/include/logger/SysLogHandler.hpp b/ndb/include/logger/SysLogHandler.hpp index 4f13308d61b..0dfc1cb2d43 100644 --- a/ndb/include/logger/SysLogHandler.hpp +++ b/ndb/include/logger/SysLogHandler.hpp @@ -18,7 +18,9 @@ #define SYSLOGHANDLER_H #include "LogHandler.hpp" +#ifndef NDB_WIN32 #include <syslog.h> +#endif /** * Logs messages to syslog. The default identity is 'NDB'. @@ -62,7 +64,7 @@ public: * @param pIdentity a syslog identity. * @param facility syslog facility, defaults to LOG_USER */ - SysLogHandler(const char* pIdentity, int facility = LOG_USER); + SysLogHandler(const char* pIdentity, int facility); /** * Destructor. diff --git a/ndb/include/ndb_global.h b/ndb/include/ndb_global.h index bdd4e503cc5..775d69b38e5 100644 --- a/ndb/include/ndb_global.h +++ b/ndb/include/ndb_global.h @@ -2,16 +2,23 @@ #ifndef NDBGLOBAL_H #define NDBGLOBAL_H -#include <my_global.h> - -/** signal & SIG_PIPE */ -#include <my_alarm.h> +#include <ndb_types.h> #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) #define NDB_WIN32 +#include <winsock2.h> +#include <my_global.h> +#include <m_ctype.h> + +#define PATH_MAX 256 +#define DIR_SEPARATOR "\\" + +#pragma warning(disable: 4503 4786) + #else #undef NDB_WIN32 -#endif +#include <my_global.h> +#include <my_alarm.h> #ifdef _AIX #undef _H_STRINGS @@ -47,23 +54,22 @@ #include <sys/mman.h> #endif -#ifdef NDB_WIN32 -#include <winsock2.h> -#include <ws2tcpip.h> - -#define DIR_SEPARATOR "\\" -#define PATH_MAX 256 +#define DIR_SEPARATOR "/" -#pragma warning(disable: 4503 4786) -#else +#endif -#define DIR_SEPARATOR "/" +#ifndef HAVE_STRDUP +extern char * strdup(const char *s); +#endif +#ifndef HAVE_STRCASECMP +extern int strcasecmp(const char *s1, const char *s2); +extern int strncasecmp(const char *s1, const char *s2, size_t n); #endif static const char table_name_separator = '/'; -#if defined(_AIX) || defined(NDB_VC98) +#if defined(_AIX) || defined(WIN32) || defined(NDB_VC98) #define STATIC_CONST(x) enum { x } #else #define STATIC_CONST(x) static const Uint32 x @@ -84,15 +90,6 @@ extern int ndb_init(void); extern void ndb_end(int); #define NDB_INIT(prog_name) {my_progname=(prog_name); ndb_init();} -#ifndef HAVE_STRDUP -extern char * strdup(const char *s); -#endif - -#ifndef HAVE_STRCASECMP -extern int strcasecmp(const char *s1, const char *s2); -extern int strncasecmp(const char *s1, const char *s2, size_t n); -#endif - #ifdef SCO #ifndef PATH_MAX diff --git a/ndb/include/portlib/PortDefs.h b/ndb/include/portlib/PortDefs.h index b61bb627e65..a115c60cfe1 100644 --- a/ndb/include/portlib/PortDefs.h +++ b/ndb/include/portlib/PortDefs.h @@ -22,55 +22,12 @@ $Id: PortDefs.h,v 1.5 2003/10/07 07:59:59 mikael Exp $ */ -#ifdef NDB_WIN32 -#include <time.h> - - -struct tms -{ - time_t tms_utime; /* user time */ - time_t tms_stime; /* system time */ - time_t tms_cutime; /* user time of children */ - time_t tms_cstime; /* system time of children */ -}; - -struct timespec -{ - long tv_sec; /* Seconds */ - long tv_nsec; /* Nanoseconds */ -}; - -#define strcasecmp(a,b) _strcmpi(a,b) - -/* Exports a WIN32 getopt function */ -extern int optind; -extern char *optarg; -int getopt(int, char **, char *opts); -#endif /* NDB_WIN32 */ #ifdef NDB_ALPHA #ifdef NDB_GCC /* only for NDB_ALPHA */ extern int gnuShouldNotUseRPCC(); #define RPCC() gnuShouldNotUseRPCC(); #else -#ifdef NDB_WIN32 -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - u_int64 __asm(char *, ...); - double __dasm(char *, ...); - float __fasm(char *, ...); - void _AcquireSpinLock(long *); - void _ReleaseSpinLock(long *); - int __ADD_ATOMIC_LONG2(void *, int); -#ifdef __cplusplus -}; -#endif /* __cplusplus */ -#pragma intrinsic (__asm, __dasm, __fasm) -#pragma intrinsic(_ReleaseSpinLock, _AcquireSpinLock) -#pragma intrinsic(__ADD_ATOMIC_LONG2) -#endif /* NDB_WIN32 */ - #define RPCC() ((int)__asm(" rpcc v0;")) #define MB() __asm(" mb;"); #define WMB() __asm(" wmb;"); diff --git a/ndb/src/common/mgmcommon/NdbConfig.c b/ndb/src/common/mgmcommon/NdbConfig.c index e92f8fa8392..15dbcff8a56 100644 --- a/ndb/src/common/mgmcommon/NdbConfig.c +++ b/ndb/src/common/mgmcommon/NdbConfig.c @@ -18,6 +18,7 @@ #include <NdbConfig.h> #include <NdbEnv.h> #include <NdbMem.h> +#include <basestring_vsnprintf.h> static const char *datadir_path= 0; @@ -48,7 +49,7 @@ NdbConfig_AllocHomePath(int _len) const char *path= NdbConfig_get_path(&path_len); int len= _len+path_len; char *buf= NdbMem_Allocate(len); - snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); + basestring_snprintf(buf, len, "%s%s", path, DIR_SEPARATOR); return buf; } @@ -67,7 +68,7 @@ NdbConfig_NdbCfgName(int with_ndb_home){ len= strlen(buf); } else buf= NdbMem_Allocate(128); - snprintf(buf+len, 128, "Ndb.cfg"); + basestring_snprintf(buf+len, 128, "Ndb.cfg"); return buf; } @@ -77,9 +78,9 @@ char *get_prefix_buf(int len, int node_id) char tmp_buf[sizeof("ndb_pid#########")+1]; char *buf; if (node_id > 0) - snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id); + basestring_snprintf(tmp_buf, sizeof(tmp_buf), "ndb_%u", node_id); else - snprintf(tmp_buf, sizeof(tmp_buf), "ndb_pid%u", getpid()); + basestring_snprintf(tmp_buf, sizeof(tmp_buf), "ndb_pid%u", getpid()); tmp_buf[sizeof(tmp_buf)-1]= 0; buf= NdbConfig_AllocHomePath(len+strlen(tmp_buf)); @@ -91,7 +92,7 @@ char* NdbConfig_ErrorFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_error.log"); + basestring_snprintf(buf+len, 128, "_error.log"); return buf; } @@ -99,7 +100,7 @@ char* NdbConfig_ClusterLogFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_cluster.log"); + basestring_snprintf(buf+len, 128, "_cluster.log"); return buf; } @@ -107,7 +108,7 @@ char* NdbConfig_SignalLogFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_signal.log"); + basestring_snprintf(buf+len, 128, "_signal.log"); return buf; } @@ -115,7 +116,7 @@ char* NdbConfig_TraceFileName(int node_id, int file_no){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_trace.log.%u", file_no); + basestring_snprintf(buf+len, 128, "_trace.log.%u", file_no); return buf; } @@ -123,7 +124,7 @@ char* NdbConfig_NextTraceFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_trace.log.next"); + basestring_snprintf(buf+len, 128, "_trace.log.next"); return buf; } @@ -131,7 +132,7 @@ char* NdbConfig_PidFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, ".pid"); + basestring_snprintf(buf+len, 128, ".pid"); return buf; } @@ -139,6 +140,6 @@ char* NdbConfig_StdoutFileName(int node_id){ char *buf= get_prefix_buf(128, node_id); int len= strlen(buf); - snprintf(buf+len, 128, "_out.log"); + basestring_snprintf(buf+len, 128, "_out.log"); return buf; } diff --git a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp index 234d832655c..c4127ba9283 100644 --- a/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp +++ b/ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp @@ -150,6 +150,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) ndbrequire(false); } +#ifndef NDB_WIN32 if(ERROR_INSERTED(9996)){ simulate_error_during_shutdown= SIGSEGV; ndbrequire(false); @@ -159,6 +160,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) simulate_error_during_shutdown= SIGSEGV; kill(getpid(), SIGABRT); } +#endif }//execNDB_TAMPER() void Cmvmi::execSET_LOGLEVELORD(Signal* signal) diff --git a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp index 76aa745c3e0..9fd69378359 100644 --- a/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp +++ b/ndb/src/kernel/blocks/dbdih/DbdihMain.cpp @@ -12944,7 +12944,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) Uint32 nodeOrder[MAX_REPLICAS]; const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, nodeOrder); char buf[100]; - snprintf(buf, sizeof(buf), " Table %d Fragment %d - ", tabPtr.i, j); + BaseString::snprintf(buf, sizeof(buf), " Table %d Fragment %d - ", tabPtr.i, j); for(Uint32 k = 0; k < noOfReplicas; k++){ char tmp[100]; BaseString::snprintf(tmp, sizeof(tmp), "%d ", nodeOrder[k]); @@ -13155,7 +13155,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) getFragstore(tabPtr.p, fid, fragPtr); char buf[100], buf2[100]; - snprintf(buf, sizeof(buf), " Fragment %d: noLcpReplicas==%d ", + BaseString::snprintf(buf, sizeof(buf), " Fragment %d: noLcpReplicas==%d ", fid, fragPtr.p->noLcpReplicas); Uint32 num=0; diff --git a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp index 56e3d3abbed..21b0a2cb54f 100644 --- a/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp +++ b/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp @@ -730,7 +730,7 @@ Ndbfs::scanIPC(Signal* signal) jam(); report(request, signal); theRequestPool->put(request); - return &request; + return true; } return false; } diff --git a/ndb/src/kernel/main.cpp b/ndb/src/kernel/main.cpp index 926647838c9..2901320633c 100644 --- a/ndb/src/kernel/main.cpp +++ b/ndb/src/kernel/main.cpp @@ -77,11 +77,13 @@ int main(int argc, char** argv) } { // Do configuration - signal(SIGPIPE, SIG_IGN); +#ifndef NDB_WIN32 + signal(SIGPIPE, SIG_IGN); +#endif theConfig->fetch_configuration(local_config); } - - chdir(NdbConfig_get_path(0)); + + my_setwd(NdbConfig_get_path(0), MYF(0)); if (theConfig->getDaemonMode()) { // Become a daemon @@ -95,6 +97,7 @@ int main(int argc, char** argv) } } +#ifndef NDB_WIN32 for(pid_t child = fork(); child != 0; child = fork()){ /** * Parent @@ -145,6 +148,9 @@ int main(int argc, char** argv) } g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid()); +#else + g_eventLogger.info("Ndb started"); +#endif theConfig->setupConfiguration(); systemInfo(* theConfig, * theConfig->m_logLevel); @@ -276,7 +282,7 @@ systemInfo(const Configuration & config, const LogLevel & logLevel){ void catchsigs(bool ignore){ -#if ! defined NDB_SOFTOSE && !defined NDB_OSE +#if !defined NDB_WIN32 && !defined NDB_SOFTOSE && !defined NDB_OSE static const int signals_shutdown[] = { #ifdef SIGBREAK @@ -318,7 +324,6 @@ catchsigs(bool ignore){ SIGTRAP #endif }; -#endif static const int signals_ignore[] = { SIGPIPE @@ -331,6 +336,7 @@ catchsigs(bool ignore){ handler_register(signals_error[i], handler_error, ignore); for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++) handler_register(signals_ignore[i], SIG_IGN, ignore); +#endif } extern "C" @@ -349,8 +355,10 @@ handler_error(int signum){ if (thread_id != 0 && thread_id == my_thread_id()) { // Shutdown thread received signal - signal(signum, SIG_DFL); +#ifndef NDB_WIN32 + signal(signum, SIG_DFL); kill(getpid(), signum); +#endif while(true) NdbSleep_MilliSleep(10); } diff --git a/ndb/src/kernel/vm/Configuration.cpp b/ndb/src/kernel/vm/Configuration.cpp index 795670a1322..05a5aaf1c76 100644 --- a/ndb/src/kernel/vm/Configuration.cpp +++ b/ndb/src/kernel/vm/Configuration.cpp @@ -278,13 +278,13 @@ static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter, memset(buf2, 0,sizeof(buf2)); #ifdef NDB_WIN32 char* szFilePart; - if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) - || (::GetFileAttributes(alloc_path)&FILE_ATTRIBUTE_READONLY)) + if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) || + (GetFileAttributes(buf2) & FILE_ATTRIBUTE_READONLY)); #else - if((::realpath(path, buf2) == NULL)|| + if((::realpath(path, buf2) == NULL)|| (::access(buf2, W_OK) != 0)) #endif - { + { ERROR_SET(fatal, AFS_ERROR_INVALIDPATH, path, " Filename::init()"); } diff --git a/ndb/src/kernel/vm/Emulator.cpp b/ndb/src/kernel/vm/Emulator.cpp index a5897cd4064..adf3c438945 100644 --- a/ndb/src/kernel/vm/Emulator.cpp +++ b/ndb/src/kernel/vm/Emulator.cpp @@ -179,12 +179,14 @@ NdbShutdown(NdbShutdownType type, exit(-1); #endif } - + +#ifndef NDB_WIN32 if (simulate_error_during_shutdown) { kill(getpid(), simulate_error_during_shutdown); while(true) NdbSleep_MilliSleep(10); } +#endif globalEmulatorData.theWatchDog->doStop(); diff --git a/ndb/src/mgmsrv/CommandInterpreter.cpp b/ndb/src/mgmsrv/CommandInterpreter.cpp index 2a054a01f1e..c6ea9f662bb 100644 --- a/ndb/src/mgmsrv/CommandInterpreter.cpp +++ b/ndb/src/mgmsrv/CommandInterpreter.cpp @@ -28,7 +28,7 @@ #include "ConfigInfo.hpp" #include <version.h> - +#include <m_string.h> static const char* helpTexts[] = { "HELP Print help text", @@ -492,7 +492,7 @@ void CommandInterpreter::executeClusterLog(char* parameters) { noArgs = true; } while (item != NULL) { - snprintf(name, 12, item); + BaseString::snprintf(name, 12, item); if (strcmp(item, "ALL") == 0) { severity = 7; @@ -740,9 +740,10 @@ CommandInterpreter::executeDumpState(int processId, const char* parameters, char * tmpString = strdup(parameters); char * tmpPtr = 0; char * item = strtok_r(tmpString, " ", &tmpPtr); + int error; while(item != NULL){ - if (0x0 <= strtoll(item, NULL, 0) && strtoll(item, NULL, 0) <= 0xffffffff) { - pars[no] = strtoll(item, NULL, 0); + if (0x0 <= my_strtoll10(item, NULL, &error) && my_strtoll10(item, NULL, &error) <= 0xffffffff) { + pars[no] = my_strtoll10(item, NULL, &error); } else { ndbout << "Illegal value in argument to signal." << endl << "(Value must be between 0 and 0xffffffff.)" diff --git a/ndb/src/mgmsrv/main.cpp b/ndb/src/mgmsrv/main.cpp index 15767e4766d..5712ade8ea1 100644 --- a/ndb/src/mgmsrv/main.cpp +++ b/ndb/src/mgmsrv/main.cpp @@ -231,7 +231,7 @@ int main(int argc, char** argv) local_config, glob.cluster_config); - chdir(NdbConfig_get_path(0)); + my_setwd(NdbConfig_get_path(0), MYF(0)); glob.cluster_config = 0; glob.localNodeId= glob.mgmObject->getOwnNodeId(); @@ -294,7 +294,9 @@ int main(int argc, char** argv) } } +#ifndef NDB_WIN32 signal(SIGPIPE, SIG_IGN); +#endif { BaseString error_string; if(!glob.mgmObject->start(error_string)){ diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index d9144ab3dce..62a9fb54b59 100644 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -246,7 +246,7 @@ done # # Create project files for ndb # -make -C ndb windoze +make -C $SOURCE/ndb windoze # # Input directories to be copied recursively |