Commit 63b40952 authored by unknown's avatar unknown

wl1744 - nbd windoze port


ndb/include/logger/SysLogHandler.hpp:
  win-port
ndb/include/ndb_global.h:
  win-port
ndb/include/portlib/PortDefs.h:
  win-port
ndb/src/common/mgmcommon/NdbConfig.c:
  win-port
ndb/src/kernel/blocks/cmvmi/Cmvmi.cpp:
  win-port
ndb/src/kernel/blocks/dbdih/DbdihMain.cpp:
  win-port
ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp:
  win-port
ndb/src/kernel/main.cpp:
  win-port
ndb/src/kernel/vm/Configuration.cpp:
  win-port
ndb/src/kernel/vm/Emulator.cpp:
  win-port
ndb/src/mgmsrv/CommandInterpreter.cpp:
  win-port
ndb/src/mgmsrv/main.cpp:
  win-port
scripts/make_win_src_distribution.sh:
  win-port
parent 6049821c
......@@ -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.
......
......@@ -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
......
......@@ -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;");
......
......@@ -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;
}
......@@ -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)
......
......@@ -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;
......
......@@ -730,7 +730,7 @@ Ndbfs::scanIPC(Signal* signal)
jam();
report(request, signal);
theRequestPool->put(request);
return &request;
return true;
}
return false;
}
......
......@@ -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);
}
......
......@@ -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()");
}
......
......@@ -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();
......
......@@ -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.)"
......
......@@ -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)){
......
......@@ -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
......
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