Commit 7c98d151 authored by Administrator@w2k's avatar Administrator@w2k

Merge joreland@bk-internal.mysql.com:wl1744 into w2k.:C:/mysql-4.1

parents 414298f3 5172eace
...@@ -18,7 +18,9 @@ ...@@ -18,7 +18,9 @@
#define SYSLOGHANDLER_H #define SYSLOGHANDLER_H
#include "LogHandler.hpp" #include "LogHandler.hpp"
#ifndef NDB_WIN32
#include <syslog.h> #include <syslog.h>
#endif
/** /**
* Logs messages to syslog. The default identity is 'NDB'. * Logs messages to syslog. The default identity is 'NDB'.
...@@ -62,7 +64,7 @@ public: ...@@ -62,7 +64,7 @@ public:
* @param pIdentity a syslog identity. * @param pIdentity a syslog identity.
* @param facility syslog facility, defaults to LOG_USER * @param facility syslog facility, defaults to LOG_USER
*/ */
SysLogHandler(const char* pIdentity, int facility = LOG_USER); SysLogHandler(const char* pIdentity, int facility);
/** /**
* Destructor. * Destructor.
......
...@@ -2,16 +2,23 @@ ...@@ -2,16 +2,23 @@
#ifndef NDBGLOBAL_H #ifndef NDBGLOBAL_H
#define NDBGLOBAL_H #define NDBGLOBAL_H
#include <my_global.h> #include <ndb_types.h>
/** signal & SIG_PIPE */
#include <my_alarm.h>
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32) #if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
#define NDB_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 #else
#undef NDB_WIN32 #undef NDB_WIN32
#endif #include <my_global.h>
#include <my_alarm.h>
#ifdef _AIX #ifdef _AIX
#undef _H_STRINGS #undef _H_STRINGS
...@@ -47,23 +54,22 @@ ...@@ -47,23 +54,22 @@
#include <sys/mman.h> #include <sys/mman.h>
#endif #endif
#ifdef NDB_WIN32 #define DIR_SEPARATOR "/"
#include <winsock2.h>
#include <ws2tcpip.h>
#define DIR_SEPARATOR "\\"
#define PATH_MAX 256
#pragma warning(disable: 4503 4786) #endif
#else
#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 #endif
static const char table_name_separator = '/'; 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 } #define STATIC_CONST(x) enum { x }
#else #else
#define STATIC_CONST(x) static const Uint32 x #define STATIC_CONST(x) static const Uint32 x
...@@ -84,15 +90,6 @@ extern int ndb_init(void); ...@@ -84,15 +90,6 @@ extern int ndb_init(void);
extern void ndb_end(int); extern void ndb_end(int);
#define NDB_INIT(prog_name) {my_progname=(prog_name); ndb_init();} #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 #ifdef SCO
#ifndef PATH_MAX #ifndef PATH_MAX
......
...@@ -22,55 +22,12 @@ ...@@ -22,55 +22,12 @@
$Id: PortDefs.h,v 1.5 2003/10/07 07:59:59 mikael Exp $ $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_ALPHA
#ifdef NDB_GCC /* only for NDB_ALPHA */ #ifdef NDB_GCC /* only for NDB_ALPHA */
extern int gnuShouldNotUseRPCC(); extern int gnuShouldNotUseRPCC();
#define RPCC() gnuShouldNotUseRPCC(); #define RPCC() gnuShouldNotUseRPCC();
#else #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 RPCC() ((int)__asm(" rpcc v0;"))
#define MB() __asm(" mb;"); #define MB() __asm(" mb;");
#define WMB() __asm(" wmb;"); #define WMB() __asm(" wmb;");
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include <NdbConfig.h> #include <NdbConfig.h>
#include <NdbEnv.h> #include <NdbEnv.h>
#include <NdbMem.h> #include <NdbMem.h>
#include <basestring_vsnprintf.h>
static const char *datadir_path= 0; static const char *datadir_path= 0;
...@@ -48,7 +49,7 @@ NdbConfig_AllocHomePath(int _len) ...@@ -48,7 +49,7 @@ NdbConfig_AllocHomePath(int _len)
const char *path= NdbConfig_get_path(&path_len); const char *path= NdbConfig_get_path(&path_len);
int len= _len+path_len; int len= _len+path_len;
char *buf= NdbMem_Allocate(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; return buf;
} }
...@@ -67,7 +68,7 @@ NdbConfig_NdbCfgName(int with_ndb_home){ ...@@ -67,7 +68,7 @@ NdbConfig_NdbCfgName(int with_ndb_home){
len= strlen(buf); len= strlen(buf);
} else } else
buf= NdbMem_Allocate(128); buf= NdbMem_Allocate(128);
snprintf(buf+len, 128, "Ndb.cfg"); basestring_snprintf(buf+len, 128, "Ndb.cfg");
return buf; return buf;
} }
...@@ -77,9 +78,9 @@ char *get_prefix_buf(int len, int node_id) ...@@ -77,9 +78,9 @@ char *get_prefix_buf(int len, int node_id)
char tmp_buf[sizeof("ndb_pid#########")+1]; char tmp_buf[sizeof("ndb_pid#########")+1];
char *buf; char *buf;
if (node_id > 0) 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 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; tmp_buf[sizeof(tmp_buf)-1]= 0;
buf= NdbConfig_AllocHomePath(len+strlen(tmp_buf)); buf= NdbConfig_AllocHomePath(len+strlen(tmp_buf));
...@@ -91,7 +92,7 @@ char* ...@@ -91,7 +92,7 @@ char*
NdbConfig_ErrorFileName(int node_id){ NdbConfig_ErrorFileName(int node_id){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); int len= strlen(buf);
snprintf(buf+len, 128, "_error.log"); basestring_snprintf(buf+len, 128, "_error.log");
return buf; return buf;
} }
...@@ -99,7 +100,7 @@ char* ...@@ -99,7 +100,7 @@ char*
NdbConfig_ClusterLogFileName(int node_id){ NdbConfig_ClusterLogFileName(int node_id){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); int len= strlen(buf);
snprintf(buf+len, 128, "_cluster.log"); basestring_snprintf(buf+len, 128, "_cluster.log");
return buf; return buf;
} }
...@@ -107,7 +108,7 @@ char* ...@@ -107,7 +108,7 @@ char*
NdbConfig_SignalLogFileName(int node_id){ NdbConfig_SignalLogFileName(int node_id){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); int len= strlen(buf);
snprintf(buf+len, 128, "_signal.log"); basestring_snprintf(buf+len, 128, "_signal.log");
return buf; return buf;
} }
...@@ -115,7 +116,7 @@ char* ...@@ -115,7 +116,7 @@ char*
NdbConfig_TraceFileName(int node_id, int file_no){ NdbConfig_TraceFileName(int node_id, int file_no){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); 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; return buf;
} }
...@@ -123,7 +124,7 @@ char* ...@@ -123,7 +124,7 @@ char*
NdbConfig_NextTraceFileName(int node_id){ NdbConfig_NextTraceFileName(int node_id){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); int len= strlen(buf);
snprintf(buf+len, 128, "_trace.log.next"); basestring_snprintf(buf+len, 128, "_trace.log.next");
return buf; return buf;
} }
...@@ -131,7 +132,7 @@ char* ...@@ -131,7 +132,7 @@ char*
NdbConfig_PidFileName(int node_id){ NdbConfig_PidFileName(int node_id){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); int len= strlen(buf);
snprintf(buf+len, 128, ".pid"); basestring_snprintf(buf+len, 128, ".pid");
return buf; return buf;
} }
...@@ -139,6 +140,6 @@ char* ...@@ -139,6 +140,6 @@ char*
NdbConfig_StdoutFileName(int node_id){ NdbConfig_StdoutFileName(int node_id){
char *buf= get_prefix_buf(128, node_id); char *buf= get_prefix_buf(128, node_id);
int len= strlen(buf); int len= strlen(buf);
snprintf(buf+len, 128, "_out.log"); basestring_snprintf(buf+len, 128, "_out.log");
return buf; return buf;
} }
...@@ -150,6 +150,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) ...@@ -150,6 +150,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal)
ndbrequire(false); ndbrequire(false);
} }
#ifndef NDB_WIN32
if(ERROR_INSERTED(9996)){ if(ERROR_INSERTED(9996)){
simulate_error_during_shutdown= SIGSEGV; simulate_error_during_shutdown= SIGSEGV;
ndbrequire(false); ndbrequire(false);
...@@ -159,6 +160,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal) ...@@ -159,6 +160,7 @@ void Cmvmi::execNDB_TAMPER(Signal* signal)
simulate_error_during_shutdown= SIGSEGV; simulate_error_during_shutdown= SIGSEGV;
kill(getpid(), SIGABRT); kill(getpid(), SIGABRT);
} }
#endif
}//execNDB_TAMPER() }//execNDB_TAMPER()
void Cmvmi::execSET_LOGLEVELORD(Signal* signal) void Cmvmi::execSET_LOGLEVELORD(Signal* signal)
......
...@@ -12944,7 +12944,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) ...@@ -12944,7 +12944,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal)
Uint32 nodeOrder[MAX_REPLICAS]; Uint32 nodeOrder[MAX_REPLICAS];
const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, nodeOrder); const Uint32 noOfReplicas = extractNodeInfo(fragPtr.p, nodeOrder);
char buf[100]; 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++){ for(Uint32 k = 0; k < noOfReplicas; k++){
char tmp[100]; char tmp[100];
BaseString::snprintf(tmp, sizeof(tmp), "%d ", nodeOrder[k]); BaseString::snprintf(tmp, sizeof(tmp), "%d ", nodeOrder[k]);
...@@ -13155,7 +13155,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal) ...@@ -13155,7 +13155,7 @@ Dbdih::execDUMP_STATE_ORD(Signal* signal)
getFragstore(tabPtr.p, fid, fragPtr); getFragstore(tabPtr.p, fid, fragPtr);
char buf[100], buf2[100]; 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); fid, fragPtr.p->noLcpReplicas);
Uint32 num=0; Uint32 num=0;
......
...@@ -730,7 +730,7 @@ Ndbfs::scanIPC(Signal* signal) ...@@ -730,7 +730,7 @@ Ndbfs::scanIPC(Signal* signal)
jam(); jam();
report(request, signal); report(request, signal);
theRequestPool->put(request); theRequestPool->put(request);
return &request; return true;
} }
return false; return false;
} }
......
...@@ -77,11 +77,13 @@ int main(int argc, char** argv) ...@@ -77,11 +77,13 @@ int main(int argc, char** argv)
} }
{ // Do configuration { // Do configuration
#ifndef NDB_WIN32
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
#endif
theConfig->fetch_configuration(local_config); theConfig->fetch_configuration(local_config);
} }
chdir(NdbConfig_get_path(0)); my_setwd(NdbConfig_get_path(0), MYF(0));
if (theConfig->getDaemonMode()) { if (theConfig->getDaemonMode()) {
// Become a daemon // Become a daemon
...@@ -95,6 +97,7 @@ int main(int argc, char** argv) ...@@ -95,6 +97,7 @@ int main(int argc, char** argv)
} }
} }
#ifndef NDB_WIN32
for(pid_t child = fork(); child != 0; child = fork()){ for(pid_t child = fork(); child != 0; child = fork()){
/** /**
* Parent * Parent
...@@ -145,6 +148,9 @@ int main(int argc, char** argv) ...@@ -145,6 +148,9 @@ int main(int argc, char** argv)
} }
g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid()); g_eventLogger.info("Angel pid: %d ndb pid: %d", getppid(), getpid());
#else
g_eventLogger.info("Ndb started");
#endif
theConfig->setupConfiguration(); theConfig->setupConfiguration();
systemInfo(* theConfig, * theConfig->m_logLevel); systemInfo(* theConfig, * theConfig->m_logLevel);
...@@ -276,7 +282,7 @@ systemInfo(const Configuration & config, const LogLevel & logLevel){ ...@@ -276,7 +282,7 @@ systemInfo(const Configuration & config, const LogLevel & logLevel){
void void
catchsigs(bool ignore){ 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[] = { static const int signals_shutdown[] = {
#ifdef SIGBREAK #ifdef SIGBREAK
...@@ -318,7 +324,6 @@ catchsigs(bool ignore){ ...@@ -318,7 +324,6 @@ catchsigs(bool ignore){
SIGTRAP SIGTRAP
#endif #endif
}; };
#endif
static const int signals_ignore[] = { static const int signals_ignore[] = {
SIGPIPE SIGPIPE
...@@ -331,6 +336,7 @@ catchsigs(bool ignore){ ...@@ -331,6 +336,7 @@ catchsigs(bool ignore){
handler_register(signals_error[i], handler_error, ignore); handler_register(signals_error[i], handler_error, ignore);
for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++) for(i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++)
handler_register(signals_ignore[i], SIG_IGN, ignore); handler_register(signals_ignore[i], SIG_IGN, ignore);
#endif
} }
extern "C" extern "C"
...@@ -349,8 +355,10 @@ handler_error(int signum){ ...@@ -349,8 +355,10 @@ handler_error(int signum){
if (thread_id != 0 && thread_id == my_thread_id()) if (thread_id != 0 && thread_id == my_thread_id())
{ {
// Shutdown thread received signal // Shutdown thread received signal
#ifndef NDB_WIN32
signal(signum, SIG_DFL); signal(signum, SIG_DFL);
kill(getpid(), signum); kill(getpid(), signum);
#endif
while(true) while(true)
NdbSleep_MilliSleep(10); NdbSleep_MilliSleep(10);
} }
......
...@@ -278,8 +278,8 @@ static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter, ...@@ -278,8 +278,8 @@ static char * get_and_validate_path(ndb_mgm_configuration_iterator &iter,
memset(buf2, 0,sizeof(buf2)); memset(buf2, 0,sizeof(buf2));
#ifdef NDB_WIN32 #ifdef NDB_WIN32
char* szFilePart; char* szFilePart;
if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) if(!GetFullPathName(path, sizeof(buf2), buf2, &szFilePart) ||
|| (::GetFileAttributes(alloc_path)&FILE_ATTRIBUTE_READONLY)) (GetFileAttributes(buf2) & FILE_ATTRIBUTE_READONLY));
#else #else
if((::realpath(path, buf2) == NULL)|| if((::realpath(path, buf2) == NULL)||
(::access(buf2, W_OK) != 0)) (::access(buf2, W_OK) != 0))
......
...@@ -180,11 +180,13 @@ NdbShutdown(NdbShutdownType type, ...@@ -180,11 +180,13 @@ NdbShutdown(NdbShutdownType type,
#endif #endif
} }
#ifndef NDB_WIN32
if (simulate_error_during_shutdown) { if (simulate_error_during_shutdown) {
kill(getpid(), simulate_error_during_shutdown); kill(getpid(), simulate_error_during_shutdown);
while(true) while(true)
NdbSleep_MilliSleep(10); NdbSleep_MilliSleep(10);
} }
#endif
globalEmulatorData.theWatchDog->doStop(); globalEmulatorData.theWatchDog->doStop();
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "ConfigInfo.hpp" #include "ConfigInfo.hpp"
#include <version.h> #include <version.h>
#include <m_string.h>
static const char* helpTexts[] = { static const char* helpTexts[] = {
"HELP Print help text", "HELP Print help text",
...@@ -492,7 +492,7 @@ void CommandInterpreter::executeClusterLog(char* parameters) { ...@@ -492,7 +492,7 @@ void CommandInterpreter::executeClusterLog(char* parameters) {
noArgs = true; noArgs = true;
} }
while (item != NULL) { while (item != NULL) {
snprintf(name, 12, item); BaseString::snprintf(name, 12, item);
if (strcmp(item, "ALL") == 0) { if (strcmp(item, "ALL") == 0) {
severity = 7; severity = 7;
...@@ -740,9 +740,10 @@ CommandInterpreter::executeDumpState(int processId, const char* parameters, ...@@ -740,9 +740,10 @@ CommandInterpreter::executeDumpState(int processId, const char* parameters,
char * tmpString = strdup(parameters); char * tmpString = strdup(parameters);
char * tmpPtr = 0; char * tmpPtr = 0;
char * item = strtok_r(tmpString, " ", &tmpPtr); char * item = strtok_r(tmpString, " ", &tmpPtr);
int error;
while(item != NULL){ while(item != NULL){
if (0x0 <= strtoll(item, NULL, 0) && strtoll(item, NULL, 0) <= 0xffffffff) { if (0x0 <= my_strtoll10(item, NULL, &error) && my_strtoll10(item, NULL, &error) <= 0xffffffff) {
pars[no] = strtoll(item, NULL, 0); pars[no] = my_strtoll10(item, NULL, &error);
} else { } else {
ndbout << "Illegal value in argument to signal." << endl ndbout << "Illegal value in argument to signal." << endl
<< "(Value must be between 0 and 0xffffffff.)" << "(Value must be between 0 and 0xffffffff.)"
......
...@@ -231,7 +231,7 @@ int main(int argc, char** argv) ...@@ -231,7 +231,7 @@ int main(int argc, char** argv)
local_config, local_config,
glob.cluster_config); glob.cluster_config);
chdir(NdbConfig_get_path(0)); my_setwd(NdbConfig_get_path(0), MYF(0));
glob.cluster_config = 0; glob.cluster_config = 0;
glob.localNodeId= glob.mgmObject->getOwnNodeId(); glob.localNodeId= glob.mgmObject->getOwnNodeId();
...@@ -294,7 +294,9 @@ int main(int argc, char** argv) ...@@ -294,7 +294,9 @@ int main(int argc, char** argv)
} }
} }
#ifndef NDB_WIN32
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
#endif
{ {
BaseString error_string; BaseString error_string;
if(!glob.mgmObject->start(error_string)){ if(!glob.mgmObject->start(error_string)){
......
...@@ -246,7 +246,7 @@ done ...@@ -246,7 +246,7 @@ done
# #
# Create project files for ndb # Create project files for ndb
# #
make -C ndb windoze make -C $SOURCE/ndb windoze
# #
# Input directories to be copied recursively # Input directories to be copied recursively
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment